Skip to content

Commit 3e03b78

Browse files
authored
[SyntaxColoring] Tolerating empty spaces between doc-comment openning… (#3373)
* [SyntaxColoring] Tolerating empty spaces between doc-comment opennings and field keywords. rdar://26310081 * [test] Update test for SourceKit.
1 parent 500fdd2 commit 3e03b78

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

lib/IDE/SyntaxModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static const char *const RegexStrURL =
245245
#define MARKUP_SIMPLE_FIELD(Id, Keyword, XMLKind) \
246246
#Keyword "|"
247247
static const char *const RegexStrDocCommentField =
248-
"^[ ]?- ("
248+
"^[ ]*- ("
249249
#include "swift/Markup/SimpleFields.def"
250250
"returns):";
251251

test/IDE/coloring.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ func foo(n: Float) -> Int {
168168
return 100009
169169
}
170170

171+
///- returns: single-line, no space
172+
// CHECK: ///- <doc-comment-field>returns</doc-comment-field>: single-line, no space
173+
174+
/// - returns: single-line, 1 space
175+
// CHECK: /// - <doc-comment-field>returns</doc-comment-field>: single-line, 1 space
176+
177+
/// - returns: single-line, 2 spaces
178+
// CHECK: /// - <doc-comment-field>returns</doc-comment-field>: single-line, 2 spaces
179+
180+
/// - returns: single-line, more spaces
181+
// CHECK: /// - <doc-comment-field>returns</doc-comment-field>: single-line, more spaces
182+
171183
// CHECK: <kw>protocol</kw> Prot {
172184
protocol Prot {
173185
// CHECK: <kw>typealias</kw> Blarg

test/SourceKit/SyntaxMapData/syntaxmap.swift.response

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,17 @@
361361
{
362362
key.kind: source.lang.swift.syntaxtype.doccomment,
363363
key.offset: 666,
364-
key.length: 59
364+
key.length: 13
365+
},
366+
{
367+
key.kind: source.lang.swift.syntaxtype.doccomment.field,
368+
key.offset: 679,
369+
key.length: 8
370+
},
371+
{
372+
key.kind: source.lang.swift.syntaxtype.doccomment,
373+
key.offset: 687,
374+
key.length: 38
365375
},
366376
{
367377
key.kind: source.lang.swift.syntaxtype.keyword,

0 commit comments

Comments
 (0)