-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Parse/CodeCompletion] Cleanup code completion facilities in Parse #28182
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
[Parse/CodeCompletion] Cleanup code completion facilities in Parse #28182
Conversation
@swift-ci Please smoke test |
This is a PR for #28014 (review) |
lib/Parse/Parser.cpp
Outdated
auto EndLexerState = L->getStateForEndOfTokenLoc(info.BodyEnd); | ||
auto range = SourceRange(info.BodyPos.Loc, info.BodyEnd); | ||
llvm::errs().write_escaped( | ||
L->getCharSourceRangeFromSourceRange(SourceMgr, range).str()); |
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.
Debugging output?
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.
Ah, thanks!
// Expressions can't begin with a closure literal at statement position. This | ||
// prevents potential ambiguities with trailing closure syntax. | ||
if (Tok.is(tok::l_brace)) { | ||
diagnose(Tok, diag::statement_begins_with_closure); |
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 see you removed this code - do we know why it was originally there? It seems odd to emit a diagnostic during code completion like this.
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 guess this was added when diag::statement_begins_with_closure
was implemented (ad78204) without knowing how this code path was used.
}; | ||
|
||
enum class DelayedDeclKind { | ||
enum class CodeCompletionSecondPassInfoKind { |
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.
How about CodeCompletionDelayedDeclKind?
TopLevelCodeDecl, | ||
Decl, | ||
FunctionBody, | ||
}; | ||
|
||
class DelayedDeclState { | ||
class CodeCompletionSecondPassInfoTy { |
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.
How about CodeCompletionDelayedDeclState?
FunctionBodyState is no longer used.
- delayParseFromBeginningToHere is useless. Use delayDecl() instead - Inline PersistentParserState::delayTopLevel() - Cleanup completion handling in parseDecl()
- Rename code completion related names in 'PersistentParserState' so it's clear when you are using. - Refactor 'performCodeCompletionSecondPass()': Inline and consolidate 'parse*Delayed()' because they used to share many code. rdar://problem/56926367
20b7d0e
to
cd8ebe4
Compare
@swift-ci Please smoke test |
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.
LGTM, thanks!
FunctionBodyState
fromPersistentParserState
delayParseFromBeginningToHere()
. Use delayDecl() insteadPersistentParserState::delayTopLevel()
parseDecl()
PersistentParserState
so it's clear when you are usingperformCodeCompletionSecondPass()
: Inline and consolidateparse*Delayed()
functions because they used to share some coderdar://problem/56926367