This repository was archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Add LSIF support #229
Merged
Merged
Add LSIF support #229
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9266153
Remove feedback button
chrismwendt 9b1acbe
Bump sourcegraph 23.0.1
chrismwendt eba101c
Bump basic-code-intel 7.0.3
chrismwendt 4b57e6c
Add LSIF support
chrismwendt 1e998aa
Use Felix's suggestion
chrismwendt 203f971
reorganize
chrismwendt 1669c05
reorganize
chrismwendt b141c30
Bump basic-code-intel 7.0.4
chrismwendt 08324dc
prettier
chrismwendt c447618
Forgot to add a file
chrismwendt 22bf37d
Bump basic-code-intel 7.0.5
chrismwendt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { Handler, Providers } from '@sourcegraph/basic-code-intel' | ||
| import * as path from 'path' | ||
| import * as sourcegraph from 'sourcegraph' | ||
|
|
||
| export function initBasicCodeIntel(): Providers { | ||
| return new Handler({ | ||
| sourcegraph, | ||
| languageID: 'typescript', | ||
| fileExts: ['ts', 'tsx', 'js', 'jsx'], | ||
| commentStyle: { | ||
| lineRegex: /\/\/\s?/, | ||
| block: { | ||
| startRegex: /\/\*\*?/, | ||
| lineNoiseRegex: /(^\s*\*\s?)?/, | ||
| endRegex: /\*\//, | ||
| }, | ||
| }, | ||
| filterDefinitions: ({ filePath, fileContent, results }) => { | ||
| const imports = fileContent | ||
| .split('\n') | ||
| .map(line => { | ||
| // Matches the import at index 1 | ||
| const match = /\bfrom ['"](.*)['"];?$/.exec(line) || /\brequire\(['"](.*)['"]\)/.exec(line) | ||
| return match ? match[1] : undefined | ||
| }) | ||
| .filter((x): x is string => Boolean(x)) | ||
|
|
||
| const filteredResults = results.filter(result => | ||
| imports.some(i => path.join(path.dirname(filePath), i) === result.file.replace(/\.[^/.]+$/, '')) | ||
| ) | ||
|
|
||
| return filteredResults.length === 0 ? results : filteredResults | ||
| }, | ||
| }) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not important, maybe keep in mind for future code) Since this is only a factory function now, I'd recommend the
createprefix instead ofinit. That's the conventional prefix used e.g. in the Node stdlib. Withinit, I personally wouldn't be sure if it might do side effects like register providers in the Sourcegraph API, whilecreatecommunicates it's only creating an object but not causes side effects (assuming that is the case here)