Skip to content

Commit 38700f2

Browse files
authored
Fix diagnostics in Objective-C documentation comments appearing on the wrong line (#949)
* Remove workaround for offset Objective-C source ranges rdar://129668876 * Update test data to reflect correct Objective-C source ranges
1 parent 316b9d8 commit 38700f2

File tree

4 files changed

+43
-154
lines changed

4 files changed

+43
-154
lines changed

Sources/SwiftDocC/Model/DocumentationNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public struct DocumentationNode {
453453

454454
let documentOptions: ParseOptions = [.parseBlockDirectives, .parseSymbolLinks, .parseMinimalDoxygen]
455455
let docCommentMarkup = Document(parsing: docCommentString, source: docCommentLocation?.url, options: documentOptions)
456-
let offset = symbol.offsetAdjustedForInterfaceLanguage()
456+
let offset = symbol.docComment?.lines.first?.range
457457

458458
let docCommentDirectives = docCommentMarkup.children.compactMap({ $0 as? BlockDirective })
459459
if !docCommentDirectives.isEmpty {

Sources/SwiftDocC/Utility/SymbolExtensions.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.

Tests/SwiftDocCTests/Test Bundles/ObjCFrameworkWithInvalidLink.docc/symbol-graphs/clang/HelloWorldFramework.symbols.json

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@
6767
{
6868
"range": {
6969
"end": {
70-
"character": 52,
71-
"line": 10
70+
"character": 51,
71+
"line": 9
7272
},
7373
"start": {
74-
"character": 5,
75-
"line": 10
74+
"character": 4,
75+
"line": 9
7676
}
7777
},
7878
"text": "Project version number for HelloWorldFramework."
@@ -89,8 +89,8 @@
8989
},
9090
"location": {
9191
"position": {
92-
"character": 26,
93-
"line": 11
92+
"character": 25,
93+
"line": 10
9494
},
9595
"uri": "file:///Users/admin/HelloWorldFramework/HelloWorldFramework/HelloWorldFramework.h"
9696
},
@@ -155,12 +155,12 @@
155155
{
156156
"range": {
157157
"end": {
158-
"character": 52,
159-
"line": 13
158+
"character": 51,
159+
"line": 12
160160
},
161161
"start": {
162-
"character": 5,
163-
"line": 13
162+
"character": 4,
163+
"line": 12
164164
}
165165
},
166166
"text": "Project version string for HelloWorldFramework."
@@ -177,8 +177,8 @@
177177
},
178178
"location": {
179179
"position": {
180-
"character": 39,
181-
"line": 14
180+
"character": 38,
181+
"line": 13
182182
},
183183
"uri": "file:///Users/admin/HelloWorldFramework/HelloWorldFramework/HelloWorldFramework.h"
184184
},
@@ -231,12 +231,12 @@
231231
{
232232
"range": {
233233
"end": {
234-
"character": 40,
235-
"line": 21
234+
"character": 39,
235+
"line": 20
236236
},
237237
"start": {
238-
"character": 5,
239-
"line": 21
238+
"character": 4,
239+
"line": 20
240240
}
241241
},
242242
"text": "Manage hello world related logging."
@@ -253,8 +253,8 @@
253253
},
254254
"location": {
255255
"position": {
256-
"character": 12,
257-
"line": 22
256+
"character": 11,
257+
"line": 21
258258
},
259259
"uri": "file:///Users/admin/HelloWorldFramework/HelloWorldFramework/HelloWorldFramework.h"
260260
},
@@ -349,64 +349,64 @@
349349
{
350350
"range": {
351351
"end": {
352-
"character": 71,
353-
"line": 24
352+
"character": 70,
353+
"line": 23
354354
},
355355
"start": {
356-
"character": 5,
357-
"line": 24
356+
"character": 4,
357+
"line": 23
358358
}
359359
},
360360
"text": "Log a hello world message. This line contains an ``invalid`` link."
361361
},
362362
{
363363
"range": {
364364
"end": {
365-
"character": 4,
366-
"line": 25
365+
"character": 3,
366+
"line": 24
367367
},
368368
"start": {
369-
"character": 4,
370-
"line": 25
369+
"character": 3,
370+
"line": 24
371371
}
372372
},
373373
"text": ""
374374
},
375375
{
376376
"range": {
377377
"end": {
378-
"character": 18,
379-
"line": 26
378+
"character": 17,
379+
"line": 25
380380
},
381381
"start": {
382-
"character": 5,
383-
"line": 26
382+
"character": 4,
383+
"line": 25
384384
}
385385
},
386386
"text": "- Parameters:"
387387
},
388388
{
389389
"range": {
390390
"end": {
391-
"character": 31,
392-
"line": 27
391+
"character": 30,
392+
"line": 26
393393
},
394394
"start": {
395-
"character": 5,
396-
"line": 27
395+
"character": 4,
396+
"line": 26
397397
}
398398
},
399399
"text": " - log: The string to log"
400400
},
401401
{
402402
"range": {
403403
"end": {
404-
"character": 52,
405-
"line": 28
404+
"character": 51,
405+
"line": 27
406406
},
407407
"start": {
408-
"character": 5,
409-
"line": 28
408+
"character": 4,
409+
"line": 27
410410
}
411411
},
412412
"text": " - prefixWith: Prefix the log with this string"
@@ -478,8 +478,8 @@
478478
},
479479
"location": {
480480
"position": {
481-
"character": 1,
482-
"line": 29
481+
"character": 0,
482+
"line": 28
483483
},
484484
"uri": "file:///Users/admin/HelloWorldFramework/HelloWorldFramework/HelloWorldFramework.h"
485485
},
@@ -533,8 +533,8 @@
533533
},
534534
"location": {
535535
"position": {
536-
"character": 9,
537-
"line": 19
536+
"character": 8,
537+
"line": 18
538538
},
539539
"uri": "file:///Users/admin/HelloWorldFramework/HelloWorldFramework/HelloWorldFramework.h"
540540
},

Tests/SwiftDocCTests/Utility/SymbolExtensionsTests.swift

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)