Skip to content

Commit 1b218b2

Browse files
authored
Merge pull request #1731 from Microsoft/dev/seanmcm/0_16_0_insiders2
Dev/seanmcm/0 16 0 insiders2
2 parents 263b69e + ddd8551 commit 1b218b2

File tree

10 files changed

+95
-53
lines changed

10 files changed

+95
-53
lines changed

Code Samples/SampleClangProject/.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"taskName": "clang++",
7+
"label": "clang++",
88
"command": "clang++ --debug -o main.exe main.cpp",
99
// "--debug" enables debugging symbols
1010
// "-o main.exe" specifies the output executable
@@ -16,4 +16,4 @@
1616
}
1717
}
1818
]
19-
}
19+
}

Documentation/LanguageServer/c_cpp_properties.json.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
{
99
"name": "Win32",
1010
"intelliSenseMode": "msvc-x64",
11-
"includePath": [ "${workspaceRoot}" ],
11+
"includePath": [ "${workspaceFolder}" ],
1212
"macFrameworkPath": [ "/System/Library/Frameworks" ],
1313
"defines": [ "FOO", "BAR=100" ],
14+
"forcedInclude": [ "${workspaceFolder}/include/config.h" ],
15+
"compilerPath": "/usr/bin/clang",
16+
"cStandard": "c11",
17+
"cppStandard": "c++17",
1418
"compileCommands": "/path/to/compile_commands.json",
1519
"browse": {
16-
"path": [ "${workspaceRoot}" ],
20+
"path": [ "${workspaceFolder}" ],
1721
"limitSymbolsToIncludedHeaders": true,
1822
"databaseFilename": ""
1923
}
@@ -40,18 +44,30 @@
4044
If `"C_Cpp.intelliSenseEngine"` is set to "Default" in your settings file, this property determines which mode the IntelliSense engine will run in. `"msvc-x64"` maps to Visual Studio mode with 64-bit pointer sizes. `"clang-x64"` maps to GCC/CLang mode with 64-bit pointer sizes. Windows uses `"msvc-x64"` by default and Linux/Mac use `"clang-x64"` by default.
4145

4246
* #### `includePath`
43-
If `"C_Cpp.intelliSenseEngine"` is set to "Default" in your settings file, this list of paths will be used by IntelliSense to search for headers included by your source files. This is basically the same as the list of paths you pass to your compiler with the `-I` switch; the IntelliSense engine will not do a recursive search in these paths for includes.
47+
If `"C_Cpp.intelliSenseEngine"` is set to "Default" in your settings file, this list of paths will be used by IntelliSense to search for headers included by your source files. This is basically the same as the list of paths you pass to your compiler with the `-I` switch; the IntelliSense engine will not do a recursive search in these paths for includes. If a GCC/CLang compiler is specified in the `compilerPath` setting, it is not necessary to list the system include paths in this list.
4448

4549
* #### `macFrameworkPath`
4650
If `"C_Cpp.intelliSenseEngine"` is set to "Default" in your settings file, this list of paths will be used by IntelliSense to search for framework headers included by your source files. This is basically the same as the list of paths you pass to your compiler with the `-F` switch; the IntelliSense engine will not do a recursive search in these paths for includes.
4751

4852
* #### `defines`
4953
If `"C_Cpp.intelliSenseEngine"` is set to "Default" in your settings file, this list of preprocessor symbols will be used by IntelliSense during the compilation of your source files. This is basically the same as the list of symbols you pass to your compiler with the `-D` switch.
5054

55+
* #### `forcedInclude` (optional)
56+
A list of files that should be included before any other characters in the source file are processed. Files are included in the order listed.
57+
58+
* #### `compilerPath` (optional)
59+
The absolute path to the compiler you use to build your project. The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense. Args can be added to modify the includes/defines used, e.g. `-nostdinc++`, `-m32`, etc., but paths with spaces must be surrounded by double quotes (`"`) if args are used.
60+
61+
* #### `cStandard`
62+
The C standard revision to use for IntelliSense in your project.
63+
64+
* #### `cppStandard`
65+
The C++ standard revision to use for IntelliSense in your project.
66+
5167
* #### `compileCommands` (optional)
5268
If `"C_Cpp.intelliSenseEngine"` is set to "Default" in your settings file, the includes and defines discovered in this file will be used instead of the values set for `includePath` and `defines`. If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, then a warning message will appear and the extension will use the `includePath` and `defines` settings instead.
5369

54-
*For more information about the file format, see the [Clang documentation](https://clang.llvm.org/docs/JSONCompilationDatabase.html). Some build systems, such as CMake, [simplify generating this file](https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html).*
70+
*For more information about the file format, see the [Clang documentation](https://clang.llvm.org/docs/JSONCompilationDatabase.html). Some build systems, such as CMake, [simplify generating this file](https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html).*
5571

5672
* #### `browse`
5773
The set of properties used when `"C_Cpp.intelliSenseEngine"` is set to `"Tag Parser"` (also referred to as "fuzzy" IntelliSense, or the "browse" engine). These properties are also used by the Go To Definition/Declaration features, or when the "Default" IntelliSense engine is unable to resolve the #includes in your source files.

Extension/CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# C/C++ for Visual Studio Code Change Log
22

3-
## Version 0.16.0-insiders: March 8, 2018
3+
## Version 0.16.0-insiders2: March 23, 2018
44
* Enable autocomplete for local and global scopes. [#13](https://github.com/Microsoft/vscode-cpptools/issues/13)
55
* Add a setting to define multiline comment patterns: `C_Cpp.commentContinuationPatterns`. [#1100](https://github.com/Microsoft/vscode-cpptools/issues/1100), [#1539](https://github.com/Microsoft/vscode-cpptools/issues/1539)
66
* Add a setting to disable inactive region highlighting: `C_Cpp.dimInactiveRegions`. [#1592](https://github.com/Microsoft/vscode-cpptools/issues/1592)
77
* Add `forcedInclude` configuration setting. [#852](https://github.com/Microsoft/vscode-cpptools/issues/852)
88
* Add `compilerPath`, `cStandard`, and `cppStandard` configuration settings, and query gcc/clang-based compilers for default defines. [#1293](https://github.com/Microsoft/vscode-cpptools/issues/1293), [#1251](https://github.com/Microsoft/vscode-cpptools/issues/1251), [#1448](https://github.com/Microsoft/vscode-cpptools/issues/1448), [#1465](https://github.com/Microsoft/vscode-cpptools/issues/1465), [#1484](https://github.com/Microsoft/vscode-cpptools/issues/1484)
99
* Fix text being temporarily gray when an inactive region is deleted. [Microsoft/vscode#44872](https://github.com/Microsoft/vscode/issues/44872)
1010
* Add support for `${workspaceFolder}` variable in **c_cpp_properties.json**. [#1392](https://github.com/Microsoft/vscode-cpptools/issues/1392)
11-
* Fix debugging being delayed (by cpptools.json downloading). [#1640](https://github.com/Microsoft/vscode-cpptools/issues/1640)
11+
* Fix IntelliSense not updating in source files after dependent header files are changed. [#1501](https://github.com/Microsoft/vscode-cpptools/issues/1501)
12+
* Change database icon to use the `statusBar.foreground` color. [#1638](https://github.com/Microsoft/vscode-cpptools/issues/1638)
13+
* Enable C++/CLI IntelliSense mode via adding the `/clr` arg to the `compilerPath`. [#1596](https://github.com/Microsoft/vscode-cpptools/issues/1596)
14+
* Fix delay in language service activation caused by **cpptools.json** downloading. [#1640](https://github.com/Microsoft/vscode-cpptools/issues/1640)
15+
* Fix debugger failure when a single quote is in the path. [#1554](https://github.com/Microsoft/vscode-cpptools/issues/1554)
16+
* Fix terminal stdout and stderr redirection to not send to VS Code. [#1348](https://github.com/Microsoft/vscode-cpptools/issues/1348)
17+
* Fix blank config and endless "Initializing..." if the file watcher limit is hit when using `compileCommands`. [PR #1709](https://github.com/Microsoft/vscode-cpptools/pull/1709)
18+
* Fix error squiggles re-appearing after editing then closing a file. [#1712](https://github.com/Microsoft/vscode-cpptools/issues/1712)
19+
* Show error output from clang-format. [#1259](https://github.com/Microsoft/vscode-cpptools/issues/1259)
20+
* Fix `add_expression_to_index` crash (most frequent crash in 0.15.0). [#1396](https://github.com/Microsoft/vscode-cpptools/issues/1396)
21+
* Fix incorrect error squiggle `explicitly instantiated more than once`. [#871](https://github.com/Microsoft/vscode-cpptools/issues/871)
1222

1323
## Version 0.15.0: February 15, 2018
1424
* Add colorization for inactive regions. [#1466](https://github.com/Microsoft/vscode-cpptools/issues/1466)

Extension/ReleaseNotes.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ <h1>Microsoft C/C++ Extension for VS Code</h1>
205205
<tr>
206206
<td>
207207
<div>
208-
<h2 class="caption">February 2018 Update</h2>
209-
<div>Thank you for installing the C/C++ extension. In the February update, we added colorization around inactive preprocessor blocks. We also accepted our first pull requests from the community. Thanks for helping to make our extension better!<br />
208+
<h2 class="caption">March 2018 Update</h2>
209+
<div>Thank you for installing the C/C++ extension. In the March update, we finished our implementation of autocomplete for the default IntelliSense engine. We also added additional configuration settings for forced include files, specifying your compiler path and language standard to improve IntelliSense accuracy.<br />
210210
<br />
211211
Additional features and bug fixes are detailed in the <a href="https://github.com/Microsoft/vscode-cpptools/releases">full release notes</a>.</div>
212212
</div>
@@ -231,9 +231,9 @@ <h3 class="caption">Getting Started</h3>
231231
<td>
232232
<div>
233233
<h3 class="caption">Blog Posts</h3>
234+
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2018/02/20/visual-studio-code-cc-extension-feb-2018-update/">February 2018 Update</a></div>
234235
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2018/01/17/visual-studio-code-cc-extension-jan-2018-update/">January 2018 Update</a></div>
235236
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2017/12/11/visual-studio-code-cc-extension-dec-2017-update-support-for-more-linux-distros/">December 2017 Update</a></div>
236-
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2017/11/09/visual-studio-code-cc-extension-nov-2017-update-multi-root-workspaces-support-is-here/">November 2017 Update</a></div>
237237
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2016/03/31/cc-extension-for-visual-studio-code/">C/C++ Extension anouncement</a></div>
238238
</div>
239239
</td>

Extension/c_cpp_properties.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
],
1212
"properties": {
1313
"name": {
14-
"description": "Platform name. Mac, Linux, or Win32 are the defaults unless a custom platform is added.",
14+
"description": "Configuration identifier. Mac, Linux, or Win32 are special identifiers for configurations that will be auto-selected on those platforms, but the identifier can be anything.",
1515
"type": "string"
1616
},
1717
"compilerPath": {
18-
"description": "Full path name of the compiler being used, e.g. /usr/bin/gcc, to enable more accurate IntelliSense.",
18+
"description": "Full path of the compiler being used, e.g. /usr/bin/gcc, to enable more accurate IntelliSense. Args can be added to modify the includes/defines used, e.g. -nostdinc++, -m32, etc., but paths with spaces must be surrounded with \\\" if args are used.",
1919
"type": "string"
2020
},
2121
"cStandard": {
@@ -39,7 +39,7 @@
3939
]
4040
},
4141
"compileCommands": {
42-
"description": "path to compile_commands.json file for the workspace",
42+
"description": "Full path to compile_commands.json file for the workspace.",
4343
"type": "string"
4444
},
4545
"includePath": {
@@ -82,7 +82,7 @@
8282
"type": "object",
8383
"properties": {
8484
"limitSymbolsToIncludedHeaders": {
85-
"description": "true to process only those files directly or indirectly included as headers, false to process all files under the specified include paths",
85+
"description": "true to process only those files directly or indirectly included as headers, false to process all files under the specified include paths.",
8686
"type": "boolean"
8787
},
8888
"databaseFilename": {

Extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpptools",
33
"displayName": "C/C++",
44
"description": "C/C++ IntelliSense, debugging, and code browsing.",
5-
"version": "0.16.0-insiders",
5+
"version": "0.16.0-insiders2",
66
"publisher": "ms-vscode",
77
"preview": true,
88
"icon": "LanguageCCPP_color_128x.png",

Extension/src/Debugger/configurations.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ function CreateRemoteAttachString(name: string, type: string, executable: string
6363
`;
6464
}
6565

66-
function CreatePipeTransportString(pipeProgram: string, debuggerProgram: string): string {
66+
function CreatePipeTransportString(pipeProgram: string, debuggerProgram: string, pipeArgs: string[] = []): string {
6767
return `
6868
"pipeTransport": {
6969
\t"debuggerPath": "/usr/bin/${debuggerProgram}",
7070
\t"pipeProgram": "${pipeProgram}",
71-
\t"pipeArgs": [],
71+
\t"pipeArgs": ${JSON.stringify(pipeArgs)},
7272
\t"pipeCwd": ""
7373
}`;
7474
}
@@ -226,7 +226,7 @@ export class WSLConfigurations extends Configuration {
226226
let body: string = formatString(`
227227
{
228228
\t${indentJsonString(CreateLaunchString(name, this.miDebugger, this.executable))},
229-
\t${indentJsonString(CreatePipeTransportString(this.bashPipeProgram, this.MIMode))}{0}
229+
\t${indentJsonString(CreatePipeTransportString(this.bashPipeProgram, this.MIMode, ["-c"]))}{0}
230230
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
231231

232232
return {
@@ -242,8 +242,8 @@ export class WSLConfigurations extends Configuration {
242242

243243
let body: string = formatString(`
244244
{
245-
\t${indentJsonString(CreateAttachString(name, this.miDebugger, this.executable))},
246-
\t${indentJsonString(CreatePipeTransportString(this.bashPipeProgram, this.MIMode))}{0}
245+
\t${indentJsonString(CreateRemoteAttachString(name, this.miDebugger, this.executable))},
246+
\t${indentJsonString(CreatePipeTransportString(this.bashPipeProgram, this.MIMode, ["-c"]))}{0}
247247
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);
248248

249249
return {

Extension/src/LanguageServer/configurations.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,18 @@ export class CppProperties {
346346
filePaths.add(c.compileCommands);
347347
}
348348
});
349-
filePaths.forEach((path: string) => {
350-
this.compileCommandFileWatchers.push(fs.watch(path, (event: string, filename: string) => {
351-
if (event !== "rename") {
352-
this.onCompileCommandsChanged(path);
353-
}
354-
}));
355-
});
349+
try {
350+
filePaths.forEach((path: string) => {
351+
this.compileCommandFileWatchers.push(fs.watch(path, (event: string, filename: string) => {
352+
if (event !== "rename") {
353+
this.onCompileCommandsChanged(path);
354+
}
355+
}));
356+
});
357+
} catch (e) {
358+
// The file watcher limit is hit.
359+
// TODO: Check if the compile commands file has a higher timestamp during the interval timer.
360+
}
356361
}
357362

358363
public handleConfigurationEditCommand(onSuccess: (document: vscode.TextDocument) => void): void {
@@ -424,7 +429,11 @@ export class CppProperties {
424429

425430
// Try to use the same configuration as before the change.
426431
let newJson: ConfigurationJson = JSON.parse(readResults);
427-
if (!this.configurationIncomplete && newJson.configurations && this.configurationJson) {
432+
if (!newJson || !newJson.configurations || newJson.configurations.length === 0) {
433+
throw { message: "Invalid configuration file. There must be at least one configuration present in the array." };
434+
}
435+
if (!this.configurationIncomplete && this.configurationJson && this.configurationJson.configurations &&
436+
this.CurrentConfiguration < this.configurationJson.configurations.length) {
428437
for (let i: number = 0; i < newJson.configurations.length; i++) {
429438
if (newJson.configurations[i].name === this.configurationJson.configurations[this.CurrentConfiguration].name) {
430439
this.currentConfigurationIndex.Value = i;
@@ -433,6 +442,9 @@ export class CppProperties {
433442
}
434443
}
435444
this.configurationJson = newJson;
445+
if (this.CurrentConfiguration >= newJson.configurations.length) {
446+
this.currentConfigurationIndex.Value = this.getConfigIndexForPlatform(newJson);
447+
}
436448

437449
// Warning: There is a chance that this is incorrect in the event that the c_cpp_properties.json file was created before
438450
// the system includes were available.

Extension/src/LanguageServer/extension.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -384,29 +384,33 @@ function reportMacCrashes(): void {
384384
}
385385

386386
// vscode.workspace.createFileSystemWatcher only works in workspace folders.
387-
fs.watch(crashFolder, (event, filename) => {
388-
if (event !== "rename") {
389-
return;
390-
}
391-
if (filename === prevCrashFile) {
392-
return;
393-
}
394-
prevCrashFile = filename;
395-
if (!filename.startsWith("Microsoft.VSCode.CPP.")) {
396-
return;
397-
}
398-
// Wait 5 seconds to allow time for the crash log to finish being written.
399-
setTimeout(() => {
400-
fs.readFile(path.resolve(crashFolder, filename), 'utf8', (err, data) => {
401-
if (err) {
402-
// Try again?
403-
fs.readFile(path.resolve(crashFolder, filename), 'utf8', handleCrashFileRead);
404-
return;
405-
}
406-
handleCrashFileRead(err, data);
407-
});
408-
}, 5000);
409-
});
387+
try {
388+
fs.watch(crashFolder, (event, filename) => {
389+
if (event !== "rename") {
390+
return;
391+
}
392+
if (filename === prevCrashFile) {
393+
return;
394+
}
395+
prevCrashFile = filename;
396+
if (!filename.startsWith("Microsoft.VSCode.CPP.")) {
397+
return;
398+
}
399+
// Wait 5 seconds to allow time for the crash log to finish being written.
400+
setTimeout(() => {
401+
fs.readFile(path.resolve(crashFolder, filename), 'utf8', (err, data) => {
402+
if (err) {
403+
// Try again?
404+
fs.readFile(path.resolve(crashFolder, filename), 'utf8', handleCrashFileRead);
405+
return;
406+
}
407+
handleCrashFileRead(err, data);
408+
});
409+
}, 5000);
410+
});
411+
} catch (e) {
412+
// The file watcher limit is hit (may not be possible on Mac, but just in case).
413+
}
410414
});
411415
}
412416
}

0 commit comments

Comments
 (0)