Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const identifier = this.toPluginViewWidgetIdentifier(viewId);
const widget = await this.widgetManager.getOrCreateWidget(PLUGIN_VIEW_FACTORY_ID, identifier);
if (containerWidget.getTrackableWidgets().indexOf(widget) === -1) {
containerWidget.addWidget(widget, {
initiallyCollapsed: !!containerWidget.getParts().length
});
}
const part = containerWidget.getPartFor(widget);
if (part) {
const tryFireOnDidExpandView = () => {
if (!part.collapsed && part.isVisible) {
toFire.dispose();
}
};
const toFire = new DisposableCollection(
Disposable.create(() => this.onDidExpandViewEmitter.fire(viewId)),
part.onCollapsed(tryFireOnDidExpandView),
part.onVisibilityChanged(tryFireOnDidExpandView)
);
tryFireOnDidExpandView();
}
}
}
register(definition: TaskDefinition): Disposable {
const taskType = definition.taskType;
const definitions = this.definitions.get(taskType) || [];
definitions.push(definition);
this.definitions.set(taskType, definitions);
this.onDidRegisterTaskDefinitionEmitter.fire(undefined);
return Disposable.create(() => {
const index = definitions.indexOf(definition);
if (index !== -1) {
definitions.splice(index, 1);
}
this.onDidUnregisterTaskDefinitionEmitter.fire(undefined);
});
}
private onTextEditorAdd(editor: TextEditorMain): void {
const id = editor.getId();
const toDispose = new DisposableCollection(
editor.onPropertiesChangedEvent(e => {
this.proxy.$acceptEditorPropertiesChanged(id, e);
}),
Disposable.create(() => this.editorsToDispose.delete(id))
);
this.editorsToDispose.set(id, toDispose);
this.toDispose.push(toDispose);
}
registerDebugger(contribution: DebuggerContribution): Disposable {
this.debuggers.push(contribution);
return Disposable.create(() => {
const index = this.debuggers.indexOf(contribution);
if (index !== -1) {
this.debuggers.splice(index, 1);
}
});
}
protected async trackTerminal(terminal: TerminalWidget): Promise {
let name = terminal.title.label;
this.extProxy.$terminalCreated(terminal.id, name);
const updateTitle = () => {
if (name !== terminal.title.label) {
name = terminal.title.label;
this.extProxy.$terminalNameChanged(terminal.id, name);
}
};
terminal.title.changed.connect(updateTitle);
this.toDispose.push(Disposable.create(() => terminal.title.changed.disconnect(updateTitle)));
const updateProcessId = () => terminal.processId.then(
processId => this.extProxy.$terminalOpened(terminal.id, processId),
() => {/*no-op*/ }
);
updateProcessId();
this.toDispose.push(terminal.onDidOpen(() => updateProcessId()));
this.toDispose.push(terminal.onTerminalDidClose(() => this.extProxy.$terminalClosed(terminal.id)));
}
$registerHandler(id: string): void {
this.handlers.set(id, this.contributions.registerCommandHandler(id, (...args) =>
this.proxy.$executeCommand(id, ...args)
));
this.toDispose.push(Disposable.create(() => this.$unregisterHandler(id)));
}
$unregisterHandler(id: string): void {
protected async load(): Promise {
if (this.styleSheetContent !== undefined) {
return;
}
this.styleSheetContent = '';
this.toUnload.push(Disposable.create(() => {
this.styleSheetContent = undefined;
this.hasFileIcons = undefined;
this.hasFolderIcons = undefined;
this.hidesExplorerArrows = undefined;
this.icons.clear();
}));
const { content } = await this.fileSystem.resolveContent(this.uri);
const json: RecursivePartial = jsoncparser.parse(content, undefined, { disallowComments: false });
this.hidesExplorerArrows = !!json.hidesExplorerArrows;
const uri = new URI(this.uri);
const toUnwatch = await this.fsWatcher.watchFileChanges(uri);
if (this.toUnload.disposed) {
toUnwatch.dispose();
} else {
activate(): Disposable {
if (!this.toDeactivate.disposed) {
return this.toDeactivate;
}
this.toDeactivate.push(Disposable.create(() => this.fireDidChange()));
this.doActivate();
return this.toDeactivate;
}
);
const toDispose = new DisposableCollection(
Disposable.create(() => this.debuggerContributions.delete(debugType))
);
this.debuggerContributions.set(debugType, toDispose);
toDispose.pushAll([
this.adapterContributionRegistrator.registerDebugAdapterContribution(
new PluginDebugAdapterContribution(description, this.debugExt, this.pluginService)
),
this.sessionContributionRegistrator.registerDebugSessionContribution({
debugType: description.type,
debugSessionFactory: () => debugSessionFactory
})
]);
this.toDispose.push(Disposable.create(() => this.$unregisterDebuggerConfiguration(debugType)));
}
command: string | undefined): Promise {
const entry = {
text: text || '',
priority,
alignment: alignment === types.StatusBarAlignment.Left ? StatusBarAlignment.LEFT : StatusBarAlignment.RIGHT,
color: color && (this.colorRegistry.getCurrentColor(color) || color),
tooltip,
command
};
this.entries.set(id, entry);
await this.delegate.setElement(id, entry);
if (this.toDispose.disposed) {
this.$dispose(id);
} else {
this.toDispose.push(Disposable.create(() => this.$dispose(id)));
}
}