Skip to content

Commit df91a46

Browse files
author
Nathan Hawes
committed
Filter out 0-length tokens when generating syntax model nodes.
Resolves rdar://problem/33601932.
1 parent 11254d0 commit df91a46

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/IDE/SyntaxModel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ SyntaxModelContext::SyntaxModelContext(SourceFile &SrcFile)
6363
auto LiteralStartLoc = Optional<SourceLoc>();
6464
for (unsigned I = 0, E = Tokens.size(); I != E; ++I) {
6565
auto &Tok = Tokens[I];
66+
// Ignore empty string literals between interpolations, e.g. "\(1)\(2)"
67+
if (!Tok.getLength())
68+
continue;
6669
SyntaxNodeKind Kind;
6770
SourceLoc Loc;
6871
Optional<unsigned> Length;

test/IDE/coloring.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ func f(x: Int) -> Int {
240240
"""
241241
This is a multiline\( "interpolated" )string
242242
"""
243+
244+
// CHECK: <str>"</str>\<anchor>(</anchor><int>1</int><anchor>)</anchor>\<anchor>(</anchor><int>1</int><anchor>)</anchor><str>"</str>
245+
"\(1)\(1)"
243246
}
244247

245248
// CHECK: <kw>func</kw> bar(x: <type>Int</type>) -> (<type>Int</type>, <type>Float</type>) {

0 commit comments

Comments
 (0)