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

Commitada1d0c

Browse files
committed
Stop UTILITY targets from affecting IntelliSense
Some `UTILITY` targets, such as the ones created by `Doxygen.cmake`,have a list of associated sources but don't have any useful`includePath`, `defines`, etc. If the selected Build Target is `all` orsome other non-artifact target, these targets could be chosen as afallback source of configuration instead of a more complete one. Filterout targets with empty configurations before selecting a fallback, sothat doesn't happen.
1 parentf1080cc commitada1d0c

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Bug Fixes:
3333
- Fix bug that makes some build hang[#4424](https://github.com/microsoft/vscode-cmake-tools/issues/4424) and[#4465](https://github.com/microsoft/vscode-cmake-tools/issues/4465)
3434
- Fix issue with switching to presets during Quick Start.[#4409](https://github.com/microsoft/vscode-cmake-tools/issues/4409)
3535
- Fix bug that shows empty lines in Pinned Commands view.[#4406](https://github.com/microsoft/vscode-cmake-tools/issues/4406)
36+
- Fix incorrect IntelliSense configuration when a`UTILITY` has source files.[#4404](https://github.com/microsoft/vscode-cmake-tools/issues/4404)
3637

3738
##1.20.53
3839

‎src/cpptools.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,27 @@ export function getIntelliSenseMode(cptVersion: cpptools.Version, compilerPath:
310310
}
311311
}
312312

313+
/**
314+
* Try to find a target configuration with some populated properties.
315+
*
316+
* All targets get defaults for `compilerPath`, `compilerArgs`, and
317+
* `compilerFragments`, even `UTILITY` targets defined with
318+
* `add_custom_command()` that provide no other useful configuration, so if
319+
* possible, return one with more than just those populated.
320+
*/
321+
functionfallbackConfiguration(configurations:Map<string,cpptools.SourceFileConfigurationItem>|undefined){
322+
if(!configurations){
323+
returnundefined;
324+
}
325+
for(constitemofconfigurations.values()){
326+
const{configuration:{ includePath, defines, intelliSenseMode, standard}}=item;
327+
if(includePath.length||defines.length||intelliSenseMode||standard){
328+
returnitem;
329+
}
330+
}
331+
returnconfigurations.values().next().value;
332+
}
333+
313334
/**
314335
* The actual class that provides information to the cpptools extension. See
315336
* the `CustomConfigurationProvider` interface for information on how this class
@@ -345,7 +366,7 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro
345366
if(this.activeTarget&&configurations?.has(this.activeTarget)){
346367
returnconfigurations!.get(this.activeTarget);
347368
}else{
348-
returnconfigurations?.values().next().value;// Any value is fine if the target doesn't match
369+
returnfallbackConfiguration(configurations);
349370
}
350371
}
351372

‎test/unit-tests/cpptools.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,21 @@ suite('CppTools tests', () => {
321321
name:'cpptools-test2',
322322
sourceDirectory:smokeFolder,
323323
targets:[
324+
{
325+
name:'utilityTarget',
326+
type:'UTILITY',
327+
fileGroups:[{
328+
sources:[sourceFile3],
329+
isGenerated:false
330+
}]
331+
},
324332
{
325333
name:'target3',
326334
type:'EXECUTABLE',
327335
fileGroups:[{
328336
sources:[sourceFile3],
329337
isGenerated:false,
338+
defines:['DEFINE3'],// make this a more attractive fallback than utilityTarget
330339
compileCommandFragments:['-DFRAGMENT3'],
331340
language:'CXX'
332341
}]
@@ -370,7 +379,8 @@ suite('CppTools tests', () => {
370379
// Verify the browsePath with a different folder.
371380
constconfigurations2=awaitprovider.provideConfigurations([uri3]);
372381
expect(configurations2.length).to.eq(1);
373-
expect(configurations2[0].configuration.defines).to.be.empty;
382+
expect(configurations2[0].configuration.defines.length).to.eq(1);
383+
expect(configurations2[0].configuration.defines).to.contain('DEFINE3');
374384
expect(configurations2[0].configuration.compilerFragments).to.contain('-DFRAGMENT3');
375385
constbrowseConfig2=awaitprovider.provideFolderBrowseConfiguration(vscode.Uri.file(smokeFolder));
376386
expect(browseConfig2?.browsePath.length).to.eq(1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp