mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SourceKit] Don’t provide incorrect semantic highlighting of nil in case statements as enum decl element
If a 'nil' literal occurs in a swift-case statment, it gets replaced by a reference to 'Optional.none' in the AST. We want to continue highlighting 'nil' as a keyword and not as an enum element. Resolves apple/sourcekit-lsp#599 rdar://97961865
This commit is contained in:
@@ -963,6 +963,15 @@ public:
|
||||
if (AvailableAttr::isUnavailable(D))
|
||||
return true;
|
||||
|
||||
auto &SM = D->getASTContext().SourceMgr;
|
||||
if (D == D->getASTContext().getOptionalNoneDecl() &&
|
||||
SM.extractText(Range, BufferID) == "nil") {
|
||||
// If a 'nil' literal occurs in a swift-case statement, it gets replaced
|
||||
// by a reference to 'Optional.none' in the AST. We want to continue
|
||||
// highlighting 'nil' as a keyword and not as an enum element.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CtorTyRef)
|
||||
D = CtorTyRef;
|
||||
annotate(D, /*IsRef=*/true, Range);
|
||||
|
||||
Reference in New Issue
Block a user