Skip to content

[libSyntax] Incremental syntax tree transfer #18152

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

Merged
merged 4 commits into from
Jul 25, 2018

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 23, 2018

This PR adds the ability to incrementally transfer a libSyntax tree from the C++ side to the Swift side of swiftSyntax.

The basic idea behind it is that we assign a unique ID to each node. If the node has been pulled from the SyntaxParsingCache during incremental syntax parsing, we know that the client already has that node. So, instead of serialising it again, we just add a stub node to the transferred tree that consists of only the node's ID. The client can then substitute the stub node with the node of that ID which is already present in its old syntax tree.

@ahoppen ahoppen requested review from rintaro and nkcsgexi July 23, 2018 19:37
@ahoppen
Copy link
Member Author

ahoppen commented Jul 23, 2018

@swift-ci Please smoke test

@@ -3,6 +3,8 @@ set(EXTRA_COMPILE_FLAGS "-I" "${SWIFT_SYNTAX_PATH}")
set(EXTRA_LINKER_FLAGS "-Xlinker" "-rpath" "-Xlinker" "${SWIFT_SYNTAX_PATH}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also remove these above three lines. I've added them before however it seems they are not necessary.

printHelp()
exit(0)
} else {
try performRoundTrip(args: args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also define action kind like swift-ide-test. It's likely we'll use swift-swiftsyntax-test for other testing purposes.

@ahoppen ahoppen force-pushed the 01-incr-tree-transfer branch from 326e23d to d926b74 Compare July 24, 2018 23:32
@ahoppen
Copy link
Member Author

ahoppen commented Jul 24, 2018

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Jul 24, 2018

@nkcsgexi I implemented the changes you requested in the comments and have refactored the swiftSyntax entry point API so that we no longer need to pass the IncrementalParsingSession around.

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've no other comments.

@rintaro
Copy link
Member

rintaro commented Jul 25, 2018

So, instead of serialising it again, we just add a stub node to the transferred tree that consists of only the node's ID.

I couldn't find JSON output test cases for "omitted": true node. Could you add some? Or am I missing something?

@ahoppen
Copy link
Member Author

ahoppen commented Jul 25, 2018

@rintaro It's implicitly tested when we do the round trip through swiftSyntax. But good point. I'll add a test case.

@ahoppen
Copy link
Member Author

ahoppen commented Jul 25, 2018

@rintaro I've added a test case that checks the JSON syntax tree with omitted nodes.

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Jul 25, 2018

Test failure seems unrelated.

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Jul 25, 2018

@swift-ci Please Python lint

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ahoppen ahoppen merged commit c8fc286 into swiftlang:master Jul 25, 2018
@ahoppen ahoppen deleted the 01-incr-tree-transfer branch July 25, 2018 22:27
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 this pull request may close these issues.

3 participants