refactor: 🎨 format snippets so that it's more model prefix-friendly
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { pathToFileURL } from "url";
|
||||
import Parser from "web-tree-sitter";
|
||||
import { IDE, Position } from "../../..";
|
||||
import { localPathOrUriToPath } from "../../../util/pathToUri";
|
||||
@@ -153,14 +154,33 @@ export class StaticContextService {
|
||||
|
||||
this.logAutocompleteStaticSnippet(ctx);
|
||||
|
||||
console.log(end - start);
|
||||
// console.log(end - start);
|
||||
|
||||
return [
|
||||
{
|
||||
const snippets: AutocompleteStaticSnippet[] = [];
|
||||
|
||||
snippets.push({
|
||||
type: AutocompleteSnippetType.Static,
|
||||
filepath: pathToFileURL(path.resolve(holeContext.source)).toString(),
|
||||
content: holeContext.fullHoverResult,
|
||||
});
|
||||
|
||||
for (const [filepath, typs] of ctx.relevantTypes.entries()) {
|
||||
snippets.push({
|
||||
type: AutocompleteSnippetType.Static,
|
||||
content: StaticContextService.formatAutocompleteStaticSnippet(ctx),
|
||||
},
|
||||
];
|
||||
filepath: pathToFileURL(path.resolve(filepath)).toString(),
|
||||
content: typs.join("\n"),
|
||||
});
|
||||
}
|
||||
|
||||
for (const [filepath, headers] of ctx.relevantHeaders.entries()) {
|
||||
snippets.push({
|
||||
type: AutocompleteSnippetType.Static,
|
||||
filepath: pathToFileURL(path.resolve(filepath)).toString(),
|
||||
content: headers.join("\n"),
|
||||
});
|
||||
}
|
||||
|
||||
return snippets;
|
||||
}
|
||||
|
||||
private async getHoleContext(
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface AutocompleteClipboardSnippet extends BaseAutocompleteSnippet {
|
||||
|
||||
export interface AutocompleteStaticSnippet extends BaseAutocompleteSnippet {
|
||||
type: AutocompleteSnippetType.Static;
|
||||
filepath: string;
|
||||
}
|
||||
|
||||
export type AutocompleteSnippet =
|
||||
|
||||
Reference in New Issue
Block a user