Skip to content

Commit

Permalink
Don't mix generated and non-generated files in same group (#4263)
Browse files Browse the repository at this point in the history
* Don't mix generated and non-generated files in same group

* insure not two unecessary groups

* Add todo

* Add changelog entry
  • Loading branch information
paulmaybee authored Jan 30, 2025
1 parent 24fd6d4 commit 7e6f915
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Improvements:

Bug Fixes:

- 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)
- 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)
- 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)
- Fix issue where duplicate presets are being listed in dropdown. [#4104](https://github.com/microsoft/vscode-cmake-tools/issues/4104)
Expand Down
15 changes: 11 additions & 4 deletions src/drivers/cmakeFileApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ function convertToExtCodeModelFileGroup(targetObject: CodeModelKind.TargetObject
});
// Collection all without compilegroup like headers
const defaultIndex = fileGroup.push({ sources: [], isGenerated: false } as CodeModelFileGroup) - 1;
const generatedIndex = fileGroup.push({ sources: [], isGenerated: true } as CodeModelFileGroup) - 1;

const targetRootSource = convertToAbsolutePath(targetObject.paths.source, rootPaths.source);
targetObject.sources.forEach(sourceFile => {
Expand All @@ -486,12 +487,18 @@ function convertToExtCodeModelFileGroup(targetObject: CodeModelKind.TargetObject
if (sourceFile.compileGroupIndex !== undefined) {
fileGroup[sourceFile.compileGroupIndex].sources.push(fileRelativePath);
} else {
fileGroup[defaultIndex].sources.push(fileRelativePath);
if (!!sourceFile.isGenerated) {
fileGroup[defaultIndex].isGenerated = sourceFile.isGenerated;
}
const i = !!sourceFile.isGenerated ? generatedIndex : defaultIndex;
fileGroup[i].sources.push(fileRelativePath);
}
});

// TODO: Update code model interface so that the fileapi source file isGenerated property is plumbed through.
if (fileGroup[generatedIndex].sources.length === 0) {
fileGroup.splice(generatedIndex, 1);
} else if (fileGroup[defaultIndex].sources.length === 0) {
fileGroup.splice(defaultIndex, 1);
}

return fileGroup;
}

Expand Down
3 changes: 2 additions & 1 deletion test/unit-tests/driver/driver-codemodel-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ export function makeCodeModelDriverTestsuite(driverName: string, driver_generato
expect(target).to.be.not.undefined;

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

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

0 comments on commit 7e6f915

Please sign in to comment.