-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[libSyntax] Store Range of ParsedRawSyntaxNode in dedicated field #36274
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
[libSyntax] Store Range of ParsedRawSyntaxNode in dedicated field #36274
Conversation
@swift-ci Please smoke test |
@swift-ci Please smoke test Windows |
llvm_unreachable("node not deferred"); | ||
} | ||
} | ||
CharSourceRange getRange() const { return Range; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are here, please add a comment that this includes trivia ranges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll do.
unsigned len = leadTriviaLen + DeferredToken.TokLength + trailTriviaLen; | ||
|
||
return CharSourceRange{begin, len}; | ||
} | ||
CharSourceRange getDeferredTokenRange() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, this getDeferredTokenRange()
(doesn't include trivia) is used only in ParsedRawSyntaxRecorder
and it's just for calculating the range with trivia after all. Can we abolish this method? If you prefer not to remove this, please add a comment to clarify this does not include trivia ranges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’ll be gone in the next PR (here). I know that this splitting between PRs sometimes feels a little bit random. Sorry about that.
Essentially all ParsedRawSyntaxNode types have a range associated with them, so let's just store it in a dedicated field with a common getter. Additionally, this cleans up the recorded storage to just contain an OpaqueSyntaxNode. When deferred nodes are being handled by SyntaxParseActions, we can use this OpaqueNode storage to store either recorded or deferred node data, which is left to be interpreted by the SyntaxParseAction.
69c4f88
to
7be748d
Compare
@swift-ci Please smoke test |
Essentially all ParsedRawSyntaxNode types have a range associated with them, so let's just store it in a dedicated field with a common getter.
Additionally, this cleans up the recorded storage to just contain an
OpaqueSyntaxNode
. When deferred nodes are being handled by SyntaxParseActions, we can use this OpaqueNode storage to store either recorded or deferred node data, which is left to be interpreted by theSyntaxParseAction
.We could also rewrite
TokLoc
andTokLength
inDeferredTokenNode
in terms of the newRange
property for now. But since I’ll moveDeferredTokenNode
down toSyntaxParseActions
in the next PR which also needs the range information, it’s easier to keep the information duplicated for now.