Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56c1a63

Browse files
authored
Fix exception when IntelliSenseEngine is Diabled (microsoft#9178)
1 parent23038f4 commit56c1a63

File tree

4 files changed

+155
-150
lines changed

4 files changed

+155
-150
lines changed

‎Extension/src/Debugger/configurationProvider.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ import * as debugUtils from './utils';
77
import*asosfrom'os';
88
import*aspathfrom'path';
99
import*asvscodefrom'vscode';
10-
import{CppBuildTask,CppBuildTaskDefinition}from'../LanguageServer/cppBuildTaskProvider';
10+
import{CppBuildTask,CppBuildTaskDefinition,cppBuildTaskProvider}from'../LanguageServer/cppBuildTaskProvider';
1111
import*asutilfrom'../common';
1212
import*asfsfrom'fs';
1313
import*asTelemetryfrom'../telemetry';
14-
import{cppBuildTaskProvider,configPrefix}from'../LanguageServer/extension';
1514
import*asloggerfrom'../logger';
1615
import*asnlsfrom'vscode-nls';
1716
import{IConfiguration,IConfigurationSnippet,DebuggerType,DebuggerEvent,MIConfigurations,WindowsConfigurations,WSLConfigurations,PipeTransportConfigurations}from'./configurations';
1817
import{parse}from'comment-json';
1918
import{PlatformInformation}from'../platform';
2019
import{Environment,ParsedEnvironmentFile}from'./ParsedEnvironmentFile';
20+
import{configPrefix}from'../LanguageServer/extension';
2121

2222
nls.config({messageFormat:nls.MessageFormat.bundle,bundleFormat:nls.BundleFormat.standalone})();
2323
constlocalize:nls.LocalizeFunc=nls.loadMessageBundle();

‎Extension/src/LanguageServer/cppBuildTaskProvider.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ export class CppBuildTaskProvider implements TaskProvider {
9494
try{
9595
activeClient=ext.getActiveClient();
9696
}catch(errJS){
97-
conste:Error=errJSasError;
98-
if(!e||e.message!==ext.intelliSenseDisabledError){
99-
console.error("Unknown error calling getActiveClient().");
100-
}
10197
returnemptyTasks;// Language service features may be disabled.
10298
}
10399

@@ -346,6 +342,8 @@ export class CppBuildTaskProvider implements TaskProvider {
346342

347343
}
348344

345+
exportconstcppBuildTaskProvider:CppBuildTaskProvider=newCppBuildTaskProvider();
346+
349347
classCustomBuildTaskTerminalimplementsPseudoterminal{
350348
privatewriteEmitter=newEventEmitter<string>();
351349
privatecloseEmitter=newEventEmitter<number>();

‎Extension/src/LanguageServer/extension.ts‎

Lines changed: 9 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ import { Readable } from 'stream';
2525
import*asnlsfrom'vscode-nls';
2626
import{CppBuildTaskProvider}from'./cppBuildTaskProvider';
2727
import{UpdateInsidersAccess}from'../main';
28-
import{PlatformInformation}from'../platform';
29-
import*assemverfrom'semver';
3028

3129
nls.config({messageFormat:nls.MessageFormat.bundle,bundleFormat:nls.BundleFormat.standalone})();
3230
constlocalize:nls.LocalizeFunc=nls.loadMessageBundle();
33-
exportconstcppBuildTaskProvider:CppBuildTaskProvider=newCppBuildTaskProvider();
3431
exportconstCppSourceStr:string="C/C++";
3532
exportconstconfigPrefix:string="C/C++: ";
3633

@@ -41,7 +38,6 @@ let ui: UI;
4138
constdisposables:vscode.Disposable[]=[];
4239
letlanguageConfigurations:vscode.Disposable[]=[];
4340
letintervalTimer:NodeJS.Timer;
44-
lettaskProvider:vscode.Disposable;
4541
letcodeActionProvider:vscode.Disposable;
4642
exportconstintelliSenseDisabledError:string="Do not activate the extension when IntelliSense is disabled.";
4743

@@ -157,129 +153,20 @@ function sendActivationTelemetry(): void {
157153
telemetry.logLanguageServerEvent("Activate",activateEvent);
158154
}
159155

160-
asyncfunctioncheckVsixCompatibility():Promise<void>{
161-
constignoreMismatchedCompatibleVsix:PersistentState<boolean>=newPersistentState<boolean>("CPP."+util.packageJson.version+".ignoreMismatchedCompatibleVsix",false);
162-
letresetIgnoreMismatchedCompatibleVsix:boolean=true;
163-
164-
// Check to ensure the correct platform-specific VSIX was installed.
165-
constvsixManifestPath:string=path.join(util.extensionPath,".vsixmanifest");
166-
// Skip the check if the file does not exist, such as when debugging cpptools.
167-
if(awaitutil.checkFileExists(vsixManifestPath)){
168-
constcontent:string=awaitutil.readFileText(vsixManifestPath);
169-
constmatches:RegExpMatchArray|null=content.match(/TargetPlatform="(?<platform>[^"]*)"/);
170-
if(matches&&matches.length>0&&matches.groups){
171-
constvsixTargetPlatform:string=matches.groups['platform'];
172-
constplatformInfo:PlatformInformation=awaitPlatformInformation.GetPlatformInformation();
173-
letisPlatformCompatible:boolean=true;
174-
letisPlatformMatching:boolean=true;
175-
switch(vsixTargetPlatform){
176-
case"win32-x64":
177-
isPlatformMatching=platformInfo.platform==="win32"&&platformInfo.architecture==="x64";
178-
// x64 binaries can also be run on arm64 Windows 11.
179-
isPlatformCompatible=platformInfo.platform==="win32"&&(platformInfo.architecture==="x64"||(platformInfo.architecture==="arm64"&&semver.gte(os.release(),"10.0.22000")));
180-
break;
181-
case"win32-ia32":
182-
isPlatformMatching=platformInfo.platform==="win32"&&platformInfo.architecture==="x86";
183-
// x86 binaries can also be run on x64 and arm64 Windows.
184-
isPlatformCompatible=platformInfo.platform==="win32"&&(platformInfo.architecture==="x86"||platformInfo.architecture==="x64"||platformInfo.architecture==="arm64");
185-
break;
186-
case"win32-arm64":
187-
isPlatformMatching=platformInfo.platform==="win32"&&platformInfo.architecture==="arm64";
188-
isPlatformCompatible=isPlatformMatching;
189-
break;
190-
case"linux-x64":
191-
isPlatformMatching=platformInfo.platform==="linux"&&platformInfo.architecture==="x64"&&platformInfo.distribution?.name!=="alpine";
192-
isPlatformCompatible=isPlatformMatching;
193-
break;
194-
case"linux-arm64":
195-
isPlatformMatching=platformInfo.platform==="linux"&&platformInfo.architecture==="arm64"&&platformInfo.distribution?.name!=="alpine";
196-
isPlatformCompatible=isPlatformMatching;
197-
break;
198-
case"linux-armhf":
199-
isPlatformMatching=platformInfo.platform==="linux"&&platformInfo.architecture==="arm"&&platformInfo.distribution?.name!=="alpine";
200-
// armhf binaries can also be run on aarch64 linux.
201-
isPlatformCompatible=platformInfo.platform==="linux"&&(platformInfo.architecture==="arm"||platformInfo.architecture==="arm64")&&platformInfo.distribution?.name!=="alpine";
202-
break;
203-
case"alpine-x64":
204-
isPlatformMatching=platformInfo.platform==="linux"&&platformInfo.architecture==="x64"&&platformInfo.distribution?.name==="alpine";
205-
isPlatformCompatible=isPlatformMatching;
206-
break;
207-
case"alpine-arm64":
208-
isPlatformMatching=platformInfo.platform==="linux"&&platformInfo.architecture==="arm64"&&platformInfo.distribution?.name==="alpine";
209-
isPlatformCompatible=isPlatformMatching;
210-
break;
211-
case"darwin-x64":
212-
isPlatformMatching=platformInfo.platform==="darwin"&&platformInfo.architecture==="x64";
213-
isPlatformCompatible=isPlatformMatching;
214-
break;
215-
case"darwin-arm64":
216-
isPlatformMatching=platformInfo.platform==="darwin"&&platformInfo.architecture==="arm64";
217-
// x64 binaries can also be run on arm64 macOS.
218-
isPlatformCompatible=platformInfo.platform==="darwin"&&(platformInfo.architecture==="x64"||platformInfo.architecture==="arm64");
219-
break;
220-
default:
221-
console.log("Unrecognized TargetPlatform in .vsixmanifest");
222-
break;
223-
}
224-
constmoreInfoButton:string=localize("more.info.button","More Info");
225-
constignoreButton:string=localize("ignore.button","Ignore");
226-
letpromise:Thenable<string|undefined>|undefined;
227-
if(!isPlatformCompatible){
228-
promise=vscode.window.showErrorMessage(localize("vsix.platform.incompatible","The C/C++ extension installed does not match your system.",vsixTargetPlatform),moreInfoButton);
229-
}elseif(!isPlatformMatching){
230-
if(!ignoreMismatchedCompatibleVsix.Value){
231-
resetIgnoreMismatchedCompatibleVsix=false;
232-
promise=vscode.window.showWarningMessage(localize("vsix.platform.mismatching","The C/C++ extension installed is compatible with but does not match your system.",vsixTargetPlatform),moreInfoButton,ignoreButton);
233-
}
234-
}
235-
if(promise){
236-
promise.then(async(value)=>{
237-
if(value===moreInfoButton){
238-
awaitvscode.commands.executeCommand("markdown.showPreview",vscode.Uri.file(util.getLocalizedHtmlPath("Reinstalling the Extension.md")));
239-
}elseif(value===ignoreButton){
240-
ignoreMismatchedCompatibleVsix.Value=true;
241-
}
242-
});
243-
}
244-
}else{
245-
console.log("Unable to find TargetPlatform in .vsixmanifest");
246-
}
247-
}
248-
if(resetIgnoreMismatchedCompatibleVsix){
249-
ignoreMismatchedCompatibleVsix.Value=false;
250-
}
251-
}
252-
253156
/**
254157
* activate: set up the extension for language services
255158
*/
256159
exportasyncfunctionactivate():Promise<void>{
257160

258-
awaitcheckVsixCompatibility();
259-
260-
if(vscode.workspace.workspaceFolders&&vscode.workspace.workspaceFolders.length>0){
261-
for(leti:number=0;i<vscode.workspace.workspaceFolders.length;++i){
262-
constconfig:string=path.join(vscode.workspace.workspaceFolders[i].uri.fsPath,".vscode/c_cpp_properties.json");
263-
if(awaitutil.checkFileExists(config)){
264-
constdoc:vscode.TextDocument=awaitvscode.workspace.openTextDocument(config);
265-
vscode.languages.setTextDocumentLanguage(doc,"jsonc");
266-
}
267-
}
268-
}
269-
270-
if(newCppSettings((vscode.workspace.workspaceFolders&&vscode.workspace.workspaceFolders.length>0) ?vscode.workspace.workspaceFolders[0]?.uri :undefined).intelliSenseEngine==="Disabled"){
271-
thrownewError(intelliSenseDisabledError);
272-
}else{
273-
console.log("activating extension");
274-
sendActivationTelemetry();
275-
constcheckForConflictingExtensions:PersistentState<boolean>=newPersistentState<boolean>("CPP."+util.packageJson.version+".checkForConflictingExtensions",true);
276-
if(checkForConflictingExtensions.Value){
277-
checkForConflictingExtensions.Value=false;
278-
constclangCommandAdapterActive:boolean=vscode.extensions.all.some((extension:vscode.Extension<any>,index:number,array:Readonly<vscode.Extension<any>[]>):boolean=>
279-
extension.isActive&&extension.id==="mitaki28.vscode-clang");
280-
if(clangCommandAdapterActive){
281-
telemetry.logLanguageServerEvent("conflictingExtension");
282-
}
161+
console.log("activating extension");
162+
sendActivationTelemetry();
163+
constcheckForConflictingExtensions:PersistentState<boolean>=newPersistentState<boolean>("CPP."+util.packageJson.version+".checkForConflictingExtensions",true);
164+
if(checkForConflictingExtensions.Value){
165+
checkForConflictingExtensions.Value=false;
166+
constclangCommandAdapterActive:boolean=vscode.extensions.all.some((extension:vscode.Extension<any>,index:number,array:Readonly<vscode.Extension<any>[]>):boolean=>
167+
extension.isActive&&extension.id==="mitaki28.vscode-clang");
168+
if(clangCommandAdapterActive){
169+
telemetry.logLanguageServerEvent("conflictingExtension");
283170
}
284171
}
285172

@@ -311,21 +198,14 @@ export async function activate(): Promise<void> {
311198

312199
registerCommands();
313200

314-
taskProvider=vscode.tasks.registerTaskProvider(CppBuildTaskProvider.CppBuildScriptType,cppBuildTaskProvider);
315-
316201
vscode.tasks.onDidStartTask(event=>{
317202
getActiveClient().PauseCodeAnalysis();
318-
if(event.execution.task.definition.type===CppBuildTaskProvider.CppBuildScriptType
319-
||event.execution.task.name.startsWith(configPrefix)){
320-
telemetry.logLanguageServerEvent('buildTaskStarted');
321-
}
322203
});
323204

324205
vscode.tasks.onDidEndTask(event=>{
325206
getActiveClient().ResumeCodeAnalysis();
326207
if(event.execution.task.definition.type===CppBuildTaskProvider.CppBuildScriptType
327208
||event.execution.task.name.startsWith(configPrefix)){
328-
telemetry.logLanguageServerEvent('buildTaskFinished');
329209
if(event.execution.task.scope!==vscode.TaskScope.Global&&event.execution.task.scope!==vscode.TaskScope.Workspace){
330210
constfolder:vscode.WorkspaceFolder|undefined=event.execution.task.scope;
331211
if(folder){
@@ -1032,9 +912,6 @@ export function deactivate(): Thenable<void> {
1032912
disposables.forEach(d=>d.dispose());
1033913
languageConfigurations.forEach(d=>d.dispose());
1034914
ui.dispose();
1035-
if(taskProvider){
1036-
taskProvider.dispose();
1037-
}
1038915
if(codeActionProvider){
1039916
codeActionProvider.dispose();
1040917
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp