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

Simplify SwiftBasicFormat by introducing structural information of the syntax tree as static properties #1013

Merged
merged 4 commits into from Oct 27, 2022

Conversation

ahoppen
Copy link
Collaborator

@ahoppen ahoppen commented Oct 24, 2022

The core idea here is that we a static property structure to all the syntax nodes, which allows us to query the statically known structure of the syntax tree. That way BasicFormat can have a list of all the children it should indent or put on a new line, reducing its implementation from 3,000 to 300 lines.

structure will also be useful in a variety of other use cases:

  • We can use it to improve debugInitCall to insert upcast conversions it is currently missing because it can use childrenKeyPaths to query the static variable type of a child
  • I have a feeling that childNameForDiagnostics could be implemented more cleanly on top of childrenKeyPaths
  • I will try to implement keyword completion on top of this infrastructur
  • It could allow us to specify where nodes should be inserted into a syntax tree. Currently e.g. Fix-Its only support replacements.

@ahoppen
Copy link
Collaborator Author

ahoppen commented Oct 24, 2022

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented Oct 24, 2022

@swift-ci Please test

@ahoppen ahoppen changed the title Simplify SwiftBasicFormat by introducing childrenKeyPaths Simplify SwiftBasicFormat by introducing structural information of the syntax tree as static properties Oct 26, 2022
@ahoppen
Copy link
Collaborator Author

ahoppen commented Oct 26, 2022

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented Oct 26, 2022

@swift-ci Please test

@ahoppen
Copy link
Collaborator Author

ahoppen commented Oct 26, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit 95d3b69 into apple:main Oct 27, 2022
@ahoppen ahoppen deleted the ahoppen/simplify-basicfomat branch October 27, 2022 20:17
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.

None yet

1 participant