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

ParentNotInitializedException when processing comments with -c #1073

Closed
giphon opened this issue Dec 24, 2016 · 2 comments
Closed

ParentNotInitializedException when processing comments with -c #1073

giphon opened this issue Dec 24, 2016 · 2 comments
Labels

Comments

@giphon
Copy link

giphon commented Dec 24, 2016

I am aware that comments can be processed using the command "-c" since Spoon 5.2.0. Thanks for this feature.

When using Spoon to process comments in either code snippet below, ParentNotInitializedException will be thrown. An empty processor can be used to reproduce this issue. This happens in both Spoon 5.2 and 5.4.

public class Comment_1 {

public void code_1()
{
	try {		}
	// A 
	// B
	catch (Exception ex)
	{		}
}

}

public class Comment2 {

// C
@interface Code_2{} 	

}

Details of the exception are as follows.

spoon.reflect.declaration.ParentNotInitializedException: parent not initialized for class spoon.support.reflect.code.CtCommentImpl (/home/jifeng/workspace/Temp4/src/main/java/example/Comment1.java:17)
at spoon.support.reflect.declaration.CtElementImpl.getParent(CtElementImpl.java:284)
at spoon.support.compiler.jdt.JDTCommentBuilder.insertCommentInAST(JDTCommentBuilder.java:377)
at spoon.support.compiler.jdt.JDTCommentBuilder.buildComment(JDTCommentBuilder.java:131)
at spoon.support.compiler.jdt.JDTCommentBuilder.build(JDTCommentBuilder.java:96)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:387)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:116)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:99)
at spoon.Launcher.buildModel(Launcher.java:712)
at spoon.Launcher.run(Launcher.java:663)
at spoon.Launcher.run(Launcher.java:106)
at spoon.Launcher.main(Launcher.java:99)

surli added a commit to surli/spoon that referenced this issue Dec 24, 2016
@surli
Copy link
Collaborator

surli commented Dec 24, 2016

Thank you for the feedback, I just reproduce your bug in surli@7082dcf I will investigate for a fix.
In the meantime, you can pass the checks in Spoon using -a argument in command-line.

@giphon
Copy link
Author

giphon commented Dec 25, 2016

Thanks a lot. Here is another example for incorrect comments for -c .
When processing

	public void code_3()
	{
		int[] myArray = {
				3, 5	// D
		};
	}

The result is as follows.

    public void code_3() {
        int[] myArray = new int[]{ 3 , 5 ,  //  };  
    }

surli added a commit to surli/spoon that referenced this issue Jan 5, 2017
surli added a commit to surli/spoon that referenced this issue Jan 5, 2017
monperrus pushed a commit to monperrus/spoon that referenced this issue Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants