Skip to content

test: Strip prefix from relationship symbol names #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/conflicting-const-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ConflictingConst {}
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`conflicting-const-interface.ts`/ConflictingConst#
export class ImplementsConflictingConst implements ConflictingConst {}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`conflicting-const-interface.ts`/ImplementsConflictingConst#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`conflicting-const-interface.ts`/ConflictingConst#
// relationship implementation syntax 1.0.0 src/`conflicting-const-interface.ts`/ConflictingConst#
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`conflicting-const-interface.ts`/ConflictingConst.
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`conflicting-const-interface.ts`/ConflictingConst#

2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/destructuring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const props: Props = { a: 42 }
// ^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/props.
// ^^^^^ reference syntax 1.0.0 src/`destructuring.ts`/Props#
// ^ definition syntax 1.0.0 src/`destructuring.ts`/a0:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`destructuring.ts`/Props#a.
// relationship implementation reference syntax 1.0.0 src/`destructuring.ts`/Props#a.

export function objectDestructuring(): number[] {
// ^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/objectDestructuring().
Expand Down
14 changes: 7 additions & 7 deletions snapshots/output/syntax/src/infer-relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function returnStatement(): Configuration {
return {
property: 41,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property0:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}
for (let i = 0; i < 9; i++) {
Expand All @@ -36,7 +36,7 @@ export function returnStatement(): Configuration {
return {
property: 41,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property1:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}
}
Expand All @@ -48,7 +48,7 @@ export function returnStatement(): Configuration {
return {
property: 41,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property2:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}
}
Expand All @@ -66,7 +66,7 @@ export function returnStatement(): Configuration {
return {
property: 41,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property3:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}
}
Expand All @@ -75,7 +75,7 @@ export function returnStatement(): Configuration {
return {
property: 41,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property4:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}
do {
Expand All @@ -84,7 +84,7 @@ export function returnStatement(): Configuration {
return {
property: 41,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property5:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}
} while (random() < 0)
Expand All @@ -93,7 +93,7 @@ export function returnStatement(): Configuration {
return {
property: 42,
// ^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/property6:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
// relationship implementation reference syntax 1.0.0 src/`infer-relationship.ts`/Configuration#property.
}
}

Expand Down
36 changes: 18 additions & 18 deletions snapshots/output/syntax/src/inheritance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ export abstract class Superclass {
}
export abstract class IntermediateSuperclass extends Superclass {
// ^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superclass#
// relationship implementation syntax 1.0.0 src/`inheritance.ts`/Superclass#
// ^^^^^^^^^^ reference syntax 1.0.0 src/`inheritance.ts`/Superclass#
public override overrideMethod(): string {
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#overrideMethod().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superclass#overrideMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superclass#overrideMethod().
return 'this will get overridden'
}
public abstract intermediateOverrideMethod(): string
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#intermediateOverrideMethod().
}
export class Subclass
// ^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperinterface#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superclass#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#
// relationship implementation scip-typescript npm syntax 1.0.0 src/`overload.d.ts`/Overloader#
// relationship implementation syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#
// relationship implementation syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperinterface#
// relationship implementation syntax 1.0.0 src/`inheritance.ts`/Superclass#
// relationship implementation syntax 1.0.0 src/`inheritance.ts`/Superinterface#
// relationship implementation syntax 1.0.0 src/`overload.d.ts`/Overloader#
extends IntermediateSuperclass
// ^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#
implements IntermediateSuperinterface, Overloader
Expand All @@ -49,7 +49,7 @@ export class Subclass
{
public onLiteral(param: any): void {
// ^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#onLiteral().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`overload.d.ts`/Overloader#onLiteral().
// relationship implementation reference syntax 1.0.0 src/`overload.d.ts`/Overloader#onLiteral().
// ^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#onLiteral().(param)
throw new Error('Method not implemented.' + param)
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error#
Expand All @@ -58,32 +58,32 @@ export class Subclass
}
property = 'property'
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#property.
//relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
public overrideMethod(): string {
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#overrideMethod().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#overrideMethod().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superclass#overrideMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#overrideMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superclass#overrideMethod().
throw new Error('Method not implemented.')
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error#
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error.
}
public intermediateOverrideMethod(): string {
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#intermediateOverrideMethod().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#intermediateOverrideMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperclass#intermediateOverrideMethod().
throw new Error('Method not implemented.')
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error#
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error.
}
public interfaceMethod(): string {
// ^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#interfaceMethod().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
throw new Error('Method not implemented.')
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error#
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error.
}
public intermediateInterfaceMethod(): string {
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Subclass#intermediateInterfaceMethod().
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperinterface#intermediateInterfaceMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/IntermediateSuperinterface#intermediateInterfaceMethod().
throw new Error('Method not implemented.')
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error#
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error.
Expand All @@ -94,10 +94,10 @@ export const objectLiteralImplementation: Superinterface = {
// ^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#
property: 'property',
//^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property0:
//relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
interfaceMethod: (): string => {
//^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/interfaceMethod0:
//relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
//relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
throw new Error('Function not implemented.')
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error#
// ^^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Error.
Expand All @@ -113,10 +113,10 @@ export function infersInterface(): void {
//^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`inheritance.ts`/consumesInterface().
interfaceMethod: (): string => 'inferred',
// ^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/interfaceMethod1:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#interfaceMethod().
property: 'inferred',
// ^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/property1:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
// relationship implementation reference syntax 1.0.0 src/`inheritance.ts`/Superinterface#property.
})
}

6 changes: 3 additions & 3 deletions snapshots/output/syntax/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ export function newInterface(): Interface {
return {
property: 'a',
// ^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/property0:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`interface.ts`/Interface#property.
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/Interface#property.
methodSignature(param: string): string {
// ^^^^^^^^^^^^^^^ definition local 4
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`interface.ts`/Interface#methodSignature().
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/Interface#methodSignature().
// ^^^^^ definition local 5
return param
// ^^^^^ reference local 5
},
methodSignature2: (param: string): string => {
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/methodSignature20:
// relationship implementation reference scip-typescript npm syntax 1.0.0 src/`interface.ts`/Interface#methodSignature2.
// relationship implementation reference syntax 1.0.0 src/`interface.ts`/Interface#methodSignature2.
// ^^^^^ definition local 7
return param
// ^^^^^ reference local 7
Expand Down
14 changes: 7 additions & 7 deletions src/SnapshotTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ function parseOptions(lines: string[]): {
return formatOptions
}

function symbolNameForSnapshot(occurrence: scip.Occurrence): string {
return occurrence.symbol.startsWith(stripIndexerPrefix)
? occurrence.symbol.slice(stripIndexerPrefix.length)
: occurrence.symbol
function symbolNameForSnapshot(fullName: string): string {
return fullName.startsWith(stripIndexerPrefix)
? fullName.slice(stripIndexerPrefix.length)
: fullName
}

export function formatSnapshot(
Expand Down Expand Up @@ -144,7 +144,7 @@ export function formatSnapshot(
if (relationship.is_type_definition) {
out.push(' type_definition')
}
out.push(' ' + relationship.symbol)
out.push(' ' + symbolNameForSnapshot(relationship.symbol))
}
}

Expand Down Expand Up @@ -181,7 +181,7 @@ export function formatSnapshot(
out.push(' < ')
out.push(isDefinition ? 'definition' : 'reference')
out.push(' ')
out.push(symbolNameForSnapshot(occurrence))
out.push(symbolNameForSnapshot(occurrence.symbol))
pushDoc(range, occurrence.symbol, isDefinition, true)
out.push('\n')

Expand Down Expand Up @@ -230,7 +230,7 @@ export function formatSnapshot(
(occurrence.symbol_roles & scip.SymbolRole.Definition) > 0
out.push(isDefinition ? 'definition' : 'reference')
out.push(' ')
const symbol = symbolNameForSnapshot(occurrence)
const symbol = symbolNameForSnapshot(occurrence.symbol)
out.push(symbol.replace('\n', '|'))

pushDoc(range, occurrence.symbol, isDefinition, isStartOfLine)
Expand Down