Skip to content

Commit 2bedaac

Browse files
authored
Merge pull request swiftlang#80244 from DougGregor/diags-url-recognition
[Diagnostics] Fix recognition of URLs in category file/URL
2 parents a7b8cb7 + 7083009 commit 2bedaac

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/ASTGen/Sources/ASTGen/DiagnosticsBridge.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,17 @@ extension String {
407407
/// Simple check to determine whether the string looks like the start of a
408408
/// URL.
409409
fileprivate var looksLikeURL: Bool {
410+
var sawColon: Bool = false
410411
var forwardSlashes: Int = 0
411412
for c in self {
412-
if c == "/" {
413+
if c == ":" {
414+
sawColon = true
415+
continue
416+
}
417+
418+
if c == "/" && sawColon {
413419
forwardSlashes += 1
414-
if forwardSlashes > 2 {
420+
if forwardSlashes >= 2 {
415421
return true
416422
}
417423

@@ -420,6 +426,7 @@ extension String {
420426

421427
if c.isLetter || c.isNumber {
422428
forwardSlashes = 0
429+
sawColon = false
423430
continue
424431
}
425432

test/diagnostics/print-diagnostic-groups.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %target-swift-frontend -typecheck %s 2>&1 | %FileCheck %s --check-prefix=CHECK
1+
// RUN: %target-swift-frontend -typecheck %s 2>&1 | %FileCheck %s --check-prefix=CHECK-FILE -check-prefix CHECK
2+
// RUN: %target-swift-frontend -typecheck %s -diagnostic-documentation-path https://www.swift.org/documentation/compiler/diagnostics/ 2>&1 | %FileCheck %s --check-prefix=CHECK-HTTPS -check-prefix CHECK
23
// REQUIRES: swift_swift_parser
34

45
// CHECK: warning: file 'print-diagnostic-groups.swift' is part of module 'main'; ignoring import{{$}}
@@ -13,4 +14,6 @@ func bar() {
1314
// CHECK: warning: 'bar()' is deprecated: renamed to 'bar2' [#DeprecatedDeclaration]{{$}}
1415
bar()
1516

16-
// CHECK: [#DeprecatedDeclarations]: <{{.*}}deprecated-declaration.md>
17+
// CHECK-FILE: [#DeprecatedDeclarations]: <file://{{.*}}deprecated-declaration.md>
18+
19+
// CHECK-HTTPS: [#DeprecatedDeclaration]: <https://www.swift.org/documentation/compiler/diagnostics/deprecated-declaration.md>

0 commit comments

Comments
 (0)