pull in static context
This commit is contained in:
parent
30bfaa0904
commit
be46653d1e
3 changed files with 26 additions and 1 deletions
|
|
@ -2,16 +2,19 @@ import { IDE } from "../..";
|
|||
import {
|
||||
AutocompleteCodeSnippet,
|
||||
AutocompleteSnippetType,
|
||||
AutocompleteStaticSnippet,
|
||||
} from "../snippets/types";
|
||||
import { HelperVars } from "../util/HelperVars";
|
||||
|
||||
import { ImportDefinitionsService } from "./ImportDefinitionsService";
|
||||
import { getSymbolsForSnippet } from "./ranking";
|
||||
import { RootPathContextService } from "./root-path-context/RootPathContextService";
|
||||
import { StaticContextService } from "./static-context/StaticContextService";
|
||||
|
||||
export class ContextRetrievalService {
|
||||
private importDefinitionsService: ImportDefinitionsService;
|
||||
private rootPathContextService: RootPathContextService;
|
||||
private staticContextService: StaticContextService;
|
||||
|
||||
constructor(private readonly ide: IDE) {
|
||||
this.importDefinitionsService = new ImportDefinitionsService(this.ide);
|
||||
|
|
@ -19,6 +22,7 @@ export class ContextRetrievalService {
|
|||
this.importDefinitionsService,
|
||||
this.ide,
|
||||
);
|
||||
this.staticContextService = new StaticContextService(this.ide);
|
||||
}
|
||||
|
||||
public async getSnippetsFromImportDefinitions(
|
||||
|
|
@ -70,4 +74,10 @@ export class ContextRetrievalService {
|
|||
helper.treePath,
|
||||
);
|
||||
}
|
||||
|
||||
public async getStaticContextSnippets(
|
||||
helper: HelperVars
|
||||
): Promise<AutocompleteStaticSnippet> {
|
||||
return this.staticContextService.getContext(helper);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { context } from "esbuild";
|
||||
import { IDE } from "../../index";
|
||||
import { findUriInDirs } from "../../util/uri";
|
||||
import { ContextRetrievalService } from "../context/ContextRetrievalService";
|
||||
|
|
@ -123,6 +124,7 @@ export const getAllSnippets = async ({
|
|||
ideSnippets,
|
||||
diffSnippets,
|
||||
clipboardSnippets,
|
||||
staticSnippets
|
||||
] = await Promise.all([
|
||||
racePromise(contextRetrievalService.getRootPathSnippets(helper)),
|
||||
racePromise(
|
||||
|
|
@ -133,6 +135,7 @@ export const getAllSnippets = async ({
|
|||
: [],
|
||||
[], // racePromise(getDiffSnippets(ide)) // temporarily disabled, see https://github.com/continuedev/continue/pull/5882,
|
||||
racePromise(getClipboardSnippets(ide)),
|
||||
racePromise(contextRetrievalService.getStaticContextSnippets(helper))
|
||||
]);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,19 @@ export interface AutocompleteClipboardSnippet extends BaseAutocompleteSnippet {
|
|||
copiedAt: string;
|
||||
}
|
||||
|
||||
type Filepath = string;
|
||||
type RelevantType = string;
|
||||
type RelevantHeader = string;
|
||||
|
||||
export interface AutocompleteStaticSnippet extends BaseAutocompleteSnippet {
|
||||
type: AutocompleteSnippetType.Code;
|
||||
holeType: string,
|
||||
relevantTypes: Map<Filepath, RelevantType[]>,
|
||||
relevantHeaders: Map<Filepath, RelevantHeader[]>
|
||||
}
|
||||
|
||||
export type AutocompleteSnippet =
|
||||
| AutocompleteCodeSnippet
|
||||
| AutocompleteDiffSnippet
|
||||
| AutocompleteClipboardSnippet;
|
||||
| AutocompleteClipboardSnippet
|
||||
| AutocompleteStaticSnippet;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue