vscode#workspace TypeScript Examples
The following examples show how to use
vscode#workspace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From dendron with GNU Affero General Public License v3.0 | 7 votes |
findDanglingRefsByFsPath = async (uris: vscode.Uri[]) => {
const refsByFsPath: { [key: string]: string[] } = {};
// eslint-disable-next-line no-restricted-syntax
for (const { fsPath } of uris) {
const fsPathExists = fs.existsSync(fsPath);
if (
!fsPathExists ||
!containsMarkdownExt(fsPath) ||
(fsPathExists && fs.lstatSync(fsPath).isDirectory())
) {
continue; // eslint-disable-line no-continue
}
const doc = workspace.textDocuments.find(
(doc) => doc.uri.fsPath === fsPath
);
const refs = extractDanglingRefs(
doc ? doc.getText() : fs.readFileSync(fsPath).toString()
);
if (refs.length) {
refsByFsPath[fsPath] = refs;
}
}
return refsByFsPath;
}
Example #2
Source File: DoComment.ts From vscode-alxmldocumentation with MIT License | 6 votes |
/**
* DoComment constructor
*/
constructor() {
const subscriptions: Disposable[] = [];
workspace.onDidChangeTextDocument(event => {
const activeEditor = window.activeTextEditor;
if (event.document.languageId !== 'al') {
return;
}
if (activeEditor && event.document === activeEditor.document) {
this.DoComment(activeEditor, event.contentChanges[0]);
}
}, this, subscriptions);
this.disposable = Disposable.from(...subscriptions);
}
Example #3
Source File: config.ts From vscode-cadence with Apache License 2.0 | 6 votes |
// Adds an event handler that prompts the user to reload whenever the config
// changes.
export function handleConfigChanges (): void {
workspace.onDidChangeConfiguration((e) => {
// TODO: do something smarter for account/emulator config (re-send to server)
const promptRestartKeys = [
'languageServerPath',
'accountKey',
'accountAddress',
'emulatorAddress'
]
const shouldPromptRestart = promptRestartKeys.some((key) =>
e.affectsConfiguration(`cadence.${key}`)
)
if (shouldPromptRestart) {
window
.showInformationMessage(
'Server launch configuration change detected. Reload the window for changes to take effect',
'Reload Window',
'Not now'
)
.then((choice) => {
if (choice === 'Reload Window') {
commands.executeCommand('workbench.action.reloadWindow')
.then(() => {}, () => {})
}
}, () => {})
}
})
}
Example #4
Source File: command.ts From typescript-explicit-types with GNU General Public License v3.0 | 6 votes |
generateType = async (
{ typescriptHoverResult, typePosition, isFunction }: GenerateTypeInfo,
editor: TextEditor,
isAutoFormatOn?: boolean
) => {
const indexes = findMatchIndexes(/:/gm, typescriptHoverResult);
const dirtyType = typescriptHoverResult.slice(isFunction ? indexes.slice(-1)[0] : indexes[0]);
const cleanType = dirtyType.replace(/(`)/gm, '').replace(/\n+$/, '');
await editor.edit((editor) => editor.insert(typePosition, cleanType));
if (!isAutoFormatOn) return;
const document = editor.document;
const text = document.getText();
const typeIndex = text.indexOf(cleanType.replace(/\n/gm, '\r\n'), document.offsetAt(typePosition));
if (typeIndex < 0) return;
const typePositionStart = document.positionAt(typeIndex);
const typePositionEnd = document.positionAt(typeIndex + cleanType.length + (cleanType.match(/\n/gm)?.length ?? 0));
const typeRange = new Range(typePositionStart, typePositionEnd);
if (!typeRange) return;
if (isAutoFormatOn) {
const edits = await executeFormatDocumentProvider(document.uri);
if (!edits) return;
const workspaceEdit = new WorkspaceEdit();
workspaceEdit.set(document.uri, edits);
await workspace.applyEdit(workspaceEdit);
}
}
Example #5
Source File: file-watcher.ts From karma-test-explorer with MIT License | 6 votes |
private registerFileHandler(
filePatterns: readonly string[],
handler: (filePath: string, changeType: FileChangeType) => void
): FileSystemWatcher[] {
const fileWatchers: FileSystemWatcher[] = [];
const workspaceRootPath = normalizePath(this.workspaceFolder.uri.fsPath);
const relativeProjectRootPath = relative(workspaceRootPath, this.projectRootPath);
const isProjectRootSameAsWorkspace = this.projectRootPath === workspaceRootPath;
this.logger.debug(() => `Registering file handler for files: ${JSON.stringify(filePatterns, null, 2)}`);
for (const fileOrPattern of filePatterns) {
const relativeFileOrPattern = isProjectRootSameAsWorkspace
? fileOrPattern
: normalizePath(join(relativeProjectRootPath, fileOrPattern));
const absoluteFileOrPattern = new RelativePattern(this.workspaceFolder, relativeFileOrPattern);
this.logger.debug(
() =>
`Creating file watcher for file or pattern '${fileOrPattern}' ` +
`using base path: ${absoluteFileOrPattern.base}`
);
const fileWatcher = workspace.createFileSystemWatcher(absoluteFileOrPattern);
fileWatchers.push(fileWatcher);
this.disposables.push(
fileWatcher.onDidChange(fileUri => handler(normalizePath(fileUri.fsPath), FileChangeType.Changed)),
fileWatcher.onDidCreate(fileUri => handler(normalizePath(fileUri.fsPath), FileChangeType.Created)),
fileWatcher.onDidDelete(fileUri => handler(normalizePath(fileUri.fsPath), FileChangeType.Deleted))
);
}
return fileWatchers;
}
Example #6
Source File: leanpkg.ts From vscode-lean4 with Apache License 2.0 | 6 votes |
constructor() {
// track changes in the version of lean specified in the lean-toolchain file
// or the leanpkg.toml. While this is looking for all files with these names
// it ignores files that are not in the package root.
['**/lean-toolchain', '**/leanpkg.toml'].forEach(pattern => {
const watcher = workspace.createFileSystemWatcher(pattern);
watcher.onDidChange((u) => this.handleFileChanged(u, true));
watcher.onDidCreate((u) => this.handleFileChanged(u, true));
watcher.onDidDelete((u) => this.handleFileChanged(u, true));
this.subscriptions.push(watcher);
const watcher2 = workspace.createFileSystemWatcher(`**/${this.lakeFileName}`);
watcher2.onDidChange((u) => this.handleLakeFileChanged(u, true));
watcher2.onDidCreate((u) => this.handleLakeFileChanged(u, true));
watcher2.onDidDelete((u) => this.handleLakeFileChanged(u, true));
this.subscriptions.push(watcher);
});
}
Example #7
Source File: findNonIgnoredFiles.ts From vscode-markdown-notes with GNU General Public License v3.0 | 6 votes |
export default async function findNonIgnoredFiles(
pattern: string,
checkGitIgnore = true
): Promise<Uri[]> {
const exclude = [
...Object.keys((await workspace.getConfiguration('search', null).get('exclude')) || {}),
...Object.keys((await workspace.getConfiguration('files', null).get('exclude')) || {}),
].join(',');
const uris = await workspace.findFiles(pattern, `{${exclude}}`);
if (!checkGitIgnore) {
return uris;
}
return filterGitIgnored(uris);
}
Example #8
Source File: q-term.ts From vscode-q with MIT License | 6 votes |
export function runQFile(filepath: string): void {
const file = path.parse(filepath).base;
const title = `q - ${file}`;
// close existing terminal and create a new one
window.terminals.forEach(term => {
if (term.name === title)
term.dispose();
});
const term = window.createTerminal(`q - ${file}`);
term.show();
const qBinary = workspace.getConfiguration('q-client.term').get('qBinary');
const envPath = workspace.getConfiguration('q-client.term').get('envPath');
let cmd = `${qBinary} ${filepath}`;
if (envPath)
cmd = `source ${envPath} && ` + cmd;
term.sendText(cmd);
}
Example #9
Source File: new-trongate-module.command.ts From trongate-vscode with MIT License | 6 votes |
// Helper Function to open the controller file and place curosr at good position
function openEditorAndPutCursorAtGoodPosition(
targetDirectory,
moduleName,
isViewTemplate
) {
const validatedModuleName = validateModuleName(moduleName);
const upperModuleName = makeFirstLetterGoUpper(validatedModuleName);
const controllerLocation = `${targetDirectory}/${validatedModuleName}/controllers/${upperModuleName}.php`;
var setting: vscode.Uri = Uri.file(controllerLocation);
setting = setting.fsPath;
workspace.openTextDocument(setting).then((document) =>
window.showTextDocument(document).then((e) => {
e.selections =
isViewTemplate === "no"
? [new Selection(new Position(0, 5), new Position(0, 5))]
: [new Selection(new Position(0, 5), new Position(0, 5))];
})
);
}
Example #10
Source File: pythonEnvironment.ts From vscode-dbt-power-user with MIT License | 6 votes |
private async activatePythonExtension(): Promise<PythonExecutionDetails> {
const extension = extensions.getExtension("ms-python.python")!;
if (!extension.isActive) {
await extension.activate();
}
await extension.exports.ready;
const settings = extension.exports.settings;
return (this.executionDetails = {
getPythonPath: () =>
settings.getExecutionDetails(workspace.workspaceFile).execCommand[0],
onDidChangeExecutionDetails: settings.onDidChangeExecutionDetails,
});
}
Example #11
Source File: annotationProvider.ts From vscode-inline-parameters with MIT License | 6 votes |
public static parameterAnnotation(
message: string,
range: Range
): DecorationOptions {
return {
range,
renderOptions: {
before: {
contentText: message,
color: new ThemeColor("inlineparameters.annotationForeground"),
backgroundColor: new ThemeColor("inlineparameters.annotationBackground"),
fontStyle: workspace.getConfiguration("inline-parameters").get("fontStyle"),
fontWeight: workspace.getConfiguration("inline-parameters").get("fontWeight"),
textDecoration: `;
font-size: ${workspace.getConfiguration("inline-parameters").get("fontSize")};
margin: ${workspace.getConfiguration("inline-parameters").get("margin")};
padding: ${workspace.getConfiguration("inline-parameters").get("padding")};
border-radius: ${workspace.getConfiguration("inline-parameters").get("borderRadius")};
border: ${workspace.getConfiguration("inline-parameters").get("border")};
vertical-align: middle;
`,
},
} as DecorationInstanceRenderOptions,
} as DecorationOptions
}
Example #12
Source File: extension.ts From svlangserver with MIT License | 6 votes |
// Below implements coc.nvim style of sending settings
function getSettings(client) {
let newSettings: Object = new Object();
let workspaceConfig = workspace.getConfiguration();
for (let [prop, val] of settings) {
let newVal = workspaceConfig.get(prop);
if (newVal != val) {
newSettings[prop] = newVal;
settings.set(prop, newVal);
}
}
return { settings: newSettings };
}
Example #13
Source File: venusDebug.ts From vscode-riscv-venus with MIT License | 6 votes |
/**
* Reads the configuration of the extension settings and wraps it into a VenusSettings object.
* Note: Reads the extension settings, not the launch attributes in launch.json.
*
* @returns A initialized VenusSettings object
*/
private getSettings(): VenusSettings{
let simSettings: VenusSettings = new VenusSettings();
simSettings.alignedAddress = workspace.getConfiguration('riscv-venus').get('forceAlignedAddressing');
simSettings.mutableText = workspace.getConfiguration('riscv-venus').get('mutableText');
simSettings.ecallOnlyExit = workspace.getConfiguration('riscv-venus').get('ecallOnlyExit');
simSettings.setRegesOnInit = workspace.getConfiguration('riscv-venus').get('setRegesOnInit');
simSettings.allowAccessBtnStackHeap = workspace.getConfiguration('riscv-venus').get('allowAccessBtnStackHeap');
simSettings.maxSteps = workspace.getConfiguration('riscv-venus').get('maxSteps');
simSettings.onlyShowUsedRegs = workspace.getConfiguration('riscv-venus').get('onlyShowUsedRegs');
return simSettings;
}
Example #14
Source File: index.ts From Json-to-Dart-Model with MIT License | 6 votes |
export function activate(context: ExtensionContext) {
context.subscriptions.push(
commands.registerCommand(
'jsonToDart.fromFile',
transformFromFile
),
commands.registerCommand(
'jsonToDart.fromSelection',
transformFromSelection
),
commands.registerCommand(
'jsonToDart.fromClipboard',
transformFromClipboard
),
commands.registerCommand(
'jsonToDart.addCodeGenerationLibraries',
addCodeGenerationLibraries
),
commands.registerCommand(
'jsonToDart.fromClipboardToCodeGen',
transformFromClipboardToCodeGen
),
commands.registerCommand(
'jsonToDart.fromSelectionToCodeGen',
transformFromSelectionToCodeGen
),
);
const disposableOnDidSave = workspace.onDidSaveTextDocument((doc) => jsonReader.onChange(doc));
context.subscriptions.push(disposableOnDidSave);
}
Example #15
Source File: VsCodeSetting.ts From vscode-drawio with GNU General Public License v3.0 | 6 votes |
private readValue(): any {
const config = workspace.getConfiguration(undefined, this.scope);
if (this.target === undefined) {
return config.get(this.id);
} else {
const result = config.inspect(this.id);
if (!result) {
return undefined;
}
if (this.target === ConfigurationTarget.Global) {
return result.globalValue;
} else if (this.target === ConfigurationTarget.Workspace) {
return result.workspaceValue;
} else if (this.target === ConfigurationTarget.WorkspaceFolder) {
return result.workspaceFolderValue;
}
}
}
Example #16
Source File: plugin.ts From vs-code-conan with MIT License | 6 votes |
private getWorkspaceUri(): Uri{
if (workspace.workspaceFolders !== undefined) {
if (workspace.workspaceFolders.length === 1) {
return workspace.workspaceFolders[0].uri;
}
else {
throw new Error("Multiple workspaces are not supported");
}
}
throw new Error("No workspace folders");
}
Example #17
Source File: testUtilsv2.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
stubWorkspaceFolders = (wsRoot: string, vaults: DVault[]) => {
const folders = vaults
.map((v) => ({
name: VaultUtils.getName(v),
index: 1,
uri: Uri.file(path.join(wsRoot, VaultUtils.getRelPath(v))),
}))
.concat([
{
name: "root",
index: 0,
uri: Uri.parse(wsRoot),
},
]);
sinon.stub(workspace, "workspaceFolders").value(folders);
DendronExtension.workspaceFolders = () => folders;
}
Example #18
Source File: config.ts From format-imports-vscode with MIT License | 6 votes |
function loadVscConfig(fileUri: Uri, languageId: string) {
const log = logger('vscode.loadVscConfig');
log.debug('Loading VSCode config for fileName:', fileUri.fsPath);
const wsConfig = workspaceConfig(fileUri);
const general = workspace.getConfiguration(undefined, fileUri);
const langSpec = workspace.getConfiguration(`[${languageId}]`, fileUri);
const { config: c1, codeAction: a1 } = transform(general);
const { config: c2, codeAction: a2 } = transform(langSpec);
return { config: mergeConfig(wsConfig, c1, c2), codeAction: a1 || a2 };
}
Example #19
Source File: verificationGutterStatusView.ts From ide-vscode with MIT License | 6 votes |
public static createAndRegister(context: ExtensionContext, languageClient: DafnyLanguageClient): VerificationGutterStatusView {
const instance = new VerificationGutterStatusView(context);
context.subscriptions.push(
workspace.onDidCloseTextDocument(document => instance.clearVerificationDiagnostics(document.uri.toString())),
window.onDidChangeActiveTextEditor(editor => instance.refreshDisplayedVerificationGutterStatuses(editor)),
languageClient.onVerificationStatusGutter(params => instance.updateVerificationStatusGutter(params))
);
return instance;
}
Example #20
Source File: export-factory.ts From vscode-code-review with MIT License | 6 votes |
/**
* for trying out: https://stackblitz.com/edit/code-review-template
*/
constructor(private context: ExtensionContext, private workspaceRoot: string, private generator: FileGenerator) {
let groupByConfig = workspace.getConfiguration().get('code-review.groupBy') as string;
if (!groupByConfig || groupByConfig === '-') {
groupByConfig = Group.filename;
}
this.groupBy = groupByConfig as GroupBy;
this.includeCodeSelection = workspace.getConfiguration().get('code-review.reportWithCodeSelection') as boolean;
this.includePrivateComments = workspace.getConfiguration().get('code-review.reportWithPrivateComments') as boolean;
this.privateCommentIcon = workspace.getConfiguration().get('code-review.privateCommentIcon') as string;
this.filterByCommit = workspace.getConfiguration().get('code-review.filterCommentsByCommit') as boolean;
this.setFilterByCommit(this.filterByCommit);
this.filterByFilename = workspace.getConfiguration().get('code-review.filterCommentsByFilename') as boolean;
this.setFilterByFilename(this.filterByFilename, true);
}
Example #21
Source File: coverage.ts From gnucobol-debug with GNU General Public License v3.0 | 6 votes |
constructor() {
workspace.onDidOpenTextDocument(() => {
this.updateStatus();
});
workspace.onDidCloseTextDocument(() => {
this.updateStatus();
});
window.onDidChangeActiveTextEditor(() => {
this.updateStatus();
});
commands.registerCommand(this.COMMAND, () => {
this.highlight = !this.highlight;
this.updateStatus();
});
this.statusBar.command = this.COMMAND;
}
Example #22
Source File: tree-data-provider.ts From plugin-vscode with Apache License 2.0 | 6 votes |
constructor(ballerinaExtension: BallerinaExtension) {
this.ballerinaExtension = ballerinaExtension;
this.langClient = ballerinaExtension.langClient;
this.extensionPath = ballerinaExtension.extension.extensionPath;
workspace.onDidOpenTextDocument(document => {
if (document.languageId === BALLERINA || document.fileName.endsWith(BAL_TOML)) {
this.refresh();
}
});
workspace.onDidChangeTextDocument(activatedTextEditor => {
if (activatedTextEditor && activatedTextEditor.document.languageId === BALLERINA ||
activatedTextEditor.document.fileName.endsWith(BAL_TOML)) {
this.refresh();
}
});
}
Example #23
Source File: manifestUtils.ts From flatpak-vscode with MIT License | 6 votes |
/**
* Finds possible manifests in workspace then deserialize them.
* @returns List of Flatpak Manifest
*/
export async function findManifests(): Promise<ManifestMap> {
const uris: Uri[] = await workspace.findFiles(
MANIFEST_PATH_GLOB_PATTERN,
'**/{target,.vscode,.flatpak-builder,flatpak_app,.flatpak,_build,.github}/*',
1000
)
const manifests = new ManifestMap()
for (const uri of uris) {
try {
const manifest = await parseManifest(uri)
if (manifest) {
manifests.add(manifest)
}
} catch (err) {
console.warn(`Failed to parse the manifest at ${uri.fsPath}`)
}
}
return manifests
}
Example #24
Source File: codelens-provider.ts From plugin-vscode with Apache License 2.0 | 6 votes |
constructor(extensionInstance: BallerinaExtension) {
this.ballerinaExtension = extensionInstance;
workspace.onDidChangeConfiguration(() => {
this._onDidChangeCodeLenses.fire();
});
workspace.onDidOpenTextDocument(() => {
this._onDidChangeCodeLenses.fire();
});
workspace.onDidChangeTextDocument(() => {
this._onDidChangeCodeLenses.fire();
});
commands.registerCommand(SOURCE_DEBUG_COMMAND, async (...args: any[]) => {
sendTelemetryEvent(this.ballerinaExtension, TM_EVENT_SOURCE_DEBUG_CODELENS, CMP_EXECUTOR_CODELENS);
clearTerminal();
commands.executeCommand(FOCUS_DEBUG_CONSOLE_COMMAND);
startDebugging(window.activeTextEditor!.document.uri, false, this.ballerinaExtension.getBallerinaCmd(),
this.ballerinaExtension.getBallerinaHome(), args);
});
commands.registerCommand(TEST_DEBUG_COMMAND, async (...args: any[]) => {
sendTelemetryEvent(this.ballerinaExtension, TM_EVENT_TEST_DEBUG_CODELENS, CMP_EXECUTOR_CODELENS);
clearTerminal();
commands.executeCommand(FOCUS_DEBUG_CONSOLE_COMMAND);
startDebugging(window.activeTextEditor!.document.uri, true, this.ballerinaExtension.getBallerinaCmd(),
this.ballerinaExtension.getBallerinaHome(), args);
});
}
Example #25
Source File: element-hover-provider.ts From element-ui-helper with MIT License | 6 votes |
/**
* 获取Hover实例
*
* @param tag 标签
* @param attr 属性
* @param range 区域
*/
getHoverInstance(tag: TagObject | undefined, attr: string, range: Range) {
const config = workspace.getConfiguration().get<ExtensionConfigutation>('element-ui-helper')
const language = config?.language || ExtensionLanguage.cn
const kebabCaseTag = toKebabCase(tag?.text)
const kebabCaseAttr = toKebabCase(attr)
return this.createHoverInstance(language, kebabCaseTag, kebabCaseAttr, range)
}
Example #26
Source File: tool.ts From git-commit-plugin with MIT License | 6 votes |
getLocalPluginConfig =(key:string)=>{
// workspace.fs.readFile('.gitcommitplugin.json')
const workspaceFolders = workspace.workspaceFolders;
const gitExtension = getGitExtension();
let localPluginConfig = workspace.getConfiguration('GitCommitPlugin').get<boolean>(key);
if(Array.isArray(workspaceFolders)){
if(gitExtension !== undefined){
const target = workspaceFolders.find((item)=>{
return gitExtension.getAPI(1).repositories.find(repo => {
return repo.rootUri.path === item.uri.path;
});
});
}
}
// console.log(workspace.workspaceFolders,'workspace.workspaceFolders');
return localPluginConfig;
}
Example #27
Source File: element-completion-item-povider.ts From element-ui-helper with MIT License | 6 votes |
/**
* 获取属性的提示信息
*
* @param tag 标签
*/
getAttrCompletionItems(tag: string): CompletionItem[] {
let completionItems: CompletionItem[] = []
const config = workspace.getConfiguration().get<ExtensionConfigutation>('element-ui-helper')
const language = config?.language || ExtensionLanguage.cn
const document: Record<string, any> = localDocument[language]
const preText = this.getTextBeforePosition(this._position)
const prefix = preText.replace(/.*[\s@:]/g, '')
const attributes: DocumentAttribute[] = document[tag].attributes || []
const likeTag = attributes.filter((attribute: DocumentAttribute) => attribute.name.includes(prefix))
likeTag.forEach((attribute: DocumentAttribute) => {
const start = Math.max(preText.lastIndexOf(' '), preText.lastIndexOf(':')) + 1
const end = start + prefix.length
const startPos = new Position(this._position.line, start)
const endPos = new Position(this._position.line, end)
const range = new Range(startPos, endPos)
completionItems.push({
label: `${attribute.name}`,
sortText: `0${attribute.name}`,
detail: `${tag} Attribute`,
documentation: attribute.description,
kind: CompletionItemKind.Value,
insertText: attribute.name,
range
})
})
return completionItems
}
Example #28
Source File: export-factory.ts From vscode-code-review with MIT License | 6 votes |
/**
* Enable/Disable filtering comments by commit
* @param state The state of the filter
* @returns The new state of the filter
*/
public setFilterByCommit(state: boolean): boolean {
this.filterByCommit = state;
if (this.filterByCommit) {
try {
const gitDirectory = workspace.getConfiguration().get('code-review.gitDirectory') as string;
const gitRepositoryPath = path.resolve(this.workspaceRoot, gitDirectory);
this.currentCommitId = gitCommitId({ cwd: gitRepositoryPath });
} catch (error) {
this.filterByCommit = false;
this.currentCommitId = null;
console.log('Not in a git repository. Disabling filter by commit', error);
}
} else {
this.currentCommitId = null;
}
commands.executeCommand('setContext', 'isFilteredByCommit', this.filterByCommit);
return this.filterByCommit;
}
Example #29
Source File: element-completion-item-povider.ts From element-ui-helper with MIT License | 6 votes |
/**
* 获取事件名称提示
*
* @param tag 标签
*/
getEventCompletionItems(tag: string): CompletionItem[] {
let completionItems: CompletionItem[] = []
const config = workspace.getConfiguration().get<ExtensionConfigutation>('element-ui-helper')
const language = config?.language || ExtensionLanguage.cn
const document: Record<string, any> = localDocument[language]
const preText = this.getTextBeforePosition(this._position)
const prefix = preText.replace(/.*@([\w-]*)$/, '$1')
const events: DocumentEvent[] = document[tag]?.events || []
const likeTag = events.filter((evnet: DocumentEvent) => evnet.name.includes(prefix))
likeTag.forEach((event: DocumentEvent) => {
const start = preText.lastIndexOf('@') + 1
const end = start + prefix.length
const startPos = new Position(this._position.line, start)
const endPos = new Position(this._position.line, end)
const range = new Range(startPos, endPos)
completionItems.push({
label: `${event.name}`,
sortText: `0${event.name}`,
detail: `${tag} Event`,
documentation: event.description,
kind: CompletionItemKind.Value,
insertText: event.name,
range
})
})
return completionItems
}