Skip to content

Commit fe6fa7d

Browse files
authored
Merge pull request #6581 from continuedev/jacob/feature/static
feat: Test static contextualization
2 parents a146343 + b3e4d36 commit fe6fa7d

File tree

29 files changed

+1614
-28
lines changed

29 files changed

+1614
-28
lines changed

core/autocomplete/CompletionProvider.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { BracketMatchingService } from "./filtering/BracketMatchingService.js";
1010
import { CompletionStreamer } from "./generation/CompletionStreamer.js";
1111
import { postprocessCompletion } from "./postprocessing/index.js";
1212
import { shouldPrefilter } from "./prefiltering/index.js";
13-
import { getAllSnippets } from "./snippets/index.js";
13+
import { getAllSnippetsWithoutRace } from "./snippets/index.js";
1414
import { renderPrompt } from "./templating/index.js";
1515
import { GetLspDefinitionsFunction } from "./types.js";
1616
import { AutocompleteDebouncer } from "./util/AutocompleteDebouncer.js";
@@ -121,6 +121,12 @@ export class CompletionProvider {
121121
...config?.tabAutocompleteOptions,
122122
...llm.autocompleteOptions,
123123
};
124+
125+
// Enable static contextualization if defined.
126+
if (config?.experimental?.enableStaticContextualization) {
127+
options.experimental_enableStaticContextualization = true;
128+
}
129+
124130
return options;
125131
}
126132

@@ -171,7 +177,7 @@ export class CompletionProvider {
171177
}
172178

173179
const [snippetPayload, workspaceDirs] = await Promise.all([
174-
getAllSnippets({
180+
getAllSnippetsWithoutRace({
175181
helper,
176182
ide: this.ide,
177183
getDefinitionsFromLsp: this.getDefinitionsFromLsp,
@@ -258,6 +264,10 @@ export class CompletionProvider {
258264
...helper.options,
259265
};
260266

267+
if (options.experimental_enableStaticContextualization) {
268+
outcome.enabledStaticContextualization = true;
269+
}
270+
261271
//////////
262272

263273
// Save to cache

core/autocomplete/context/ContextRetrievalService.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@ import { IDE } from "../..";
22
import {
33
AutocompleteCodeSnippet,
44
AutocompleteSnippetType,
5+
AutocompleteStaticSnippet,
56
} from "../snippets/types";
67
import { HelperVars } from "../util/HelperVars";
78

89
import { ImportDefinitionsService } from "./ImportDefinitionsService";
910
import { getSymbolsForSnippet } from "./ranking";
1011
import { RootPathContextService } from "./root-path-context/RootPathContextService";
12+
import { StaticContextService } from "./static-context/StaticContextService";
1113

1214
export class ContextRetrievalService {
1315
private importDefinitionsService: ImportDefinitionsService;
1416
private rootPathContextService: RootPathContextService;
17+
private staticContextService: StaticContextService;
1518

1619
constructor(private readonly ide: IDE) {
1720
this.importDefinitionsService = new ImportDefinitionsService(this.ide);
1821
this.rootPathContextService = new RootPathContextService(
1922
this.importDefinitionsService,
2023
this.ide,
2124
);
25+
this.staticContextService = new StaticContextService(this.ide);
2226
}
2327

2428
public async getSnippetsFromImportDefinitions(
@@ -71,6 +75,12 @@ export class ContextRetrievalService {
7175
);
7276
}
7377

78+
public async getStaticContextSnippets(
79+
helper: HelperVars,
80+
): Promise<AutocompleteStaticSnippet[]> {
81+
return this.staticContextService.getContext(helper);
82+
}
83+
7484
/**
7585
* Initialize the import definitions cache for a file.
7686
* This is normally done automatically when the active text editor changes,

0 commit comments

Comments
 (0)