Giter Site home page Giter Site logo

com.github.javaparser.ast.expr.MethodReferenceExpr and com.github.javaparser.ast.expr.TypeExpr do not set themselves as parent of their child nodes about javaparser HOT 2 CLOSED

javaparser avatar javaparser commented on May 22, 2024
com.github.javaparser.ast.expr.MethodReferenceExpr and com.github.javaparser.ast.expr.TypeExpr do not set themselves as parent of their child nodes

from javaparser.

Comments (2)

sebastiankirsch avatar sebastiankirsch commented on May 22, 2024

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 the parent field, but they don't have a parent set
    • an ImportDeclaration does not set itself as parent of its NameExpr
    • one of the two constructors of QualifiedNameExpr misses to set itself as parent of its NameExpr

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.

ftomassetti avatar ftomassetti commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.