Skip to content

Commit

Permalink
[scip][typescript] Port typescript indexer from LSIF to SCIP
Browse files Browse the repository at this point in the history
Faster, more precise. Aligned with go and rust-analyer

Currently blocked on sourcegraph/scip-typescript#263
but we might be able to work around this
  • Loading branch information
donsbot committed Jun 27, 2023
1 parent bbbc51f commit aacd1cd
Show file tree
Hide file tree
Showing 145 changed files with 6,809 additions and 13,828 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
curl -LO "https://nodejs.org/dist/v18.0.0/${NODEARCH}.tar.xz"
tar -xvf "${NODEARCH}.tar.xz"
cp -r "${NODEARCH}"/* "$HOME"/.hsthrift/
npm install -g @sourcegraph/lsif-tsc
npm install -g @sourcegraph/scip-typescript
- name: Install indexer (rust)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-clang-rocksdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
curl -LO "https://nodejs.org/dist/v18.0.0/${NODEARCH}.tar.xz"
tar -xvf "${NODEARCH}.tar.xz"
cp -r "${NODEARCH}"/* "$HOME"/.hsthrift/
npm install -g @sourcegraph/lsif-tsc
npm install -g @sourcegraph/scip-typescript
- name: Install indexer (go)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs
npm install -g @sourcegraph/lsif-tsc
npm install -g @sourcegraph/scip-typescript
- name: Install indexer (go)
run: |
Expand Down
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,24 @@ There is currently full support for:
* [Haskell](https://glean.software/docs/indexer/haskell)
* [JavaScript/Flow](https://glean.software/docs/indexer/flow)

We are actively adding support for:
We also support the [SCIP](https://github.com/sourcegraph/scip) or [LSIF](https://lsif.dev) code indexing formats, for:

* Rust
* [Rust (via rust-analyzer)](https://glean.software/docs/indexer/lsif-rust)
* [Go](https://glean.software/docs/indexer/lsif-go)
* [TypeScript](https://glean.software/docs/indexer/lsif-typescript)
* [Java](https://glean.software/docs/indexer/lsif-java)

Indexers for these languages exist but aren't in the open source
release yet; we hope to make these available in the future:

* Python
* Objective-C
* Java
* Kotlin
* Erlang
* Thrift
* Buck

We have also added support for the [LSIF](https://lsif.dev) code indexing format.
The following LSIF indexers are supported:

* [TypeScript](https://glean.software/docs/indexer/lsif-typescript)
* [Go](https://glean.software/docs/indexer/lsif-go)
* [Rust](https://glean.software/docs/indexer/lsif-rust)
* [Java](https://glean.software/docs/indexer/lsif-java)

LSIF indexers are more limited than full language indexers, but are sufficient
for common code navigation and symbol search use cases.

## License

Glean is licensed under a [BSD LICENSE](LICENSE).
Expand Down
4 changes: 4 additions & 0 deletions glean/glass/Glean/Glass/SymbolId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ entityLanguage e = case e of
-- scip languages
Code.Entity_scip Scip.Entity_rust{} -> Language_Rust
Code.Entity_scip Scip.Entity_go{} -> Language_Go
Code.Entity_scip Scip.Entity_typescript{} -> Language_TypeScript
Code.Entity_scip _ -> Language__UNKNOWN 0
Code.Entity_EMPTY -> Language__UNKNOWN 0

Expand Down Expand Up @@ -291,6 +292,7 @@ instance Symbol Code.Entity where
Code.Entity_scip ent -> case ent of
Scip.Entity_rust se -> toSymbolWithPath se p
Scip.Entity_go se -> toSymbolWithPath se p
Scip.Entity_typescript se -> toSymbolWithPath se p
Scip.Entity_EMPTY -> throwM $ SymbolError "Unknown SCIP language"

-- Code.Entity_lsif (Lsif.Entity_java x) -> toSymbol x
Expand Down Expand Up @@ -337,6 +339,7 @@ entityToAngle e = case e of
Code.Entity_scip se -> alt @"scip" <$> case se of
Scip.Entity_rust x -> Right $ alt @"rust" (toAngle x)
Scip.Entity_go x -> Right $ alt @"go" (toAngle x)
Scip.Entity_typescript x -> Right $ alt @"typescript" (toAngle x)
Scip.Entity_EMPTY -> Left "toAngle: Unknown SCIP language"

_ -> Left $
Expand Down Expand Up @@ -369,6 +372,7 @@ instance ToQName Code.Entity where
Code.Entity_scip se -> case se of -- enumerate all cases for lsif
Scip.Entity_rust x -> toQName x
Scip.Entity_go x -> toQName x
Scip.Entity_typescript x -> toQName x
Scip.Entity_EMPTY -> pure $ Left "SCIP: language unsupported"
_ -> pure $ Left ("Language unsupported: " <> textShow (entityLanguage e))

Expand Down
1 change: 1 addition & 0 deletions glean/glass/Glean/Glass/SymbolSig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ instance ToSymbolSignature Code.Entity where
Code.Entity_scip e -> case e of
Scip.Entity_rust x -> SCIP.prettyScipSignature opts x
Scip.Entity_go x -> SCIP.prettyScipSignature opts x
Scip.Entity_typescript x -> SCIP.prettyScipSignature opts x
Scip.Entity_EMPTY -> pure Nothing
-- lsif languages, just enumerate completely to stay total
Code.Entity_lsif e -> case e of
Expand Down
17 changes: 1 addition & 16 deletions glean/glass/test/regression/Glean/Glass/Regression/TypeScript.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,12 @@

module Glean.Glass.Regression.TypeScript (main) where

import Test.HUnit

import Glean.Glass.Regression.Snapshot as Glass
import Glean.Glass.Regression.Tests
import Glean.Glass.Types
import Glean.Indexer.Typescript as Typescript

main :: IO ()
main = mainGlassSnapshot testName testPath testIndexer unitTests
main = mainGlassSnapshot testName testPath testIndexer (const [])
where
testName = "glass-regression-typescript"
testPath = "glean/glass/test/regression/tests/typescript"
testIndexer = Typescript.indexer

-- some legacy unit tests
unitTests :: Glass.Getter -> [Test]
unitTests get =
[ testDocumentSymbolListX path get
, testResolveSymbol sym path get
, testDescribeSymbolMatchesPath sym path get
]
where
path = Path "glean/lang/typescript/tests/cases/xrefs/example.ts"
sym = SymbolId "test/ts/lsif/example%3AcreateTempRepo"
51 changes: 0 additions & 51 deletions glean/glass/test/regression/tests/typescript/describeSymbol.out

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit aacd1cd

Please sign in to comment.