Skip to content

Commit 7e6f915

Browse files
authored
Don't mix generated and non-generated files in same group (#4263)
* Don't mix generated and non-generated files in same group * insure not two unecessary groups * Add todo * Add changelog entry
1 parent 24fd6d4 commit 7e6f915

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Improvements:
2525

2626
Bug Fixes:
2727

28+
- Fix issue where files don't show up in the outline if any in the group are generated. [#4099](https://github.com/microsoft/vscode-cmake-tools/issues/4099)
2829
- Fix issue where setting test suite delimiter prevent execution of all tests. [#4092](https://github.com/microsoft/vscode-cmake-tools/issues/4092) [@hippo91](https://github.com/hippo91)
2930
- Fix our setting of `isUserPreset` for presets, only set it to `true` if it's defined in a user presets file. [#4059](https://github.com/microsoft/vscode-cmake-tools/issues/4059)
3031
- Fix issue where duplicate presets are being listed in dropdown. [#4104](https://github.com/microsoft/vscode-cmake-tools/issues/4104)

src/drivers/cmakeFileApi.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ function convertToExtCodeModelFileGroup(targetObject: CodeModelKind.TargetObject
478478
});
479479
// Collection all without compilegroup like headers
480480
const defaultIndex = fileGroup.push({ sources: [], isGenerated: false } as CodeModelFileGroup) - 1;
481+
const generatedIndex = fileGroup.push({ sources: [], isGenerated: true } as CodeModelFileGroup) - 1;
481482

482483
const targetRootSource = convertToAbsolutePath(targetObject.paths.source, rootPaths.source);
483484
targetObject.sources.forEach(sourceFile => {
@@ -486,12 +487,18 @@ function convertToExtCodeModelFileGroup(targetObject: CodeModelKind.TargetObject
486487
if (sourceFile.compileGroupIndex !== undefined) {
487488
fileGroup[sourceFile.compileGroupIndex].sources.push(fileRelativePath);
488489
} else {
489-
fileGroup[defaultIndex].sources.push(fileRelativePath);
490-
if (!!sourceFile.isGenerated) {
491-
fileGroup[defaultIndex].isGenerated = sourceFile.isGenerated;
492-
}
490+
const i = !!sourceFile.isGenerated ? generatedIndex : defaultIndex;
491+
fileGroup[i].sources.push(fileRelativePath);
493492
}
494493
});
494+
495+
// TODO: Update code model interface so that the fileapi source file isGenerated property is plumbed through.
496+
if (fileGroup[generatedIndex].sources.length === 0) {
497+
fileGroup.splice(generatedIndex, 1);
498+
} else if (fileGroup[defaultIndex].sources.length === 0) {
499+
fileGroup.splice(defaultIndex, 1);
500+
}
501+
495502
return fileGroup;
496503
}
497504

test/unit-tests/driver/driver-codemodel-tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ export function makeCodeModelDriverTestsuite(driverName: string, driver_generato
231231
expect(target).to.be.not.undefined;
232232

233233
// maybe could be used to exclude file list from utility targets
234-
expect(target!.fileGroups![0].isGenerated).to.be.true;
234+
const last = target!.fileGroups!.length - 1;
235+
expect(target!.fileGroups![last].isGenerated).to.be.true;
235236
}).timeout(90000);
236237

237238
test('Test sysroot access', async () => {

0 commit comments

Comments
 (0)