-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
- Loading branch information
1 parent
4d68be9
commit bc50059
Showing
12 changed files
with
237 additions
and
82 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
import { Disposable } from "@cursorless/common"; | ||
|
||
/** | ||
* Provides raw tree-sitter queries. These are usually read from `.scm` files | ||
* on the filesystem, but this class abstracts away the details of how the | ||
* queries are stored. | ||
*/ | ||
export interface RawTreeSitterQueryProvider { | ||
/** | ||
* Listen for changes to queries. For now, this is only used during | ||
* development, when we want to hot-reload queries. | ||
*/ | ||
onChanges(listener: () => void): Disposable; | ||
|
||
/** | ||
* Return the raw text of the tree-sitter query of the given name. The query | ||
* name is the name of one of the `.scm` files in our monorepo. | ||
*/ | ||
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
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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 { | ||
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.