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

Commit4d1a2a0

Browse files
authored
Change how logging level is passed to native process (#11438)
1 parentdec5059 commit4d1a2a0

File tree

2 files changed

+49
-19
lines changed

2 files changed

+49
-19
lines changed

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,6 @@ function logTelemetry(notificationBody: TelemetryPayload): void {
115115
telemetry.logLanguageServerEvent(notificationBody.event,notificationBody.properties,notificationBody.metrics);
116116
}
117117

118-
/**
119-
* listen for logging messages from the language server and print them to the Output window
120-
*/
121-
functionsetupOutputHandlers():void{
122-
console.assert(languageClient!==undefined,"This method must not be called until this.languageClient is set in \"onReady\"");
123-
124-
languageClient.onNotification(DebugProtocolNotification,logDebugProtocol);
125-
languageClient.onNotification(DebugLogNotification,logLocalized);
126-
}
127-
128118
/** Note: We should not await on the following functions,
129119
* or any function that returns a promise acquired from them,
130120
* vscode.window.showInformationMessage, vscode.window.showWarningMessage, vscode.window.showErrorMessage
@@ -537,7 +527,11 @@ export interface TextDocumentWillSaveParams {
537527
reason:vscode.TextDocumentSaveReason;
538528
}
539529

540-
interfaceInitializationOptions{
530+
interfaceLspInitializationOptions{
531+
loggingLevel:number;
532+
}
533+
534+
interfaceCppInitializationParams{
541535
packageVersion:string;
542536
extensionPath:string;
543537
cacheStoragePath:string;
@@ -559,6 +553,7 @@ interface TagParseStatus {
559553
}
560554

561555
// Requests
556+
constInitializationRequest:RequestType<CppInitializationParams,void,void>=newRequestType<CppInitializationParams,void,void>('cpptools/initialize');
562557
constQueryCompilerDefaultsRequest:RequestType<QueryDefaultCompilerParams,configs.CompilerDefaults,void>=newRequestType<QueryDefaultCompilerParams,configs.CompilerDefaults,void>('cpptools/queryCompilerDefaults');
563558
constQueryTranslationUnitSourceRequest:RequestType<QueryTranslationUnitSourceParams,QueryTranslationUnitSourceResult,void>=newRequestType<QueryTranslationUnitSourceParams,QueryTranslationUnitSourceResult,void>('cpptools/queryTranslationUnitSource');
564559
constSwitchHeaderSourceRequest:RequestType<SwitchHeaderSourceParams,string,void>=newRequestType<SwitchHeaderSourceParams,string,void>('cpptools/didSwitchHeaderSource');
@@ -597,7 +592,6 @@ const PreviewReferencesNotification: NotificationType<void> = new NotificationTy
597592
constRescanFolderNotification:NotificationType<void>=newNotificationType<void>('cpptools/rescanFolder');
598593
constFinishedRequestCustomConfig:NotificationType<FinishedRequestCustomConfigParams>=newNotificationType<FinishedRequestCustomConfigParams>('cpptools/finishedRequestCustomConfig');
599594
constDidChangeSettingsNotification:NotificationType<SettingsParams>=newNotificationType<SettingsParams>('cpptools/didChangeSettings');
600-
constInitializationNotification:NotificationType<InitializationOptions>=newNotificationType<InitializationOptions>('cpptools/initialize');
601595

602596
constCodeAnalysisNotification:NotificationType<CodeAnalysisParams>=newNotificationType<CodeAnalysisParams>('cpptools/runCodeAnalysis');
603597
constPauseCodeAnalysisNotification:NotificationType<void>=newNotificationType<void>('cpptools/pauseCodeAnalysis');
@@ -828,7 +822,7 @@ export class DefaultClient implements Client {
828822
privateisSupported:boolean=true;
829823
privateinactiveRegionsDecorations=newMap<string,DecorationRangesPair>();
830824
privatesettingsTracker:SettingsTracker;
831-
privateloggingLevel:string|undefined;
825+
privateloggingLevel:number=1;
832826
privateconfigurationProvider?:string;
833827

834828
publiclastCustomBrowseConfiguration:PersistentFolderState<WorkspaceBrowseConfiguration|undefined>|undefined;
@@ -1522,7 +1516,7 @@ export class DefaultClient implements Client {
15221516
constdatabaseStoragePath:string=(cacheStoragePath.length>0)&&(workspaceHash.length>0) ?
15231517
path.join(cacheStoragePath,workspaceHash) :"";
15241518

1525-
constinitializationOptions:InitializationOptions={
1519+
constcppInitializationParams:CppInitializationParams={
15261520
packageVersion:util.packageJson.version,
15271521
extensionPath:util.extensionPath,
15281522
databaseStoragePath:databaseStoragePath,
@@ -1538,12 +1532,18 @@ export class DefaultClient implements Client {
15381532
settings:this.getAllSettings()
15391533
};
15401534

1535+
this.loggingLevel=util.getNumericLoggingLevel(cppInitializationParams.settings.loggingLevel);
1536+
constlspInitializationOptions:LspInitializationOptions={
1537+
loggingLevel:this.loggingLevel
1538+
};
1539+
15411540
constclientOptions:LanguageClientOptions={
15421541
documentSelector:[
15431542
{scheme:'file',language:'c'},
15441543
{scheme:'file',language:'cpp'},
15451544
{scheme:'file',language:'cuda-cpp'}
15461545
],
1546+
initializationOptions:lspInitializationOptions,
15471547
middleware:createProtocolFilter(),
15481548
errorHandler:{
15491549
error:(_error,_message,_count)=>({action:ErrorAction.Continue}),
@@ -1576,13 +1576,16 @@ export class DefaultClient implements Client {
15761576
};
15771577

15781578
// Create the language client
1579-
this.loggingLevel=initializationOptions.settings.loggingLevel;
15801579
languageClient=newLanguageClient(`cpptools`,serverOptions,clientOptions);
1581-
setupOutputHandlers();
1580+
languageClient.onNotification(DebugProtocolNotification,logDebugProtocol);
1581+
languageClient.onNotification(DebugLogNotification,logLocalized);
15821582
languageClient.registerProposedFeatures();
15831583
awaitlanguageClient.start();
1584+
15841585
// Move initialization to a separate message, so we can see log output from it.
1585-
awaitlanguageClient.sendNotification(InitializationNotification,initializationOptions);
1586+
// A request is used in order to wait for completion and ensure that no subsequent
1587+
// higher priority message may be processed before the Initialization request.
1588+
awaitlanguageClient.sendRequest(InitializationRequest,cppInitializationParams);
15861589
}
15871590

15881591
publicasyncsendDidChangeSettings():Promise<void>{
@@ -1607,9 +1610,9 @@ export class DefaultClient implements Client {
16071610
updateLanguageConfigurations();
16081611
}
16091612
if(changedSettings.loggingLevel){
1610-
constoldLoggingLevelLogged:boolean=!!this.loggingLevel&&this.loggingLevel!=="None"&&this.loggingLevel!=="Error";
1613+
constoldLoggingLevelLogged:boolean=!!this.loggingLevel&&this.loggingLevel!==0&&this.loggingLevel!==1;
16111614
constnewLoggingLevel:string|undefined=changedSettings.loggingLevel;
1612-
this.loggingLevel=newLoggingLevel;
1615+
this.loggingLevel=util.getNumericLoggingLevel(newLoggingLevel);
16131616
constnewLoggingLevelLogged:boolean=!!newLoggingLevel&&newLoggingLevel!=="None"&&newLoggingLevel!=="Error";
16141617
if(oldLoggingLevelLogged||newLoggingLevelLogged){
16151618
constout:Logger=getOutputChannelLogger();

‎Extension/src/common.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,3 +1519,30 @@ export function hasMsvcEnvironment(): boolean {
15191519
];
15201520
returnmsvcEnvVars.every((envVarName)=>process.env[envVarName]!==undefined&&process.env[envVarName]!=='');
15211521
}
1522+
1523+
functionisIntegral(str:string):boolean{
1524+
constregex=/^-?\d+$/;
1525+
returnregex.test(str);
1526+
}
1527+
1528+
exportfunctiongetNumericLoggingLevel(loggingLevel:string|undefined):number{
1529+
if(!loggingLevel){
1530+
return1;
1531+
}
1532+
if(isIntegral(loggingLevel)){
1533+
returnparseInt(loggingLevel,10);
1534+
}
1535+
constlowerCaseLoggingLevel:string=loggingLevel.toLowerCase();
1536+
switch(lowerCaseLoggingLevel){
1537+
case"error":
1538+
return1;
1539+
case"warning":
1540+
return3;
1541+
case"information":
1542+
return5;
1543+
case"debug":
1544+
return6;
1545+
default:
1546+
return0;
1547+
}
1548+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp