From 324c5f59f47c24a729d7e2e9695de254eace9991 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Thu, 25 Oct 2018 15:38:26 -0700 Subject: [PATCH 01/19] Update changelog for 0.20.0 release. --- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 066401f194..da98bdd56d 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.20.0-master", + "version": "0.20.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index f034b87eee..90ad7751de 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.20.0-master", + "version": "0.20.0", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From 082435ec8b99fb3460e00951a6ed28f083eb5571 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Thu, 25 Oct 2018 15:48:28 -0700 Subject: [PATCH 02/19] Fix comment for intelliSenseEngine setting. --- Extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package.json b/Extension/package.json index f034b87eee..ea0e896c85 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -108,7 +108,7 @@ "Disabled" ], "default": "Default", - "description": "Controls the IntelliSense provider. \"Tag Parser\" provides \"fuzzy\" results that are not context-aware. \"Default\" provides context-aware results and is in preview mode - member list, hover tooltips, and error squiggles are currently implemented. Features not yet implemented in the new default engine will use the tag parser engine instead.", + "description": "Controls the IntelliSense provider. \"Tag Parser\" provides \"fuzzy\" results that are not context-aware. \"Default\" provides context-aware results. \"Disabled\" turns off C/C++ language service features.", "scope": "resource" }, "C_Cpp.intelliSenseEngineFallback": { From 8729804dc2a46e012af618859adfb46302464afe Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 31 Oct 2018 16:27:42 -0700 Subject: [PATCH 03/19] Update version. --- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 77fa47a75b..cb04cbb318 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.20.1-master", + "version": "0.20.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index 31fe809aa1..ed80eb7898 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.20.1-master", + "version": "0.20.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From a4b51997ff9474e2d96ed3cd1d76eaf8b107a326 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Tue, 22 Jan 2019 14:30:32 -0800 Subject: [PATCH 04/19] Update version. --- Extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package.json b/Extension/package.json index ed80eb7898..238654be3a 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.20.1", + "version": "0.21.0", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From 9702eae9537b01380aa74a71ec6e2acdc0b6c6b9 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Tue, 22 Jan 2019 14:32:04 -0800 Subject: [PATCH 05/19] Update package.json. --- Extension/package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index cb04cbb318..8f1748e902 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.20.1", + "version": "0.21.0", "lockfileVersion": 1, "requires": true, "dependencies": { From da277c85934fd8a94d6d201921d43f561d8b7fba Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Tue, 22 Jan 2019 19:17:42 -0800 Subject: [PATCH 06/19] Seanmcm/0 21 0 release2 (#3070) * Update yauzl version and changelog date. (#3069) --- Extension/CHANGELOG.md | 2 +- Extension/package-lock.json | 14 +++++++------- Extension/package.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 811394644c..c479629532 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,6 +1,6 @@ # C/C++ for Visual Studio Code Change Log -## Version 0.21.0 January 17, 2019 +## Version 0.21.0 January 23, 2019 ### New Features * Add documentation comments for hover, completion, and signature help. [#399](https://github.com/Microsoft/vscode-cpptools/issues/399) * Add completion committing for methods after `(`. [#1184](https://github.com/Microsoft/vscode-cpptools/issues/1184) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index ab00d5abab..ba61a2dcbf 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1752,9 +1752,9 @@ "dev": true }, "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", "requires": { "pend": "~1.2.0" } @@ -7190,12 +7190,12 @@ } }, "yauzl": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.8.0.tgz", - "integrity": "sha1-eUUK/yKyqcWkHvVOAtuQfM+/nuI=", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", "requires": { "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.0.1" + "fd-slicer": "~1.1.0" } }, "yazl": { diff --git a/Extension/package.json b/Extension/package.json index d977e238e0..bd82f44471 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -1412,7 +1412,7 @@ "vscode-debugprotocol": "~1.24.0", "vscode-extension-telemetry": "~0.1.0", "vscode-languageclient": "5.1.1", - "yauzl": "~2.8.0" + "yauzl": "~2.10.0" }, "runtimeDependencies": [ { From 6724e13c631dcfee97cd2e440916c27df7f1bf89 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 20 Mar 2019 18:44:44 -0700 Subject: [PATCH 07/19] Update for 0.22.1. --- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 2d99963562..e13a5f2671 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.22.0-master", + "version": "0.22.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index 2b8572f6bd..8e92302964 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.22.1-master", + "version": "0.22.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From 68eda1966546ab6aa943cc9dc1265b9e5f7437b9 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Fri, 10 May 2019 15:14:16 -0700 Subject: [PATCH 08/19] Update version. --- Extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package.json b/Extension/package.json index 1f87a88110..7c3ad31ce0 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.23.1-master", + "version": "0.23.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From 32e98912df6ffa02228373ad1705b00c3e46f650 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Tue, 2 Jul 2019 18:33:53 -0700 Subject: [PATCH 09/19] Change version --- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 597b37f97b..89b6925b30 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.24.0-master", + "version": "0.24.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index dd1397bd21..6b747b4728 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.24.0-master", + "version": "0.24.0", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From 347794b0c72997fbf5788850674f95a892ff8413 Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Thu, 18 Jul 2019 17:28:00 -0700 Subject: [PATCH 10/19] cherry pick fixes for 0.24.1 (#3943) --- Documentation/LanguageServer/colorization.md | 78 ++++----- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- Extension/src/LanguageServer/client.ts | 158 ++++++++++-------- Extension/src/LanguageServer/colorization.ts | 28 ++-- .../src/LanguageServer/protocolFilter.ts | 7 +- Extension/src/common.ts | 8 +- 7 files changed, 151 insertions(+), 132 deletions(-) diff --git a/Documentation/LanguageServer/colorization.md b/Documentation/LanguageServer/colorization.md index 595d846a2f..49ef83d96a 100644 --- a/Documentation/LanguageServer/colorization.md +++ b/Documentation/LanguageServer/colorization.md @@ -19,32 +19,32 @@ Colors are associated with [TextMate scopes](https://macromates.com/manual/en/la | Token | Scope | | ------------- |:-------------:| -| Class Template | entity.name.class.template | +| Class Template | entity.name.type.class.templated | | Enumerator | variable.other.enummember | | Event (C++/CLI) | variable.other.event | | Function | entity.name.function | -| Function Template | entity.name.function.template | -| Generic Type (C++/CLI) | entity.name.class.generic | +| Function Template | entity.name.function.templated | +| Generic Type (C++/CLI) | entity.name.type.class.generic | | Global Variable | variable.other.global | | Label | entity.name.label | | Local Variable | variable.other.local | | Macro | entity.name.function.preprocessor | -| Member Field | variable.other.member | +| Member Field | variable.other.property | | Member Function | entity.name.function.member | -| Member Operator | keyword.operator.member | -| Namespace | entity.name.type.namespace | +| Namespace | entity.name.namespace | | New / Delete | keyword.operator.new | -| Operator Function | entity.name.function.operator | +| Operator Overload Function | entity.name.function.operator | +| Operator Overload Member | entity.name.function.operator.member | | Parameter | variable.parameter | -| Property (C++/CLI) | variable.other.property | -| Reference Type (C++/CLI) | entity.name.class.reference | -| Static Member Field | variable.other.member.static | +| Property (C++/CLI) | variable.other.property.cli | +| Reference Type (C++/CLI) | entity.name.type.class.reference | +| Static Member Field | variable.other.property.static | | Static Member Function | entity.name.function.member.static | -| Type | entity.name.type | -| User-Defined Literal - Number | entity.name.user-defined-literal.number | -| User-Defined Literal - Raw | entity.name.user-defined-literal | -| User-Defined Literal - String | entity.name.user-defined-literal.string | -| Value Type (C++/CLI) | entity.name.class.value | +| Type | entity.name.type.class | +| User-Defined Literal - Number | entity.name.operator.custom-literal.number | +| User-Defined Literal - Raw | entity.name.operator.custom-literal | +| User-Defined Literal - String | entity.name.operator.custom-literal.string | +| Value Type (C++/CLI) | entity.name.type.class.value | Many of the tokens recognized by IntelliSense do not directly map to existing scopes in the VS Code's default C/C++ TextMate grammar, so are likely not colored by existing VS Code themes. @@ -55,7 +55,7 @@ Colors can also be overridden globally, in settings: "editor.tokenColorCustomizations": { "textMateRules": [ { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#FF0000", "fontStyle": "italic bold underline" @@ -70,7 +70,7 @@ Or, overridden on a per-theme basis: "[Visual Studio Dark]": { "textMateRules": [ { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#FF0000", "fontStyle": "italic bold underline" @@ -171,19 +171,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.class.reference", + "scope": "entity.name.type.class.reference", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.class.value", + "scope": "entity.name.type.class.value", "settings": { "foreground": "#4EC9B0" } @@ -201,7 +201,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "variable.other.member", + "scope": "variable.other.property", "settings": { "foreground": "#DADADA" } @@ -213,7 +213,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "variable.other.member.static", + "scope": "variable.other.property.static", "settings": { "foreground": "#C8C8C8" } @@ -225,19 +225,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.class.template", + "scope": "entity.name.type.class.templated", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.class.generic", + "scope": "entity.name.type.class.generic", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.function.template", + "scope": "entity.name.function.templated", "settings": { "foreground": "#C8C8C8" } @@ -255,19 +255,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.user-defined-literal", + "scope": "entity.name.operator.custom-literal", "settings": { "foreground": "#DADADA" } }, { - "scope": "entity.name.user-defined-literal.string", + "scope": "entity.name.operator.custom-literal.string", "settings": { "foreground": "#D69D85" } }, { - "scope": "entity.name.user-defined-literal.number", + "scope": "entity.name.operator.custom-literal.number", "settings": { "foreground": "#B5CEA8" } @@ -386,19 +386,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.class.reference", + "scope": "entity.name.type.class.reference", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.class.value", + "scope": "entity.name.type.class.value", "settings": { "foreground": "#2B91AF" } @@ -416,7 +416,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "variable.other.member", + "scope": "variable.other.property", "settings": { "foreground": "#000000" } @@ -428,7 +428,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "variable.other.member.static", + "scope": "variable.other.property.static", "settings": { "foreground": "#000000" } @@ -440,19 +440,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.class.template", + "scope": "entity.name.type.class.templated", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.class.generic", + "scope": "entity.name.type.class.generic", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.function.template", + "scope": "entity.name.function.templated", "settings": { "foreground": "#000000" } @@ -470,19 +470,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.user-defined-literal", + "scope": "entity.name.operator.custom-literal", "settings": { "foreground": "#000000" } }, { - "scope": "entity.name.user-defined-literal.string", + "scope": "entity.name.operator.custom-literal.string", "settings": { "foreground": "#A31515" } }, { - "scope": "entity.name.user-defined-literal.number", + "scope": "entity.name.operator.custom-literal.number", "settings": { "foreground": "#000000" } diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 89b6925b30..5509aef524 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.24.0", + "version": "0.24.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index 6b747b4728..dbc019b268 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.24.0", + "version": "0.24.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index e7ee88eae7..fb838d3f3c 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -786,75 +786,76 @@ class DefaultClient implements Client { } public async provideCustomConfiguration(document: vscode.TextDocument): Promise { - let tokenSource: CancellationTokenSource = new CancellationTokenSource(); - let providers: CustomConfigurationProviderCollection = getCustomConfigProviders(); - if (providers.size === 0) { - return Promise.resolve(); - } - console.log("provideCustomConfiguration"); - let providerId: string|undefined = await this.getCustomConfigurationProviderId(); - if (!providerId) { - return Promise.resolve(); - } + return this.queueBlockingTask(async () => { + let tokenSource: CancellationTokenSource = new CancellationTokenSource(); + let providers: CustomConfigurationProviderCollection = getCustomConfigProviders(); + if (providers.size === 0) { + return Promise.resolve(); + } + console.log("provideCustomConfiguration"); + let providerId: string|undefined = this.configuration.CurrentConfigurationProvider; + if (!providerId) { + return Promise.resolve(); + } - let providerName: string = providerId; - let params: QueryTranslationUnitSourceParams = { - uri: document.uri.toString() - }; - let response: QueryTranslationUnitSourceResult = await this.requestWhenReady(() => this.languageClient.sendRequest(QueryTranslationUnitSourceRequest, params)); - if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.ConfigNotNeeded) { - return Promise.resolve(); - } + let providerName: string = providerId; + let params: QueryTranslationUnitSourceParams = { + uri: document.uri.toString() + }; + let response: QueryTranslationUnitSourceResult = await this.languageClient.sendRequest(QueryTranslationUnitSourceRequest, params); + if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.ConfigNotNeeded) { + return Promise.resolve(); + } - let tuUri: vscode.Uri = vscode.Uri.parse(response.uri); - let configName: string = await this.getCurrentConfigName(); - const notReadyMessage: string = `${providerName} is not ready`; - let provideConfigurationAsync: () => Thenable = async () => { - // The config requests that we use a provider, try to get IntelliSense configuration info from that provider. - try { - let provider: CustomConfigurationProvider1|null = providers.get(providerId); - if (provider) { - if (!provider.isReady) { - return Promise.reject(notReadyMessage); - } + let tuUri: vscode.Uri = vscode.Uri.parse(response.uri); + let configName: string = this.configuration.CurrentConfiguration.name; + const notReadyMessage: string = `${providerName} is not ready`; + let provideConfigurationAsync: () => Thenable = async () => { + // The config requests that we use a provider, try to get IntelliSense configuration info from that provider. + try { + let provider: CustomConfigurationProvider1|null = providers.get(providerId); + if (provider) { + if (!provider.isReady) { + return Promise.reject(notReadyMessage); + } - providerName = provider.name; - if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) { - return provider.provideConfigurations([tuUri], tokenSource.token); + providerName = provider.name; + if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) { + return provider.provideConfigurations([tuUri], tokenSource.token); + } } + } catch (err) { } - } catch (err) { - } - console.warn("failed to provide configuration"); - return Promise.reject(""); - }; + console.warn("failed to provide configuration"); + return Promise.reject(""); + }; - return this.queueTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( - (configs: SourceFileConfigurationItem[]) => { - if (configs && configs.length > 0) { - this.sendCustomConfigurations(configs, true); - if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.AncestorConfigNeeded) { - // replacing uri with original uri - let newConfig: SourceFileConfigurationItem = { uri: document.uri, configuration: configs[0].configuration }; - this.sendCustomConfigurations([newConfig], true); + return this.callTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( + (configs: SourceFileConfigurationItem[]) => { + if (configs && configs.length > 0) { + this.sendCustomConfigurations(configs, false); + if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.AncestorConfigNeeded) { + // replacing uri with original uri + let newConfig: SourceFileConfigurationItem = { uri: document.uri, configuration: configs[0].configuration }; + this.sendCustomConfigurations([newConfig], false); + } } - } - }, - (err) => { - if (err === notReadyMessage) { - return; - } - let settings: CppSettings = new CppSettings(this.RootUri); - if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document.uri) && !vscode.debug.activeDebugSession) { - const dismiss: string = "Dismiss"; - const disable: string = "Disable Warnings"; - let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + - `Settings from the '${configName}' configuration will be used instead.`; - if (err) { - message += ` (${err})`; + }, + (err) => { + if (err === notReadyMessage) { + return; } + let settings: CppSettings = new CppSettings(this.RootUri); + if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document.uri) && !vscode.debug.activeDebugSession) { + const dismiss: string = "Dismiss"; + const disable: string = "Disable Warnings"; + let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + + `Settings from the '${configName}' configuration will be used instead.`; + if (err) { + message += ` (${err})`; + } - vscode.window.showInformationMessage(message, dismiss, disable).then(response => { + vscode.window.showInformationMessage(message, dismiss, disable).then(response => { switch (response) { case disable: { settings.toggleSetting("configurationWarnings", "Enabled", "Disabled"); @@ -862,18 +863,15 @@ class DefaultClient implements Client { } } }); - } - }); + } + }); + }); } private isExternalHeader(uri: vscode.Uri): boolean { return util.isHeader(uri) && !uri.toString().startsWith(this.RootUri.toString()); } - private getCustomConfigurationProviderId(): Thenable { - return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfigurationProvider)); - } - public getCurrentConfigName(): Thenable { return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfiguration.name)); } @@ -923,7 +921,7 @@ class DefaultClient implements Client { if (this.pendingTask && !this.pendingTask.Done) { // We don't want the queue to stall because of a rejected promise. - return this.pendingTask.then(nextTask, nextTask); + return this.pendingTask.getPromise().then(nextTask, nextTask); } else { this.pendingTask = undefined; return nextTask(); @@ -941,6 +939,7 @@ class DefaultClient implements Client { private queueBlockingTask(task: () => Thenable): Thenable { if (this.isSupported) { this.pendingTask = new util.BlockingTask(task, this.pendingTask); + return this.pendingTask.getPromise(); } else { return Promise.reject("Unsupported client"); } @@ -973,6 +972,31 @@ class DefaultClient implements Client { }); } + private callTaskWithTimeout(task: () => Thenable, ms: number, cancelToken?: CancellationTokenSource): Thenable { + let timer: NodeJS.Timer; + // Create a promise that rejects in milliseconds + let timeout: () => Promise = () => new Promise((resolve, reject) => { + timer = setTimeout(() => { + clearTimeout(timer); + if (cancelToken) { + cancelToken.cancel(); + } + reject("Timed out in " + ms + "ms."); + }, ms); + }); + + // Returns a race between our timeout and the passed in promise + return Promise.race([task(), timeout()]).then( + (result: any) => { + clearTimeout(timer); + return result; + }, + (error: any) => { + clearTimeout(timer); + throw error; + }); + } + public requestWhenReady(request: () => Thenable): Thenable { return this.queueTask(request); } diff --git a/Extension/src/LanguageServer/colorization.ts b/Extension/src/LanguageServer/colorization.ts index 1d006b125c..fc1d5f7032 100644 --- a/Extension/src/LanguageServer/colorization.ts +++ b/Extension/src/LanguageServer/colorization.ts @@ -213,26 +213,26 @@ export class ColorizationSettings { this.calculateStyleForToken(TokenKind.GlobalVariable, "variable.other.global", themeName, textMateRules); this.calculateStyleForToken(TokenKind.LocalVariable, "variable.other.local", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Parameter, "variable.parameter", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Type, "entity.name.type", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.RefType, "entity.name.class.reference", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.ValueType, "entity.name.class.value", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Type, "entity.name.type.class", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.RefType, "entity.name.type.class.reference", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.ValueType, "entity.name.type.class.value", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Function, "entity.name.function", themeName, textMateRules); this.calculateStyleForToken(TokenKind.MemberFunction, "entity.name.function.member", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.MemberField, "variable.other.member", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.MemberField, "variable.other.property", themeName, textMateRules); this.calculateStyleForToken(TokenKind.StaticMemberFunction, "entity.name.function.member.static", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.StaticMemberField, "variable.other.member.static", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Property, "variable.other.property", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.StaticMemberField, "variable.other.property.static", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Property, "variable.other.property.cli", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Event, "variable.other.event", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.ClassTemplate, "entity.name.class.template", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.GenericType, "entity.name.class.generic", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.FunctionTemplate, "entity.name.function.template", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Namespace, "entity.name.type.namespace", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.ClassTemplate, "entity.name.type.class.templated", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.GenericType, "entity.name.type.class.generic", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.FunctionTemplate, "entity.name.function.templated", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Namespace, "entity.name.namespace", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Label, "entity.name.label", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlRaw, "entity.name.user-defined-literal", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlNumber, "entity.name.user-defined-literal.number", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlString, "entity.name.user-defined-literal.string", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlRaw, "entity.name.operator.custom-literal", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlNumber, "entity.name.operator.custom-literal.number", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlString, "entity.name.operator.custom-literal.string", themeName, textMateRules); this.calculateStyleForToken(TokenKind.OperatorFunction, "entity.name.function.operator", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.MemberOperator, "keyword.operator.member", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.MemberOperator, "entity.name.function.operator.member", themeName, textMateRules); this.calculateStyleForToken(TokenKind.NewDelete, "keyword.operator.new", themeName, textMateRules); } diff --git a/Extension/src/LanguageServer/protocolFilter.ts b/Extension/src/LanguageServer/protocolFilter.ts index 3b71ad69e5..01b63b6396 100644 --- a/Extension/src/LanguageServer/protocolFilter.ts +++ b/Extension/src/LanguageServer/protocolFilter.ts @@ -33,11 +33,8 @@ export function createProtocolFilter(me: Client, clients: ClientCollection): Mid } me.onDidOpenTextDocument(document); - me.provideCustomConfiguration(document).then(() => { - sendMessage(document); - }, () => { - sendMessage(document); - }); + me.provideCustomConfiguration(document); + me.notifyWhenReady(() => sendMessage(document)); } }, didChange: (textDocumentChangeEvent, sendMessage) => { diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 6b24452e98..dd3af4cba9 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -890,16 +890,14 @@ export class BlockingTask { this.dependency.promise.then(f1, f2); }); } + this.promise.then(() => this.done = true, () => this.done = true); } public get Done(): boolean { return this.done; } - public then(onSucceeded: (value: T) => T2, onRejected?: (err) => any): Thenable { - if (onRejected) { - return this.promise.then(onSucceeded, onRejected); - } - return this.promise.then(onSucceeded); + public getPromise(): Thenable { + return this.promise; } } From 36ce8f885fc104a418cefa7729625fa4fb8f1fdb Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson Date: Thu, 18 Jul 2019 18:37:18 -0700 Subject: [PATCH 11/19] Revert "cherry pick fixes for 0.24.1 (#3943)" This reverts commit 347794b0c72997fbf5788850674f95a892ff8413. --- Documentation/LanguageServer/colorization.md | 78 ++++----- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- Extension/src/LanguageServer/client.ts | 158 ++++++++---------- Extension/src/LanguageServer/colorization.ts | 28 ++-- .../src/LanguageServer/protocolFilter.ts | 7 +- Extension/src/common.ts | 8 +- 7 files changed, 132 insertions(+), 151 deletions(-) diff --git a/Documentation/LanguageServer/colorization.md b/Documentation/LanguageServer/colorization.md index 49ef83d96a..595d846a2f 100644 --- a/Documentation/LanguageServer/colorization.md +++ b/Documentation/LanguageServer/colorization.md @@ -19,32 +19,32 @@ Colors are associated with [TextMate scopes](https://macromates.com/manual/en/la | Token | Scope | | ------------- |:-------------:| -| Class Template | entity.name.type.class.templated | +| Class Template | entity.name.class.template | | Enumerator | variable.other.enummember | | Event (C++/CLI) | variable.other.event | | Function | entity.name.function | -| Function Template | entity.name.function.templated | -| Generic Type (C++/CLI) | entity.name.type.class.generic | +| Function Template | entity.name.function.template | +| Generic Type (C++/CLI) | entity.name.class.generic | | Global Variable | variable.other.global | | Label | entity.name.label | | Local Variable | variable.other.local | | Macro | entity.name.function.preprocessor | -| Member Field | variable.other.property | +| Member Field | variable.other.member | | Member Function | entity.name.function.member | -| Namespace | entity.name.namespace | +| Member Operator | keyword.operator.member | +| Namespace | entity.name.type.namespace | | New / Delete | keyword.operator.new | -| Operator Overload Function | entity.name.function.operator | -| Operator Overload Member | entity.name.function.operator.member | +| Operator Function | entity.name.function.operator | | Parameter | variable.parameter | -| Property (C++/CLI) | variable.other.property.cli | -| Reference Type (C++/CLI) | entity.name.type.class.reference | -| Static Member Field | variable.other.property.static | +| Property (C++/CLI) | variable.other.property | +| Reference Type (C++/CLI) | entity.name.class.reference | +| Static Member Field | variable.other.member.static | | Static Member Function | entity.name.function.member.static | -| Type | entity.name.type.class | -| User-Defined Literal - Number | entity.name.operator.custom-literal.number | -| User-Defined Literal - Raw | entity.name.operator.custom-literal | -| User-Defined Literal - String | entity.name.operator.custom-literal.string | -| Value Type (C++/CLI) | entity.name.type.class.value | +| Type | entity.name.type | +| User-Defined Literal - Number | entity.name.user-defined-literal.number | +| User-Defined Literal - Raw | entity.name.user-defined-literal | +| User-Defined Literal - String | entity.name.user-defined-literal.string | +| Value Type (C++/CLI) | entity.name.class.value | Many of the tokens recognized by IntelliSense do not directly map to existing scopes in the VS Code's default C/C++ TextMate grammar, so are likely not colored by existing VS Code themes. @@ -55,7 +55,7 @@ Colors can also be overridden globally, in settings: "editor.tokenColorCustomizations": { "textMateRules": [ { - "scope": "entity.name.type.class", + "scope": "entity.name.type", "settings": { "foreground": "#FF0000", "fontStyle": "italic bold underline" @@ -70,7 +70,7 @@ Or, overridden on a per-theme basis: "[Visual Studio Dark]": { "textMateRules": [ { - "scope": "entity.name.type.class", + "scope": "entity.name.type", "settings": { "foreground": "#FF0000", "fontStyle": "italic bold underline" @@ -171,19 +171,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.type.class", + "scope": "entity.name.type", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.type.class.reference", + "scope": "entity.name.class.reference", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.type.class.value", + "scope": "entity.name.class.value", "settings": { "foreground": "#4EC9B0" } @@ -201,7 +201,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "variable.other.property", + "scope": "variable.other.member", "settings": { "foreground": "#DADADA" } @@ -213,7 +213,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "variable.other.property.static", + "scope": "variable.other.member.static", "settings": { "foreground": "#C8C8C8" } @@ -225,19 +225,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.type.class.templated", + "scope": "entity.name.class.template", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.type.class.generic", + "scope": "entity.name.class.generic", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.function.templated", + "scope": "entity.name.function.template", "settings": { "foreground": "#C8C8C8" } @@ -255,19 +255,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.operator.custom-literal", + "scope": "entity.name.user-defined-literal", "settings": { "foreground": "#DADADA" } }, { - "scope": "entity.name.operator.custom-literal.string", + "scope": "entity.name.user-defined-literal.string", "settings": { "foreground": "#D69D85" } }, { - "scope": "entity.name.operator.custom-literal.number", + "scope": "entity.name.user-defined-literal.number", "settings": { "foreground": "#B5CEA8" } @@ -386,19 +386,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.type.class", + "scope": "entity.name.type", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.type.class.reference", + "scope": "entity.name.class.reference", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.type.class.value", + "scope": "entity.name.class.value", "settings": { "foreground": "#2B91AF" } @@ -416,7 +416,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "variable.other.property", + "scope": "variable.other.member", "settings": { "foreground": "#000000" } @@ -428,7 +428,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "variable.other.property.static", + "scope": "variable.other.member.static", "settings": { "foreground": "#000000" } @@ -440,19 +440,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.type.class.templated", + "scope": "entity.name.class.template", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.type.class.generic", + "scope": "entity.name.class.generic", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.function.templated", + "scope": "entity.name.function.template", "settings": { "foreground": "#000000" } @@ -470,19 +470,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.operator.custom-literal", + "scope": "entity.name.user-defined-literal", "settings": { "foreground": "#000000" } }, { - "scope": "entity.name.operator.custom-literal.string", + "scope": "entity.name.user-defined-literal.string", "settings": { "foreground": "#A31515" } }, { - "scope": "entity.name.operator.custom-literal.number", + "scope": "entity.name.user-defined-literal.number", "settings": { "foreground": "#000000" } diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 5509aef524..89b6925b30 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.24.1", + "version": "0.24.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index dbc019b268..6b747b4728 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.24.1", + "version": "0.24.0", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index fb838d3f3c..e7ee88eae7 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -786,76 +786,75 @@ class DefaultClient implements Client { } public async provideCustomConfiguration(document: vscode.TextDocument): Promise { - return this.queueBlockingTask(async () => { - let tokenSource: CancellationTokenSource = new CancellationTokenSource(); - let providers: CustomConfigurationProviderCollection = getCustomConfigProviders(); - if (providers.size === 0) { - return Promise.resolve(); - } - console.log("provideCustomConfiguration"); - let providerId: string|undefined = this.configuration.CurrentConfigurationProvider; - if (!providerId) { - return Promise.resolve(); - } + let tokenSource: CancellationTokenSource = new CancellationTokenSource(); + let providers: CustomConfigurationProviderCollection = getCustomConfigProviders(); + if (providers.size === 0) { + return Promise.resolve(); + } + console.log("provideCustomConfiguration"); + let providerId: string|undefined = await this.getCustomConfigurationProviderId(); + if (!providerId) { + return Promise.resolve(); + } - let providerName: string = providerId; - let params: QueryTranslationUnitSourceParams = { - uri: document.uri.toString() - }; - let response: QueryTranslationUnitSourceResult = await this.languageClient.sendRequest(QueryTranslationUnitSourceRequest, params); - if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.ConfigNotNeeded) { - return Promise.resolve(); - } + let providerName: string = providerId; + let params: QueryTranslationUnitSourceParams = { + uri: document.uri.toString() + }; + let response: QueryTranslationUnitSourceResult = await this.requestWhenReady(() => this.languageClient.sendRequest(QueryTranslationUnitSourceRequest, params)); + if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.ConfigNotNeeded) { + return Promise.resolve(); + } - let tuUri: vscode.Uri = vscode.Uri.parse(response.uri); - let configName: string = this.configuration.CurrentConfiguration.name; - const notReadyMessage: string = `${providerName} is not ready`; - let provideConfigurationAsync: () => Thenable = async () => { - // The config requests that we use a provider, try to get IntelliSense configuration info from that provider. - try { - let provider: CustomConfigurationProvider1|null = providers.get(providerId); - if (provider) { - if (!provider.isReady) { - return Promise.reject(notReadyMessage); - } + let tuUri: vscode.Uri = vscode.Uri.parse(response.uri); + let configName: string = await this.getCurrentConfigName(); + const notReadyMessage: string = `${providerName} is not ready`; + let provideConfigurationAsync: () => Thenable = async () => { + // The config requests that we use a provider, try to get IntelliSense configuration info from that provider. + try { + let provider: CustomConfigurationProvider1|null = providers.get(providerId); + if (provider) { + if (!provider.isReady) { + return Promise.reject(notReadyMessage); + } - providerName = provider.name; - if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) { - return provider.provideConfigurations([tuUri], tokenSource.token); - } + providerName = provider.name; + if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) { + return provider.provideConfigurations([tuUri], tokenSource.token); } - } catch (err) { } - console.warn("failed to provide configuration"); - return Promise.reject(""); - }; + } catch (err) { + } + console.warn("failed to provide configuration"); + return Promise.reject(""); + }; - return this.callTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( - (configs: SourceFileConfigurationItem[]) => { - if (configs && configs.length > 0) { - this.sendCustomConfigurations(configs, false); - if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.AncestorConfigNeeded) { - // replacing uri with original uri - let newConfig: SourceFileConfigurationItem = { uri: document.uri, configuration: configs[0].configuration }; - this.sendCustomConfigurations([newConfig], false); - } + return this.queueTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( + (configs: SourceFileConfigurationItem[]) => { + if (configs && configs.length > 0) { + this.sendCustomConfigurations(configs, true); + if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.AncestorConfigNeeded) { + // replacing uri with original uri + let newConfig: SourceFileConfigurationItem = { uri: document.uri, configuration: configs[0].configuration }; + this.sendCustomConfigurations([newConfig], true); } - }, - (err) => { - if (err === notReadyMessage) { - return; + } + }, + (err) => { + if (err === notReadyMessage) { + return; + } + let settings: CppSettings = new CppSettings(this.RootUri); + if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document.uri) && !vscode.debug.activeDebugSession) { + const dismiss: string = "Dismiss"; + const disable: string = "Disable Warnings"; + let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + + `Settings from the '${configName}' configuration will be used instead.`; + if (err) { + message += ` (${err})`; } - let settings: CppSettings = new CppSettings(this.RootUri); - if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document.uri) && !vscode.debug.activeDebugSession) { - const dismiss: string = "Dismiss"; - const disable: string = "Disable Warnings"; - let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + - `Settings from the '${configName}' configuration will be used instead.`; - if (err) { - message += ` (${err})`; - } - vscode.window.showInformationMessage(message, dismiss, disable).then(response => { + vscode.window.showInformationMessage(message, dismiss, disable).then(response => { switch (response) { case disable: { settings.toggleSetting("configurationWarnings", "Enabled", "Disabled"); @@ -863,15 +862,18 @@ class DefaultClient implements Client { } } }); - } - }); - }); + } + }); } private isExternalHeader(uri: vscode.Uri): boolean { return util.isHeader(uri) && !uri.toString().startsWith(this.RootUri.toString()); } + private getCustomConfigurationProviderId(): Thenable { + return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfigurationProvider)); + } + public getCurrentConfigName(): Thenable { return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfiguration.name)); } @@ -921,7 +923,7 @@ class DefaultClient implements Client { if (this.pendingTask && !this.pendingTask.Done) { // We don't want the queue to stall because of a rejected promise. - return this.pendingTask.getPromise().then(nextTask, nextTask); + return this.pendingTask.then(nextTask, nextTask); } else { this.pendingTask = undefined; return nextTask(); @@ -939,7 +941,6 @@ class DefaultClient implements Client { private queueBlockingTask(task: () => Thenable): Thenable { if (this.isSupported) { this.pendingTask = new util.BlockingTask(task, this.pendingTask); - return this.pendingTask.getPromise(); } else { return Promise.reject("Unsupported client"); } @@ -972,31 +973,6 @@ class DefaultClient implements Client { }); } - private callTaskWithTimeout(task: () => Thenable, ms: number, cancelToken?: CancellationTokenSource): Thenable { - let timer: NodeJS.Timer; - // Create a promise that rejects in milliseconds - let timeout: () => Promise = () => new Promise((resolve, reject) => { - timer = setTimeout(() => { - clearTimeout(timer); - if (cancelToken) { - cancelToken.cancel(); - } - reject("Timed out in " + ms + "ms."); - }, ms); - }); - - // Returns a race between our timeout and the passed in promise - return Promise.race([task(), timeout()]).then( - (result: any) => { - clearTimeout(timer); - return result; - }, - (error: any) => { - clearTimeout(timer); - throw error; - }); - } - public requestWhenReady(request: () => Thenable): Thenable { return this.queueTask(request); } diff --git a/Extension/src/LanguageServer/colorization.ts b/Extension/src/LanguageServer/colorization.ts index fc1d5f7032..1d006b125c 100644 --- a/Extension/src/LanguageServer/colorization.ts +++ b/Extension/src/LanguageServer/colorization.ts @@ -213,26 +213,26 @@ export class ColorizationSettings { this.calculateStyleForToken(TokenKind.GlobalVariable, "variable.other.global", themeName, textMateRules); this.calculateStyleForToken(TokenKind.LocalVariable, "variable.other.local", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Parameter, "variable.parameter", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Type, "entity.name.type.class", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.RefType, "entity.name.type.class.reference", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.ValueType, "entity.name.type.class.value", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Type, "entity.name.type", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.RefType, "entity.name.class.reference", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.ValueType, "entity.name.class.value", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Function, "entity.name.function", themeName, textMateRules); this.calculateStyleForToken(TokenKind.MemberFunction, "entity.name.function.member", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.MemberField, "variable.other.property", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.MemberField, "variable.other.member", themeName, textMateRules); this.calculateStyleForToken(TokenKind.StaticMemberFunction, "entity.name.function.member.static", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.StaticMemberField, "variable.other.property.static", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Property, "variable.other.property.cli", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.StaticMemberField, "variable.other.member.static", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Property, "variable.other.property", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Event, "variable.other.event", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.ClassTemplate, "entity.name.type.class.templated", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.GenericType, "entity.name.type.class.generic", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.FunctionTemplate, "entity.name.function.templated", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Namespace, "entity.name.namespace", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.ClassTemplate, "entity.name.class.template", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.GenericType, "entity.name.class.generic", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.FunctionTemplate, "entity.name.function.template", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Namespace, "entity.name.type.namespace", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Label, "entity.name.label", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlRaw, "entity.name.operator.custom-literal", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlNumber, "entity.name.operator.custom-literal.number", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlString, "entity.name.operator.custom-literal.string", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlRaw, "entity.name.user-defined-literal", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlNumber, "entity.name.user-defined-literal.number", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlString, "entity.name.user-defined-literal.string", themeName, textMateRules); this.calculateStyleForToken(TokenKind.OperatorFunction, "entity.name.function.operator", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.MemberOperator, "entity.name.function.operator.member", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.MemberOperator, "keyword.operator.member", themeName, textMateRules); this.calculateStyleForToken(TokenKind.NewDelete, "keyword.operator.new", themeName, textMateRules); } diff --git a/Extension/src/LanguageServer/protocolFilter.ts b/Extension/src/LanguageServer/protocolFilter.ts index 01b63b6396..3b71ad69e5 100644 --- a/Extension/src/LanguageServer/protocolFilter.ts +++ b/Extension/src/LanguageServer/protocolFilter.ts @@ -33,8 +33,11 @@ export function createProtocolFilter(me: Client, clients: ClientCollection): Mid } me.onDidOpenTextDocument(document); - me.provideCustomConfiguration(document); - me.notifyWhenReady(() => sendMessage(document)); + me.provideCustomConfiguration(document).then(() => { + sendMessage(document); + }, () => { + sendMessage(document); + }); } }, didChange: (textDocumentChangeEvent, sendMessage) => { diff --git a/Extension/src/common.ts b/Extension/src/common.ts index dd3af4cba9..6b24452e98 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -890,14 +890,16 @@ export class BlockingTask { this.dependency.promise.then(f1, f2); }); } - this.promise.then(() => this.done = true, () => this.done = true); } public get Done(): boolean { return this.done; } - public getPromise(): Thenable { - return this.promise; + public then(onSucceeded: (value: T) => T2, onRejected?: (err) => any): Thenable { + if (onRejected) { + return this.promise.then(onSucceeded, onRejected); + } + return this.promise.then(onSucceeded); } } From a369ede8d9c4ebc9c8306cb77a8ff0b104dc9102 Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Thu, 18 Jul 2019 18:34:48 -0700 Subject: [PATCH 12/19] Update changelog for 0.24.1 release (#3945) --- Extension/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index dacc0e3095..418ce7c8d9 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,5 +1,10 @@ # C/C++ for Visual Studio Code Change Log +## Version 0.24.1: July 22, 2019 +### Bug Fixes +* Fix an issue with the Outline not being populated when a file is opened. [#3877](https://github.com/microsoft/vscode-cpptools/issues/3877) +* Update scopes used by semantic colorization. [PR# 3896](https://github.com/microsoft/vscode-cpptools/pull/3896) + ## Version 0.24.0: July 3, 2019 ### New Features * Semantic colorization [Documentation](https://github.com/microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/colorization.md) [#230](https://github.com/microsoft/vscode-cpptools/issues/230) From 0c4c83e5bda143dc2e1efed956e67e35d4493bcd Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Thu, 18 Jul 2019 16:30:05 -0700 Subject: [PATCH 13/19] Improve scope names used by Enhanced Colorization (#3896) --- Documentation/LanguageServer/colorization.md | 78 ++++++++++---------- Extension/src/LanguageServer/colorization.ts | 28 +++---- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Documentation/LanguageServer/colorization.md b/Documentation/LanguageServer/colorization.md index 595d846a2f..49ef83d96a 100644 --- a/Documentation/LanguageServer/colorization.md +++ b/Documentation/LanguageServer/colorization.md @@ -19,32 +19,32 @@ Colors are associated with [TextMate scopes](https://macromates.com/manual/en/la | Token | Scope | | ------------- |:-------------:| -| Class Template | entity.name.class.template | +| Class Template | entity.name.type.class.templated | | Enumerator | variable.other.enummember | | Event (C++/CLI) | variable.other.event | | Function | entity.name.function | -| Function Template | entity.name.function.template | -| Generic Type (C++/CLI) | entity.name.class.generic | +| Function Template | entity.name.function.templated | +| Generic Type (C++/CLI) | entity.name.type.class.generic | | Global Variable | variable.other.global | | Label | entity.name.label | | Local Variable | variable.other.local | | Macro | entity.name.function.preprocessor | -| Member Field | variable.other.member | +| Member Field | variable.other.property | | Member Function | entity.name.function.member | -| Member Operator | keyword.operator.member | -| Namespace | entity.name.type.namespace | +| Namespace | entity.name.namespace | | New / Delete | keyword.operator.new | -| Operator Function | entity.name.function.operator | +| Operator Overload Function | entity.name.function.operator | +| Operator Overload Member | entity.name.function.operator.member | | Parameter | variable.parameter | -| Property (C++/CLI) | variable.other.property | -| Reference Type (C++/CLI) | entity.name.class.reference | -| Static Member Field | variable.other.member.static | +| Property (C++/CLI) | variable.other.property.cli | +| Reference Type (C++/CLI) | entity.name.type.class.reference | +| Static Member Field | variable.other.property.static | | Static Member Function | entity.name.function.member.static | -| Type | entity.name.type | -| User-Defined Literal - Number | entity.name.user-defined-literal.number | -| User-Defined Literal - Raw | entity.name.user-defined-literal | -| User-Defined Literal - String | entity.name.user-defined-literal.string | -| Value Type (C++/CLI) | entity.name.class.value | +| Type | entity.name.type.class | +| User-Defined Literal - Number | entity.name.operator.custom-literal.number | +| User-Defined Literal - Raw | entity.name.operator.custom-literal | +| User-Defined Literal - String | entity.name.operator.custom-literal.string | +| Value Type (C++/CLI) | entity.name.type.class.value | Many of the tokens recognized by IntelliSense do not directly map to existing scopes in the VS Code's default C/C++ TextMate grammar, so are likely not colored by existing VS Code themes. @@ -55,7 +55,7 @@ Colors can also be overridden globally, in settings: "editor.tokenColorCustomizations": { "textMateRules": [ { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#FF0000", "fontStyle": "italic bold underline" @@ -70,7 +70,7 @@ Or, overridden on a per-theme basis: "[Visual Studio Dark]": { "textMateRules": [ { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#FF0000", "fontStyle": "italic bold underline" @@ -171,19 +171,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.class.reference", + "scope": "entity.name.type.class.reference", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.class.value", + "scope": "entity.name.type.class.value", "settings": { "foreground": "#4EC9B0" } @@ -201,7 +201,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "variable.other.member", + "scope": "variable.other.property", "settings": { "foreground": "#DADADA" } @@ -213,7 +213,7 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "variable.other.member.static", + "scope": "variable.other.property.static", "settings": { "foreground": "#C8C8C8" } @@ -225,19 +225,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.class.template", + "scope": "entity.name.type.class.templated", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.class.generic", + "scope": "entity.name.type.class.generic", "settings": { "foreground": "#4EC9B0" } }, { - "scope": "entity.name.function.template", + "scope": "entity.name.function.templated", "settings": { "foreground": "#C8C8C8" } @@ -255,19 +255,19 @@ Use the following to augment the Visual Studio Dark theme to match what Visual S } }, { - "scope": "entity.name.user-defined-literal", + "scope": "entity.name.operator.custom-literal", "settings": { "foreground": "#DADADA" } }, { - "scope": "entity.name.user-defined-literal.string", + "scope": "entity.name.operator.custom-literal.string", "settings": { "foreground": "#D69D85" } }, { - "scope": "entity.name.user-defined-literal.number", + "scope": "entity.name.operator.custom-literal.number", "settings": { "foreground": "#B5CEA8" } @@ -386,19 +386,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.type", + "scope": "entity.name.type.class", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.class.reference", + "scope": "entity.name.type.class.reference", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.class.value", + "scope": "entity.name.type.class.value", "settings": { "foreground": "#2B91AF" } @@ -416,7 +416,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "variable.other.member", + "scope": "variable.other.property", "settings": { "foreground": "#000000" } @@ -428,7 +428,7 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "variable.other.member.static", + "scope": "variable.other.property.static", "settings": { "foreground": "#000000" } @@ -440,19 +440,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.class.template", + "scope": "entity.name.type.class.templated", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.class.generic", + "scope": "entity.name.type.class.generic", "settings": { "foreground": "#2B91AF" } }, { - "scope": "entity.name.function.template", + "scope": "entity.name.function.templated", "settings": { "foreground": "#000000" } @@ -470,19 +470,19 @@ Use the following to augment the Visual Studio Light theme to match what Visual } }, { - "scope": "entity.name.user-defined-literal", + "scope": "entity.name.operator.custom-literal", "settings": { "foreground": "#000000" } }, { - "scope": "entity.name.user-defined-literal.string", + "scope": "entity.name.operator.custom-literal.string", "settings": { "foreground": "#A31515" } }, { - "scope": "entity.name.user-defined-literal.number", + "scope": "entity.name.operator.custom-literal.number", "settings": { "foreground": "#000000" } diff --git a/Extension/src/LanguageServer/colorization.ts b/Extension/src/LanguageServer/colorization.ts index 1d006b125c..fc1d5f7032 100644 --- a/Extension/src/LanguageServer/colorization.ts +++ b/Extension/src/LanguageServer/colorization.ts @@ -213,26 +213,26 @@ export class ColorizationSettings { this.calculateStyleForToken(TokenKind.GlobalVariable, "variable.other.global", themeName, textMateRules); this.calculateStyleForToken(TokenKind.LocalVariable, "variable.other.local", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Parameter, "variable.parameter", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Type, "entity.name.type", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.RefType, "entity.name.class.reference", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.ValueType, "entity.name.class.value", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Type, "entity.name.type.class", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.RefType, "entity.name.type.class.reference", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.ValueType, "entity.name.type.class.value", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Function, "entity.name.function", themeName, textMateRules); this.calculateStyleForToken(TokenKind.MemberFunction, "entity.name.function.member", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.MemberField, "variable.other.member", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.MemberField, "variable.other.property", themeName, textMateRules); this.calculateStyleForToken(TokenKind.StaticMemberFunction, "entity.name.function.member.static", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.StaticMemberField, "variable.other.member.static", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Property, "variable.other.property", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.StaticMemberField, "variable.other.property.static", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Property, "variable.other.property.cli", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Event, "variable.other.event", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.ClassTemplate, "entity.name.class.template", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.GenericType, "entity.name.class.generic", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.FunctionTemplate, "entity.name.function.template", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.Namespace, "entity.name.type.namespace", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.ClassTemplate, "entity.name.type.class.templated", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.GenericType, "entity.name.type.class.generic", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.FunctionTemplate, "entity.name.function.templated", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.Namespace, "entity.name.namespace", themeName, textMateRules); this.calculateStyleForToken(TokenKind.Label, "entity.name.label", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlRaw, "entity.name.user-defined-literal", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlNumber, "entity.name.user-defined-literal.number", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.UdlString, "entity.name.user-defined-literal.string", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlRaw, "entity.name.operator.custom-literal", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlNumber, "entity.name.operator.custom-literal.number", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.UdlString, "entity.name.operator.custom-literal.string", themeName, textMateRules); this.calculateStyleForToken(TokenKind.OperatorFunction, "entity.name.function.operator", themeName, textMateRules); - this.calculateStyleForToken(TokenKind.MemberOperator, "keyword.operator.member", themeName, textMateRules); + this.calculateStyleForToken(TokenKind.MemberOperator, "entity.name.function.operator.member", themeName, textMateRules); this.calculateStyleForToken(TokenKind.NewDelete, "keyword.operator.new", themeName, textMateRules); } From 779f2ce2b5d883f0b18ebb9cf99529341643c19a Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Wed, 3 Jul 2019 21:05:02 -0700 Subject: [PATCH 14/19] Fix issue with didClose received after didOpen (#3844) --- Extension/src/LanguageServer/client.ts | 158 ++++++++++-------- .../src/LanguageServer/protocolFilter.ts | 7 +- Extension/src/common.ts | 8 +- 3 files changed, 96 insertions(+), 77 deletions(-) diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index e7ee88eae7..fb838d3f3c 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -786,75 +786,76 @@ class DefaultClient implements Client { } public async provideCustomConfiguration(document: vscode.TextDocument): Promise { - let tokenSource: CancellationTokenSource = new CancellationTokenSource(); - let providers: CustomConfigurationProviderCollection = getCustomConfigProviders(); - if (providers.size === 0) { - return Promise.resolve(); - } - console.log("provideCustomConfiguration"); - let providerId: string|undefined = await this.getCustomConfigurationProviderId(); - if (!providerId) { - return Promise.resolve(); - } + return this.queueBlockingTask(async () => { + let tokenSource: CancellationTokenSource = new CancellationTokenSource(); + let providers: CustomConfigurationProviderCollection = getCustomConfigProviders(); + if (providers.size === 0) { + return Promise.resolve(); + } + console.log("provideCustomConfiguration"); + let providerId: string|undefined = this.configuration.CurrentConfigurationProvider; + if (!providerId) { + return Promise.resolve(); + } - let providerName: string = providerId; - let params: QueryTranslationUnitSourceParams = { - uri: document.uri.toString() - }; - let response: QueryTranslationUnitSourceResult = await this.requestWhenReady(() => this.languageClient.sendRequest(QueryTranslationUnitSourceRequest, params)); - if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.ConfigNotNeeded) { - return Promise.resolve(); - } + let providerName: string = providerId; + let params: QueryTranslationUnitSourceParams = { + uri: document.uri.toString() + }; + let response: QueryTranslationUnitSourceResult = await this.languageClient.sendRequest(QueryTranslationUnitSourceRequest, params); + if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.ConfigNotNeeded) { + return Promise.resolve(); + } - let tuUri: vscode.Uri = vscode.Uri.parse(response.uri); - let configName: string = await this.getCurrentConfigName(); - const notReadyMessage: string = `${providerName} is not ready`; - let provideConfigurationAsync: () => Thenable = async () => { - // The config requests that we use a provider, try to get IntelliSense configuration info from that provider. - try { - let provider: CustomConfigurationProvider1|null = providers.get(providerId); - if (provider) { - if (!provider.isReady) { - return Promise.reject(notReadyMessage); - } + let tuUri: vscode.Uri = vscode.Uri.parse(response.uri); + let configName: string = this.configuration.CurrentConfiguration.name; + const notReadyMessage: string = `${providerName} is not ready`; + let provideConfigurationAsync: () => Thenable = async () => { + // The config requests that we use a provider, try to get IntelliSense configuration info from that provider. + try { + let provider: CustomConfigurationProvider1|null = providers.get(providerId); + if (provider) { + if (!provider.isReady) { + return Promise.reject(notReadyMessage); + } - providerName = provider.name; - if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) { - return provider.provideConfigurations([tuUri], tokenSource.token); + providerName = provider.name; + if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) { + return provider.provideConfigurations([tuUri], tokenSource.token); + } } + } catch (err) { } - } catch (err) { - } - console.warn("failed to provide configuration"); - return Promise.reject(""); - }; + console.warn("failed to provide configuration"); + return Promise.reject(""); + }; - return this.queueTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( - (configs: SourceFileConfigurationItem[]) => { - if (configs && configs.length > 0) { - this.sendCustomConfigurations(configs, true); - if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.AncestorConfigNeeded) { - // replacing uri with original uri - let newConfig: SourceFileConfigurationItem = { uri: document.uri, configuration: configs[0].configuration }; - this.sendCustomConfigurations([newConfig], true); + return this.callTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then( + (configs: SourceFileConfigurationItem[]) => { + if (configs && configs.length > 0) { + this.sendCustomConfigurations(configs, false); + if (response.configDisposition === QueryTranslationUnitSourceConfigDisposition.AncestorConfigNeeded) { + // replacing uri with original uri + let newConfig: SourceFileConfigurationItem = { uri: document.uri, configuration: configs[0].configuration }; + this.sendCustomConfigurations([newConfig], false); + } } - } - }, - (err) => { - if (err === notReadyMessage) { - return; - } - let settings: CppSettings = new CppSettings(this.RootUri); - if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document.uri) && !vscode.debug.activeDebugSession) { - const dismiss: string = "Dismiss"; - const disable: string = "Disable Warnings"; - let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + - `Settings from the '${configName}' configuration will be used instead.`; - if (err) { - message += ` (${err})`; + }, + (err) => { + if (err === notReadyMessage) { + return; } + let settings: CppSettings = new CppSettings(this.RootUri); + if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document.uri) && !vscode.debug.activeDebugSession) { + const dismiss: string = "Dismiss"; + const disable: string = "Disable Warnings"; + let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` + + `Settings from the '${configName}' configuration will be used instead.`; + if (err) { + message += ` (${err})`; + } - vscode.window.showInformationMessage(message, dismiss, disable).then(response => { + vscode.window.showInformationMessage(message, dismiss, disable).then(response => { switch (response) { case disable: { settings.toggleSetting("configurationWarnings", "Enabled", "Disabled"); @@ -862,18 +863,15 @@ class DefaultClient implements Client { } } }); - } - }); + } + }); + }); } private isExternalHeader(uri: vscode.Uri): boolean { return util.isHeader(uri) && !uri.toString().startsWith(this.RootUri.toString()); } - private getCustomConfigurationProviderId(): Thenable { - return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfigurationProvider)); - } - public getCurrentConfigName(): Thenable { return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfiguration.name)); } @@ -923,7 +921,7 @@ class DefaultClient implements Client { if (this.pendingTask && !this.pendingTask.Done) { // We don't want the queue to stall because of a rejected promise. - return this.pendingTask.then(nextTask, nextTask); + return this.pendingTask.getPromise().then(nextTask, nextTask); } else { this.pendingTask = undefined; return nextTask(); @@ -941,6 +939,7 @@ class DefaultClient implements Client { private queueBlockingTask(task: () => Thenable): Thenable { if (this.isSupported) { this.pendingTask = new util.BlockingTask(task, this.pendingTask); + return this.pendingTask.getPromise(); } else { return Promise.reject("Unsupported client"); } @@ -973,6 +972,31 @@ class DefaultClient implements Client { }); } + private callTaskWithTimeout(task: () => Thenable, ms: number, cancelToken?: CancellationTokenSource): Thenable { + let timer: NodeJS.Timer; + // Create a promise that rejects in milliseconds + let timeout: () => Promise = () => new Promise((resolve, reject) => { + timer = setTimeout(() => { + clearTimeout(timer); + if (cancelToken) { + cancelToken.cancel(); + } + reject("Timed out in " + ms + "ms."); + }, ms); + }); + + // Returns a race between our timeout and the passed in promise + return Promise.race([task(), timeout()]).then( + (result: any) => { + clearTimeout(timer); + return result; + }, + (error: any) => { + clearTimeout(timer); + throw error; + }); + } + public requestWhenReady(request: () => Thenable): Thenable { return this.queueTask(request); } diff --git a/Extension/src/LanguageServer/protocolFilter.ts b/Extension/src/LanguageServer/protocolFilter.ts index 3b71ad69e5..01b63b6396 100644 --- a/Extension/src/LanguageServer/protocolFilter.ts +++ b/Extension/src/LanguageServer/protocolFilter.ts @@ -33,11 +33,8 @@ export function createProtocolFilter(me: Client, clients: ClientCollection): Mid } me.onDidOpenTextDocument(document); - me.provideCustomConfiguration(document).then(() => { - sendMessage(document); - }, () => { - sendMessage(document); - }); + me.provideCustomConfiguration(document); + me.notifyWhenReady(() => sendMessage(document)); } }, didChange: (textDocumentChangeEvent, sendMessage) => { diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 6b24452e98..dd3af4cba9 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -890,16 +890,14 @@ export class BlockingTask { this.dependency.promise.then(f1, f2); }); } + this.promise.then(() => this.done = true, () => this.done = true); } public get Done(): boolean { return this.done; } - public then(onSucceeded: (value: T) => T2, onRejected?: (err) => any): Thenable { - if (onRejected) { - return this.promise.then(onSucceeded, onRejected); - } - return this.promise.then(onSucceeded); + public getPromise(): Thenable { + return this.promise; } } From fa4d7b22c15422ec6cf01ca2cb7e31145819402c Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Fri, 19 Jul 2019 12:33:53 -0700 Subject: [PATCH 15/19] Update package.json version. (#3948) --- Extension/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/package.json b/Extension/package.json index 6b747b4728..dbc019b268 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.24.0", + "version": "0.24.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", From 940a7205016769ace0197890a807557959e141f2 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Thu, 12 Mar 2020 14:09:25 -0700 Subject: [PATCH 16/19] Update version. --- Extension/package.json | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Extension/package.json b/Extension/package.json index 88263c6499..d9cf658fad 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.27.0-master", + "version": "0.27.0", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", @@ -39,7 +39,28 @@ "Snippets" ], "activationEvents": [ - "*" + "onLanguage:cpp", + "onLanguage:c", + "onCommand:extension.pickNativeProcess", + "onCommand:extension.pickRemoteNativeProcess", + "onCommand:C_Cpp.BuildAndDebugActiveFile", + "onCommand:C_Cpp.ConfigurationEditJSON", + "onCommand:C_Cpp.ConfigurationEditUI", + "onCommand:C_Cpp.ConfigurationSelect", + "onCommand:C_Cpp.ConfigurationProviderSelect", + "onCommand:C_Cpp.SwitchHeaderSource", + "onCommand:C_Cpp.EnableErrorSquiggles", + "onCommand:C_Cpp.DisableErrorSquiggles", + "onCommand:C_Cpp.ToggleIncludeFallback", + "onCommand:C_Cpp.ToggleDimInactiveRegions", + "onCommand:C_Cpp.ResetDatabase", + "onCommand:C_Cpp.TakeSurvey", + "onCommand:C_Cpp.LogDiagnostics", + "onCommand:C_Cpp.RescanWorkspace", + "onCommand:C_Cpp.VcpkgClipboardInstallSuggested", + "onCommand:C_Cpp.VcpkgClipboardOnlineHelpSuggested", + "onDebug", + "workspaceContains:/.vscode/c_cpp_properties.json" ], "main": "./dist/main", "contributes": { From 5878686eac522f13d61dfe4317ccbc9c083a4e81 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Mon, 23 Mar 2020 14:39:20 -0700 Subject: [PATCH 17/19] Add cleanUnusedBinaries stage (#5170) Our offline installer will include two versions of lldb. ./debugAdapters/lldb is lldb-mi 3.8 and is used for High-Sierra and older ./debugAdapters/lldb-mi is lldb-mi 10.x and is used for Mojave and higher. Co-authored-by: Andrew Wang --- Extension/src/main.ts | 34 +++++++++++++++-- Extension/src/packageManager.ts | 66 ++++++++++++++++----------------- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/Extension/src/main.ts b/Extension/src/main.ts index e3b0da4be4..e90d9ad434 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -16,7 +16,7 @@ import * as nls from 'vscode-nls'; import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools'; import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands'; import { PlatformInformation } from './platform'; -import { PackageManager, PackageManagerError, IPackage } from './packageManager'; +import { PackageManager, PackageManagerError, IPackage, VersionsMatch, ArchitecturesMatch, PlatformsMatch } from './packageManager'; import { getInstallationInformation, InstallationInformation, setInstallationStage, setInstallationType, InstallationType } from './installationInformation'; import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; @@ -103,6 +103,9 @@ async function offlineInstallation(): Promise { setInstallationType(InstallationType.Offline); const info: PlatformInformation = await PlatformInformation.GetPlatformInformation(); + setInstallationStage('cleanUpUnusedBinaries'); + await cleanUpUnusedBinaries(info); + setInstallationStage('makeBinariesExecutable'); await makeBinariesExecutable(); @@ -168,19 +171,44 @@ function makeBinariesExecutable(): Promise { return util.allowExecution(util.getDebugAdaptersPath("OpenDebugAD7")); } +function packageMatchesPlatform(pkg: IPackage, info: PlatformInformation): boolean { + return PlatformsMatch(pkg, info) && + (pkg.architectures === undefined || ArchitecturesMatch(pkg, info)) && + VersionsMatch(pkg, info); +} + function makeOfflineBinariesExecutable(info: PlatformInformation): Promise { let promises: Thenable[] = []; let packages: IPackage[] = util.packageJson["runtimeDependencies"]; packages.forEach(p => { if (p.binaries && p.binaries.length > 0 && - p.platforms.findIndex(plat => plat === info.platform) !== -1 && - (p.architectures === undefined || p.architectures.findIndex(arch => arch === info.architecture) !== - 1)) { + packageMatchesPlatform(p, info)) { p.binaries.forEach(binary => promises.push(util.allowExecution(util.getExtensionFilePath(binary)))); } }); return Promise.all(promises).then(() => { }); } +function cleanUpUnusedBinaries(info: PlatformInformation): Promise { + let promises: Thenable[] = []; + let packages: IPackage[] = util.packageJson["runtimeDependencies"]; + const logger: Logger = getOutputChannelLogger(); + + packages.forEach(p => { + if (p.binaries && p.binaries.length > 0 && + !packageMatchesPlatform(p, info)) { + p.binaries.forEach(binary => { + const path: string = util.getExtensionFilePath(binary); + if (fs.existsSync(path)) { + logger.appendLine(`deleting: ${path}`); + promises.push(util.deleteFile(path)); + } + }); + } + }); + return Promise.all(promises).then(() => { }); +} + function removeUnnecessaryFile(): Promise { if (os.platform() !== 'win32') { let sourcePath: string = util.getDebugAdaptersPath("bin/OpenDebugAD7.exe.config"); diff --git a/Extension/src/packageManager.ts b/Extension/src/packageManager.ts index 9937d3b8a4..8229b26cf5 100644 --- a/Extension/src/packageManager.ts +++ b/Extension/src/packageManager.ts @@ -153,43 +153,13 @@ export class PackageManager { return this.GetPackageList() .then((list) => list.filter((value, index, array) => - this.ArchitecturesMatch(value) && - this.PlatformsMatch(value) && - this.VersionsMatch(value) + ArchitecturesMatch(value, this.platformInfo) && + PlatformsMatch(value, this.platformInfo) && + VersionsMatch(value, this.platformInfo) ) ); } - private ArchitecturesMatch(value: IPackage): boolean { - return !value.architectures || (this.platformInfo.architecture !== undefined && value.architectures.indexOf(this.platformInfo.architecture) !== -1); - } - - private PlatformsMatch(value: IPackage): boolean { - return !value.platforms || value.platforms.indexOf(this.platformInfo.platform) !== -1; - } - - private VersionsMatch(value: IPackage): boolean { - if (value.versionRegex) { - // If we have a versionRegex but did not get a platformVersion - if (!this.platformInfo.version) { - // If we are expecting to match the versionRegex, return false since there was no version found. - // - // If we are expecting to not match the versionRegex, return true since we are expecting to - // not match the version string, the only match would be if versionRegex was not set. - return !value.matchVersion; - } - const regex: RegExp = new RegExp(value.versionRegex); - - return (value.matchVersion ? - regex.test(this.platformInfo.version) : - !regex.test(this.platformInfo.version) - ); - } - - // No versionRegex provided. - return true; - } - private async DownloadPackage(pkg: IPackage, progressCount: string, progress: vscode.Progress<{message?: string; increment?: number}>): Promise { this.AppendChannel(localize("downloading.package", "Downloading package '{0}' ", pkg.description)); @@ -467,3 +437,33 @@ export class PackageManager { } } } + +export function VersionsMatch(pkg: IPackage, info: PlatformInformation): boolean { + if (pkg.versionRegex) { + // If we have a versionRegex but did not get a platformVersion + if (!info.version) { + // If we are expecting to match the versionRegex, return false since there was no version found. + // + // If we are expecting to not match the versionRegex, return true since we are expecting to + // not match the version string, the only match would be if versionRegex was not set. + return !pkg.matchVersion; + } + const regex: RegExp = new RegExp(pkg.versionRegex); + + return (pkg.matchVersion ? + regex.test(info.version) : + !regex.test(info.version) + ); + } + + // No versionRegex provided. + return true; +} + +export function ArchitecturesMatch(value: IPackage, info: PlatformInformation): boolean { + return !value.architectures || (info.architecture !== undefined && value.architectures.indexOf(info.architecture) !== -1); +} + +export function PlatformsMatch(value: IPackage, info: PlatformInformation): boolean { + return !value.platforms || value.platforms.indexOf(info.platform) !== -1; +} From 882b62c25b70db851dfa8b2f7d8cf123278782e8 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Mon, 23 Mar 2020 14:40:37 -0700 Subject: [PATCH 18/19] Fix package.json activation events. (#5173) --- Extension/package.json | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/Extension/package.json b/Extension/package.json index d4b62a769d..d8722da616 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -39,28 +39,7 @@ "Snippets" ], "activationEvents": [ - "onLanguage:cpp", - "onLanguage:c", - "onCommand:extension.pickNativeProcess", - "onCommand:extension.pickRemoteNativeProcess", - "onCommand:C_Cpp.BuildAndDebugActiveFile", - "onCommand:C_Cpp.ConfigurationEditJSON", - "onCommand:C_Cpp.ConfigurationEditUI", - "onCommand:C_Cpp.ConfigurationSelect", - "onCommand:C_Cpp.ConfigurationProviderSelect", - "onCommand:C_Cpp.SwitchHeaderSource", - "onCommand:C_Cpp.EnableErrorSquiggles", - "onCommand:C_Cpp.DisableErrorSquiggles", - "onCommand:C_Cpp.ToggleIncludeFallback", - "onCommand:C_Cpp.ToggleDimInactiveRegions", - "onCommand:C_Cpp.ResetDatabase", - "onCommand:C_Cpp.TakeSurvey", - "onCommand:C_Cpp.LogDiagnostics", - "onCommand:C_Cpp.RescanWorkspace", - "onCommand:C_Cpp.VcpkgClipboardInstallSuggested", - "onCommand:C_Cpp.VcpkgClipboardOnlineHelpSuggested", - "onDebug", - "workspaceContains:/.vscode/c_cpp_properties.json" + "*" ], "main": "./dist/main", "contributes": { From 6c4080832b47223f4d94035dba19c4f27ea6561c Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Mon, 23 Mar 2020 14:48:36 -0700 Subject: [PATCH 19/19] Seanmcm/0 27 0 insider4 changelog2 (#5172) * Update changelog. --- Extension/CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index d574e724ea..808f93693b 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -9,12 +9,17 @@ * Fix the "Open Fileā€¦" scenario without a workspace folder (again). [#5136](https://github.com/microsoft/vscode-cpptools/issues/5136) * Fix changes to `files.exclude` having no effect if they're identical to the previous workspace folder's. [#5138](https://github.com/microsoft/vscode-cpptools/issues/5138) * Fix the debugger not working for macOS High Sierra or older. [#5146](https://github.com/microsoft/vscode-cpptools/issues/5146) -* Fix the configuration UI showing errors when an older version of `cl.exe` is set in the `compilerPath`. [#5151](https://github.com/microsoft/vscode-cpptools/issues/5151) * Fix `search.exclude` not applying if there are > 1 symbols matching in the excluded file. [#5152](https://github.com/microsoft/vscode-cpptools/issues/5152) +* Fix tag parsing (workspace symbol searching) not working on Windows 7. [#5155](https://github.com/microsoft/vscode-cpptools/issues/5155) * Fix a race condition that could cause the Outline, `Find All References`, etc. to stop working. * Fix `Rescan Workspace` running an extra time per workspace folder. * Fix a random crash after settings change. +### Known Issues +* The configuration UI and json shows errors when an older version of `cl.exe` is set in the `compilerPath`. [#5151](https://github.com/microsoft/vscode-cpptools/issues/5151) +* The debugger doesn't work until the extension is reinstalled after macOS High Sierra or older is upgraded to a newer OS. [#5171](https://github.com/microsoft/vscode-cpptools/issues/5171) +* The Outline view may sometimes be incorrect for files outside the workspace. [#3949](https://github.com/microsoft/vscode-cpptools/issues/3949) + ## Version 0.27.0-insiders3: March 16, 2019 ### Bug Fixes * Fix update to clang-format 9.0.1 (and without shared library dependencies). [#2887](https://github.com/microsoft/vscode-cpptools/issues/2887), [#3174](https://github.com/microsoft/vscode-cpptools/issues/3174)