Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@theia/variable-resolver
Advanced tools
The @theia/variable-resolved
extension provides variable substitution mechanism inside of strings using ${variableName}
syntax.
Extension provides a hook that allows any extensions to contribute its own variables. Here's the example of contributing two variables:
${file}
- returns the name of the file opened in the current editor${lineNumber}
- returns the current line number in the current file@injectable()
export class EditorVariableContribution implements VariableContribution {
constructor(
@inject(EditorManager) protected readonly editorManager: EditorManager
) { }
registerVariables(variables: VariableRegistry): void {
variables.registerVariable({
name: 'file',
description: 'The name of the file opened in the current editor',
resolve: () => {
const currentEditor = this.getCurrentEditor();
if (currentEditor) {
return currentEditor.uri.displayName;
}
return undefined;
}
});
variables.registerVariable({
name: 'lineNumber',
description: 'The current line number in the current file',
resolve: () => {
const currentEditor = this.getCurrentEditor();
if (currentEditor) {
return `${currentEditor.cursor.line + 1}`;
}
return undefined;
}
});
}
protected getCurrentEditor(): TextEditor | undefined {
const currentEditor = this.editorManager.currentEditor;
if (currentEditor) {
return currentEditor.editor;
}
return undefined;
}
}
Note that a Variable is resolved to MaybePromise<string | undefined>
which means that it can be resolved synchronously or within a Promise.
There's the example of how one can use Variable Resolver Service in its own plugin:
@injectable()
export class MyService {
constructor(
@inject(VariableResolverService) protected readonly variableResolver: VariableResolverService
) { }
async resolve(): Promise<void> {
const text = 'cursor is in file ${file} on line ${lineNumber}';
const resolved = await this.variableResolver.resolve(text);
console.log(resolved);
}
}
If package.json
file is currently opened and cursor is on line 5 then the following output will be logged to the console:
cursor is in file package.json on line 5
"Theia" is a trademark of the Eclipse Foundation https://www.eclipse.org/theia
The extension
FAQs
Theia - Variable Resolver Extension
The npm package @theia/variable-resolver receives a total of 3,758 weekly downloads. As such, @theia/variable-resolver popularity was classified as popular.
We found that @theia/variable-resolver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.