Comments (2)
Spoon doesn't visit CtImport
, don't ask me why, but I think it was explained in #5168.
This is the code I am using to visit all imports in a model:
private static void visitCtCompilationUnit(CtModel ctModel, Consumer<? super CtCompilationUnit> lambda) {
// it is not possible to visit CtCompilationUnit through the processor API.
//
// in https://github.com/INRIA/spoon/issues/5168 the below code is mentioned as a workaround:
ctModel
.getAllTypes()
.stream()
.map(CtType::getPosition)
.filter(SourcePosition::isValidPosition)
.map(SourcePosition::getCompilationUnit)
// visit each compilation unit only once
.distinct()
.forEach(lambda);
}
public void visitAllImports(CtModel ctModel) {
visitCtCompilationUnit(ctModel, ctCompilationUnit -> {
for (CtImport ctImport : ctCompilationUnit.getImports()) {
this.checkImport(ctImport, ctCompilationUnit);
}
});
}
private void checkImport(CtImport ctImport, CtCompilationUnit ctCompilationUnit) {
// write your code for imports here
}
from spoon.
Great, thanks for the help.
from spoon.
Related Issues (20)
- Update a method calls reference
- java 22 HOT 1
- [Bug]: Control Flow graph missing edge for implicit default case in switch
- [Bug]: Control Flow Graph doesn't handle cases with multiple expressions
- Spotless for imports HOT 4
- [Bug]: Spoon inserts incorrect break in enhanced switch block
- [Feature Request]: Minimize Parens in `DefaultJavaPrettyPrinter` should use operator precedence (`(a == b) || (b == c)` could be `a == b || b == c`) HOT 2
- [Bug]: Javadoc of class missing HOT 1
- improve reproducible build architecture for Spoon HOT 7
- Unable to start JavaFX UI HOT 2
- How to Implement Angelic Value with Spoon for APR
- links to some of the transformation examples are broken
- [Bug]: Not allowed javaletter or keyword in identifier found. See JLS for correct identifier. Identifier: E' HOT 1
- [Bug]: can not process lombok annatations HOT 3
- How to create static call graph with only invocations within project?
- [Bug]: Inconsistent parent for `CtTypeReferenceImpl` in `CtRecordComponentImpl` which points to a `CtMethodImpl`
- [Bug]: JLSViolation occurs when using a setter method created using Lombok's @Setter annotation HOT 1
- How to use Spoon and spoon-maven-plugin with Lombok? HOT 3
- Spelling mistake in AnnotationProcessor API HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spoon.