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

[Bug]: Comments not in method included in method #5172

Open
AlexanderStocks opened this issue Apr 11, 2023 · 0 comments
Open

[Bug]: Comments not in method included in method #5172

AlexanderStocks opened this issue Apr 11, 2023 · 0 comments
Labels

Comments

@AlexanderStocks
Copy link

Describe the bug

When I prettyprint a CtMethod, comments that are in the class but not in the method are included.

Source code you are trying to analyze/transform

public class CommentExample {
    // This is another comment

    public int method1() {
        //A comment
    }
}

Source code for your Spoon processing

val launcher = Launcher()
    launcher.factory.environment.setCommentEnabled(true)
    launcher.addInputResource("src/main/resources/TestCases/comment.java")
    launcher.buildModel()
    launcher.model.processWith(ExtractClones())

class ExtractClones : AbstractProcessor<CtClass<*>>() {
    override fun process(element: CtClass<*>) {
        element.methods.forEach { println(it.prettyprint()) }
    }
}

Actual output

// This is another comment
public int method1() {
    // A comment
}

Expected output

public int method1() {
    // A comment
}

Spoon Version

10.3.0

JVM Version

17

What operating system are you using?

Windows 11

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

1 participant