Skip to content

Commit cbad87d

Browse files
authored
Merge pull request #82950 from hamishknight/ident-range-6.2
[6.2] [SourceKit] Fix raw identifier handling for semantic tokens
2 parents a349e64 + 32f8406 commit cbad87d

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

lib/IDE/SourceEntityWalker.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,8 @@ bool SemaAnnotator::passCallAsFunctionReference(ValueDecl *D, SourceLoc Loc,
868868

869869
bool SemaAnnotator::
870870
passReference(ValueDecl *D, Type Ty, DeclNameLoc Loc, ReferenceMetaData Data) {
871-
SourceManager &SM = D->getASTContext().SourceMgr;
872-
SourceLoc BaseStart = Loc.getBaseNameLoc(), BaseEnd = BaseStart;
873-
if (BaseStart.isValid() && SM.extractText({BaseStart, 1}) == "`")
874-
BaseEnd = Lexer::getLocForEndOfToken(SM, BaseStart.getAdvancedLoc(1));
875-
return passReference(D, Ty, BaseStart, {BaseStart, BaseEnd}, Data);
871+
SourceLoc BaseLoc = Loc.getBaseNameLoc();
872+
return passReference(D, Ty, BaseLoc, BaseLoc, Data);
876873
}
877874

878875
bool SemaAnnotator::
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
// RUN: %sourcekitd-test -req=semantic-tokens %t/main.swift -- %t/main.swift > %t/result.json
4+
// RUN: diff -u %t/tokens.json %t/result.json
5+
6+
//--- main.swift
7+
func `foo`(x: Int) {}
8+
`foo`(x: 0)
9+
10+
func `foo bar baz`() {}
11+
`foo bar baz`()
12+
13+
//--- tokens.json
14+
{
15+
key.semantic_tokens: [
16+
{
17+
key.kind: source.lang.swift.ref.struct,
18+
key.offset: 14,
19+
key.length: 3,
20+
key.is_system: 1
21+
},
22+
{
23+
key.kind: source.lang.swift.ref.function.free,
24+
key.offset: 22,
25+
key.length: 5
26+
},
27+
{
28+
key.kind: source.lang.swift.ref.function.free,
29+
key.offset: 59,
30+
key.length: 13
31+
}
32+
]
33+
}

0 commit comments

Comments
 (0)