Skip to content

Commit b3143f1

Browse files
authored
Remove remnants from "LSIF Typed" (sourcegraph#191)
* Remove remnants from "LSIF Typed" The codebase had a lot of outdated references to "LSIF Typed", which has been renamed to SCIP. This commit replaces these outdated references to avoid confusion for people who are reading the codebase for the first time. * Empty commit to trigger ci
1 parent 2d39f91 commit b3143f1

20 files changed

+1759
-1618
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
parserOptions: {
88
project: 'tsconfig.json',
99
},
10-
ignorePatterns: ['temp', 'lsif.ts', 'snapshots'],
10+
ignorePatterns: ['temp', 'scip.ts', 'snapshots'],
1111
rules: {
1212
'no-sync': 'off',
1313
},

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dist
22
node_modules
3-
src/lsif.ts
3+
src/scip.ts
44
snapshots/output

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
"homepage": "https://github.com/sourcegraph/scip-typescript#readme",
3535
"dependencies": {
3636
"commander": "^9.2.0",
37-
"google-protobuf": "^3.20.0",
37+
"google-protobuf": "^3.20.1",
3838
"pretty-ms": "^7.0.1",
3939
"progress": "^2.0.3",
40-
"typescript": "^4.5.4"
40+
"typescript": "^4.8.4"
4141
},
4242
"devDependencies": {
4343
"@sourcegraph/eslint-config": "0.32.0",
4444
"@sourcegraph/prettierrc": "3.0.3",
4545
"@sourcegraph/tsconfig": "4.0.1",
4646
"@types/diff": "5.0.2",
47-
"@types/google-protobuf": "3.15.5",
47+
"@types/google-protobuf": "3.15.6",
4848
"@types/node": "17.0.14",
4949
"@types/pretty-ms": "5.0.1",
5050
"@types/progress": "2.0.5",

snapshots/input/syntax/src/issue-45.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export namespace example {
22
class Server {
3-
// This overloaded method reproduces the following issue https://github.com/sourcegraph/lsif-typescript/issues/45
3+
// This overloaded method reproduces the following issue https://github.com/sourcegraph/scip-typescript/issues/45
44
addListener(name: 'a'): void
55
addListener(name: 'b'): void
66
}

snapshots/output/syntax/src/issue-45.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Server {
77
// ^^^^^^ definition syntax 1.0.0 src/`issue-45.d.ts`/example/Server#
88
// documentation ```ts\nclass Server\n```
9-
// This overloaded method reproduces the following issue https://github.com/sourcegraph/lsif-typescript/issues/45
9+
// This overloaded method reproduces the following issue https://github.com/sourcegraph/scip-typescript/issues/45
1010
addListener(name: 'a'): void
1111
// ^^^^^^^^^^^ definition syntax 1.0.0 src/`issue-45.d.ts`/example/Server#addListener().
1212
// documentation ```ts\n(method) addListener(name: "a"): void\n```

src/.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lsif.ts linguist-generated=true
1+
scip.ts linguist-generated=true

src/CommandLineOptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import ts from 'typescript'
44

55
import packageJson from '../package.json'
66

7-
import * as lsif from './lsif'
7+
import * as scip from './scip'
88

99
/** Configuration options to index a multi-project workspace. */
1010
export interface MultiProjectOptions {
@@ -22,7 +22,7 @@ export interface MultiProjectOptions {
2222
export interface ProjectOptions extends MultiProjectOptions {
2323
projectRoot: string
2424
projectDisplayName: string
25-
writeIndex: (index: lsif.lib.codeintel.lsiftyped.Index) => void
25+
writeIndex: (index: scip.scip.Index) => void
2626
}
2727

2828
/** Cached values */
@@ -42,7 +42,7 @@ export function mainCommand(
4242
.name('scip-typescript')
4343
.version(packageJson.version)
4444
.description(
45-
'LSIF indexer for TypeScript and JavaScript\nFor usage examples, see https://github.com/sourcegraph/scip-typescript/blob/main/README.md'
45+
'SCIP indexer for TypeScript and JavaScript\nFor usage examples, see https://github.com/sourcegraph/scip-typescript/blob/main/README.md'
4646
)
4747
command
4848
.command('index')

src/Descriptor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as lsif from './lsif'
1+
import * as scip from './scip'
22

3-
type Descriptor = lsif.lib.codeintel.lsiftyped.Descriptor
4-
const Descriptor = lsif.lib.codeintel.lsiftyped.Descriptor
5-
type Suffix = lsif.lib.codeintel.lsiftyped.Descriptor.Suffix
6-
const Suffix = lsif.lib.codeintel.lsiftyped.Descriptor.Suffix
3+
type Descriptor = scip.scip.Descriptor
4+
const Descriptor = scip.scip.Descriptor
5+
type Suffix = scip.scip.Descriptor.Suffix
6+
const Suffix = scip.scip.Descriptor.Suffix
77

88
export function packageDescriptor(name: string): Descriptor {
99
return new Descriptor({ name, suffix: Suffix.Package })

src/FileIndexer.ts

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,23 @@ import {
1414
typeParameterDescriptor,
1515
} from './Descriptor'
1616
import { Input } from './Input'
17-
import * as lsif from './lsif'
18-
import { LsifSymbol } from './LsifSymbol'
19-
import { lsiftyped } from './main'
2017
import { Packages } from './Packages'
2118
import { Range } from './Range'
19+
import * as scip from './scip'
20+
import { ScipSymbol } from './ScipSymbol'
2221
import * as ts_inline from './TypeScriptInternal'
2322

24-
type Descriptor = lsif.lib.codeintel.lsiftyped.Descriptor
25-
type Relationship = lsif.lib.codeintel.lsiftyped.Relationship
26-
2723
export class FileIndexer {
2824
private localCounter = new Counter()
2925
private propertyCounters: Map<string, Counter> = new Map()
30-
private localSymbolTable: Map<ts.Node, LsifSymbol> = new Map()
26+
private localSymbolTable: Map<ts.Node, ScipSymbol> = new Map()
3127
private workingDirectoryRegExp: RegExp
3228
constructor(
3329
public readonly checker: ts.TypeChecker,
3430
public readonly options: ProjectOptions,
3531
public readonly input: Input,
36-
public readonly document: lsif.lib.codeintel.lsiftyped.Document,
37-
public readonly globalSymbolTable: Map<ts.Node, LsifSymbol>,
32+
public readonly document: scip.scip.Document,
33+
public readonly globalSymbolTable: Map<ts.Node, ScipSymbol>,
3834
public readonly packages: Packages,
3935
public readonly sourceFile: ts.SourceFile
4036
) {
@@ -45,21 +41,21 @@ export class FileIndexer {
4541
this.visit(this.sourceFile)
4642
}
4743
private emitSourceFileOccurrence(): void {
48-
const symbol = this.lsifSymbol(this.sourceFile)
44+
const symbol = this.scipSymbol(this.sourceFile)
4945
if (symbol.isEmpty()) {
5046
return
5147
}
5248
this.document.occurrences.push(
53-
new lsif.lib.codeintel.lsiftyped.Occurrence({
49+
new scip.scip.Occurrence({
5450
range: [0, 0, 0],
5551
symbol: symbol.value,
56-
symbol_roles: lsiftyped.SymbolRole.Definition,
52+
symbol_roles: scip.scip.SymbolRole.Definition,
5753
})
5854
)
5955
const moduleName =
6056
this.sourceFile.moduleName || path.basename(this.sourceFile.fileName)
6157
this.document.symbols.push(
62-
new lsiftyped.SymbolInformation({
58+
new scip.scip.SymbolInformation({
6359
symbol: symbol.value,
6460
documentation: ['```ts\nmodule "' + moduleName + '"\n```'],
6561
})
@@ -106,24 +102,24 @@ export class FileIndexer {
106102
let role = 0
107103
const isDefinition = this.declarationName(node.parent) === node
108104
if (isDefinition) {
109-
role |= lsiftyped.SymbolRole.Definition
105+
role |= scip.scip.SymbolRole.Definition
110106
}
111107
for (const declaration of sym?.declarations || []) {
112-
const lsifSymbol = this.lsifSymbol(declaration)
108+
const scipSymbol = this.scipSymbol(declaration)
113109

114-
if (lsifSymbol.isEmpty()) {
110+
if (scipSymbol.isEmpty()) {
115111
// Skip empty symbols
116112
continue
117113
}
118114
this.document.occurrences.push(
119-
new lsif.lib.codeintel.lsiftyped.Occurrence({
115+
new scip.scip.Occurrence({
120116
range,
121-
symbol: lsifSymbol.value,
117+
symbol: scipSymbol.value,
122118
symbol_roles: role,
123119
})
124120
)
125121
if (isDefinition) {
126-
this.addSymbolInformation(node, sym, declaration, lsifSymbol)
122+
this.addSymbolInformation(node, sym, declaration, scipSymbol)
127123
this.handleShorthandPropertyDefinition(declaration, range)
128124
this.handleObjectBindingPattern(node, range)
129125
// Only emit one symbol for definitions sites, see https://github.com/sourcegraph/lsif-typescript/issues/45
@@ -153,14 +149,14 @@ export class FileIndexer {
153149
const tpe = this.checker.getTypeAtLocation(node.parent.parent)
154150
const property = tpe.getProperty(node.getText())
155151
for (const declaration of property?.declarations || []) {
156-
const lsifSymbol = this.lsifSymbol(declaration)
157-
if (lsifSymbol.isEmpty()) {
152+
const scipSymbol = this.scipSymbol(declaration)
153+
if (scipSymbol.isEmpty()) {
158154
continue
159155
}
160156
this.document.occurrences.push(
161-
new lsif.lib.codeintel.lsiftyped.Occurrence({
157+
new scip.scip.Occurrence({
162158
range,
163-
symbol: lsifSymbol.value,
159+
symbol: scipSymbol.value,
164160
})
165161
)
166162
}
@@ -190,14 +186,14 @@ export class FileIndexer {
190186
return
191187
}
192188
for (const symbol of valueSymbol?.declarations || []) {
193-
const lsifSymbol = this.lsifSymbol(symbol)
194-
if (lsifSymbol.isEmpty()) {
189+
const scipSymbol = this.scipSymbol(symbol)
190+
if (scipSymbol.isEmpty()) {
195191
continue
196192
}
197193
this.document.occurrences.push(
198-
new lsif.lib.codeintel.lsiftyped.Occurrence({
194+
new scip.scip.Occurrence({
199195
range,
200-
symbol: lsifSymbol.value,
196+
symbol: scipSymbol.value,
201197
})
202198
)
203199
}
@@ -210,7 +206,7 @@ export class FileIndexer {
210206
node: ts.Node,
211207
sym: ts.Symbol,
212208
declaration: ts.Node,
213-
symbol: LsifSymbol
209+
symbol: ScipSymbol
214210
): void {
215211
const documentation = [
216212
'```ts\n' +
@@ -223,7 +219,7 @@ export class FileIndexer {
223219
}
224220

225221
this.document.symbols.push(
226-
new lsiftyped.SymbolInformation({
222+
new scip.scip.SymbolInformation({
227223
symbol: symbol.value,
228224
documentation,
229225
relationships: this.relationships(declaration, symbol),
@@ -233,15 +229,15 @@ export class FileIndexer {
233229

234230
private relationships(
235231
declaration: ts.Node,
236-
declarationSymbol: LsifSymbol
237-
): Relationship[] {
238-
const relationships: Relationship[] = []
232+
declarationSymbol: ScipSymbol
233+
): scip.scip.Relationship[] {
234+
const relationships: scip.scip.Relationship[] = []
239235
const isAddedSymbol = new Set<string>()
240236
const pushImplementation = (
241237
node: ts.NamedDeclaration,
242238
isReferences: boolean
243239
): void => {
244-
const symbol = this.lsifSymbol(node)
240+
const symbol = this.scipSymbol(node)
245241
if (symbol.isEmpty()) {
246242
return
247243
}
@@ -255,7 +251,7 @@ export class FileIndexer {
255251
}
256252
isAddedSymbol.add(symbol.value)
257253
relationships.push(
258-
new lsiftyped.Relationship({
254+
new scip.scip.Relationship({
259255
symbol: symbol.value,
260256
is_implementation: true,
261257
is_reference: isReferences,
@@ -309,19 +305,19 @@ export class FileIndexer {
309305
return undefined
310306
}
311307

312-
private lsifSymbol(node: ts.Node): LsifSymbol {
313-
const fromCache: LsifSymbol | undefined =
308+
private scipSymbol(node: ts.Node): ScipSymbol {
309+
const fromCache: ScipSymbol | undefined =
314310
this.globalSymbolTable.get(node) || this.localSymbolTable.get(node)
315311
if (fromCache) {
316312
return fromCache
317313
}
318314
if (ts.isBlock(node)) {
319-
return LsifSymbol.empty()
315+
return ScipSymbol.empty()
320316
}
321317
if (ts.isSourceFile(node)) {
322318
const package_ = this.packages.symbol(node.fileName)
323319
if (!package_) {
324-
return this.cached(node, LsifSymbol.empty())
320+
return this.cached(node, ScipSymbol.empty())
325321
}
326322
return this.cached(node, package_)
327323
}
@@ -337,8 +333,8 @@ export class FileIndexer {
337333
}
338334
return this.cached(
339335
node,
340-
LsifSymbol.global(
341-
this.lsifSymbol(node.getSourceFile()),
336+
ScipSymbol.global(
337+
this.scipSymbol(node.getSourceFile()),
342338
metaDescriptor(`${node.name.getText()}${counter.next()}`)
343339
)
344340
)
@@ -362,7 +358,7 @@ export class FileIndexer {
362358
const tpe = this.checker.getTypeOfSymbolAtLocation(props, node)
363359
const property = tpe.getProperty(node.name.text)
364360
for (const decl of property?.declarations || []) {
365-
return this.lsifSymbol(decl)
361+
return this.scipSymbol(decl)
366362
}
367363
} catch {
368364
// TODO: https://github.com/sourcegraph/lsif-typescript/issues/34
@@ -373,25 +369,25 @@ export class FileIndexer {
373369
}
374370
}
375371

376-
const owner = this.lsifSymbol(node.parent)
372+
const owner = this.scipSymbol(node.parent)
377373
if (owner.isEmpty() || owner.isLocal()) {
378374
return this.newLocalSymbol(node)
379375
}
380376

381377
if (isAnonymousContainerOfSymbols(node)) {
382-
return this.cached(node, this.lsifSymbol(node.parent))
378+
return this.cached(node, this.scipSymbol(node.parent))
383379
}
384380

385381
if (ts.isImportSpecifier(node) || ts.isImportClause(node)) {
386382
const tpe = this.checker.getTypeAtLocation(node)
387383
for (const declaration of tpe.symbol?.declarations || []) {
388-
return this.lsifSymbol(declaration)
384+
return this.scipSymbol(declaration)
389385
}
390386
}
391387

392388
const desc = this.descriptor(node)
393389
if (desc) {
394-
return this.cached(node, LsifSymbol.global(owner, desc))
390+
return this.cached(node, ScipSymbol.global(owner, desc))
395391
}
396392

397393
// Fallback case: generate a local symbol. It's not a bug when this case
@@ -401,16 +397,16 @@ export class FileIndexer {
401397
return this.newLocalSymbol(node)
402398
}
403399

404-
private newLocalSymbol(node: ts.Node): LsifSymbol {
405-
const symbol = LsifSymbol.local(this.localCounter.next())
400+
private newLocalSymbol(node: ts.Node): ScipSymbol {
401+
const symbol = ScipSymbol.local(this.localCounter.next())
406402
this.localSymbolTable.set(node, symbol)
407403
return symbol
408404
}
409-
private cached(node: ts.Node, symbol: LsifSymbol): LsifSymbol {
405+
private cached(node: ts.Node, symbol: ScipSymbol): ScipSymbol {
410406
this.globalSymbolTable.set(node, symbol)
411407
return symbol
412408
}
413-
private descriptor(node: ts.Node): Descriptor | undefined {
409+
private descriptor(node: ts.Node): scip.scip.Descriptor | undefined {
414410
if (
415411
ts.isInterfaceDeclaration(node) ||
416412
ts.isEnumDeclaration(node) ||

0 commit comments

Comments
 (0)