-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Added Tree sitter provider #2488
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
56cfb70
Added Tree sitter provider
AndreasArvidsson 6d46d87
Import as type
AndreasArvidsson a2d50c2
Make provide optional
AndreasArvidsson ea13626
Reorder arguments
AndreasArvidsson 789f4ae
update import
AndreasArvidsson bc68185
Merge branch 'main' into treeSitterProvider
AndreasArvidsson 1a8691f
tweaks
pokey 6283491
fix
AndreasArvidsson 95ae4ab
Make constructor private
AndreasArvidsson cbf71c7
more tweaks
pokey ee530de
Remove singleton
AndreasArvidsson 1310947
doc string
pokey 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
13 changes: 13 additions & 0 deletions
13
packages/common/src/ide/types/RawTreeSitterQueryProvider.ts
This file contains 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,13 @@ | ||
import { Disposable } from "@cursorless/common"; | ||
|
||
export interface RawTreeSitterQueryProvider { | ||
/** | ||
* Listen for changes to language definitions | ||
*/ | ||
onChanges(listener: () => void): Disposable; | ||
|
||
/** | ||
* Read a query definition. The query name is the name of one of our `.scm` files. | ||
*/ | ||
readQuery(name: string): Promise<string | undefined>; | ||
} |
This file contains 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
This file contains 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
33 changes: 33 additions & 0 deletions
33
packages/cursorless-engine/src/disabledComponents/DisabledLanguageDefinitions.ts
This file contains 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,33 @@ | ||
import type { TextDocument, Range, Listener } from "@cursorless/common"; | ||
import type { SyntaxNode } from "web-tree-sitter"; | ||
import type { LanguageDefinition } from "../languages/LanguageDefinition"; | ||
import type { LanguageDefinitions } from "../languages/LanguageDefinitions"; | ||
|
||
export class DisabledLanguageDefinitions implements LanguageDefinitions { | ||
init(): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
onDidChangeDefinition(_listener: Listener) { | ||
return { dispose: () => {} }; | ||
} | ||
|
||
loadLanguage(_languageId: string): Promise<void> { | ||
return Promise.resolve(); | ||
} | ||
|
||
get(_languageId: string): LanguageDefinition | undefined { | ||
return undefined; | ||
} | ||
|
||
getNodeAtLocation( | ||
_document: TextDocument, | ||
_range: Range, | ||
): SyntaxNode | undefined { | ||
return undefined; | ||
} | ||
|
||
dispose(): void { | ||
// Do nothing | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/cursorless-engine/src/disabledComponents/DisabledTreeSitter.ts
This file contains 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,21 @@ | ||
import type { TextDocument, Range } from "@cursorless/common"; | ||
import type { SyntaxNode, Tree, Language } from "web-tree-sitter"; | ||
import type { TreeSitter } from "../typings/TreeSitter"; | ||
|
||
export class DisabledTreeSitter implements TreeSitter { | ||
getTree(_document: TextDocument): Tree { | ||
throw new Error("Tree sitter not provided"); | ||
} | ||
|
||
loadLanguage(_languageId: string): Promise<boolean> { | ||
return Promise.resolve(false); | ||
} | ||
|
||
getLanguage(_languageId: string): Language | undefined { | ||
throw new Error("Tree sitter not provided"); | ||
} | ||
|
||
getNodeAtLocation(_document: TextDocument, _range: Range): SyntaxNode { | ||
throw new Error("Tree sitter not provided"); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
The reason for switching from path to name is that if we have a non file system implementation of the language provider, path is irrelevant. I think every definition name(scm filename) should just be unique and in which folder they are located doesn't really matter.