Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Code Samples/SampleClangProject/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "2.0.0",
"tasks": [
{
"taskName": "clang++",
"label": "clang++",
"command": "clang++ --debug -o main.exe main.cpp",
// "--debug" enables debugging symbols
// "-o main.exe" specifies the output executable
Expand All @@ -16,4 +16,4 @@
}
}
]
}
}
24 changes: 20 additions & 4 deletions Documentation/LanguageServer/c_cpp_properties.json.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
{
"name": "Win32",
"intelliSenseMode": "msvc-x64",
"includePath": [ "${workspaceRoot}" ],
"includePath": [ "${workspaceFolder}" ],
"macFrameworkPath": [ "/System/Library/Frameworks" ],
"defines": [ "FOO", "BAR=100" ],
"forcedInclude": [ "${workspaceFolder}/include/config.h" ],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "/path/to/compile_commands.json",
"browse": {
"path": [ "${workspaceRoot}" ],
"path": [ "${workspaceFolder}" ],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
Expand All @@ -40,18 +44,30 @@
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.

* #### `includePath`
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 `"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.

* #### `macFrameworkPath`
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.

* #### `defines`
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.

* #### `forcedInclude` (optional)
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.

* #### `compilerPath` (optional)
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.

* #### `cStandard`
The C standard revision to use for IntelliSense in your project.

* #### `cppStandard`
The C++ standard revision to use for IntelliSense in your project.

* #### `compileCommands` (optional)
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.

*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).*
*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).*

* #### `browse`
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.
Expand Down
14 changes: 12 additions & 2 deletions Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# C/C++ for Visual Studio Code Change Log

## Version 0.16.0-insiders: March 8, 2018
## Version 0.16.0-insiders2: March 23, 2018
* Enable autocomplete for local and global scopes. [#13](https://github.com/Microsoft/vscode-cpptools/issues/13)
* 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)
* Add a setting to disable inactive region highlighting: `C_Cpp.dimInactiveRegions`. [#1592](https://github.com/Microsoft/vscode-cpptools/issues/1592)
* Add `forcedInclude` configuration setting. [#852](https://github.com/Microsoft/vscode-cpptools/issues/852)
* 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)
* Fix text being temporarily gray when an inactive region is deleted. [Microsoft/vscode#44872](https://github.com/Microsoft/vscode/issues/44872)
* Add support for `${workspaceFolder}` variable in **c_cpp_properties.json**. [#1392](https://github.com/Microsoft/vscode-cpptools/issues/1392)
* Fix debugging being delayed (by cpptools.json downloading). [#1640](https://github.com/Microsoft/vscode-cpptools/issues/1640)
* Fix IntelliSense not updating in source files after dependent header files are changed. [#1501](https://github.com/Microsoft/vscode-cpptools/issues/1501)
* Change database icon to use the `statusBar.foreground` color. [#1638](https://github.com/Microsoft/vscode-cpptools/issues/1638)
* Enable C++/CLI IntelliSense mode via adding the `/clr` arg to the `compilerPath`. [#1596](https://github.com/Microsoft/vscode-cpptools/issues/1596)
* Fix delay in language service activation caused by **cpptools.json** downloading. [#1640](https://github.com/Microsoft/vscode-cpptools/issues/1640)
* Fix debugger failure when a single quote is in the path. [#1554](https://github.com/Microsoft/vscode-cpptools/issues/1554)
* Fix terminal stdout and stderr redirection to not send to VS Code. [#1348](https://github.com/Microsoft/vscode-cpptools/issues/1348)
* 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)
* Fix error squiggles re-appearing after editing then closing a file. [#1712](https://github.com/Microsoft/vscode-cpptools/issues/1712)
* Show error output from clang-format. [#1259](https://github.com/Microsoft/vscode-cpptools/issues/1259)
* Fix `add_expression_to_index` crash (most frequent crash in 0.15.0). [#1396](https://github.com/Microsoft/vscode-cpptools/issues/1396)
* Fix incorrect error squiggle `explicitly instantiated more than once`. [#871](https://github.com/Microsoft/vscode-cpptools/issues/871)

## Version 0.15.0: February 15, 2018
* Add colorization for inactive regions. [#1466](https://github.com/Microsoft/vscode-cpptools/issues/1466)
Expand Down
6 changes: 3 additions & 3 deletions Extension/ReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ <h1>Microsoft C/C++ Extension for VS Code</h1>
<tr>
<td>
<div>
<h2 class="caption">February 2018 Update</h2>
<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 />
<h2 class="caption">March 2018 Update</h2>
<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 />
<br />
Additional features and bug fixes are detailed in the <a href="https://github.com/Microsoft/vscode-cpptools/releases">full release notes</a>.</div>
</div>
Expand All @@ -231,9 +231,9 @@ <h3 class="caption">Getting Started</h3>
<td>
<div>
<h3 class="caption">Blog Posts</h3>
<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>
<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>
<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>
<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>
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2016/03/31/cc-extension-for-visual-studio-code/">C/C++ Extension anouncement</a></div>
</div>
</td>
Expand Down
8 changes: 4 additions & 4 deletions Extension/c_cpp_properties.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
],
"properties": {
"name": {
"description": "Platform name. Mac, Linux, or Win32 are the defaults unless a custom platform is added.",
"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.",
"type": "string"
},
"compilerPath": {
"description": "Full path name of the compiler being used, e.g. /usr/bin/gcc, to enable more accurate IntelliSense.",
"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.",
"type": "string"
},
"cStandard": {
Expand All @@ -39,7 +39,7 @@
]
},
"compileCommands": {
"description": "path to compile_commands.json file for the workspace",
"description": "Full path to compile_commands.json file for the workspace.",
"type": "string"
},
"includePath": {
Expand Down Expand Up @@ -82,7 +82,7 @@
"type": "object",
"properties": {
"limitSymbolsToIncludedHeaders": {
"description": "true to process only those files directly or indirectly included as headers, false to process all files under the specified include paths",
"description": "true to process only those files directly or indirectly included as headers, false to process all files under the specified include paths.",
"type": "boolean"
},
"databaseFilename": {
Expand Down
2 changes: 1 addition & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cpptools",
"displayName": "C/C++",
"description": "C/C++ IntelliSense, debugging, and code browsing.",
"version": "0.16.0-insiders",
"version": "0.16.0-insiders2",
"publisher": "ms-vscode",
"preview": true,
"icon": "LanguageCCPP_color_128x.png",
Expand Down
10 changes: 5 additions & 5 deletions Extension/src/Debugger/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ function CreateRemoteAttachString(name: string, type: string, executable: string
`;
}

function CreatePipeTransportString(pipeProgram: string, debuggerProgram: string): string {
function CreatePipeTransportString(pipeProgram: string, debuggerProgram: string, pipeArgs: string[] = []): string {
return `
"pipeTransport": {
\t"debuggerPath": "/usr/bin/${debuggerProgram}",
\t"pipeProgram": "${pipeProgram}",
\t"pipeArgs": [],
\t"pipeArgs": ${JSON.stringify(pipeArgs)},
\t"pipeCwd": ""
}`;
}
Expand Down Expand Up @@ -226,7 +226,7 @@ export class WSLConfigurations extends Configuration {
let body: string = formatString(`
{
\t${indentJsonString(CreateLaunchString(name, this.miDebugger, this.executable))},
\t${indentJsonString(CreatePipeTransportString(this.bashPipeProgram, this.MIMode))}{0}
\t${indentJsonString(CreatePipeTransportString(this.bashPipeProgram, this.MIMode, ["-c"]))}{0}
}`, [this.additionalProperties ? `,${os.EOL}\t${indentJsonString(this.additionalProperties)}` : ""]);

return {
Expand All @@ -242,8 +242,8 @@ export class WSLConfigurations extends Configuration {

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

return {
Expand Down
28 changes: 20 additions & 8 deletions Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,18 @@ export class CppProperties {
filePaths.add(c.compileCommands);
}
});
filePaths.forEach((path: string) => {
this.compileCommandFileWatchers.push(fs.watch(path, (event: string, filename: string) => {
if (event !== "rename") {
this.onCompileCommandsChanged(path);
}
}));
});
try {
filePaths.forEach((path: string) => {
this.compileCommandFileWatchers.push(fs.watch(path, (event: string, filename: string) => {
if (event !== "rename") {
this.onCompileCommandsChanged(path);
}
}));
});
} catch (e) {
// The file watcher limit is hit.
// TODO: Check if the compile commands file has a higher timestamp during the interval timer.
}
}

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

// Try to use the same configuration as before the change.
let newJson: ConfigurationJson = JSON.parse(readResults);
if (!this.configurationIncomplete && newJson.configurations && this.configurationJson) {
if (!newJson || !newJson.configurations || newJson.configurations.length === 0) {
throw { message: "Invalid configuration file. There must be at least one configuration present in the array." };
}
if (!this.configurationIncomplete && this.configurationJson && this.configurationJson.configurations &&
this.CurrentConfiguration < this.configurationJson.configurations.length) {
for (let i: number = 0; i < newJson.configurations.length; i++) {
if (newJson.configurations[i].name === this.configurationJson.configurations[this.CurrentConfiguration].name) {
this.currentConfigurationIndex.Value = i;
Expand All @@ -433,6 +442,9 @@ export class CppProperties {
}
}
this.configurationJson = newJson;
if (this.CurrentConfiguration >= newJson.configurations.length) {
this.currentConfigurationIndex.Value = this.getConfigIndexForPlatform(newJson);
}

// Warning: There is a chance that this is incorrect in the event that the c_cpp_properties.json file was created before
// the system includes were available.
Expand Down
50 changes: 27 additions & 23 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,29 +384,33 @@ function reportMacCrashes(): void {
}

// vscode.workspace.createFileSystemWatcher only works in workspace folders.
fs.watch(crashFolder, (event, filename) => {
if (event !== "rename") {
return;
}
if (filename === prevCrashFile) {
return;
}
prevCrashFile = filename;
if (!filename.startsWith("Microsoft.VSCode.CPP.")) {
return;
}
// Wait 5 seconds to allow time for the crash log to finish being written.
setTimeout(() => {
fs.readFile(path.resolve(crashFolder, filename), 'utf8', (err, data) => {
if (err) {
// Try again?
fs.readFile(path.resolve(crashFolder, filename), 'utf8', handleCrashFileRead);
return;
}
handleCrashFileRead(err, data);
});
}, 5000);
});
try {
fs.watch(crashFolder, (event, filename) => {
if (event !== "rename") {
return;
}
if (filename === prevCrashFile) {
return;
}
prevCrashFile = filename;
if (!filename.startsWith("Microsoft.VSCode.CPP.")) {
return;
}
// Wait 5 seconds to allow time for the crash log to finish being written.
setTimeout(() => {
fs.readFile(path.resolve(crashFolder, filename), 'utf8', (err, data) => {
if (err) {
// Try again?
fs.readFile(path.resolve(crashFolder, filename), 'utf8', handleCrashFileRead);
return;
}
handleCrashFileRead(err, data);
});
}, 5000);
});
} catch (e) {
// The file watcher limit is hit (may not be possible on Mac, but just in case).
}
});
}
}
Expand Down
Loading