Comments (2)
Hm, while writing a test (every node has to have a parent set), I noticed that there's a some more nodes that don't set themselves as parent:
- comments have an additional
commentedNode
field which practically serves the same purpose as theparent
field, but they don't have a parent set- an
ImportDeclaration
does not set itself as parent of itsNameExpr
- one of the two constructors of
QualifiedNameExpr
misses to set itself as parent of itsNameExpr
- an
I'll fix the import declaration as well as the qualified name expression; not sure about the comment however. I'd probably leave them be... any suggestions?
from javaparser.
As I remember things to be (and I could definitely be wrong):
- I think that the commentedNode and the parent are tipically two different nodes: a comment tend to be applied to an element at its own level, not to its container.
- Comments are added after parsing and behave differently because they could be put everywhere, so they do not fit as nicely as other nodes in the AST.
I think it is something we should clarify and if comments do not have parents maybe they should not have the methods get/set parent. Maybe they should not derive from Node but from some ancestor of Node containing the code common to proper nodes and comments.
from javaparser.
Related Issues (20)
- Getting error while calling calculateResolvedType() on scope in Java Parser HOT 9
- Method 'forEach' cannot be resolved in certain context HOT 5
- Regression in 3.25.9: `Cannot be 'abstract' and also 'private'.` for a `private` method in an interface HOT 2
- Processing nested classes and their methods HOT 9
- Find the first ancestor of a type? HOT 1
- Arrays as Variables HOT 1
- UnsolvedSymbolException ... cannot be resolved in context ... MethodCallExprContext HOT 2
- somtimes AssignExpr.target is wrong HOT 4
- Pattern matching for switch - JEP 441 HOT 2
- nameExpr.resolve().isField() resolves incorrectly in certain context HOT 2
- Strange error when trying to find erasure of generic type where one of two type parameters is an array HOT 2
- Unable to check equality of `ResolvedReferenceType` with a `LazyType`
- Regression from #602 HOT 6
- StackOverflowError with import static in circular dependencies HOT 1
- Question about switch statements and pattern representation HOT 4
- Children may be out of order after adding a statement HOT 4
- Jar file location for JarTypeSolver HOT 5
- Disappearing comments with LexicalPreservingPrinter HOT 1
- 【Question】Can a API be provided with a very concise judgment of whether the current variable is a local variable or a ginseng or field? HOT 2
- 【Question】Should the results of `Expression#RESOLVE` cache? 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 javaparser.