MCPcopy Create free account
hub / github.com/davidquinn/psi-header / insertFileHeader

Function insertFileHeader

src/insertFileHeaderCommand.ts:42–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 * @returns
41 */
42export function insertFileHeader() {
43 const editor: TextEditor = window.activeTextEditor;
44 if (!editor) {
45 window.showErrorMessage('psi-header requires an active document.');
46 return;
47 }
48 const wsConfig: WorkspaceConfiguration = workspace.getConfiguration(BASE_SETTINGS);
49 const langConfig: ILangConfig = getLanguageConfig(wsConfig, editor.document.languageId, editor.document.fileName);
50 const template: Array<string> = getTemplateConfig(wsConfig, editor.document.languageId, editor.document.fileName).template;
51 const config: IConfig = getConfig(wsConfig, langConfig);
52 const variables: IVariableList = getVariables(wsConfig, editor.document, config, langConfig);
53
54 // console.log(`insertFileHeader into ${editor.document.fileName}`);
55
56 if (config.forceToTop) {
57 const position = new Position(0, 0);
58 editor.selection = new Selection(position, position);
59 }
60
61 editor.edit(function(edit) {
62 edit.insert(editor.selection.active, merge(template, langConfig, variables, config, editor));
63 });
64}

Callers 2

activateFunction · 0.90
_onWillSaveMethod · 0.90

Calls 5

getLanguageConfigFunction · 0.90
getTemplateConfigFunction · 0.90
getConfigFunction · 0.90
getVariablesFunction · 0.90
mergeFunction · 0.90

Tested by

no test coverage detected