diff --git a/Development.md b/Development.md index ca0c6249..9f463d1c 100644 --- a/Development.md +++ b/Development.md @@ -50,8 +50,7 @@ loop during local development. ```sh cd /path/to/dir DIR=/path/to/scip-typescript "$DIR/node_modules/.bin/tsx" "$DIR/src/main.ts" index # add --yarn-workspaces if applicable -lsif-typed index.scip > dump.lsif # from github.com/sourcegraph/sourcegraph/lib/codeintel/tools/lsif-typed -lsif-java snapshot-lsif # from github.com/sourcegraph/lsif-java +scip snapshot # from github.com/sourcegraph/scip ``` ## Publishing a release diff --git a/README.md b/README.md index c5cbe42a..e797cf17 100644 --- a/README.md +++ b/README.md @@ -117,20 +117,6 @@ index --no-global-caches REST_OF_THE_COMMAND`. By default, scip-typescript `node --max-old-space-size=16000 "$(which scip-typescript)" index REST_OF_COMMAND`. Replace 16000 with an even larger number if your computer has bigger RAM. -## Migrating from lsif-node - -Before creating scip-typescript, we used another TypeScript indexer called -[lsif-node](https://github.com/sourcegraph/lsif-node). We recommend migrating -to scip-typescript if you are using lsif-node. - -Follow the steps below to migrate from lsif-node to scip-typescript: - -- Replace usages of the `lsif-tsc -p ARGUMENTS` command with `scip-typescript index ARGUMENTS`. -- Upgrade to the latest version of the `src` command-line interface, which you - can install via `yarn global add @sourcegraph/src`. It’s okay if the version - of your `src` command-line interface does not match the version of your - Sourcegraph instance. - ## Contributing See [Development.md](./Development.md) for docs on how to work on this project. diff --git a/snapshots/input/syntax/dump.svg b/snapshots/input/syntax/dump.svg deleted file mode 100644 index 408f8324..00000000 --- a/snapshots/input/syntax/dump.svg +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - -G - - - -v4 - -(4) referenceResult - - - -v13 - -(13) definitionResult - - - -v51 - -(51) range {"start":{"line":0,"character":16},"end":{"line":0,"character":21}} - - - -v13->v51 - - -(53) item - - - -v43 - -(43) referenceResult - - - -v57 - -(57) range {"start":{"line":2,"character":9},"end":{"line":2,"character":10}} - - - -v43->v57 - - -(59) item - - - -v41 - -(41) definitionResult - - - -v54 - -(54) range {"start":{"line":1,"character":8},"end":{"line":1,"character":9}} - - - -v41->v54 - - -(56) item - - - -v42 - -(42) resultSet - - - -v57->v42 - - -(58) next - - - -v3 - -(3) resultSet - - - -v3->v4 - - -(7) textDocument/references - - - -v9 - -(9) moniker {"Kind":"export","Scheme":"lsif-node","Identifier":"lsif-node npm example 1.0.0 src/example.ts/"} - - - -v3->v9 - - -(10) moniker - - - -v5 - -(5) hoverResult "export function hello(): string { -  const a = 'a' -  return a -}" - - - -v3->v5 - - -(8) textDocument/hover - - - -v2 - -(2) definitionResult - - - -v3->v2 - - -(6) textDocument/definition - - - -v11 - -(11) packageInformation {"Name":"example","Version":"1.0.0"} - - - -v15 - -(15) referenceResult - - - -v16 - -(16) hoverResult "export function hello(): string { -  const a = 'a' -  return a -}" - - - -v42->v43 - - -(46) textDocument/references - - - -v42->v41 - - -(45) textDocument/definition - - - -v48 - -(48) moniker {"Kind":"export","Scheme":"local","Identifier":"local 2"} - - - -v42->v48 - - -(49) moniker - - - -v44 - -(44) hoverResult "a = 'a'" - - - -v42->v44 - - -(47) textDocument/hover - - - -v9->v11 - - -(12) packageInformation - - - -v50 - -(50) document "file:///Users/olafurpg/dev/sourcegraph/lsif-node/snapshots/input/example/src/example.ts" - - - -v50->v57 - - -(60) contains - - - -v50->v51 - - -(60) contains - - - -v50->v54 - - -(60) contains - - - -v14 - -(14) resultSet - - - -v14->v13 - - -(17) textDocument/definition - - - -v14->v15 - - -(18) textDocument/references - - - -v14->v16 - - -(19) textDocument/hover - - - -v20 - -(20) moniker {"Kind":"export","Scheme":"lsif-node","Identifier":"lsif-node npm example 1.0.0 src/example.ts/hello()."} - - - -v14->v20 - - -(21) moniker - - - -v20->v11 - - -(22) packageInformation - - - -v51->v14 - - -(52) next - - - -v54->v42 - - -(55) next - - - diff --git a/src/FileIndexer.ts b/src/FileIndexer.ts index 0d8a491d..01b7212a 100644 --- a/src/FileIndexer.ts +++ b/src/FileIndexer.ts @@ -322,7 +322,7 @@ export class FileIndexer { if (isDefinitionNode) { this.addSymbolInformation(node, sym, declaration, scipSymbol) this.handleObjectBindingPattern(node, range) - // Only emit one symbol for definitions sites, see https://github.com/sourcegraph/lsif-typescript/issues/45 + // Only emit one symbol for definitions sites, see https://github.com/sourcegraph/scip-typescript/issues/45 break } } @@ -732,7 +732,7 @@ export class FileIndexer { return this.scipSymbol(decl) } } catch { - // TODO: https://github.com/sourcegraph/lsif-typescript/issues/34 + // TODO: https://github.com/sourcegraph/scip-typescript/issues/34 // continue regardless of error, the TypeScript compiler tends to // trigger stack overflows in getTypeOfSymbolAtLocation and we // don't know why yet. diff --git a/src/Range.ts b/src/Range.ts index 03ccef5e..ea3c9478 100644 --- a/src/Range.ts +++ b/src/Range.ts @@ -14,7 +14,7 @@ export class Range { } return this.end.compare(other.end) } - public toLsif(): number[] { + public toPackedRange(): number[] { if (this.isSingleLine()) { return [this.start.line, this.start.character, this.end.character] } @@ -25,7 +25,7 @@ export class Range { this.end.character, ] } - public static fromLsif(range: number[]): Range { + public static fromPackedRange(range: number[]): Range { const endLine = range.length === 3 ? range[0] : range[2] const endCharacter = range.length === 3 ? range[2] : range[3] return new Range( diff --git a/src/SnapshotTesting.ts b/src/SnapshotTesting.ts index 5d10cdfd..478c6b23 100644 --- a/src/SnapshotTesting.ts +++ b/src/SnapshotTesting.ts @@ -89,7 +89,7 @@ export function formatSnapshot( if (formatOptions.showRanges && occurrence.enclosingRange.length > 0) { enclosingRanges.push({ - range: Range.fromLsif(occurrence.enclosingRange), + range: Range.fromPackedRange(occurrence.enclosingRange), symbol: occurrence.symbol, }) } @@ -244,7 +244,7 @@ export function formatSnapshot( // This is the only case where we would need to do this. if (occurrenceIndex === 0) { const occurrence = doc.occurrences[occurrenceIndex] - const range = Range.fromLsif(occurrence.range) + const range = Range.fromPackedRange(occurrence.range) // This is essentially a "file-based" item. // This guarantees that this sits above everything else in the file. @@ -286,7 +286,7 @@ export function formatSnapshot( throw new Error('not yet implemented, multi-line ranges') } - const range = Range.fromLsif(occurrence.range) + const range = Range.fromPackedRange(occurrence.range) out.push(commentSyntax) const isStartOfLine = range.start.character === 0 @@ -336,7 +336,7 @@ export function formatSnapshot( } function occurrencesByLine(a: Occurrence, b: Occurrence): number { - return Range.fromLsif(a.range).compare(Range.fromLsif(b.range)) + return Range.fromPackedRange(a.range).compare(Range.fromPackedRange(b.range)) } function enclosingRangesByLine( diff --git a/src/SourceInfo.ts b/src/SourceInfo.ts index 97c48b9b..c8a48e84 100644 --- a/src/SourceInfo.ts +++ b/src/SourceInfo.ts @@ -32,7 +32,7 @@ export function typescriptSourceInfo(sourceFile: ts.SourceFile): SourceInfo { fileName: sourceFile.fileName, originalText: sourceFile.getText(), isSvelte: false, - range: node => Range.fromNode(node).toLsif(), + range: node => Range.fromNode(node).toPackedRange(), declarationSymbol: () => undefined, releaseCaches: () => {}, } diff --git a/src/main.test.ts b/src/main.test.ts index e1bcfe44..051b2f57 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -106,7 +106,7 @@ for (const snapshotDirectory of snapshotDirectories) { fs.mkdirSync(outputRoot, { recursive: true }) fs.renameSync(output, path.join(outputRoot, 'index.scip')) if (index.documents.length === 0) { - throw new Error('empty LSIF index') + throw new Error('empty SCIP index') } if (index.documents.some(document => document.language === 'Svelte')) { assertStableSvelteSymbols(index)