Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment in lambda expression triggers a ParentNotInitializedException #2801

Closed
stefanleh opened this issue Nov 30, 2018 · 3 comments · Fixed by #3020
Closed

comment in lambda expression triggers a ParentNotInitializedException #2801

stefanleh opened this issue Nov 30, 2018 · 3 comments · Fixed by #3020
Labels

Comments

@stefanleh
Copy link

stefanleh commented Nov 30, 2018

It looks like comments in lambda expressions are a problem for 7.1.0 version of spoon lib.

Optional<Field> fieldConditionValueOptional = join.getConditions().stream().filter(condition -> //
            condition.getDescription().getName().equals(fieldName)
                    && (condition.getOperator() == EQUAL || condition.getOperator() == IS_EMPTY)
                    && condition instanceof FieldCondition)
                    .map(condition -> new Field(condition.getDescription(),
                            condition.getOperator() == EQUAL ? condition.getValue() : condition.getDescription().getInitialValue()))
                    .findFirst();
09:25:19.480 [main] ERROR jdt.JDTCommentBuilder - //  is not added into the AST
spoon.reflect.declaration.ParentNotInitializedException: parent not initialized for class spoon.support.reflect.code.CtCommentImpl (/PATHTOSOURCE/OP10704.java:1686)
	at spoon.support.reflect.declaration.CtElementImpl.getParent(CtElementImpl.java:375) ~[spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTCommentBuilder.insertCommentInAST(JDTCommentBuilder.java:493) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTCommentBuilder.buildComment(JDTCommentBuilder.java:157) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTCommentBuilder.build(JDTCommentBuilder.java:113) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildModel(JDTBasedSpoonCompiler.java:477) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:390) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:339) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:122) [spoon-core-7.1.0.jar:?]
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:105) [spoon-core-7.1.0.jar:?]
	at spoon.Launcher.buildModel(Launcher.java:767) [spoon-core-7.1.0.jar:?]
	at xxx.xxxxxx.xxxxxx.xxxxxxx.ApplicationInitFinder.main(ApplicationInitFinder.java:65) [main/:?]
@surli surli changed the title spoon.reflect.declaration.ParentNotInitializedException: parent not initialized for class spoon.support.reflect.code.CtCommentImpl comment in lambda expression triggers a ParentNotInitializedException Nov 30, 2018
@surli surli added the bug label Nov 30, 2018
@surli
Copy link
Collaborator

surli commented Nov 30, 2018

Looks like we have several bugs related to comments in lambda. We already have #2763 open

@stefanleh
Copy link
Author

I think this one can be closed as duplicate of #2763.

@stefanleh
Copy link
Author

I've tested this with 7.5.0-beta-20 and there seems to be a regression.
Its exactly the same code from above.

09:18:26.404 [main] ERROR JDTCommentBuilder - "// " cannot be added into the AST, with parent class spoon.support.reflect.code.CtLambdaImpl at (.... OP10704.java:1587), please report the bug by posting on #2482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants