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

DefaultJavaPrettyPrinter.visitCtThisAccess #826

Closed
leventov opened this issue Sep 17, 2016 · 6 comments · Fixed by #1031
Closed

DefaultJavaPrettyPrinter.visitCtThisAccess #826

leventov opened this issue Sep 17, 2016 · 6 comments · Fixed by #1031

Comments

@leventov
Copy link
Contributor

I think it shouldn't rely on getTarget().isImplicit() when printing this qualifier, because classes could be moved around, and Implicit flag is usually not modified.

Such implementation work better for me, probably it should be adapted for DefaultJavaPrettyPrinter itself (+ corner cases, which I omitted in my code because not the case for me):

    class MyPrinter extends DefaultJavaPrettyPrinter {

        Deque<CtClass<?>> currentThis = new ArrayDeque<>();

        public MyPrinter(Environment env) {
            super(env);
        }

        @Override
        public <T> void visitCtClass(CtClass<T> ctClass) {
            currentThis.push(ctClass);
            super.visitCtClass(ctClass);
            currentThis.pop();
        }

        @Override
        public <T> void visitCtThisAccess(CtThisAccess<T> thisAccess) {
            enterCtExpression(thisAccess);
            if (!thisAccess.isImplicit()) {
                if (thisAccess.getType().getDeclaration() != currentThis.peek()) {
                    visitCtTypeReferenceWithoutGenerics(thisAccess.getType());
                    write(".");
                }
                write("this");
            }
            exitCtExpression(thisAccess);
        }
    }
@monperrus
Copy link
Collaborator

if it's a bug, could you provide us with a failing test case? thanks.

@monperrus
Copy link
Collaborator

Hi @leventov , any news on this? is this really a bug?

@leventov
Copy link
Contributor Author

@monperrus probably I can pay some time for this, as well as other issues I've reported, next weekend.

@monperrus
Copy link
Collaborator

OK, thanks.

@monperrus
Copy link
Collaborator

ping @leventov
do you work on this?
(to know whether we wait for your issues for the next release)

@leventov
Copy link
Contributor Author

@monperrus please don't wait for issues opened by me.

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

Successfully merging a pull request may close this issue.

2 participants