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

[Syntax] Introduce SyntaxLayout #2824

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 26, 2024

Types:

  • SyntaxLayout<T>: represents the layout of the T syntax layout type
  • SyntaxLayoutProperty: represents an element in SyntaxLayout. like AnyKeyPath
  • ConcreteSyntaxProperty<Base, Value>: represent a typed property. like KeyPath<Root, Value>

Usage:

func usage(node: some SyntaxProtocol) {
  node.propertyInParent == FuncDeclSyntax.layout[.funcKeyword]
}

This is faster than keyPathInParent and comparing KeyPath. Combined with #2842, BasicFormat performs 30% faster

@rintaro rintaro force-pushed the syntaxlayout branch 2 times, most recently from a8678db to 0ae17dc Compare September 10, 2024 13:46
@rintaro
Copy link
Member Author

rintaro commented Sep 10, 2024

@swift-ci Please test

@rintaro rintaro marked this pull request as ready for review September 10, 2024 14:38
This replaces most use case of `keyPathInParent` and
`SyntaxNodeStructure.layout`. Since getting and comparing `KeyPath` is
not trivial, `keyPathInParent` were suffered from performance issue,

Newly introduced `SyntaxProtocol.propertyInParent` is trivial, and
comparing it with a SyntaxLayoutProperty is also trivial.
@rintaro
Copy link
Member Author

rintaro commented Sep 10, 2024

@swift-ci Please test

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.

1 participant