Don't annotatae entities not in the primary buffer

This commit is contained in:
Doug Gregor
2023-02-12 21:42:36 -08:00
parent 642d0e9d36
commit b87dfdf2ae

View File

@@ -945,13 +945,13 @@ public:
if (AvailableAttr::isUnavailable(D))
return true;
Optional<unsigned> inBufferID;
if (SM.getRangeForBuffer(BufferID).contains(Range.getStart()))
inBufferID = BufferID;
// FIXME: Ignore things that don't come from this buffer.
if (!SM.getRangeForBuffer(BufferID).contains(Range.getStart()))
return true;
auto &SM = D->getASTContext().SourceMgr;
if (D == D->getASTContext().getOptionalNoneDecl() &&
SM.extractText(Range, inBufferID) == "nil") {
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.