Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (options.configuration.name === nameOrConfiguration) {
configuration = options.configuration;
}
}
} else {
configuration = nameOrConfiguration;
}
if (!configuration) {
console.error(`There is no debug configuration for ${nameOrConfiguration}`);
return false;
}
const session = await this.sessionManager.start({
configuration,
workspaceFolderUri: folder && Uri.revive(folder.uri).toString()
});
return !!session;
}
$readFile(handle: number, resource: UriComponents, options?: { encoding?: string }): Promise {
this.checkProviderExists(handle);
return Promise.resolve(this.fsProviders.get(handle)!.readFile(URI.revive(resource))).then(data => {
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
const encoding = options === null ? undefined : options && options.encoding;
return buffer.toString(encoding);
}
);
}
}
}
if (delta.removedEditors) {
for (const id of delta.removedEditors) {
const editor = this.editors.get(id);
this.editors.delete(id);
if (editor) {
removedEditors.push(editor);
}
}
}
if (delta.addedEditors) {
for (const data of delta.addedEditors) {
const resource = URI.revive(data.documentUri);
ok(this.documents.has(resource.toString()), `document '${resource}' doesn't exist`);
ok(!this.editors.has(data.id), `editor '${data.id}' already exists!`);
const documentData = this.documents.get(resource.toString());
const editor = new TextEditorExt(
this.rpc.getProxy(PLUGIN_RPC_CONTEXT.TEXT_EDITORS_MAIN),
data.id,
documentData!,
data.selections.map(Converter.toSelection),
data.options,
data.visibleRanges.map(Converter.toRange),
Converter.toViewColumn(data.editorPosition)
);
this.editors.set(data.id, editor);
}
}
$onFileRename(event: FileMoveEvent): void {
this.workspaceDidRenameFileEmitter.fire(Object.freeze({ oldUri: URI.revive(event.oldUri), newUri: URI.revive(event.newUri) }));
}
async $trySaveDocument(uri: UriComponents): Promise {
const widget = await this.editorManager.getByUri(new URI(CodeURI.revive(uri)));
if (widget) {
await Saveable.save(widget);
return true;
}
return false;
}
async asExternalUri(target: URI): Promise {
if (!target.scheme.trim().length) {
throw new Error('Invalid scheme - cannot be empty');
}
if (Schemes.HTTP !== target.scheme && Schemes.HTTPS !== target.scheme) {
throw new Error(`Invalid scheme '${target.scheme}'`);
}
const uri = await this.proxy.$asExternalUri(target);
return URI.revive(uri);
}
return this.proxy.$tryCreateDocument(options).then(data => URI.revive(data));
}
$onWillRename(event: FileWillMoveEvent): Promise {
return this.workspaceWillRenameFileEmitter.fire({
oldUri: URI.revive(event.oldUri),
newUri: URI.revive(event.newUri),
waitUntil: (thenable: Promise): void => { }
});
}
}
async $tryOpenDocument(uri: UriComponents): Promise {
const ref = await this.modelService.createModelReference(new URI(CodeURI.revive(uri)));
if (ref.object) {
this.modelReferenceCache.add(ref);
return true;
} else {
ref.dispose();
return false;
}
}
protected toRemoteUri(uri?: UriComponents): UriComponents | undefined {
if (uri && uri.scheme === 'file') {
return theiaUritoUriComponents(this.fileEndpoint.withQuery(URI.revive(uri).toString()));
}
return uri;
}