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

Commit67eea35

Browse files
authored
Add dotconfig property for c_cpp_properties.json (microsoft#7845)
* Add dotConfig property for c_cpp_properties.json
1 parent9d6ea03 commit67eea35

File tree

8 files changed

+95
-1
lines changed

8 files changed

+95
-1
lines changed

‎Extension/c_cpp_properties.schema.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
"type":"string",
8989
"pattern":"^\\d{2}\\.\\d{1}\\.\\d{5}\\.\\d{1}$|^8\\.1$"
9090
},
91+
"dotConfig": {
92+
"description":"A path to a .config file created by Kconfig system. Kconfig system generates a file with all the defines to build a project. Examples of projects that use Kconfig system are the Linux Kernel and NuttX RTOS.",
93+
"type":"string"
94+
},
9195
"defines": {
9296
"markdownDescription":"A list of preprocessor definitions for the IntelliSense engine to use while parsing files. Optionally, use `=` to set a value, e.g. `VERSION=1`.",
9397
"descriptionHint":"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered.",

‎Extension/package.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,12 @@
24722472
"markdownDescription":"%c_cpp.configuration.default.enableConfigurationSquiggles.markdownDescription%",
24732473
"scope":"resource"
24742474
},
2475+
"C_Cpp.default.dotConfig": {
2476+
"type":"string",
2477+
"default":null,
2478+
"markdownDescription":"%c_cpp.configuration.default.dotConfig.markdownDescription%",
2479+
"scope":"resource"
2480+
},
24752481
"C_Cpp.updateChannel": {
24762482
"type":"string",
24772483
"enum": [

‎Extension/package.nls.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
"c_cpp.configuration.default.customConfigurationVariables.markdownDescription": {"message":"The value to use in a configuration if `customConfigurationVariables` is not set, or the values to insert if `${default}` is present as a key in `customConfigurationVariables`.","comment": ["Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
197197
"c_cpp.configuration.updateChannel.markdownDescription": {"message":"Set to `Insiders` to automatically download and install the latest Insiders builds of the extension, which include upcoming features and bug fixes.","comment": ["Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
198198
"c_cpp.configuration.updateChannel.deprecationMessage":"This setting is deprecated. Pre-release extensions are now available via the Marketplace.",
199+
"c_cpp.configuration.default.dotConfig.markDownDescription": {"message":"The value to use in a configuration if `dotConfig` is not specified, or the value to insert if `${default}` is present in `dotConfig`.","comment": ["Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
199200
"c_cpp.configuration.experimentalFeatures.description":"Controls whether\"experimental\" features are usable.",
200201
"c_cpp.configuration.suggestSnippets.markdownDescription": {"message":"If `true`, snippets are provided by the language server.","comment": ["Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
201202
"c_cpp.configuration.enhancedColorization.markdownDescription": {"message":"If enabled, code is colorized based on IntelliSense. This setting only applies if `#C_Cpp.intelliSenseEngine#` is set to `Default`.","comment": ["Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },

‎Extension/src/LanguageServer/configurations.ts‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import * as nls from 'vscode-nls';
2020
import{setTimeout}from'timers';
2121
import*aswhichfrom'which';
2222
import{WorkspaceBrowseConfiguration}from'vscode-cpptools';
23+
import{getOutputChannelLogger}from'../logger';
2324

2425
nls.config({messageFormat:nls.MessageFormat.bundle,bundleFormat:nls.BundleFormat.standalone})();
2526
constlocalize:nls.LocalizeFunc=nls.loadMessageBundle();
@@ -67,6 +68,7 @@ export interface Configuration {
6768
includePath?:string[];
6869
macFrameworkPath?:string[];
6970
windowsSdkVersion?:string;
71+
dotConfig?:string;
7072
defines?:string[];
7173
intelliSenseMode?:string;
7274
intelliSenseModeIsExplicit?:boolean;
@@ -86,6 +88,7 @@ export interface ConfigurationErrors {
8688
macFrameworkPath?:string;
8789
forcedInclude?:string;
8890
compileCommands?:string;
91+
dotConfig?:string;
8992
browsePath?:string;
9093
databaseFilename?:string;
9194
}
@@ -787,6 +790,23 @@ export class CppProperties {
787790
returnthis.resolveDefaultsDictionary(property,defaultValue,env);
788791
}
789792

793+
privategetDotconfigDefines(dotConfigPath:string):string[]{
794+
constisWindows:boolean=os.platform()==='win32';
795+
796+
if(dotConfigPath!==undefined){
797+
constpath:string=this.resolvePath(dotConfigPath,isWindows);
798+
try{
799+
constconfigContent:string[]=fs.readFileSync(path,"utf-8").split("\n");
800+
returnconfigContent.filter(i=>!i.startsWith("#")&&i!=="");
801+
}catch(errJS){
802+
consterr:Error=errJSasError;
803+
getOutputChannelLogger().appendLine(`Invalid input, cannot resolve .config path:${err.message}`);
804+
}
805+
}
806+
807+
return[];
808+
}
809+
790810
privateupdateServerOnFolderSettingsChange():void{
791811
if(!this.configurationJson){
792812
return;
@@ -805,7 +825,15 @@ export class CppProperties {
805825
configuration.includePath=includePath.concat(this.nodeAddonIncludes.filter(i=>includePath.indexOf(i)<0));
806826
}
807827
configuration.defines=this.updateConfigurationStringArray(configuration.defines,settings.defaultDefines,env);
808-
configuration.macFrameworkPath=this.updateConfigurationPathsArray(configuration.macFrameworkPath,settings.defaultMacFrameworkPath,env);
828+
829+
// in case we have dotConfig
830+
configuration.dotConfig=this.updateConfigurationString(configuration.dotConfig,settings.defaultDotconfig,env);
831+
if(configuration.dotConfig!==undefined){
832+
configuration.defines=configuration.defines||[];
833+
configuration.defines=configuration.defines.concat(this.getDotconfigDefines(configuration.dotConfig));
834+
}
835+
836+
configuration.macFrameworkPath=this.updateConfigurationStringArray(configuration.macFrameworkPath,settings.defaultMacFrameworkPath,env);
809837
configuration.windowsSdkVersion=this.updateConfigurationString(configuration.windowsSdkVersion,settings.defaultWindowsSdkVersion,env);
810838
configuration.forcedInclude=this.updateConfigurationPathsArray(configuration.forcedInclude,settings.defaultForcedInclude,env);
811839
configuration.compileCommands=this.updateConfigurationString(configuration.compileCommands,settings.defaultCompileCommands,env);
@@ -1445,6 +1473,7 @@ export class CppProperties {
14451473
// Validate files
14461474
errors.forcedInclude=this.validatePath(config.forcedInclude,false,true);
14471475
errors.compileCommands=this.validatePath(config.compileCommands,false);
1476+
errors.dotConfig=this.validatePath(config.dotConfig,false);
14481477
errors.databaseFilename=this.validatePath((config.browse ?config.browse.databaseFilename :undefined),false);
14491478

14501479
// Validate intelliSenseMode
@@ -1708,6 +1737,9 @@ export class CppProperties {
17081737
constcompilerPathStart:number=curText.search(/\s*\"compilerPath\"\s*:\s*\"/);
17091738
constcompilerPathValueStart:number=curText.indexOf('"',curText.indexOf(":",compilerPathStart));
17101739
constcompilerPathEnd:number=compilerPathStart===-1 ?-1 :curText.indexOf('"',compilerPathValueStart+1)+1;
1740+
constdotConfigStart:number=curText.search(/\s*\"dotConfig\"\s*:\s*\"/);
1741+
constdotConfigValueStart:number=curText.indexOf('"',curText.indexOf(":",dotConfigStart));
1742+
constdotConfigEnd:number=dotConfigStart===-1 ?-1 :curText.indexOf('"',dotConfigValueStart+1)+1;
17111743
constprocessedPaths:Set<string>=newSet<string>();
17121744

17131745
// Validate compiler paths
@@ -1753,6 +1785,39 @@ export class CppProperties {
17531785
diagnostics.push(diagnostic);
17541786
}
17551787

1788+
// validate .config path
1789+
letdotConfigPath:string|undefined;
1790+
letdotConfigPathExists:boolean=true;
1791+
letdotConfigMessage:string|undefined;
1792+
1793+
dotConfigPath=currentConfiguration.dotConfig;
1794+
dotConfigPath=util.resolveVariables(dotConfigPath,this.ExtendedEnvironment).trim();
1795+
dotConfigPath=this.resolvePath(dotConfigPath,isWindows);
1796+
constisWSLDotConfig:boolean=isWindows&&dotConfigPath.startsWith("/");
1797+
// does not try resolve if the dotConfig property is empty
1798+
dotConfigPath=dotConfigPath!=='' ?dotConfigPath :undefined;
1799+
1800+
if(dotConfigPath&&this.rootUri){
1801+
constcheckPathExists:any=util.checkPathExistsSync(dotConfigPath,this.rootUri.fsPath+path.sep,isWindows,isWSLDotConfig,true);
1802+
dotConfigPathExists=checkPathExists.pathExists;
1803+
dotConfigPath=checkPathExists.path;
1804+
}
1805+
if(!dotConfigPathExists){
1806+
dotConfigMessage=localize('cannot.find2',"Cannot find \"{0}\".",dotConfigPath);
1807+
newSquiggleMetrics.PathNonExistent++;
1808+
}elseif(dotConfigPath&&!util.checkFileExistsSync(dotConfigPath)){
1809+
dotConfigMessage=localize("path.is.not.a.file","Path is not a file: {0}",dotConfigPath);
1810+
newSquiggleMetrics.PathNotAFile++;
1811+
}
1812+
1813+
if(dotConfigMessage){
1814+
constdiagnostic:vscode.Diagnostic=newvscode.Diagnostic(
1815+
newvscode.Range(document.positionAt(curTextStartOffset+dotConfigValueStart),
1816+
document.positionAt(curTextStartOffset+dotConfigEnd)),
1817+
dotConfigMessage,vscode.DiagnosticSeverity.Warning);
1818+
diagnostics.push(diagnostic);
1819+
}
1820+
17561821
// Validate paths
17571822
for(constcurPathofpaths){
17581823
if(processedPaths.has(curPath)){

‎Extension/src/LanguageServer/settings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export class CppSettings extends Settings {
218218
publicgetfilesExclude():vscode.WorkspaceConfiguration|undefined{returnsuper.Section.get<vscode.WorkspaceConfiguration>("files.exclude");}
219219
publicgetdefaultIncludePath():string[]|undefined{returnsuper.getWithUndefinedDefault<string[]>("default.includePath");}
220220
publicgetdefaultDefines():string[]|undefined{returnsuper.getWithUndefinedDefault<string[]>("default.defines");}
221+
publicgetdefaultDotconfig():string|undefined{returnsuper.Section.get<string>("default.dotConfig");}
221222
publicgetdefaultMacFrameworkPath():string[]|undefined{returnsuper.getWithUndefinedDefault<string[]>("default.macFrameworkPath");}
222223
publicgetdefaultWindowsSdkVersion():string|undefined{returnsuper.Section.get<string>("default.windowsSdkVersion");}
223224
publicgetdefaultCompileCommands():string|undefined{returnsuper.Section.get<string>("default.compileCommands");}

‎Extension/src/LanguageServer/settingsPanel.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const elementId: { [key: string]: string } = {
3939
windowsSdkVersion:"windowsSdkVersion",
4040
macFrameworkPath:"macFrameworkPath",
4141
compileCommands:"compileCommands",
42+
dotConfig:"dotConfig",
4243
mergeConfigurations:"mergeConfigurations",
4344
configurationProvider:"configurationProvider",
4445
forcedInclude:"forcedInclude",
@@ -326,6 +327,9 @@ export class SettingsPanel {
326327
caseelementId.compileCommands:
327328
this.configValues.compileCommands=message.value;
328329
break;
330+
caseelementId.dotConfig:
331+
this.configValues.dotConfig=message.value;
332+
break;
329333
caseelementId.mergeConfigurations:
330334
this.configValues.mergeConfigurations=message.value;
331335
break;

‎Extension/ui/settings.html‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,15 @@
656656
</div>
657657
</div>
658658

659+
<divclass="section">
660+
<divclass="section-title"data-loc-id="dot.config">Dot Config</div>
661+
<divclass="section-text"data-loc-id="dot.config.description">A path to a .config file created by Kconfig system. Kconfig system generates a file with all the defines to build a project. Examples of projects that use Kconfig system are the Linux Kernel and NuttX RTOS.</div>
662+
<div>
663+
<inputname="inputValue"id="dotConfig"style="width: 798px"></input>
664+
<divid="dotConfigInvalid"class="error"style="width: 800px"></div>
665+
</div>
666+
</div>
667+
659668
<divclass="section">
660669
<divclass="section-title"data-loc-id="compile.commands">Compile commands</div>
661670
<divclass="section-text">

‎Extension/ui/settings.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const elementId: { [key: string]: string } = {
4040
forcedInclude:"forcedInclude",
4141
forcedIncludeInvalid:"forcedIncludeInvalid",
4242
mergeConfigurations:"mergeConfigurations",
43+
dotConfig:"dotConfig",
44+
dotConfigInvalid:"dotConfigInvalid",
4345

4446
// Browse properties
4547
browsePath:"browsePath",
@@ -273,6 +275,7 @@ class SettingsApp {
273275
(<HTMLInputElement>document.getElementById(elementId.mergeConfigurations)).checked=config.mergeConfigurations;
274276
(<HTMLInputElement>document.getElementById(elementId.configurationProvider)).value=config.configurationProvider ?config.configurationProvider :"";
275277
(<HTMLInputElement>document.getElementById(elementId.forcedInclude)).value=joinEntries(config.forcedInclude);
278+
(<HTMLInputElement>document.getElementById(elementId.dotConfig)).value=config.dotConfig ?config.dotConfig :"";
276279

277280
if(config.browse){
278281
(<HTMLInputElement>document.getElementById(elementId.browsePath)).value=joinEntries(config.browse.path);
@@ -301,6 +304,7 @@ class SettingsApp {
301304
this.showErrorWithInfo(elementId.compileCommandsInvalid,errors.compileCommands);
302305
this.showErrorWithInfo(elementId.browsePathInvalid,errors.browsePath);
303306
this.showErrorWithInfo(elementId.databaseFilenameInvalid,errors.databaseFilename);
307+
this.showErrorWithInfo(elementId.dotConfigInvalid,errors.dotConfig);
304308
}finally{
305309
this.updating=false;
306310
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp