- Prefix 构造:从文件开头到光标位置;若存在 selectedCompletionInfo,将已选补全文本拼进前缀。
- 参考:core/autocomplete/templating/constructPrefixSuffix.ts:18
- 跨文件 snippets 汇总(拼到 prefix 前):
- rootPathSnippets:基于 AST 语法路径的上下文片段。
- 参考:core/autocomplete/context/ContextRetrievalService.ts:47
- importDefinitionSnippets:从光标附近符号的 import 定义中提取片段。
- 参考:core/autocomplete/context/ContextRetrievalService.ts:20
- clipboardSnippets:剪贴板内容片段。
- 参考:core/autocomplete/snippets/getAllSnippets.ts:73
- recentlyOpenedFileSnippets:最近打开文件内容片段。
- 参考:core/autocomplete/snippets/getAllSnippets.ts:94
- recentlyVisitedRanges / recentlyEditedRanges:最近访问/编辑片段。
- 参考:core/autocomplete/snippets/getAllSnippets.ts:46
- rootPathSnippets:基于 AST 语法路径的上下文片段。
- snippet 格式化:
- 每个 snippet 加 Path: xxx,再用语言单行注释符包裹成注释上下文。
- 参考:core/autocomplete/templating/formatting.ts:30
- 末尾追加当前文件路径注释。
- 参考:core/autocomplete/templating/formatting.ts:68
- 每个 snippet 加 Path: xxx,再用语言单行注释符包裹成注释上下文。
- Prompt 模板变量注入:
- prefix / suffix(包含上述拼好的内容)
- filename(当前文件名)
- reponame(仓库名/工作区名)
- language(语言名)
- 参考:core/autocomplete/templating/index.ts:25