-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agent): add experimental postprocess limit scope by syntax. (#758)
* feat(agent): add tree-sitter parser. * feat(agent): make parser updating tree cache optional. * feat(agent): add experimental limit scopy by syntax. * test(agent): update unit test for limitScopeBySyntax.
- Loading branch information
Showing
26 changed files
with
822 additions
and
23 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.wasm filter=lfs diff=lfs merge=lfs -text |
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
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
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,24 @@ | ||
import { CompletionContext } from "../Agent"; | ||
import { AgentConfig } from "../AgentConfig"; | ||
import { isBrowser } from "../env"; | ||
import { PostprocessFilter } from "./base"; | ||
import { limitScopeByIndentation } from "./limitScopeByIndentation"; | ||
import { limitScopeBySyntax, supportedLanguages } from "./limitScopeBySyntax"; | ||
|
||
export function limitScope( | ||
context: CompletionContext, | ||
config: AgentConfig["postprocess"]["limitScope"], | ||
): PostprocessFilter { | ||
return isBrowser | ||
? (input) => { | ||
// syntax parser is not supported in browser yet | ||
return limitScopeByIndentation(context, config["indentation"])(input); | ||
} | ||
: (input) => { | ||
if (config.experimentalSyntax && supportedLanguages.indexOf(context.language) >= 0) { | ||
return limitScopeBySyntax(context)(input); | ||
} else { | ||
return limitScopeByIndentation(context, config["indentation"])(input); | ||
} | ||
}; | ||
} |
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.