mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Auto converting let -> const where possible in mainthread and extHost
Const provides better type guards and can make logic clearer
This commit is contained in:
@@ -92,7 +92,7 @@ export function createApiFactory(
|
||||
extHostStorage: ExtHostStorage
|
||||
): IExtensionApiFactory {
|
||||
|
||||
let schemeTransformer: ISchemeTransformer | null = null;
|
||||
const schemeTransformer: ISchemeTransformer | null = null;
|
||||
|
||||
// Addressable instances
|
||||
rpcProtocol.set(ExtHostContext.ExtHostLogService, extHostLogService);
|
||||
@@ -188,7 +188,7 @@ export function createApiFactory(
|
||||
},
|
||||
registerTextEditorCommand(id: string, callback: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => void, thisArg?: any): vscode.Disposable {
|
||||
return extHostCommands.registerCommand(true, id, (...args: any[]): any => {
|
||||
let activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
const activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
if (!activeTextEditor) {
|
||||
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
|
||||
return undefined;
|
||||
@@ -209,7 +209,7 @@ export function createApiFactory(
|
||||
},
|
||||
registerDiffInformationCommand: proposedApiFunction(extension, (id: string, callback: (diff: vscode.LineChange[], ...args: any[]) => any, thisArg?: any): vscode.Disposable => {
|
||||
return extHostCommands.registerCommand(true, id, async (...args: any[]): Promise<any> => {
|
||||
let activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
const activeTextEditor = extHostEditors.getActiveTextEditor();
|
||||
if (!activeTextEditor) {
|
||||
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
|
||||
return undefined;
|
||||
@@ -566,7 +566,7 @@ export function createApiFactory(
|
||||
openTextDocument(uriOrFileNameOrOptions?: vscode.Uri | string | { language?: string; content?: string; }) {
|
||||
let uriPromise: Thenable<URI>;
|
||||
|
||||
let options = uriOrFileNameOrOptions as { language?: string; content?: string; };
|
||||
const options = uriOrFileNameOrOptions as { language?: string; content?: string; };
|
||||
if (typeof uriOrFileNameOrOptions === 'string') {
|
||||
uriPromise = Promise.resolve(URI.file(uriOrFileNameOrOptions));
|
||||
} else if (uriOrFileNameOrOptions instanceof URI) {
|
||||
|
||||
@@ -263,7 +263,7 @@ export class ExtHostApiCommands {
|
||||
// --- command impl
|
||||
|
||||
private _register(id: string, handler: (...args: any[]) => any, description?: ICommandHandlerDescription): void {
|
||||
let disposable = this._commands.registerCommand(false, id, handler, this, description);
|
||||
const disposable = this._commands.registerCommand(false, id, handler, this, description);
|
||||
this._disposables.push(disposable);
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ export class ExtHostApiCommands {
|
||||
}
|
||||
|
||||
private _executeSelectionRangeProvider(resource: URI, positions: types.Position[]): Promise<vscode.SelectionRange[][]> {
|
||||
let pos = positions.map(typeConverters.Position.from);
|
||||
const pos = positions.map(typeConverters.Position.from);
|
||||
const args = {
|
||||
resource,
|
||||
position: pos[0],
|
||||
@@ -443,7 +443,7 @@ export class ExtHostApiCommands {
|
||||
}
|
||||
class MergedInfo extends types.SymbolInformation implements vscode.DocumentSymbol {
|
||||
static to(symbol: modes.DocumentSymbol): MergedInfo {
|
||||
let res = new MergedInfo(
|
||||
const res = new MergedInfo(
|
||||
symbol.name,
|
||||
typeConverters.SymbolKind.to(symbol.kind),
|
||||
symbol.containerName,
|
||||
|
||||
@@ -154,7 +154,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
|
||||
}
|
||||
|
||||
try {
|
||||
let result = callback.apply(thisArg, args);
|
||||
const result = callback.apply(thisArg, args);
|
||||
return Promise.resolve(result);
|
||||
} catch (err) {
|
||||
this._logService.error(err, id);
|
||||
|
||||
@@ -344,7 +344,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
}
|
||||
|
||||
getComment(commentId: string): vscode.Comment | undefined {
|
||||
let comments = this._comments.filter(comment => comment.commentId === commentId);
|
||||
const comments = this._comments.filter(comment => comment.commentId === commentId);
|
||||
|
||||
if (comments && comments.length) {
|
||||
return comments[0];
|
||||
@@ -480,7 +480,7 @@ class ExtHostCommentControl implements vscode.CommentControl {
|
||||
}
|
||||
|
||||
$onActiveCommentWidgetChange(commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string) {
|
||||
let extHostCommentThread = this._threads.get(commentThread.commentThreadHandle);
|
||||
const extHostCommentThread = this._threads.get(commentThread.commentThreadHandle);
|
||||
|
||||
const extHostCommentWidget = new ExtHostCommentWidget(
|
||||
this._proxy,
|
||||
|
||||
@@ -255,7 +255,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
console.error('DebugConfigurationProvider.debugAdapterExecutable is deprecated and will be removed soon; please use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead.');
|
||||
}
|
||||
|
||||
let handle = this._configProviderHandleCounter++;
|
||||
const handle = this._configProviderHandleCounter++;
|
||||
this._configProviders.push({ type, handle, provider });
|
||||
|
||||
this._debugServiceProxy.$registerDebugConfigurationProvider(type,
|
||||
@@ -286,7 +286,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
throw new Error(`a DebugAdapterDescriptorFactory can only be registered once per a type.`);
|
||||
}
|
||||
|
||||
let handle = this._adapterFactoryHandleCounter++;
|
||||
const handle = this._adapterFactoryHandleCounter++;
|
||||
this._adapterFactories.push({ type, handle, factory });
|
||||
|
||||
this._debugServiceProxy.$registerDebugAdapterDescriptorFactory(type, handle);
|
||||
@@ -303,7 +303,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
return new Disposable(() => { });
|
||||
}
|
||||
|
||||
let handle = this._trackerFactoryHandleCounter++;
|
||||
const handle = this._trackerFactoryHandleCounter++;
|
||||
this._trackerFactories.push({ type, handle, factory });
|
||||
|
||||
this._debugServiceProxy.$registerDebugAdapterTrackerFactory(type, handle);
|
||||
@@ -494,9 +494,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
public $acceptBreakpointsDelta(delta: IBreakpointsDeltaDto): void {
|
||||
|
||||
let a: vscode.Breakpoint[] = [];
|
||||
let r: vscode.Breakpoint[] = [];
|
||||
let c: vscode.Breakpoint[] = [];
|
||||
const a: vscode.Breakpoint[] = [];
|
||||
const r: vscode.Breakpoint[] = [];
|
||||
const c: vscode.Breakpoint[] = [];
|
||||
|
||||
if (delta.added) {
|
||||
for (const bpd of delta.added) {
|
||||
@@ -528,7 +528,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
if (delta.changed) {
|
||||
for (const bpd of delta.changed) {
|
||||
let bp = this._breakpoints.get(bpd.id);
|
||||
const bp = this._breakpoints.get(bpd.id);
|
||||
if (bp) {
|
||||
if (bp instanceof FunctionBreakpoint && bpd.type === 'function') {
|
||||
const fbp = <any>bp;
|
||||
@@ -554,7 +554,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
}
|
||||
|
||||
public async $provideDebugConfigurations(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<vscode.DebugConfiguration[]> {
|
||||
let provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
const provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
if (!provider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -566,7 +566,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
}
|
||||
|
||||
public async $resolveDebugConfiguration(configProviderHandle: number, folderUri: UriComponents | undefined, debugConfiguration: vscode.DebugConfiguration): Promise<vscode.DebugConfiguration> {
|
||||
let provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
const provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
if (!provider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -579,7 +579,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
// TODO@AW legacy
|
||||
public async $legacyDebugAdapterExecutable(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<IAdapterDescriptor> {
|
||||
let provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
const provider = this.getConfigProviderByHandle(configProviderHandle);
|
||||
if (!provider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
@@ -591,7 +591,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
}
|
||||
|
||||
public async $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
|
||||
let adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
|
||||
const adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
|
||||
if (!adapterProvider) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
const entries: [URI, IMarkerData[]][] = [];
|
||||
for (let uri of toSync) {
|
||||
let marker: IMarkerData[] = [];
|
||||
let diagnostics = this._data.get(uri.toString());
|
||||
const diagnostics = this._data.get(uri.toString());
|
||||
if (diagnostics) {
|
||||
|
||||
// no more than N diagnostics per file
|
||||
@@ -170,14 +170,14 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
|
||||
forEach(callback: (uri: URI, diagnostics: vscode.Diagnostic[], collection: DiagnosticCollection) => any, thisArg?: any): void {
|
||||
this._checkDisposed();
|
||||
this._data.forEach((value, key) => {
|
||||
let uri = URI.parse(key);
|
||||
const uri = URI.parse(key);
|
||||
callback.apply(thisArg, [uri, this.get(uri), this]);
|
||||
});
|
||||
}
|
||||
|
||||
get(uri: URI): vscode.Diagnostic[] {
|
||||
this._checkDisposed();
|
||||
let result = this._data.get(uri.toString());
|
||||
const result = this._data.get(uri.toString());
|
||||
if (Array.isArray(result)) {
|
||||
return <vscode.Diagnostic[]>Object.freeze(result.slice(0));
|
||||
}
|
||||
@@ -224,8 +224,8 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
|
||||
}
|
||||
|
||||
static _mapper(last: (vscode.Uri | string)[]): { uris: vscode.Uri[] } {
|
||||
let uris: vscode.Uri[] = [];
|
||||
let map = new Set<string>();
|
||||
const uris: vscode.Uri[] = [];
|
||||
const map = new Set<string>();
|
||||
for (const uri of last) {
|
||||
if (typeof uri === 'string') {
|
||||
if (!map.has(uri)) {
|
||||
@@ -285,8 +285,8 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
|
||||
if (resource) {
|
||||
return this._getDiagnostics(resource);
|
||||
} else {
|
||||
let index = new Map<string, number>();
|
||||
let res: [vscode.Uri, vscode.Diagnostic[]][] = [];
|
||||
const index = new Map<string, number>();
|
||||
const res: [vscode.Uri, vscode.Diagnostic[]][] = [];
|
||||
this._collections.forEach(collection => {
|
||||
collection.forEach((uri, diagnostics) => {
|
||||
let idx = index.get(uri.toString());
|
||||
|
||||
@@ -105,7 +105,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
}
|
||||
|
||||
private _getTextInRange(_range: vscode.Range): string {
|
||||
let range = this._validateRange(_range);
|
||||
const range = this._validateRange(_range);
|
||||
|
||||
if (range.isEmpty) {
|
||||
return '';
|
||||
@@ -115,7 +115,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
return this._lines[range.start.line].substring(range.start.character, range.end.character);
|
||||
}
|
||||
|
||||
let lineEnding = this._eol,
|
||||
const lineEnding = this._eol,
|
||||
startLineIndex = range.start.line,
|
||||
endLineIndex = range.end.line,
|
||||
resultLines: string[] = [];
|
||||
@@ -178,9 +178,9 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
offset = Math.max(0, offset);
|
||||
|
||||
this._ensureLineStarts();
|
||||
let out = this._lineStarts!.getIndexOf(offset);
|
||||
const out = this._lineStarts!.getIndexOf(offset);
|
||||
|
||||
let lineLength = this._lines[out.index].length;
|
||||
const lineLength = this._lines[out.index].length;
|
||||
|
||||
// Ensure we return a valid position
|
||||
return new Position(out.index, Math.min(out.remainder, lineLength));
|
||||
@@ -193,8 +193,8 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
throw new Error('Invalid argument');
|
||||
}
|
||||
|
||||
let start = this._validatePosition(range.start);
|
||||
let end = this._validatePosition(range.end);
|
||||
const start = this._validatePosition(range.start);
|
||||
const end = this._validatePosition(range.end);
|
||||
|
||||
if (start === range.start && end === range.end) {
|
||||
return range;
|
||||
@@ -221,7 +221,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
hasChanged = true;
|
||||
}
|
||||
else {
|
||||
let maxCharacter = this._lines[line].length;
|
||||
const maxCharacter = this._lines[line].length;
|
||||
if (character < 0) {
|
||||
character = 0;
|
||||
hasChanged = true;
|
||||
@@ -239,7 +239,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
}
|
||||
|
||||
private _getWordRangeAtPosition(_position: vscode.Position, regexp?: RegExp): vscode.Range | undefined {
|
||||
let position = this._validatePosition(_position);
|
||||
const position = this._validatePosition(_position);
|
||||
|
||||
if (!regexp) {
|
||||
// use default when custom-regexp isn't provided
|
||||
@@ -251,7 +251,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
|
||||
regexp = getWordDefinitionFor(this._languageId);
|
||||
}
|
||||
|
||||
let wordAtText = getWordAtText(
|
||||
const wordAtText = getWordAtText(
|
||||
position.character + 1,
|
||||
ensureValidWordDefinition(regexp),
|
||||
this._lines[position.line],
|
||||
|
||||
@@ -53,7 +53,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic
|
||||
const entries = this._callbacks.toArray();
|
||||
|
||||
let didTimeout = false;
|
||||
let didTimeoutHandle = setTimeout(() => didTimeout = true, this._thresholds.timeout);
|
||||
const didTimeoutHandle = setTimeout(() => didTimeout = true, this._thresholds.timeout);
|
||||
|
||||
const promise = sequence(entries.map(listener => {
|
||||
return () => {
|
||||
|
||||
@@ -77,7 +77,7 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
|
||||
public ensureDocumentData(uri: URI): Promise<ExtHostDocumentData> {
|
||||
|
||||
let cached = this._documentsAndEditors.getDocument(uri);
|
||||
const cached = this._documentsAndEditors.getDocument(uri);
|
||||
if (cached) {
|
||||
return Promise.resolve(cached);
|
||||
}
|
||||
|
||||
@@ -238,14 +238,14 @@ export class ExtensionsActivator {
|
||||
if (this._alreadyActivatedEvents[activationEvent]) {
|
||||
return NO_OP_VOID_PROMISE;
|
||||
}
|
||||
let activateExtensions = this._registry.getExtensionDescriptionsForActivationEvent(activationEvent);
|
||||
const activateExtensions = this._registry.getExtensionDescriptionsForActivationEvent(activationEvent);
|
||||
return this._activateExtensions(activateExtensions.map(e => e.identifier), reason).then(() => {
|
||||
this._alreadyActivatedEvents[activationEvent] = true;
|
||||
});
|
||||
}
|
||||
|
||||
public activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void> {
|
||||
let desc = this._registry.getExtensionDescription(extensionId);
|
||||
const desc = this._registry.getExtensionDescription(extensionId);
|
||||
if (!desc) {
|
||||
throw new Error('Extension `' + extensionId + '` is not known');
|
||||
}
|
||||
@@ -264,7 +264,7 @@ export class ExtensionsActivator {
|
||||
}
|
||||
|
||||
const currentExtension = this._registry.getExtensionDescription(currentExtensionId)!;
|
||||
let depIds = (typeof currentExtension.extensionDependencies === 'undefined' ? [] : currentExtension.extensionDependencies);
|
||||
const depIds = (typeof currentExtension.extensionDependencies === 'undefined' ? [] : currentExtension.extensionDependencies);
|
||||
let currentExtensionGetsGreenLight = true;
|
||||
|
||||
for (let j = 0, lenJ = depIds.length; j < lenJ; j++) {
|
||||
@@ -330,7 +330,7 @@ export class ExtensionsActivator {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
let greenMap: { [id: string]: ExtensionIdentifier; } = Object.create(null),
|
||||
const greenMap: { [id: string]: ExtensionIdentifier; } = Object.create(null),
|
||||
red: ExtensionIdentifier[] = [];
|
||||
|
||||
for (let i = 0, len = extensionIds.length; i < len; i++) {
|
||||
@@ -345,7 +345,7 @@ export class ExtensionsActivator {
|
||||
}
|
||||
}
|
||||
|
||||
let green = Object.keys(greenMap).map(id => greenMap[id]);
|
||||
const green = Object.keys(greenMap).map(id => greenMap[id]);
|
||||
|
||||
// console.log('greenExtensions: ', green.map(p => p.id));
|
||||
// console.log('redExtensions: ', red.map(p => p.id));
|
||||
|
||||
@@ -225,7 +225,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
|
||||
actualActivateExtension: async (extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<ActivatedExtension> => {
|
||||
if (hostExtensions.has(ExtensionIdentifier.toKey(extensionId))) {
|
||||
let activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
const activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
await this._mainThreadExtensionsProxy.$activateExtension(extensionId, activationEvent);
|
||||
return new HostExtension();
|
||||
}
|
||||
@@ -345,7 +345,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
return result;
|
||||
}
|
||||
|
||||
let extension = this._activator.getActivatedExtension(extensionId);
|
||||
const extension = this._activator.getActivatedExtension(extensionId);
|
||||
if (!extension) {
|
||||
return result;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
this._mainThreadExtensionsProxy.$onWillActivateExtension(extensionDescription.identifier);
|
||||
return this._doActivateExtension(extensionDescription, reason).then((activatedExtension) => {
|
||||
const activationTimes = activatedExtension.activationTimes;
|
||||
let activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
const activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
|
||||
this._mainThreadExtensionsProxy.$onDidActivateExtension(extensionDescription.identifier, activationTimes.startup, activationTimes.codeLoadingTime, activationTimes.activateCallTime, activationTimes.activateResolvedTime, activationEvent);
|
||||
this._logExtensionActivationTimes(extensionDescription, reason, 'success', activationTimes);
|
||||
return activatedExtension;
|
||||
@@ -394,7 +394,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
}
|
||||
|
||||
private _logExtensionActivationTimes(extensionDescription: IExtensionDescription, reason: ExtensionActivationReason, outcome: string, activationTimes?: ExtensionActivationTimes) {
|
||||
let event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
const event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
/* __GDPR__
|
||||
"extensionActivationTimes" : {
|
||||
"${include}": [
|
||||
@@ -412,7 +412,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
}
|
||||
|
||||
private _doActivateExtension(extensionDescription: IExtensionDescription, reason: ExtensionActivationReason): Promise<ActivatedExtension> {
|
||||
let event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
const event = getTelemetryActivationEvent(extensionDescription, reason);
|
||||
/* __GDPR__
|
||||
"activatePlugin" : {
|
||||
"${include}": [
|
||||
@@ -439,8 +439,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
|
||||
private _loadExtensionContext(extensionDescription: IExtensionDescription): Promise<IExtensionContext> {
|
||||
|
||||
let globalState = new ExtensionMemento(extensionDescription.identifier.value, true, this._storage);
|
||||
let workspaceState = new ExtensionMemento(extensionDescription.identifier.value, false, this._storage);
|
||||
const globalState = new ExtensionMemento(extensionDescription.identifier.value, true, this._storage);
|
||||
const workspaceState = new ExtensionMemento(extensionDescription.identifier.value, false, this._storage);
|
||||
|
||||
this._extHostLogService.trace(`ExtensionService#loadExtensionContext ${extensionDescription.identifier.value}`);
|
||||
return Promise.all([
|
||||
@@ -763,7 +763,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
|
||||
}
|
||||
|
||||
public async $test_down(size: number): Promise<Buffer> {
|
||||
let b = Buffer.alloc(size, Math.random() % 256);
|
||||
const b = Buffer.alloc(size, Math.random() % 256);
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ function getTelemetryActivationEvent(extensionDescription: IExtensionDescription
|
||||
"reason": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
let event = {
|
||||
const event = {
|
||||
id: extensionDescription.identifier.value,
|
||||
name: extensionDescription.name,
|
||||
extensionVersion: extensionDescription.version,
|
||||
|
||||
@@ -28,7 +28,7 @@ class FsLinkProvider {
|
||||
}
|
||||
|
||||
delete(scheme: string): void {
|
||||
let idx = this._schemes.indexOf(scheme);
|
||||
const idx = this._schemes.indexOf(scheme);
|
||||
if (idx >= 0) {
|
||||
this._schemes.splice(idx, 1);
|
||||
this._stateMachine = undefined;
|
||||
@@ -94,7 +94,7 @@ class FsLinkProvider {
|
||||
}, this._stateMachine);
|
||||
|
||||
for (const link of links) {
|
||||
let docLink = typeConverter.DocumentLink.to(link);
|
||||
const docLink = typeConverter.DocumentLink.to(link);
|
||||
if (docLink.target) {
|
||||
result.push(docLink);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
this._proxy.$registerFileSystemProvider(handle, scheme, capabilites);
|
||||
|
||||
const subscription = provider.onDidChangeFile(event => {
|
||||
let mapped: IFileChangeDto[] = [];
|
||||
const mapped: IFileChangeDto[] = [];
|
||||
for (const e of event) {
|
||||
let { uri: resource, type } = e;
|
||||
if (resource.scheme !== scheme) {
|
||||
@@ -260,12 +260,12 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
|
||||
}
|
||||
|
||||
$watch(handle: number, session: number, resource: UriComponents, opts: files.IWatchOptions): void {
|
||||
let subscription = this.getProvider(handle).watch(URI.revive(resource), opts);
|
||||
const subscription = this.getProvider(handle).watch(URI.revive(resource), opts);
|
||||
this._watches.set(session, subscription);
|
||||
}
|
||||
|
||||
$unwatch(_handle: number, session: number): void {
|
||||
let subscription = this._watches.get(session);
|
||||
const subscription = this._watches.get(session);
|
||||
if (subscription) {
|
||||
subscription.dispose();
|
||||
this._watches.delete(session);
|
||||
|
||||
@@ -49,10 +49,10 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
|
||||
const parsedPattern = parse(globPattern);
|
||||
|
||||
let subscription = dispatcher(events => {
|
||||
const subscription = dispatcher(events => {
|
||||
if (!ignoreCreateEvents) {
|
||||
for (let created of events.created) {
|
||||
let uri = URI.revive(created);
|
||||
const uri = URI.revive(created);
|
||||
if (parsedPattern(uri.fsPath)) {
|
||||
this._onDidCreate.fire(uri);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
}
|
||||
if (!ignoreChangeEvents) {
|
||||
for (let changed of events.changed) {
|
||||
let uri = URI.revive(changed);
|
||||
const uri = URI.revive(changed);
|
||||
if (parsedPattern(uri.fsPath)) {
|
||||
this._onDidChange.fire(uri);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
}
|
||||
if (!ignoreDeleteEvents) {
|
||||
for (let deleted of events.deleted) {
|
||||
let uri = URI.revive(deleted);
|
||||
const uri = URI.revive(deleted);
|
||||
if (parsedPattern(uri.fsPath)) {
|
||||
this._onDidDelete.fire(uri);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
|
||||
}
|
||||
// flatten all WorkspaceEdits collected via waitUntil-call
|
||||
// and apply them in one go.
|
||||
let allEdits = new Array<Array<ResourceFileEditDto | ResourceTextEditDto>>();
|
||||
const allEdits = new Array<Array<ResourceFileEditDto | ResourceTextEditDto>>();
|
||||
for (let edit of edits) {
|
||||
if (edit) { // sparse array
|
||||
let { edits } = typeConverter.WorkspaceEdit.from(edit, this._extHostDocumentsAndEditors);
|
||||
|
||||
@@ -65,10 +65,10 @@ class DocumentSymbolAdapter {
|
||||
}
|
||||
return res;
|
||||
});
|
||||
let res: modes.DocumentSymbol[] = [];
|
||||
let parentStack: modes.DocumentSymbol[] = [];
|
||||
const res: modes.DocumentSymbol[] = [];
|
||||
const parentStack: modes.DocumentSymbol[] = [];
|
||||
for (const info of infos) {
|
||||
let element = <modes.DocumentSymbol>{
|
||||
const element = <modes.DocumentSymbol>{
|
||||
name: info.name || '!!MISSING: name!!',
|
||||
kind: typeConvert.SymbolKind.from(info.kind),
|
||||
containerName: info.containerName,
|
||||
@@ -83,7 +83,7 @@ class DocumentSymbolAdapter {
|
||||
res.push(element);
|
||||
break;
|
||||
}
|
||||
let parent = parentStack[parentStack.length - 1];
|
||||
const parent = parentStack[parentStack.length - 1];
|
||||
if (EditorRange.containsRange(parent.range, element.range) && !EditorRange.equalsRange(parent.range, element.range)) {
|
||||
parent.children.push(element);
|
||||
parentStack.push(element);
|
||||
@@ -111,7 +111,7 @@ class CodeLensAdapter {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
|
||||
return asPromise(() => this._provider.provideCodeLenses(doc, token)).then(lenses => {
|
||||
let result: CodeLensDto[] = [];
|
||||
const result: CodeLensDto[] = [];
|
||||
if (isNonEmptyArray(lenses)) {
|
||||
for (const lens of lenses) {
|
||||
const id = this._heapService.keep(lens);
|
||||
@@ -206,7 +206,7 @@ class DefinitionAdapter {
|
||||
|
||||
provideDefinition(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asPromise(() => this._provider.provideDefinition(doc, pos, token)).then(convertToLocationLinks);
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ class DeclarationAdapter {
|
||||
|
||||
provideDeclaration(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asPromise(() => this._provider.provideDeclaration(doc, pos, token)).then(convertToLocationLinks);
|
||||
}
|
||||
}
|
||||
@@ -234,7 +234,7 @@ class ImplementationAdapter {
|
||||
|
||||
provideImplementation(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asPromise(() => this._provider.provideImplementation(doc, pos, token)).then(convertToLocationLinks);
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ class HoverAdapter {
|
||||
public provideHover(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.Hover | undefined> {
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideHover(doc, pos, token)).then(value => {
|
||||
if (!value || isFalsyOrEmpty(value.contents)) {
|
||||
@@ -291,7 +291,7 @@ class DocumentHighlightAdapter {
|
||||
provideDocumentHighlights(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DocumentHighlight[] | undefined> {
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideDocumentHighlights(doc, pos, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -311,7 +311,7 @@ class ReferenceAdapter {
|
||||
|
||||
provideReferences(resource: URI, position: IPosition, context: modes.ReferenceContext, token: CancellationToken): Promise<modes.Location[] | undefined> {
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideReferences(doc, pos, context, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -546,7 +546,7 @@ class RenameAdapter {
|
||||
provideRenameEdits(resource: URI, position: IPosition, newName: string, token: CancellationToken): Promise<WorkspaceEditDto | undefined> {
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.provideRenameEdits(doc, pos, newName, token)).then(value => {
|
||||
if (!value) {
|
||||
@@ -554,7 +554,7 @@ class RenameAdapter {
|
||||
}
|
||||
return typeConvert.WorkspaceEdit.from(value);
|
||||
}, err => {
|
||||
let rejectReason = RenameAdapter._asMessage(err);
|
||||
const rejectReason = RenameAdapter._asMessage(err);
|
||||
if (rejectReason) {
|
||||
return <WorkspaceEditDto>{ rejectReason, edits: undefined! };
|
||||
} else {
|
||||
@@ -570,7 +570,7 @@ class RenameAdapter {
|
||||
}
|
||||
|
||||
const doc = this._documents.getDocument(resource);
|
||||
let pos = typeConvert.Position.to(position);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asPromise(() => this._provider.prepareRename!(doc, pos, token)).then(rangeOrLocation => {
|
||||
|
||||
@@ -594,7 +594,7 @@ class RenameAdapter {
|
||||
}
|
||||
return { range: typeConvert.Range.from(range), text };
|
||||
}, err => {
|
||||
let rejectReason = RenameAdapter._asMessage(err);
|
||||
const rejectReason = RenameAdapter._asMessage(err);
|
||||
if (rejectReason) {
|
||||
return <modes.RenameLocation & modes.Rejection>{ rejectReason, range: undefined!, text: undefined! };
|
||||
} else {
|
||||
@@ -832,8 +832,8 @@ class LinkProviderAdapter {
|
||||
}
|
||||
const result: LinkDto[] = [];
|
||||
for (const link of links) {
|
||||
let data = typeConvert.DocumentLink.from(link);
|
||||
let id = this._heapService.keep(link);
|
||||
const data = typeConvert.DocumentLink.from(link);
|
||||
const id = this._heapService.keep(link);
|
||||
result.push(ObjectIdentifier.mixin(data, id));
|
||||
}
|
||||
return result;
|
||||
@@ -936,7 +936,7 @@ class SelectionRangeAdapter {
|
||||
return [];
|
||||
}
|
||||
|
||||
let allResults: modes.SelectionRange[][] = [];
|
||||
const allResults: modes.SelectionRange[][] = [];
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
const oneResult: modes.SelectionRange[] = [];
|
||||
allResults.push(oneResult);
|
||||
@@ -1065,7 +1065,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
|
||||
t1 = Date.now();
|
||||
this._logService.trace(`[${data.extension.identifier.value}] INVOKE provider '${(ctor as any).name}'`);
|
||||
}
|
||||
let p = callback(data.adapter, data.extension);
|
||||
const p = callback(data.adapter, data.extension);
|
||||
const extension = data.extension;
|
||||
if (extension) {
|
||||
Promise.resolve(p).then(
|
||||
|
||||
@@ -24,7 +24,7 @@ export class ExtHostMessageService {
|
||||
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem, rest: vscode.MessageItem[]): Promise<vscode.MessageItem | undefined>;
|
||||
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string | vscode.MessageItem, rest: (string | vscode.MessageItem)[]): Promise<string | vscode.MessageItem | undefined> {
|
||||
|
||||
let options: MainThreadMessageOptions = { extension };
|
||||
const options: MainThreadMessageOptions = { extension };
|
||||
let items: (string | vscode.MessageItem)[];
|
||||
|
||||
if (typeof optionsOrFirstItem === 'string' || isMessageItem(optionsOrFirstItem)) {
|
||||
@@ -37,7 +37,7 @@ export class ExtHostMessageService {
|
||||
const commands: { title: string; isCloseAffordance: boolean; handle: number; }[] = [];
|
||||
|
||||
for (let handle = 0; handle < items.length; handle++) {
|
||||
let command = items[handle];
|
||||
const command = items[handle];
|
||||
if (typeof command === 'string') {
|
||||
commands.push({ title: command, handle, isCloseAffordance: false });
|
||||
} else if (typeof command === 'object') {
|
||||
|
||||
@@ -68,10 +68,10 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
|
||||
|
||||
return itemsPromise.then(items => {
|
||||
|
||||
let pickItems: TransferQuickPickItems[] = [];
|
||||
const pickItems: TransferQuickPickItems[] = [];
|
||||
for (let handle = 0; handle < items.length; handle++) {
|
||||
|
||||
let item = items[handle];
|
||||
const item = items[handle];
|
||||
let label: string;
|
||||
let description: string | undefined;
|
||||
let detail: string | undefined;
|
||||
|
||||
@@ -116,7 +116,7 @@ export class FileIndexSearchEngine {
|
||||
}
|
||||
|
||||
private searchInFolder(fq: IFolderQuery<URI>, onResult: (match: IInternalFileMatch) => void): Promise<IFileIndexProviderStats> {
|
||||
let cancellation = new CancellationTokenSource();
|
||||
const cancellation = new CancellationTokenSource();
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = this.getSearchOptionsForFolder(fq);
|
||||
const tree = this.initDirectoryTree();
|
||||
@@ -511,10 +511,10 @@ export class FileIndexSearchManager {
|
||||
}
|
||||
|
||||
// Pattern match on results
|
||||
let results: IInternalFileMatch[] = [];
|
||||
const results: IInternalFileMatch[] = [];
|
||||
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
|
||||
for (let i = 0; i < complete.results.length; i++) {
|
||||
let entry = complete.results[i];
|
||||
const entry = complete.results[i];
|
||||
|
||||
// Check if this entry is a match for the search value
|
||||
if (!strings.fuzzyContains(entry.relativePath!, normalizedSearchValueLowercase)) {
|
||||
|
||||
@@ -139,7 +139,7 @@ class StatusBarMessage {
|
||||
this._update();
|
||||
|
||||
return new Disposable(() => {
|
||||
let idx = this._messages.indexOf(data);
|
||||
const idx = this._messages.indexOf(data);
|
||||
if (idx >= 0) {
|
||||
this._messages.splice(idx, 1);
|
||||
this._update();
|
||||
@@ -173,7 +173,7 @@ export class ExtHostStatusBar {
|
||||
|
||||
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): Disposable {
|
||||
|
||||
let d = this._statusMessage.setMessage(text);
|
||||
const d = this._statusMessage.setMessage(text);
|
||||
let handle: any;
|
||||
|
||||
if (typeof timeoutOrThenable === 'number') {
|
||||
|
||||
@@ -75,14 +75,14 @@ namespace ProcessExecutionOptionsDTO {
|
||||
|
||||
namespace ProcessExecutionDTO {
|
||||
export function is(value: ShellExecutionDTO | ProcessExecutionDTO): value is ProcessExecutionDTO {
|
||||
let candidate = value as ProcessExecutionDTO;
|
||||
const candidate = value as ProcessExecutionDTO;
|
||||
return candidate && !!candidate.process;
|
||||
}
|
||||
export function from(value: vscode.ProcessExecution): ProcessExecutionDTO {
|
||||
if (value === undefined || value === null) {
|
||||
return undefined;
|
||||
}
|
||||
let result: ProcessExecutionDTO = {
|
||||
const result: ProcessExecutionDTO = {
|
||||
process: value.process,
|
||||
args: value.args
|
||||
};
|
||||
@@ -116,14 +116,14 @@ namespace ShellExecutionOptionsDTO {
|
||||
|
||||
namespace ShellExecutionDTO {
|
||||
export function is(value: ShellExecutionDTO | ProcessExecutionDTO): value is ShellExecutionDTO {
|
||||
let candidate = value as ShellExecutionDTO;
|
||||
const candidate = value as ShellExecutionDTO;
|
||||
return candidate && (!!candidate.commandLine || !!candidate.command);
|
||||
}
|
||||
export function from(value: vscode.ShellExecution): ShellExecutionDTO {
|
||||
if (value === undefined || value === null) {
|
||||
return undefined;
|
||||
}
|
||||
let result: ShellExecutionDTO = {
|
||||
const result: ShellExecutionDTO = {
|
||||
};
|
||||
if (value.commandLine !== undefined) {
|
||||
result.commandLine = value.commandLine;
|
||||
@@ -167,9 +167,9 @@ namespace TaskDTO {
|
||||
if (tasks === undefined || tasks === null) {
|
||||
return [];
|
||||
}
|
||||
let result: TaskDTO[] = [];
|
||||
const result: TaskDTO[] = [];
|
||||
for (let task of tasks) {
|
||||
let converted = from(task, extension);
|
||||
const converted = from(task, extension);
|
||||
if (converted) {
|
||||
result.push(converted);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace TaskDTO {
|
||||
} else if (value.execution instanceof types.ShellExecution) {
|
||||
execution = ShellExecutionDTO.from(value.execution);
|
||||
}
|
||||
let definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
|
||||
const definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
|
||||
let scope: number | UriComponents;
|
||||
if (value.scope) {
|
||||
if (typeof value.scope === 'number') {
|
||||
@@ -202,8 +202,8 @@ namespace TaskDTO {
|
||||
if (!definition || !scope) {
|
||||
return undefined;
|
||||
}
|
||||
let group = (value.group as types.TaskGroup) ? (value.group as types.TaskGroup).id : undefined;
|
||||
let result: TaskDTO = {
|
||||
const group = (value.group as types.TaskGroup) ? (value.group as types.TaskGroup).id : undefined;
|
||||
const result: TaskDTO = {
|
||||
_id: (value as types.Task)._id,
|
||||
definition,
|
||||
name: value.name,
|
||||
@@ -232,7 +232,7 @@ namespace TaskDTO {
|
||||
} else if (ShellExecutionDTO.is(value.execution)) {
|
||||
execution = ShellExecutionDTO.to(value.execution);
|
||||
}
|
||||
let definition: vscode.TaskDefinition = TaskDefinitionDTO.to(value.definition);
|
||||
const definition: vscode.TaskDefinition = TaskDefinitionDTO.to(value.definition);
|
||||
let scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
|
||||
if (value.source) {
|
||||
if (value.source.scope !== undefined) {
|
||||
@@ -248,7 +248,7 @@ namespace TaskDTO {
|
||||
if (!definition || !scope) {
|
||||
return undefined;
|
||||
}
|
||||
let result = new types.Task(definition, scope, value.name, value.source.label, execution, value.problemMatchers);
|
||||
const result = new types.Task(definition, scope, value.name, value.source.label, execution, value.problemMatchers);
|
||||
if (value.isBackground !== undefined) {
|
||||
result.isBackground = value.isBackground;
|
||||
}
|
||||
@@ -345,7 +345,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
if (!provider) {
|
||||
return new types.Disposable(() => { });
|
||||
}
|
||||
let handle = this.nextHandle();
|
||||
const handle = this.nextHandle();
|
||||
this._handlers.set(handle, { provider, extension });
|
||||
this._proxy.$registerTaskProvider(handle);
|
||||
return new types.Disposable(() => {
|
||||
@@ -360,9 +360,9 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
|
||||
public fetchTasks(filter?: vscode.TaskFilter): Promise<vscode.Task[]> {
|
||||
return this._proxy.$fetchTasks(TaskFilterDTO.from(filter)).then(async (values) => {
|
||||
let result: vscode.Task[] = [];
|
||||
const result: vscode.Task[] = [];
|
||||
for (let value of values) {
|
||||
let task = await TaskDTO.to(value, this._workspaceProvider);
|
||||
const task = await TaskDTO.to(value, this._workspaceProvider);
|
||||
if (task) {
|
||||
result.push(task);
|
||||
}
|
||||
@@ -372,12 +372,12 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
|
||||
public async executeTask(extension: IExtensionDescription, task: vscode.Task): Promise<vscode.TaskExecution> {
|
||||
let tTask = (task as types.Task);
|
||||
const tTask = (task as types.Task);
|
||||
// We have a preserved ID. So the task didn't change.
|
||||
if (tTask._id !== undefined) {
|
||||
return this._proxy.$executeTask(TaskHandleDTO.from(tTask)).then(value => this.getTaskExecution(value, task));
|
||||
} else {
|
||||
let dto = TaskDTO.from(task, extension);
|
||||
const dto = TaskDTO.from(task, extension);
|
||||
if (dto === undefined) {
|
||||
return Promise.reject(new Error('Task is not valid'));
|
||||
}
|
||||
@@ -386,7 +386,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
|
||||
public get taskExecutions(): vscode.TaskExecution[] {
|
||||
let result: vscode.TaskExecution[] = [];
|
||||
const result: vscode.TaskExecution[] = [];
|
||||
this._taskExecutions.forEach(value => result.push(value));
|
||||
return result;
|
||||
}
|
||||
@@ -449,12 +449,12 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
}
|
||||
|
||||
public $provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable<TaskSetDTO> {
|
||||
let handler = this._handlers.get(handle);
|
||||
const handler = this._handlers.get(handle);
|
||||
if (!handler) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
return asPromise(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
|
||||
let sanitized: vscode.Task[] = [];
|
||||
const sanitized: vscode.Task[] = [];
|
||||
for (let task of value) {
|
||||
if (task.definition && validTypes[task.definition.type] === true) {
|
||||
sanitized.push(task);
|
||||
@@ -472,15 +472,15 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
|
||||
public async $resolveVariables(uriComponents: UriComponents, toResolve: { process?: { name: string; cwd?: string; path?: string }, variables: string[] }): Promise<{ process?: string, variables: { [key: string]: string; } }> {
|
||||
const configProvider = await this._configurationService.getConfigProvider();
|
||||
let uri: URI = URI.revive(uriComponents);
|
||||
let result = {
|
||||
const uri: URI = URI.revive(uriComponents);
|
||||
const result = {
|
||||
process: undefined as string,
|
||||
variables: Object.create(null)
|
||||
};
|
||||
let workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(uri);
|
||||
const workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(uri);
|
||||
const workspaceFolders = await this._workspaceProvider.getWorkspaceFolders2();
|
||||
let resolver = new ExtHostVariableResolverService(workspaceFolders, this._editorService, configProvider);
|
||||
let ws: IWorkspaceFolder = {
|
||||
const resolver = new ExtHostVariableResolverService(workspaceFolders, this._editorService, configProvider);
|
||||
const ws: IWorkspaceFolder = {
|
||||
uri: workspaceFolder.uri,
|
||||
name: workspaceFolder.name,
|
||||
index: workspaceFolder.index,
|
||||
|
||||
@@ -106,7 +106,7 @@ export class TextEditorEdit {
|
||||
}
|
||||
|
||||
private _pushEdit(range: Range, text: string | null, forceMoveMarkers: boolean): void {
|
||||
let validRange = this._document.validateRange(range);
|
||||
const validRange = this._document.validateRange(range);
|
||||
this._collectedEdits.push({
|
||||
range: validRange,
|
||||
text: text,
|
||||
@@ -170,11 +170,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
return 'auto';
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
let r = Math.floor(value);
|
||||
const r = Math.floor(value);
|
||||
return (r > 0 ? r : null);
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
let r = parseInt(value, 10);
|
||||
const r = parseInt(value, 10);
|
||||
if (isNaN(r)) {
|
||||
return null;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public set tabSize(value: number | string) {
|
||||
let tabSize = this._validateTabSize(value);
|
||||
const tabSize = this._validateTabSize(value);
|
||||
if (tabSize === null) {
|
||||
// ignore invalid call
|
||||
return;
|
||||
@@ -211,11 +211,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
return 'tabSize';
|
||||
}
|
||||
if (typeof value === 'number') {
|
||||
let r = Math.floor(value);
|
||||
const r = Math.floor(value);
|
||||
return (r > 0 ? r : null);
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
let r = parseInt(value, 10);
|
||||
const r = parseInt(value, 10);
|
||||
if (isNaN(r)) {
|
||||
return null;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public set indentSize(value: number | string) {
|
||||
let indentSize = this._validateIndentSize(value);
|
||||
const indentSize = this._validateIndentSize(value);
|
||||
if (indentSize === null) {
|
||||
// ignore invalid call
|
||||
return;
|
||||
@@ -255,7 +255,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public set insertSpaces(value: boolean | string) {
|
||||
let insertSpaces = this._validateInsertSpaces(value);
|
||||
const insertSpaces = this._validateInsertSpaces(value);
|
||||
if (typeof insertSpaces === 'boolean') {
|
||||
if (this._insertSpaces === insertSpaces) {
|
||||
// nothing to do
|
||||
@@ -300,11 +300,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
public assign(newOptions: vscode.TextEditorOptions) {
|
||||
let bulkConfigurationUpdate: ITextEditorConfigurationUpdate = {};
|
||||
const bulkConfigurationUpdate: ITextEditorConfigurationUpdate = {};
|
||||
let hasUpdate = false;
|
||||
|
||||
if (typeof newOptions.tabSize !== 'undefined') {
|
||||
let tabSize = this._validateTabSize(newOptions.tabSize);
|
||||
const tabSize = this._validateTabSize(newOptions.tabSize);
|
||||
if (tabSize === 'auto') {
|
||||
hasUpdate = true;
|
||||
bulkConfigurationUpdate.tabSize = tabSize;
|
||||
@@ -317,7 +317,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
}
|
||||
|
||||
// if (typeof newOptions.indentSize !== 'undefined') {
|
||||
// let indentSize = this._validateIndentSize(newOptions.indentSize);
|
||||
// const indentSize = this._validateIndentSize(newOptions.indentSize);
|
||||
// if (indentSize === 'tabSize') {
|
||||
// hasUpdate = true;
|
||||
// bulkConfigurationUpdate.indentSize = indentSize;
|
||||
@@ -330,7 +330,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
|
||||
// }
|
||||
|
||||
if (typeof newOptions.insertSpaces !== 'undefined') {
|
||||
let insertSpaces = this._validateInsertSpaces(newOptions.insertSpaces);
|
||||
const insertSpaces = this._validateInsertSpaces(newOptions.insertSpaces);
|
||||
if (insertSpaces === 'auto') {
|
||||
hasUpdate = true;
|
||||
bulkConfigurationUpdate.insertSpaces = insertSpaces;
|
||||
@@ -510,7 +510,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
TypeConverters.fromRangeOrRangeWithMessage(ranges)
|
||||
);
|
||||
} else {
|
||||
let _ranges: number[] = new Array<number>(4 * ranges.length);
|
||||
const _ranges: number[] = new Array<number>(4 * ranges.length);
|
||||
for (let i = 0, len = ranges.length; i < len; i++) {
|
||||
const range = ranges[i];
|
||||
_ranges[4 * i] = range.start.line + 1;
|
||||
@@ -539,7 +539,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
|
||||
private _trySetSelection(): Promise<vscode.TextEditor | null | undefined> {
|
||||
let selection = this._selections.map(TypeConverters.Selection.from);
|
||||
const selection = this._selections.map(TypeConverters.Selection.from);
|
||||
return this._runOnProxy(() => this._proxy.$trySetSelections(this._id, selection));
|
||||
}
|
||||
|
||||
@@ -554,13 +554,13 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
if (this._disposed) {
|
||||
return Promise.reject(new Error('TextEditor#edit not possible on closed editors'));
|
||||
}
|
||||
let edit = new TextEditorEdit(this._documentData.document, options);
|
||||
const edit = new TextEditorEdit(this._documentData.document, options);
|
||||
callback(edit);
|
||||
return this._applyEdit(edit);
|
||||
}
|
||||
|
||||
private _applyEdit(editBuilder: TextEditorEdit): Promise<boolean> {
|
||||
let editData = editBuilder.finalize();
|
||||
const editData = editBuilder.finalize();
|
||||
|
||||
// return when there is nothing to do
|
||||
if (editData.edits.length === 0 && !editData.setEndOfLine) {
|
||||
@@ -568,7 +568,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
|
||||
}
|
||||
|
||||
// check that the edits are not overlapping (i.e. illegal)
|
||||
let editRanges = editData.edits.map(edit => edit.range);
|
||||
const editRanges = editData.edits.map(edit => edit.range);
|
||||
|
||||
// sort ascending (by end and then by start)
|
||||
editRanges.sort((a, b) => {
|
||||
|
||||
@@ -75,7 +75,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
|
||||
}
|
||||
|
||||
return this._proxy.$tryShowTextDocument(document.uri, options).then(id => {
|
||||
let editor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
const editor = this._extHostDocumentsAndEditors.getEditor(id);
|
||||
if (editor) {
|
||||
return editor;
|
||||
} else {
|
||||
|
||||
@@ -366,7 +366,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
private getHandlesToRefresh(elements: T[]): TreeItemHandle[] {
|
||||
const elementsToUpdate = new Set<TreeItemHandle>();
|
||||
for (const element of elements) {
|
||||
let elementNode = this.nodes.get(element);
|
||||
const elementNode = this.nodes.get(element);
|
||||
if (elementNode && !elementsToUpdate.has(elementNode.item.handle)) {
|
||||
// check if an ancestor of extElement is already in the elements to update list
|
||||
let currentNode = elementNode;
|
||||
@@ -384,7 +384,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
// Take only top level elements
|
||||
elementsToUpdate.forEach((handle) => {
|
||||
const element = this.elements.get(handle);
|
||||
let node = this.nodes.get(element);
|
||||
const node = this.nodes.get(element);
|
||||
if (node && (!node.parent || !elementsToUpdate.has(node.parent.item.handle))) {
|
||||
handlesToUpdate.push(handle);
|
||||
}
|
||||
@@ -553,7 +553,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
|
||||
private clearChildren(parentElement?: T): void {
|
||||
if (parentElement) {
|
||||
let node = this.nodes.get(parentElement);
|
||||
const node = this.nodes.get(parentElement);
|
||||
if (node.children) {
|
||||
for (const child of node.children) {
|
||||
const childEleement = this.elements.get(child.item.handle);
|
||||
@@ -569,7 +569,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
}
|
||||
|
||||
private clear(element: T): void {
|
||||
let node = this.nodes.get(element);
|
||||
const node = this.nodes.get(element);
|
||||
if (node.children) {
|
||||
for (const child of node.children) {
|
||||
const childEleement = this.elements.get(child.item.handle);
|
||||
|
||||
@@ -236,7 +236,7 @@ export namespace MarkdownString {
|
||||
const resUris: { [href: string]: UriComponents } = Object.create(null);
|
||||
res.uris = resUris;
|
||||
|
||||
let renderer = new marked.Renderer();
|
||||
const renderer = new marked.Renderer();
|
||||
renderer.image = renderer.link = (href: string): string => {
|
||||
try {
|
||||
let uri = URI.parse(href, true);
|
||||
@@ -267,7 +267,7 @@ export namespace MarkdownString {
|
||||
}
|
||||
data = cloneAndChange(data, value => {
|
||||
if (value instanceof URI) {
|
||||
let key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
|
||||
const key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
|
||||
bucket[key] = value;
|
||||
return key;
|
||||
} else {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class Position {
|
||||
}
|
||||
let result = positions[0];
|
||||
for (let i = 1; i < positions.length; i++) {
|
||||
let p = positions[i];
|
||||
const p = positions[i];
|
||||
if (p.isBefore(result!)) {
|
||||
result = p;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ export class Position {
|
||||
}
|
||||
let result = positions[0];
|
||||
for (let i = 1; i < positions.length; i++) {
|
||||
let p = positions[i];
|
||||
const p = positions[i];
|
||||
if (p.isAfter(result!)) {
|
||||
result = p;
|
||||
}
|
||||
@@ -303,8 +303,8 @@ export class Range {
|
||||
}
|
||||
|
||||
intersection(other: Range): Range | undefined {
|
||||
let start = Position.Max(other.start, this._start);
|
||||
let end = Position.Min(other.end, this._end);
|
||||
const start = Position.Max(other.start, this._start);
|
||||
const end = Position.Min(other.end, this._end);
|
||||
if (start.isAfter(end)) {
|
||||
// this happens when there is no overlap:
|
||||
// |-----|
|
||||
@@ -320,8 +320,8 @@ export class Range {
|
||||
} else if (other.contains(this)) {
|
||||
return other;
|
||||
}
|
||||
let start = Position.Min(other.start, this._start);
|
||||
let end = Position.Max(other.end, this.end);
|
||||
const start = Position.Min(other.start, this._start);
|
||||
const end = Position.Max(other.end, this.end);
|
||||
return new Range(start, end);
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ export class TextEdit {
|
||||
}
|
||||
|
||||
static setEndOfLine(eol: EndOfLine): TextEdit {
|
||||
let ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
|
||||
const ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
|
||||
ret.newEol = eol;
|
||||
return ret;
|
||||
}
|
||||
@@ -616,7 +616,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
}
|
||||
|
||||
get(uri: URI): TextEdit[] {
|
||||
let res: TextEdit[] = [];
|
||||
const res: TextEdit[] = [];
|
||||
for (let candidate of this._edits) {
|
||||
if (candidate._type === 2 && candidate.uri.toString() === uri.toString()) {
|
||||
res.push(candidate.edit);
|
||||
@@ -626,7 +626,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
}
|
||||
|
||||
entries(): [URI, TextEdit[]][] {
|
||||
let textEdits = new Map<string, [URI, TextEdit[]]>();
|
||||
const textEdits = new Map<string, [URI, TextEdit[]]>();
|
||||
for (let candidate of this._edits) {
|
||||
if (candidate._type === 2) {
|
||||
let textEdit = textEdits.get(candidate.uri.toString());
|
||||
@@ -641,7 +641,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
}
|
||||
|
||||
_allEntries(): ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] {
|
||||
let res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
|
||||
const res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
|
||||
for (let edit of this._edits) {
|
||||
if (edit._type === 1) {
|
||||
res.push([edit.from, edit.to, edit.options]);
|
||||
@@ -1846,7 +1846,7 @@ export class Task implements vscode.Task {
|
||||
}
|
||||
this.clear();
|
||||
this._execution = value;
|
||||
let type = this._definition.type;
|
||||
const type = this._definition.type;
|
||||
if (Task.EmptyType === type || Task.ProcessType === type || Task.ShellType === type) {
|
||||
this.computeDefinitionBasedOnExecution();
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
|
||||
excludePattern: options.exclude ? globPatternToString(options.exclude) : undefined
|
||||
};
|
||||
|
||||
let isCanceled = false;
|
||||
const isCanceled = false;
|
||||
|
||||
this._activeSearchCallbacks[requestId] = p => {
|
||||
if (isCanceled) {
|
||||
|
||||
Reference in New Issue
Block a user