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

Commit862a10f

Browse files
committed
2 parents2e62382 +5f9ef54 commit862a10f

File tree

6 files changed

+46
-26
lines changed

6 files changed

+46
-26
lines changed

‎Extension/cpptools.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"intelliSenseEngine_default_percentage":100,
33
"defaultIntelliSenseEngine":100,
4-
"recursiveIncludes":100
4+
"recursiveIncludes":100,
5+
"gotoDefIntelliSense":100
56
}

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { CancellationTokenSource } from 'vscode';
2828
import{SettingsTracker,getTracker}from'./settingsTracker';
2929
import{getTestHook,TestHook}from'../testHook';
3030
import{getCustomConfigProviders,CustomConfigurationProviderCollection,CustomConfigurationProvider1}from'../LanguageServer/customProviders';
31+
import{ABTestSettings,getABTestSettings}from'../abTesting';
3132

3233
letui:UI;
3334
constconfigProviderTimeout:number=2000;
@@ -366,6 +367,7 @@ class DefaultClient implements Client {
366367
storagePath=path.join(storagePath,serverName);
367368
}
368369

370+
letabTestSettings:ABTestSettings=getABTestSettings();
369371
letclientOptions:LanguageClientOptions={
370372
documentSelector:[
371373
{scheme:'file',language:'cpp'},
@@ -400,7 +402,8 @@ class DefaultClient implements Client {
400402
default:{
401403
systemIncludePath:settings.defaultSystemIncludePath
402404
},
403-
vcpkg_root:util.getVcpkgRoot()
405+
vcpkg_root:util.getVcpkgRoot(),
406+
gotoDefIntelliSense:abTestSettings.UseGoToDefIntelliSense
404407
},
405408
middleware:createProtocolFilter(this,allClients),// Only send messages directed at this client.
406409
errorHandler:{

‎Extension/src/LanguageServer/persistentState.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ class PersistentStateBase<T> {
2020
}
2121

2222
publicgetValue():T{
23-
returnthis.state.get<T>(this.key,this.defaultvalue);
23+
returnthis.state.get<T>(this.key,this.defaultvalue);
2424
}
2525

2626
publicsetValue(newValue:T){
2727
this.state.update(this.key,newValue);
2828
}
29+
30+
publicgetDefaultValue():T{
31+
returnthis.defaultvalue;
32+
}
2933
}
3034

3135
// Abstraction for global state that persists across activations but is not present in a settings file

‎Extension/src/abTesting.ts‎

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import*asutilfrom'./common';
88
import*asTelemetryfrom'./telemetry';
99
import{PersistentState}from'./LanguageServer/persistentState';
10+
import*asfsfrom'fs';
1011

1112
constuserBucketMax:number=100;
1213
constuserBucketString:string="CPP.UserBucket";
@@ -15,61 +16,66 @@ const localConfigFile: string = "cpptools.json";
1516
interfaceSettings{
1617
defaultIntelliSenseEngine?:number;
1718
recursiveIncludes?:number;
19+
gotoDefIntelliSense?:number;
1820
}
1921

2022
exportclassABTestSettings{
2123
privatesettings:Settings;
2224
privateintelliSenseEngineDefault:PersistentState<number>;
2325
privaterecursiveIncludesDefault:PersistentState<number>;
26+
privategotoDefIntelliSenseDefault:PersistentState<number>;
2427
privatebucket:PersistentState<number>;
2528

2629
constructor(){
2730
this.intelliSenseEngineDefault=newPersistentState<number>("ABTest.1",100);
2831
this.recursiveIncludesDefault=newPersistentState<number>("ABTest.2",100);
32+
this.gotoDefIntelliSenseDefault=newPersistentState<number>("ABTest.3",100);
2933
this.settings={
3034
defaultIntelliSenseEngine:this.intelliSenseEngineDefault.Value,
31-
recursiveIncludes:this.recursiveIncludesDefault.Value
35+
recursiveIncludes:this.recursiveIncludesDefault.Value,
36+
gotoDefIntelliSense:this.gotoDefIntelliSenseDefault.Value
3237
};
3338
this.bucket=newPersistentState<number>(userBucketString,-1);
3439
if(this.bucket.Value===-1){
3540
this.bucket.Value=Math.floor(Math.random()*userBucketMax)+1;// Range is [1, userBucketMax].
3641
}
3742

38-
this.updateSettingsAsync().then(()=>{
39-
// Redownload cpptools.json after initialization so it's not blocked.
40-
// It'll be used the next time the extension reloads.
41-
this.downloadCpptoolsJsonPkgAsync();
42-
});
43+
this.updateSettings();
44+
// Redownload cpptools.json after initialization so it's not blocked.
45+
// It'll be used the next time the extension reloads.
46+
this.downloadCpptoolsJsonPkgAsync();
4347

4448
// Redownload occasionally to prevent an extra reload during long sessions.
4549
setInterval(()=>{this.downloadCpptoolsJsonPkgAsync();},30*60*1000);// 30 minutes.
4650
}
4751

4852
publicgetUseDefaultIntelliSenseEngine():boolean{
49-
returnthis.settings.defaultIntelliSenseEngine ?this.settings.defaultIntelliSenseEngine>=this.bucket.Value :true;
53+
returnutil.isNumber(this.settings.defaultIntelliSenseEngine) ?this.settings.defaultIntelliSenseEngine>=this.bucket.Value :true;
5054
}
5155

5256
publicgetUseRecursiveIncludes():boolean{
53-
returnthis.settings.recursiveIncludes ?this.settings.recursiveIncludes>=this.bucket.Value :true;
57+
returnutil.isNumber(this.settings.recursiveIncludes) ?this.settings.recursiveIncludes>=this.bucket.Value :true;
5458
}
5559

56-
privateasyncupdateSettingsAsync():Promise<void>{
60+
publicgetUseGoToDefIntelliSense():boolean{
61+
returnutil.isNumber(this.settings.gotoDefIntelliSense) ?this.settings.gotoDefIntelliSense>=this.bucket.Value :true;
62+
}
63+
64+
privateupdateSettings():void{
5765
constcpptoolsJsonFile:string=util.getExtensionFilePath(localConfigFile);
5866

5967
try{
60-
constexists:boolean=awaitutil.checkFileExists(cpptoolsJsonFile);
68+
constexists:boolean=fs.existsSync(cpptoolsJsonFile);
6169
if(exists){
62-
constfileContent:string=awaitutil.readFileText(cpptoolsJsonFile);
70+
constfileContent:string=fs.readFileSync(cpptoolsJsonFile).toString();
6371
letnewSettings:Settings=<Settings>JSON.parse(fileContent);
64-
if(newSettings.defaultIntelliSenseEngine){
65-
this.intelliSenseEngineDefault.Value=newSettings.defaultIntelliSenseEngine;
66-
}
67-
if(newSettings.recursiveIncludes){
68-
this.recursiveIncludesDefault.Value=newSettings.recursiveIncludes;
69-
}
72+
this.intelliSenseEngineDefault.Value=util.isNumber(newSettings.defaultIntelliSenseEngine) ?newSettings.defaultIntelliSenseEngine :this.intelliSenseEngineDefault.DefaultValue;
73+
this.recursiveIncludesDefault.Value=util.isNumber(newSettings.recursiveIncludes) ?newSettings.recursiveIncludes :this.recursiveIncludesDefault.DefaultValue;
74+
this.gotoDefIntelliSenseDefault.Value=util.isNumber(newSettings.gotoDefIntelliSense) ?newSettings.gotoDefIntelliSense :this.gotoDefIntelliSenseDefault.DefaultValue;
7075
this.settings={
7176
defaultIntelliSenseEngine:this.intelliSenseEngineDefault.Value,
72-
recursiveIncludes:this.recursiveIncludesDefault.Value
77+
recursiveIncludes:this.recursiveIncludesDefault.Value,
78+
gotoDefIntelliSense:this.gotoDefIntelliSenseDefault.Value
7379
};
7480
}
7581
}catch(error){
@@ -87,7 +93,7 @@ export class ABTestSettings {
8793
hasError=true;
8894
})
8995
.then(()=>{
90-
this.updateSettingsAsync();
96+
this.updateSettings();
9197
telemetryProperties['success']=(!hasError).toString();
9298
Telemetry.logDebuggerEvent("cpptoolsJsonDownload",telemetryProperties);
9399
});

‎Extension/src/common.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ export function isString(input: any): input is string {
179179
returntypeof(input)==="string";
180180
}
181181

182+
exportfunctionisNumber(input:any):input isnumber{
183+
returntypeof(input)==="number";
184+
}
185+
182186
exportfunctionisOptionalString(input:any):input isstring|undefined{
183187
returninput===undefined||isString(input);
184188
}

‎Extension/src/cppTools.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class CppTools implements CppToolsTestApi {
7777
}elseif(this.failedRegistrations.find(p=>p===provider)){
7878
console.warn("provider not successfully registered, 'notifyReady' ignored");
7979
}else{
80-
console.warn(false,"provider should be registered before signaling it's ready to provide configurations");
80+
console.warn("provider should be registered before signaling it's ready to provide configurations");
8181
}
8282
}
8383

@@ -86,12 +86,14 @@ export class CppTools implements CppToolsTestApi {
8686
letp:CustomConfigurationProvider1=providers.get(provider);
8787

8888
if(p){
89-
console.warn(p.isReady,"didChangeCustomConfiguration was invoked before notifyReady");
89+
if(!p.isReady){
90+
console.warn("didChangeCustomConfiguration was invoked before notifyReady");
91+
}
9092
LanguageServer.getClients().forEach(client=>client.updateCustomConfigurations(p));
9193
}elseif(this.failedRegistrations.find(p=>p===provider)){
9294
console.warn("provider not successfully registered, 'didChangeCustomConfiguration' ignored");
9395
}else{
94-
console.warn(false,"provider should be registered before sending config change messages");
96+
console.warn("provider should be registered before sending config change messages");
9597
}
9698
}
9799

@@ -104,7 +106,7 @@ export class CppTools implements CppToolsTestApi {
104106
}elseif(this.failedRegistrations.find(p=>p===provider)){
105107
console.warn("provider not successfully registered, 'didChangeCustomBrowseConfiguration' ignored");
106108
}else{
107-
console.warn(false,"provider should be registered before sending config change messages");
109+
console.warn("provider should be registered before sending config change messages");
108110
}
109111
}
110112

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp