Skip to content

Java parser partial reset - #2789

Merged
sambsnyd merged 1 commit into
openrewrite:mainfrom
BoykoAlex:partial-reset
Feb 14, 2023
Merged

sambsnyd merged 1 commit into
openrewrite:mainfrom
BoykoAlex:partial-reset

Conversation

@BoykoAlex

Copy link
Copy Markdown
Contributor

Partial reset of the JavaParser to avoid exception urging to call reset()

@BoykoAlex
BoykoAlex force-pushed the partial-reset branch 4 times, most recently from 188347d to 6f650bb Compare February 9, 2023 16:44
@BoykoAlex
BoykoAlex marked this pull request as ready for review February 9, 2023 16:47
@BoykoAlex

Copy link
Copy Markdown
Contributor Author

Wonder what you think of it... seems to work for us.

@BoykoAlex BoykoAlex changed the title [DO NOT MERGE] Java parser partial reset Java parser partial reset Feb 9, 2023
@timtebeek timtebeek added the enhancement New feature or request label Feb 9, 2023
@BoykoAlex
BoykoAlex marked this pull request as draft February 9, 2023 22:55
@BoykoAlex

Copy link
Copy Markdown
Contributor Author

Actually, no doesn't work for us... at least not yet :-\

@BoykoAlex

Copy link
Copy Markdown
Contributor Author

The proposed "light" or "partial" parser reset does the following:

       if (!uris.isEmpty()) {
            compilerLog.reset(uris);
        }
        pfm.flush();
        Check.instance(context).newRound();
        Annotate.instance(context).newRound();
        Enter.instance(context).newRound();
        Modules.instance(context).newRound();

However, the attached test and IDE integration seem to work if I limit the above to just:

        if (!uris.isEmpty()) {
            compilerLog.reset(uris);
        }
        Check.instance(context).newRound();

Feels like pfm.flush() is a good thing to do. Check has method to remove compiled: removeCompiled(ClassSymbol csym) which i could have used if we had the ClassSymbol from the previously compiled CU (i have this CU but there is no reference to compilers class symbol...

Anyway, "partial" reset in its current form perform and works fine. Mt test java source takes ~180ms to parse after reset() and takes ~98ms to parse after "pertial" reset (reset(Collection<URI>) that is)

@BoykoAlex
BoykoAlex marked this pull request as ready for review February 10, 2023 02:28
@BoykoAlex

Copy link
Copy Markdown
Contributor Author

@sambsnyd @jkschneider what do you think of this PR? Is this something that can be merged?

@sambsnyd
sambsnyd merged commit d1e5aa1 into openrewrite:main Feb 14, 2023
@sambsnyd

sambsnyd commented Feb 14, 2023 •

Copy link
Copy Markdown
Member

Thank you for the contribution and sorry for the slow review, @BoykoAlex. No problems with this jump out at me. I don't know everything about Java compiler internals, but I see no reason to doubt that this is useful.

@sambsnyd sambsnyd added this to the 7.36.0 milestone Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants