swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.21k stars 264 forks source link

Add line and column to test item id #1439

Open kimdv opened 1 month ago

kimdv commented 1 month ago

Fixes #1152

ahoppen commented 1 month ago

@grynspan Had a very interesting idea just now to reduce possible issues where the test index still has an old location for the test but it has been moved: We only need the file-line-column distinguisher if the test ID is otherwise ambiguous, eg. because you have two @Test fileprivate func testSomething() {} functions in different files.

What we could do is:

This is a lot more involved than what I described in the original issue. Would you be interested in trying this, @kimdv? Also: Do you think our idea makes sense?

kimdv commented 4 weeks ago

Change AnnotatedTestItem to essentially be a TestItem just with additional information.

Just to be clear, does it mean I should remove AnnotatedTestItem and replace all usage with TestItem?

ahoppen commented 3 weeks ago

I meant it the other way round: When computing the tests, everything should be AnnotatedTestItem and AnnotatedTestItem would look something like the following.

public struct TestItem: ResponseType, Equatable {
  public var id: String
  public var label: String
  public var description: String?
  public var sortText: String?
  public var disabled: Bool
  public var style: String
  public var location: Location
  public var children: [AnnotatedTestItem]
  public var tags: [TestTag]
  public var isExtension: Bool
  public var ambiguousTestDifferentiator: String
}

And only when actually creating the LSP response do we convert the AnnotatedTestItems into TestItems.