Skip to content

Commit

Permalink
Merge branch 'main' into mergeCompileCommands
Browse files Browse the repository at this point in the history
  • Loading branch information
yiftahw committed Oct 23, 2024
2 parents 9a95b02 + e58e963 commit 631b15f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
5 changes: 5 additions & 0 deletions Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# C/C++ for Visual Studio Code Changelog

## Version 1.22.10: October 21, 2024
### Bug Fixes
* Fix the 'Extract to Function' feature not working.
* Fix the 'Go to Next/Prev Preprocessor Conditional' feature not working.

## Version 1.22.9: October 10, 2024
### Performance Improvements
* Initialization performance improvements. [#12030](https://github.com/microsoft/vscode-cpptools/issues/12030)
Expand Down
8 changes: 2 additions & 6 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"Snippets"
],
"enabledApiProposals": [
"terminalDataWriteEvent",
"lmTools"
"terminalDataWriteEvent"
],
"capabilities": {
"untrustedWorkspaces": {
Expand Down Expand Up @@ -6519,10 +6518,7 @@
"userDescription": "%c_cpp.languageModelTools.configuration.userDescription%",
"modelDescription": "For the active C or C++ file, this tool provides: the language (C, C++, or CUDA), the language standard version (such as C++11, C++14, C++17, or C++20), the compiler (such as GCC, Clang, or MSVC), the target platform (such as x86, x64, or ARM), and the target architecture (such as 32-bit or 64-bit).",
"icon": "$(file-code)",
"when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)",
"supportedContentTypes": [
"text/plain"
]
"when": "(config.C_Cpp.experimentalFeatures =~ /^[eE]nabled$/)"
}
]
},
Expand Down
4 changes: 3 additions & 1 deletion Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,9 @@ export class DefaultClient implements Client {
}

this.updateInactiveRegions(intelliSenseResult.uri, intelliSenseResult.inactiveRegions, intelliSenseResult.clearExistingInactiveRegions, intelliSenseResult.isCompletePass);
this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics);
if (intelliSenseResult.clearExistingDiagnostics || intelliSenseResult.diagnostics.length > 0) {
this.updateSquiggles(intelliSenseResult.uri, intelliSenseResult.diagnostics, intelliSenseResult.clearExistingDiagnostics);
}
}

private updateSquiggles(uriString: string, diagnostics: IntelliSenseDiagnostic[], startNewSet: boolean): void {
Expand Down
6 changes: 2 additions & 4 deletions Extension/src/LanguageServer/lmTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ const knownValues: { [Property in keyof ChatContextResult]?: { [id: string]: str
'macos': 'macOS'
}
};
// todo revert changes before pull request

export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTool<void> {
public async invoke(options: vscode.LanguageModelToolInvocationOptions<void>, token: vscode.CancellationToken): Promise<vscode.LanguageModelToolResult> {
const result: vscode.LanguageModelToolResult = { "content": [] };
result.content.push(await this.getContext(token));
return result;
return new vscode.LanguageModelToolResult([
new vscode.LanguageModelTextPart(await this.getContext(token))]);
}

private async getContext(token: vscode.CancellationToken): Promise<string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ describe('registerRelatedFilesProvider', () => {
let callbackPromise: Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }> | undefined;
let vscodeExtension: vscode.Extension<unknown>;

const includedFiles = process.platform === 'win32' ?
['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] :
['/system/include/vector', '/system/include/string', '/home/src/my_project/foo.h'];
const rootUri = vscode.Uri.file(process.platform === 'win32' ? 'C:\\src\\my_project' : '/home/src/my_project');
const expectedInclude = process.platform === 'win32' ? 'file:///c%3A/src/my_project/foo.h' : 'file:///home/src/my_project/foo.h';

beforeEach(() => {
proxyquire.noPreserveCache(); // Tells proxyquire to not fetch the module from cache
// Ensures that each test has a freshly loaded instance of moduleUnderTest
Expand Down Expand Up @@ -105,9 +111,9 @@ describe('registerRelatedFilesProvider', () => {
it('should not add #cpp traits when ChatContext isn\'t available.', async () => {
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: undefined,
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: true }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -120,22 +126,22 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits === undefined, 'result.traits should be undefined');
});

it('should not add #cpp traits when copilotcppTraits flag is false.', async () => {
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: {
language: 'c++',
standardVersion: 'c++20',
compiler: 'msvc',
targetPlatform: 'windows',
targetArchitecture: 'x64'
},
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: false }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -148,22 +154,22 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits === undefined, 'result.traits should be undefined');
});

it('should add #cpp traits when copilotcppTraits flag is true.', async () => {
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: {
language: 'c++',
standardVersion: 'c++20',
compiler: 'msvc',
targetPlatform: 'windows',
targetArchitecture: 'x64'
},
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: true }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -177,7 +183,7 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits, 'result.traits should be defined');
ok(result.traits.length === 5, 'result.traits should have 5 traits');
ok(result.traits[0].name === 'language', 'result.traits[0].name should be "language"');
Expand Down Expand Up @@ -206,15 +212,15 @@ describe('registerRelatedFilesProvider', () => {
const excludeTraits = ['compiler', 'targetPlatform'];
arrange({
vscodeExtension: vscodeExtension,
getIncludeFiles: { includedFiles: ['c:\\system\\include\\vector', 'c:\\system\\include\\string', 'C:\\src\\my_project\\foo.h'] },
getIncludeFiles: { includedFiles },
chatContext: {
language: 'c++',
standardVersion: 'c++20',
compiler: 'msvc',
targetPlatform: 'windows',
targetArchitecture: 'x64'
},
rootUri: vscode.Uri.file('C:\\src\\my_project'),
rootUri,
flags: { copilotcppTraits: true, copilotcppExcludeTraits: excludeTraits }
});
await moduleUnderTest.registerRelatedFilesProvider();
Expand All @@ -228,7 +234,7 @@ describe('registerRelatedFilesProvider', () => {
ok(callbackPromise, 'callbackPromise should be defined');
ok(result, 'result should be defined');
ok(result.entries.length === 1, 'result.entries should have 1 included file');
ok(result.entries[0].toString() === 'file:///c%3A/src/my_project/foo.h', 'result.entries should have "file:///c%3A/src/my_project/foo.h"');
ok(result.entries[0].toString() === expectedInclude, `result.entries should have "${expectedInclude}"`);
ok(result.traits, 'result.traits should be defined');
ok(result.traits.length === 3, 'result.traits should have 3 traits');
ok(result.traits.filter(trait => excludeTraits.includes(trait.name)).length === 0, 'result.traits should not include excluded traits');
Expand Down

0 comments on commit 631b15f

Please sign in to comment.