Skip to content

Commit e80f571

Browse files
authored
Merge pull request #63608 from DougGregor/sourcekit-no-crash-macro-locations
Don't annotate entities not in the primary buffer
2 parents e7d2dfa + b87dfdf commit e80f571

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,13 +945,13 @@ class SemanticAnnotator : public SourceEntityWalker {
945945
if (AvailableAttr::isUnavailable(D))
946946
return true;
947947

948-
Optional<unsigned> inBufferID;
949-
if (SM.getRangeForBuffer(BufferID).contains(Range.getStart()))
950-
inBufferID = BufferID;
948+
// FIXME: Ignore things that don't come from this buffer.
949+
if (!SM.getRangeForBuffer(BufferID).contains(Range.getStart()))
950+
return true;
951951

952952
auto &SM = D->getASTContext().SourceMgr;
953953
if (D == D->getASTContext().getOptionalNoneDecl() &&
954-
SM.extractText(Range, inBufferID) == "nil") {
954+
SM.extractText(Range, BufferID) == "nil") {
955955
// If a 'nil' literal occurs in a swift-case statement, it gets replaced
956956
// by a reference to 'Optional.none' in the AST. We want to continue
957957
// highlighting 'nil' as a keyword and not as an enum element.

0 commit comments

Comments
 (0)