Open kimdv opened 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:
AnnotatedTestItem
to essentially be a TestItem
just with additional information. Differences to TestItem
are
isExtension
propertyAnnotatedTestItem
ambiguousTestDifferentiator: String
of the test (I’d prefer not to re-use the location
property because it makes sense that the test’s range contains the @
but the test location needs to be at Test
). This would eg. be MyFile.swift:4:2
.SyntacticTestIndex
add a new method ambigousTestIDs()
. This iterates over all tests in the project and checks if there are any test IDs that are used twiceAnnotatedTestItem
to TestItem
, pass in the ambiguous test IDs. If the id
of an AnnotatedTestItem
is in that set of ambiguous IDs, we append the ambiguousTestDifferentiator
to its ID. 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?
Change
AnnotatedTestItem
to essentially be aTestItem
just with additional information.
Just to be clear, does it mean I should remove AnnotatedTestItem
and replace all usage with TestItem
?
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 AnnotatedTestItem
s into TestItem
s.
Fixes #1152