Compare commits

...
106 Commits
Author SHA1 Message Date
Sean McManus b1274d3c76 Merge pull request #2749 from Microsoft/seanmcm/0_20_1_release
Seanmcm/0 20 1 release
2018-10-31 17:24:43 -07:00
Sean McManus 8f8565dbfd Merge branch 'seanmcm/0_20_1_release' of https://github.com/Microsoft/vscode-cpptools into seanmcm/0_20_1_release 2018-10-31 17:16:30 -07:00
Sean McManus 7f4614c31c Merge again. 2018-10-31 17:15:52 -07:00
Sean McManus eccee49017 Fix punctuation/spacing inconsistencies. (#2750) 2018-10-31 17:12:30 -07:00
Sean McManus e231453778 Merge branch 'release' into seanmcm/0_20_1_release 2018-10-31 16:29:33 -07:00
Sean McManus 8729804dc2 Update version. 2018-10-31 16:27:42 -07:00
Anandlal c607604b6b "taskName" changed to "label" as per version 2.0.0 (#2741)
https://code.visualstudio.com/docs/editor/tasks#_migrating-to-tasks-200
2018-10-31 16:24:50 -07:00
Sean McManus 460b95920f Update changelog, fwlinks, and update telemetry API (#2748)
Update changelog, fwlinks, and update telemetry API
2018-10-31 16:06:34 -07:00
Pierson Lee 1c38b55b9f Update external Console notes
Updated external console option to show changes to support for integratedTerminal.
2018-10-31 12:08:00 -07:00
Sean McManus 0cf237c839 Merge pull request #2725 from Microsoft/master
2nd merge for 0.20.0
2018-10-25 16:46:17 -07:00
Sean McManus e12bad5172 Fix 2 typos in the changelog. (#2723) 2018-10-25 16:42:57 -07:00
Bob Brown 04bb260577 update release notes (#2722) 2018-10-25 16:42:15 -07:00
Bob Brown ddc1f901c2 Merge pull request #2721 from Microsoft/seanmcm/0_20_0_release
Seanmcm/0 20 0 release
2018-10-25 16:21:08 -07:00
Sean McManus 9ca27af2df Merge. 2018-10-25 15:58:34 -07:00
Sean McManus b964d4ebc4 Fix comment for intelliSenseEngine setting. (#2720) 2018-10-25 15:57:20 -07:00
Sean McManus 082435ec8b Fix comment for intelliSenseEngine setting. 2018-10-25 15:48:28 -07:00
Sean McManus 324c5f59f4 Update changelog for 0.20.0 release. 2018-10-25 15:38:26 -07:00
Sean McManus 72581c23b7 Update changelog for 0.20.0. (#2718)
* Update changelog for 0.20.0.

* Revise changelog for 0.20.0.
2018-10-25 15:29:44 -07:00
Sean McManus 807ff80f56 Update vscode telemetry api used. (#2707) 2018-10-23 20:23:12 -07:00
Griffin Downs b0e17a1fd9 Don't update pre-releases (#2693) 2018-10-19 16:00:55 -07:00
Griffin Downs bc64d25a1d Ensure that package version suffix + version suffix version are set (#2686) 2018-10-19 15:29:38 -07:00
Sean McManus ed5d8c8fac Get rid of the MacCrash memory addresses. (#2695) 2018-10-18 19:17:36 -07:00
Sean McManus 3a9f4c404d Update changelog for 0.19.1-insiders3. (#2694) 2018-10-18 17:19:28 -07:00
Bob Brown 4330679e23 Don't allow configuration providers to activate the extension when IntelliSense is disabled (#2692) 2018-10-18 12:29:06 -07:00
Andrew Wang 88e9724892 Attempt to fix security and gulp 4.0 (#2689) 2018-10-17 14:34:21 -07:00
Sean McManus acf7b464eb Update changelog.md. (#2676)
* Update changelog.md.
2018-10-16 13:38:58 -07:00
Sean McManus 78f5a38110 Update changelog for 0.19.1-insiders2 (#2649)
* Update changelog for 0.19.1-insiders2
2018-10-11 15:59:02 -07:00
Pierson Lee 31eed4cee2 Add missing interop 15 file to dev workflow (#2643) 2018-10-11 12:28:32 -07:00
Pierson Lee ea8ab1358f Update CHANGELOG.md and copyDebuggerDependencies (#2641)
Update for VSCodeDebugProtocol dll and for the Integratedterminal Work.
2018-10-10 17:53:20 -07:00
Pierson Lee 55558a53e3 Update links for mono framework and runtime (#2640)
Updating to 5.14.0.177 of mono. Update TPN header per CELA
2018-10-10 16:37:23 -07:00
Griffin Downs 536685c8a0 Grdowns/update channel fix (#2637)
* Use shell optional arg

* Add try/catch around spawn to override any possible exceptions

* Default vsixname to cpptools-linux32.vsix

* Move logFailure inline

* Remove potential PII from error message to be on the safe side

* Fix linter errors

* Remove spawn optional arg; instead remove quotes surrounding command

* Remove rethrowing of error at the top level checkAndApplyUpdate

* Commenting

* Remove default case in switch statement for vsixName; Add x86, i383, i686 cases
2018-10-10 15:51:29 -07:00
Sean McManus b6f184744c Update changelog. (#2625) 2018-10-08 15:04:16 -07:00
Sean McManus 539ecc536f Update the changlog for 0.19.1-insiders. (#2615)
* Update the changlog for 0.19.1-insiders.
2018-10-08 11:42:59 -07:00
Sean McManus e819f36e91 Fix error when rootRui is null. (#2614) 2018-10-05 15:34:44 -07:00
Bob Brown 140670c371 Update c_cpp_properties.json.md 2018-10-04 08:48:54 -07:00
Pierson Lee 102ffc1616 Fixing quoting around ssh's command (#2604)
This fixes #2585
2018-10-03 17:35:02 -07:00
Bob Brown 28981f3ce6 remove telemetry that is already being blocked (#2603) 2018-10-03 16:45:53 -07:00
shankaryoga21 775aba8650 don't use falsy comparisons when resolving default settings. (#2592) 2018-10-02 13:18:16 -07:00
Bob Brown b3fb2558fd update telemetry version (#2593) 2018-10-02 12:46:35 -07:00
Griffin Downs 80716ae228 Grdowns/update channel4 (#2576)
* Remove redundant error telemetry
* Check rate limit before attempting to download release JSON
2018-10-02 10:13:10 -07:00
Bob Brown 6d71c6dd4f Merge pull request #2575 from Microsoft/bobbrow/releaseToMaster
Merge release to master
2018-09-28 09:54:40 -07:00
Bob Brown (DEVDIV) da68908e3e update version and fwlinks for October release 2018-09-28 09:35:26 -07:00
Sean McManus 963ee02117 Merge pull request #2572 from Microsoft/master
Merge latest changes
2018-09-27 15:05:13 -07:00
Sean McManus 45a1804da4 Update changelog. (#2571) 2018-09-27 14:57:45 -07:00
Pierson Lee f66eb138f4 Return null config to VS Code (#2570)
return null to trigger VS Code to open a configuration file
https://github.com/Microsoft/vscode/issues/54213
2018-09-27 14:32:35 -07:00
Bob Brown da862646c3 Merge pull request #2566 from Microsoft/bobbrow/release-19.0
Bobbrow/release 19.0
2018-09-26 16:32:14 -07:00
Bob Brown (DEVDIV) 1bcaa540b6 update version number and fwlink for abtesting json 2018-09-26 16:30:07 -07:00
Bob Brown 96e3386288 september release notes/string changes (#2563) 2018-09-26 13:38:54 -07:00
Sean McManus 862a10f3f8 Merge branch 'master' of https://github.com/Microsoft/vscode-cpptools 2018-09-26 13:16:13 -07:00
Sean McManus 2e62382b24 Update changelog for 0.19.0. 2018-09-26 13:15:40 -07:00
Sean McManus 5f9ef54c54 Add ab testing for Go to Def (fix some ab testing bugs) (#2559)
* Add goto_def_intellisense abTesting.
2018-09-26 09:39:31 -07:00
Bob Brown 4575e2840e incorrect warning messages (#2560) 2018-09-25 17:13:10 -07:00
Bob Brown a9a09dcd11 Only serialize tasks that require it (#2553)
* Remove serialization in the queuing except for cases that actually need it
2018-09-25 13:28:14 -07:00
Bob Brown e0e7944f3a Don't add workspaceFolderBasename to new config files (#2552) 2018-09-25 12:48:14 -07:00
Griffin Downs 63e18afcf1 Update Channel pt 3 (#2543)
* Instead of uninstalling then installing, install and override when prompted
2018-09-24 16:32:06 -07:00
Bob Brown fcdcd80157 Fixing queuing logic that stalls LS on Mac (#2540) 2018-09-24 15:01:06 -07:00
Griffin Downs 126cf7cef6 Update channel feature pt 2 (#2541)
* Find Mac code script; Commenting; Move code into try catches correctly filter errors; Add notification on installation

* Merge files from correct commit

* Revert changes made from not having master branch code
2018-09-21 16:25:27 -07:00
Bob Brown ad451bb438 Resolve empty array environment variables #2532 (#2534) 2018-09-20 16:15:32 -07:00
Griffin Downs 83be111769 Add updateChannel setting (#2465)
* Read json from harded-coded file location

* Expose settings tracker

* Get linux download url

* Remove unused imports

* Correctly get changed setting

* Add update timer

* Minimum end to end

* Refactoring; Commenting; Renaming

* Commenting

* Add optional param to download fn; Refactoring; Renaming

* Commenting; Then parse fn

* Mark vars const; Add todos; Refactoring

* Commenting; Refactoring

* url from any to string; Index into parsed json as separate step

* Use temp files to prevent clutter

* Correct windows platform name check; Replace quotes

* Resolve vsixName for mac + win

* Factor version comparisons into ParsedVersion class while correcting version comparison

* Use which utility to find code script

* Update timer to once per hour

* Move downloadFileToDestination to common; Replace downloadCpptoolsJsonAsync

* Return changed settings on onDidChangeSettings

* Get changed settings without stealing them

* Remove tracker from client interface

* Add basic isReleaseJson fn; Add telemetry; Add catch functions

* Write type predicates for release json

* Refactoring; Rewrite version check; Rewrite build selection

* Factor target build search into helper fn

* Reorder fn defs

* Uninstall version before installing if downgrading

* Add undefined checks; Update version comparison

* Reorder fn

* Telemetry rename; Parse versions more safely

* Turn ParsedVersion into interface; Rename release to build

* Fix fn return types

* Commenting

* Remove unneeded validity check

* Rename telemetry event; Correct fn return type

* Update setting description

* Remove promise rejection

* Remove unwanted changes

* Rename var

* Remove imports; Move call to updateSettingsAsync to .then in abTesting

* Remove import; Remove unneeded uses of await

* Remove comment

* Reformat else ifs

* Remove '| undefined' instances

* Use find fn more idiomatically

* Add type specification for predicates + rename them

* Add url var to shorten call to downloadFileToDestination

* Move parsedVersion to separate file

* Move parsedVersion into PackageVersion class

* Move helper fn's to separate file

* Get script name for both insiders and release VSCode (untested)

* Move packageVersion + ghAPI from LanguageServe to src

* Update imports to reflect mv; Check isValid on PackageVersion

* Add todo's

* Correctly get download URL; Correctly verify releaseJson by only checking recent 5 builds

* Check version numbers against undefined instead of 0

* Await install command before removing install file; Change var name

* Re-merge package.json

* Rename ghAPI.ts to githubAPI.ts

* Rename vars; Remove TODO

* Modify version comparison (untested)

* Remove todo

* Create file async

* Download and install file async

* Rework promises

* Make functions async where possible

* Commenting

* Grandfather in insiders users

* Change syntax via await keyword

* Re-enable interval timer

* Add updateChannel settings get

* Immediately check for update on extension activation if on insiders

* Surround windows code script path in quotes

* Rename versionStr to version

* Change telemetry event

* Update telemetry/exception handling

* Update telemetry strings; Reformat is functions

* Another pass at promises + telemetry

* Commenting

* Remove undefined from fn return

* Fix headers not being forwarded to recursive call

* Another pass at promises

* Correctly return promise in checkAndApplyUpdate

* Remove debug vars

* Rename fns

* Fix version parsing

* Tidy version comparison

* Remove commented out code

* Variable rename; Add newline at EOF

* Add newline at EOF

* Commenting; Unbind functions and use function syntax for .thens

* Error message; add rejection

* Correct exceptions being handled one promise too late

* PR feedback

* Rewrite promise chain to await to allow premature cancellation of promise chain

* Mark vars const; Comment; Rename var
2018-09-19 10:44:24 -07:00
Bob Brown 2f931d930d Implement provider API v2 (#2531)
* Implement provider API v2
2018-09-18 16:33:08 -07:00
Sean McManus bc6cb3e55f Add the active selection end. (#2511)
* Add the active selection end.
2018-09-17 14:11:13 -07:00
Gabriel Arjones f44e9068ca Allow workspaceFolderBasename in default settings (#2503) 2018-09-10 12:33:30 -07:00
Gabriel Arjones c206a4b88c Add support for 'workspaceFolderBasename' expansion (#2491) (#2495) 2018-09-07 15:06:08 -07:00
Bob Brown 9e95e412a8 The user settings were not considered when querying the active configuration provider (#2485) 2018-09-05 12:40:28 -07:00
Bob Brown 86ce6c6115 Update c_cpp_properties.json.md 2018-09-04 09:17:44 -07:00
Pierson Lee ecd3eb24f4 Fix sh command (#2475)
When the change from bash to sh happened, the comparison operator was
not updated.

Fixes #2444
2018-08-31 15:30:33 -07:00
Bob Brown 25e29a01c2 Fix bug in default CL macros (#2468)
* incorrect cl macros being defined
2018-08-30 17:00:56 -07:00
Bob Brown e9b8ad66a1 fix bad line endings (#2469) 2018-08-30 16:48:44 -07:00
Bob Brown 3e5a6aae80 Update c_cpp_properties.json.md 2018-08-28 10:47:22 -07:00
Bob Brown 49fea0249d Update MinGW.md 2018-08-28 10:45:36 -07:00
Bob Brown 7de9956a92 Update Windows Subsystem for Linux.md
a few people seem to be getting confused about the example usage
2018-08-28 08:38:29 -07:00
Bob Brown 9abf44b7ac Update language-service.md (#2454) 2018-08-27 12:52:35 -07:00
Bob Brown daaf169c8a Update Enabling logging.md 2018-08-24 11:27:23 -07:00
Bob Brown 23d94452bb Update MinGW.md 2018-08-20 08:29:41 -07:00
Bob Brown 705122a168 update master branch version (#2428) 2018-08-17 13:53:15 -07:00
Sean McManus 757f1f94be Merge pull request #2427 from Microsoft/master
Update changelog and version for 0.18.1. fwlinks don't need to change…
2018-08-17 11:08:28 -07:00
Sean McManus 7fe2db1202 Update changelog and version for 0.18.1. fwlinks don't need to change. (#2426) 2018-08-17 10:53:49 -07:00
Sean McManus d8738c3e0c Merge pull request #2421 from Microsoft/master
Update changelog. (#2420)
2018-08-17 06:07:19 -07:00
Sean McManus b1bd33b8f4 Update changelog. (#2420) 2018-08-17 06:05:16 -07:00
Sean McManus 436c483d35 Merge pull request #2418 from Microsoft/master
Register the config provider for new clients. (#2416)
2018-08-17 05:05:56 -07:00
Sean McManus 99bd382707 Register the config provider for new clients. (#2416) 2018-08-16 15:50:36 -07:00
Bob Brown 356bb903d0 Merge pull request #2414 from Microsoft/master
Merge for 0.18.0
2018-08-16 10:34:19 -07:00
Sean McManus b0fc9427cf Merge branch 'release' into master 2018-08-16 10:01:07 -07:00
Sean McManus 60b20dce8d Update package-lock and fix new linter errors. (#2412)
Update package-lock and fix new linter errors.
2018-08-16 09:59:18 -07:00
Sean McManus 906fd2d8f0 Seanmcm/auto open cpp properties (#2410)
* Invoke `Edit Configurations...` when the `Configuration Help` button is clicked.
2018-08-16 09:34:20 -07:00
Bob Brown 4afadad93b update changelog (#2411) 2018-08-16 09:22:46 -07:00
Sean McManus 3790fa95e7 Add intelliSenseEngine "Disabled". (#2392)
* Add intelliSenseEngine "Disabled".
2018-08-16 09:12:32 -07:00
Griffin Downs a0882446d9 Update changelog to reflect compile commands parsing fix (#2409)
* Update changelog to reflect compile commands parsing fix
2018-08-16 06:35:39 -07:00
Sean McManus ce59810a6d Update changelog for 0.18.0. (#2384)
* Update changelog for 0.18.0.
2018-08-15 13:45:38 -07:00
Sean McManus 770013d77e Enable environment variables with clang_format_path. (#2380)
* Enable environment variables with clang_format_path.
2018-08-15 09:39:45 -07:00
Pierson Lee 2388fa97f4 Update FAQs.md (#2343) 2018-08-08 11:26:53 -07:00
Sean McManus 3381cde61c Update changelog for 0.17.8-insiders. (#2353)
* Update changelog for 0.17.8-insiders.
2018-08-03 17:36:17 -07:00
Sean McManus 3a46f10d97 Add gcc-x64 intelliSenseMode. (#2315)
* Add gcc-x64 intelliSenseMode.
2018-08-02 13:53:19 -07:00
Bob Brown 2b4b5d397d add a setting to modify the behavior of go to symbol in workspace (#2349)
* add a setting to modify the behavior of go to symbol in workspace
2018-08-02 13:37:47 -07:00
Andy Neff c36eb8e7b1 Using sh instead of bash (#2340)
Fixes #569
2018-07-30 15:37:55 -07:00
Bob Brown ad46d3887a Only allow one configuration popup at a time (#2337) 2018-07-30 14:28:19 -07:00
Bob Brown 8b704f5972 allow users to use ~ for ${userprofile} on Windows (#2333) 2018-07-27 12:50:56 -07:00
Bob Brown 1009b76b22 minor tweaks to config provider experience (#2302) 2018-07-27 09:27:14 -07:00
John Patterson 84ff661e15 adds CHANGELOG entry for PR 2322 (#2325)
Realized I had left out the CHANGELOG update. For [PR
2322](https://github.com/Microsoft/vscode-cpptools/pull/2322).
2018-07-27 09:24:11 -07:00
Xeonacid 2292e7d762 Improve description in Extension/README.md (#2336)
`MinGW` is the proper spelling

`OS X` is now called `macOS`
2018-07-27 09:23:40 -07:00
Andrew Wang c8e30c70b1 Allow telemetry to detect failed downloads (#2332) 2018-07-26 13:35:34 -07:00
John Patterson 7947dd80d6 Add multi-pass environment variable resolution (#2322)
* Dependent variable definition
```
"env": {
    "envRoot": "apps/tool/builldenv",
    "arm6.include": "${envRoot}/arm6/include"
},
...
"some_config": "${arm6.include}
```

* Additionally, this fixes an open bug that was not reported. If a variable contained "env", "config", or "workspaceFolder" it would not be parsed correctly. If you used a variable ${envRoot} it would match "envR" as the type and "oot" as the variable. This has been resolved.

* Also fixes travis-ci to run the unit tests as part of checkin validation
2018-07-24 14:40:58 -07:00
John Patterson 913f740cc2 adds settings for inactive region font & bg color (#2308)
* adds settings for inactive region font & bg color

This adds the inactiveRegionForegroundColor and inactiveRegionBackgroundColor
settings. If a preprocessor block is found to be inactive, it will be
colored by these fields if they are set. They accept hexadecimal font
strings or valid theme colors as their values.These fields also
interactive with the dimInactiveRegions setting.

This was requested in issue
https://github.com/Microsoft/vscode-cpptools/issues/2212.
2018-07-23 15:52:41 -07:00
Sean McManus 2cbc90d98b Fix empty windowsSDKVersion. (#2301) 2018-07-20 17:07:14 -07:00
Bob Brown 25a29d0bc3 update fwlinks 2018-07-20 10:45:55 -07:00
Bob Brown 052f4e7b39 update version 2018-07-20 10:34:59 -07:00
50 changed files with 5410 additions and 1581 deletions
+10 -6
View File
@@ -4,10 +4,12 @@ about: 'Issues pertaining to IntelliSense, autocomplete, code editing, etc. '
---
Type: LanguageService
**----- Input information below -----**
**Type: LanguageService**
<!----- Input information below ----->
<!--
**Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.**
-->
**Describe the bug**
- OS and Version:
@@ -17,19 +19,21 @@ Type: LanguageService
- A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
*Provide a code sample including configuration files such as c_cpp_properties.json*
<!-- Steps to reproduce the behavior: -->
<!-- *The most actionable issue reports include a code sample including configuration files such as c_cpp_properties.json* -->
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. -->
**Screenshots**
If applicable, add screenshots to help explain your problem.
<!-- If applicable, add screenshots to help explain your problem. -->
**Additional context**
<!--
*Call Stacks: For bugs like crashes, deadlocks, infinite loops, etc. that we are not able to repro and for which the call stack may be useful, please attach a debugger and/or create a dmp and provide the call stacks. Starting with 0.17.3, Windows binaries have symbols available in VS Code by setting your "symbolSearchPath" to "http://msdl.microsoft.com/download/symbols".*
Add any other context about the problem here including log messages in your Output window ("C_Cpp.loggingLevel": "Debug" in settings.json).
-->
+3 -1
View File
@@ -35,7 +35,9 @@ script:
- npm run tslint
# pr-check needs to run before test. test modifies package.json.
- npm run pr-check
- npm run test
- npm run unitTests
# TODO: Merge tests into one group due to Gulp 4.0
- npm run integrationTests
# Dump integrationTest.log output
- find ~ -name "integrationTests.log" -type f -exec cat {} \;
+2 -2
View File
@@ -4,7 +4,7 @@
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"label": "build",
"type": "shell",
"group": {
"kind": "build",
@@ -47,4 +47,4 @@
}
}
]
}
}
+38 -1
View File
@@ -3,7 +3,8 @@
## Table of Contents
* Setup: [Debugging Setup](#debugging-setup)
* Debugger: [Why is debugging not working?](#why-is-debugging-not-working)
* Build: [How to enable debug symbols?](#how-to-enable-debug-symbols)
* Build: [How to enable debug symbols](#how-to-enable-debug-symbols)
* Logging: [How to enable logging](#how-to-enable-logging)
## Debugging Setup
The debugger needs to be configured to know which executable and debugger to use:
@@ -43,3 +44,39 @@ When in doubt, please check your compiler's documentation for the options necess
* #### cl.exe
Symbols are located in the `*.pdb` file.
## How to enable logging
Enabling logging will show communication information between VS Code and our extension and between our extension and the debugger.
### Logging for `MI` debuggers
The logging block with its defaults is as follows:
```
"logging": {
"trace": false,
"traceResponse": false,
"engineLogging": false
}
```
#### VS Code and the CppTools extension
The logging here is called `trace` logging and can be enabled by setting `trace` and `traceResponse` to `true` in the logging block inside `launch.json`. This will help diagnose issues related to VS Code's communication to our extension and our responses.
#### CppTools extension and the debugger
The logging between CppTools and the debugger is called `engineLogging`. When using an `MI` debugger such as `gdb` or `lldb`, this will show the request, response and events using the `mi` interpreter. This logging will help us determine whether the debugger is receiving the right commands and generating the correct responses.
### Logging for `Visual C++` debugger
The logging block with its defaults is as follows:
```
"logging": {
"engineLogging": false
}
```
The `Visual C++` debugger logging will show only the communication to and from VS Code as all communication to the debugger is done internally to the process and is not visible through logging.
@@ -2,9 +2,9 @@
If you are experiencing a problem that we are unable to diagnose based on information in your issue report, we might ask you to enable logging and send us your logs.
As of version 0.14.0 of the extension, logging information is now delivered directly to the Output window in VSCode. To turn on full logging for an issue report, add `"C_Cpp.loggingLevel": "Information"` to your **settings.json**.
As of version 0.14.0 of the extension, logging information is now delivered directly to the Output window in VSCode. To turn on full logging for an issue report, add `"C_Cpp.loggingLevel": "Information"` or `"C_Cpp.loggingLevel": "Debug"` to your **settings.json**.
![image](https://user-images.githubusercontent.com/12818240/31898313-b32ff284-b7cd-11e7-97f5-89df93b5d9de.png)
![image](https://user-images.githubusercontent.com/12818240/44601186-8a2af380-a790-11e8-9094-7064d1ba3cfb.png)
VS Code organizes the logging from different extensions to improve readability so you must select the "C/C++" option in the log filter selector to see logging from the C/C++ extension:
+2 -9
View File
@@ -4,24 +4,17 @@ To use MinGW on Windows, we recommend you add the following configuration to you
## Extension version 0.17.0 and higher:
When you set the `compilerPath` property and change `intelliSenseMode` to `clang-x64`, you no longer need to copy the system include path or defines to `includePath`, `browse.path`, or `defines` to enable IntelliSense to work properly. For example:
When you set the `compilerPath` property and change `intelliSenseMode` to `clang-x64` (or `gcc-x64` in version 0.18.0 and higher), you no longer need to copy the system include path or defines to `includePath`, `browse.path`, or `defines` to enable IntelliSense to work properly. For example:
```json
{
"name": "MinGW",
"intelliSenseMode": "clang-x64",
"intelliSenseMode": "gcc-x64",
"compilerPath": "C:/mingw64/bin/gcc.exe",
"includePath": [
"${workspaceFolder}"
],
"defines": [],
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++17"
}
@@ -1,6 +1,6 @@
# Windows Subsystem for Linux
> **Note:** If you are on **build 17110 of Windows or higher**, you must use version 0.17.0 or higher for IntelliSense to work. The Windows team turned on case-sensitive folders for the WSL environment and the C/C++ extension doesn't support case-sensitive folders until version 0.17.0.
> **Note:** If you are on **build 17110 of Windows or higher**, you must use extension version 0.17.0 or higher for IntelliSense to work. The Windows team turned on case-sensitive folders for the WSL environment and the C/C++ extension doesn't support case-sensitive folders until version 0.17.0.
To use the Windows Subsystem for Linux with this extension you need to add a configuration to your **c_cpp_properties.json** file which adds the necessary header paths from within the WSL filesystem to the `includePath`.
@@ -13,22 +13,12 @@ In **c_cpp_properties.json** you can directly address your WSL compiler and incl
```json
{
"name": "WSL",
"intelliSenseMode": "clang-x64",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"includePath": [
"${workspaceFolder}",
"/mnt/c/libraries/lib1/include",
"C:/libraries/lib2/include"
"${workspaceFolder}/**"
],
"defines": [],
"browse": {
"path": [
"${workspaceFolder}",
"/mnt/c/libraries"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++17"
}
@@ -53,7 +53,7 @@
A friendly name for the configuration. "Linux", "Mac", and "Win32" are special names that instruct the extension to load that configuration by default on the associated operating system unless additional configurations have been created. The status bar in VS Code will show you which configuration is active. You can also click on the label in the status bar to change the active configuration.
* #### `intelliSenseMode`
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.
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 CLang mode with 64-bit pointer sizes. `"gcc-x64"` maps to GCC mode with 64-bit pointer sizes. Windows uses `"msvc-x64"` by default, macOS uses `"clang-x64"` by default, and Linux uses `"gcc-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. If a path ends with `/**` the IntelliSense engine will do a recursive search for includes starting from that directory. If on Windows with Visual Studio installed, or if a compiler is specified in the `compilerPath` setting, it is not necessary to list the system include paths in this list.
@@ -68,7 +68,11 @@
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.
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`, `-fno-ms-extensions`, etc., but paths with spaces must be surrounded by double quotes (`"`) if args are used.
If you want to disable automatic querying of system include paths and defines, set this value to the emptry string `""`. This is generally not recommended, but there are some cases where automatic querying of system includes and defines is undesirable.
* #### `cStandard`
The C standard revision to use for IntelliSense in your project.
@@ -87,7 +91,7 @@
### Browse properties
* #### `path`
This list of paths will be used by the Tag Parser to search for headers included by your source files. The Tag Parser will automatically search all subfolders in these paths unless the path ends with a `/*` or `\*`. For example, `/usr/include` directs the Tag Parser to search the `include` folder and its subfolders for headers while `/usr/include/*` directs the Tag Parser not to look in any subfolders of `/usr/include`.
This list of paths will be used by the Tag Parser to search for headers included by your source files. If omitted, `includePath` will be used as the `path`. The Tag Parser will automatically search all subfolders in these paths unless the path ends with a `/*` or `\*`. For example, `/usr/include` directs the Tag Parser to search the `include` folder and its subfolders for headers while `/usr/include/*` directs the Tag Parser not to look in any subfolders of `/usr/include`.
* #### `limitSymbolsToIncludedHeaders`
When true, the Tag Parser will only parse code files that have been directly or indirectly included by a source file in `${workspaceFolder}`. When false, the Tag Parser will parse all code files found in the paths specified in the **path** list.
+2 -1
View File
@@ -17,4 +17,5 @@ install.lock
*.vsix
# ignore vscode test
.vscode-test/
.vscode-test/
browse*db*
+1 -1
View File
@@ -24,7 +24,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
"--extensionTestsPath=${workspaceFolder}/out/test/unitTests"
],
"stopOnEntry": false,
"sourceMaps": true,
+92 -2
View File
@@ -1,6 +1,96 @@
# C/C++ for Visual Studio Code Change Log
## Version 0.17.7: July 19, 2018
## Version 0.20.1: October 31, 2018
* Fix IntelliSense-based `Go to Declaration` when there's only a definition in a TU. [#2743](https://github.com/Microsoft/vscode-cpptools/issues/2743)
* Fix `#include` completion for standalone header files. [#2744](https://github.com/Microsoft/vscode-cpptools/issues/2744)
* Fix the highest hitting main process crash.
* Fix IntelliSense process crash with completion.
## Version 0.20.0: October 30, 2018
* Add IntegratedTerminal support for Linux and Windows. [#35](https://github.com/microsoft/vscode-cpptools/issues/35)
* Unify Visual Studio Code debug protocol parsing by using a shared library with Visual Studio.
* Fix IntelliSense-based `Go to Definition` on overloads (in the same TU). [#1071](https://github.com/Microsoft/vscode-cpptools/issues/1071)
* Fix inactive regions not being disabled when falling back to the Tag Parser. [#2181](https://github.com/Microsoft/vscode-cpptools/issues/2181)
* Fix `#include` completion not working with `compile_commands.json` or custom configuration providers. [#2242](https://github.com/Microsoft/vscode-cpptools/issues/2242)
* Fix IntelliSense failing if recursive includes removes all paths. [#2442](https://github.com/Microsoft/vscode-cpptools/issues/2442)
* Fix incorrect IntelliSense errors with MinGW (stop using `-fms-extensions` by default). [#2443](https://github.com/Microsoft/vscode-cpptools/issues/2443), [#2623](https://github.com/Microsoft/vscode-cpptools/issues/2623)
* Fix error squiggles sometimes not updating after typing. [#2448](https://github.com/Microsoft/vscode-cpptools/issues/2448)
* Add support for Mac framework paths in `compile_commands.json`. [#2508](https://github.com/Microsoft/vscode-cpptools/issues/2508)
* Fix IntelliSense-based `Go to Definition` falling back to the Tag Parser for definitions not in the TU. [#2536](https://github.com/Microsoft/vscode-cpptools/issues/2536), [#2677](https://github.com/Microsoft/vscode-cpptools/issues/2677)
* Fix IntelliSense-based `Go to Definition` on the identifier of a definition with no declaration. [#2573](https://github.com/Microsoft/vscode-cpptools/issues/2573)
* Fix IntelliSense-based `Go to Definition` not falling back to the declaration (in certain cases). [#2574](https://github.com/Microsoft/vscode-cpptools/issues/2574)
* Fix IntelliSense-based `Go to Definition` going to the wrong location after edits are made. [#2579](https://github.com/Microsoft/vscode-cpptools/issues/2579)
* Fix `Go to Definition` when the `intelliSenseEngineFallback` is `Disabled` and `#include`s are missing. [#2583](https://github.com/Microsoft/vscode-cpptools/issues/2583)
* Fix empty `C_Cpp.default.*` settings not being used. [#2584](https://github.com/Microsoft/vscode-cpptools/issues/2584)
* Fix quoting around `ssh`'s command (for the debugger). [#2585](https://github.com/Microsoft/vscode-cpptools/issues/2585)
* Fix crash on hover (and `Go to Definition`) when using the `Tag Parser`. [#2586](https://github.com/Microsoft/vscode-cpptools/issues/2586)
* Fix errors when a workspace folder isn't open. [#2613](https://github.com/Microsoft/vscode-cpptools/issues/2613), [#2691](https://github.com/Microsoft/vscode-cpptools/issues/2691)
* Fix `-isystem` without a space after getting ignored in `compile_comamands.json`. [#2629](https://github.com/Microsoft/vscode-cpptools/issues/2629)
* Fix Insiders update channel installation bugs. [#2636](https://github.com/Microsoft/vscode-cpptools/issues/2636), [#2685](https://github.com/Microsoft/vscode-cpptools/issues/2685)
* Fix IntelliSense-based `Go to Declaration` falling back to the Tag Parser if the definition is also in the TU. [#2642](https://github.com/Microsoft/vscode-cpptools/issues/2642)
* Fix the `Disabled` `intelliSenseEngine` setting not working with custom configuration providers. [#2656](https://github.com/Microsoft/vscode-cpptools/issues/2656)
## Version 0.19.0: September 27, 2018
* Change the symbol database to update without needing to save. [#202](https://github.com/Microsoft/vscode-cpptools/issues/202)
* Enable IntelliSense-based `Go to Definition` for the current translation unit, including local variables and overloaded operators. [#255](https://github.com/Microsoft/vscode-cpptools/issues/255), [#979](https://github.com/Microsoft/vscode-cpptools/issues/979)
* Improved the `Go to Definition` performance with large workspaces and files with lots of `#include`s. [#273](https://github.com/Microsoft/vscode-cpptools/issues/273)
* Disable `Go to Definition` for invalid tokens, e.g. comments, strings, keywords, etc. [#559](https://github.com/Microsoft/vscode-cpptools/issues/559)
* Add `C_Cpp.updateChannel` setting for easier access to Insider builds of the extension. [#1526](https://github.com/Microsoft/vscode-cpptools/issues/1526)
* Add support for v2 of the configuration provider API. [#2237](https://github.com/Microsoft/vscode-cpptools/issues/2237)
* Fix bug with parsing definitions in `compile_commands.json`. [#2305](https://github.com/Microsoft/vscode-cpptools/issues/2305)
* Fix `sh` failure when attaching to a remote Linux process. [#2444](https://github.com/Microsoft/vscode-cpptools/issues/2444)
* Fix incorrect default `cl.exe` macro. [PR #2468](https://github.com/Microsoft/vscode-cpptools/issues/2468)
* Fix multiple bugs with the symbols in the Outline view not updating correctly. [#2477](https://github.com/Microsoft/vscode-cpptools/issues/2477), [#2500](https://github.com/Microsoft/vscode-cpptools/issues/2500), [#2504](https://github.com/Microsoft/vscode-cpptools/issues/2504)
* Add support for `workspaceFolderBasename` expansion. [#2491](https://github.com/Microsoft/vscode-cpptools/issues/2491)
* Gabriel Arjones (@g-arjones) [PR #2495](https://github.com/Microsoft/vscode-cpptools/pull/2495), [PR #2503](https://github.com/Microsoft/vscode-cpptools/pull/2503)
* Fix bug with variable resolution. [#2532](https://github.com/Microsoft/vscode-cpptools/issues/2532)
* Fix off-by-one bug with hover and `Go to Definition`. [#2535](https://github.com/Microsoft/vscode-cpptools/issues/2535)
* Fix for [Microsoft/vscode#54213](https://github.com/Microsoft/vscode/issues/54213)
## Version 0.18.1: August 17, 2018
* Fix 0.18.0 regression causing non-MinGW compilers to use `-fms-extensions` on Windows. [#2424](https://github.com/Microsoft/vscode-cpptools/issues/2424), [#2425](https://github.com/Microsoft/vscode-cpptools/issues/2425)
## Version 0.18.0: August 17, 2018
### New Features
* Add the `C_Cpp.intelliSenseEngine` setting value of `Disabled` (for users who only use the debugger). [#785](https://github.com/Microsoft/vscode-cpptools/issues/785)
* Add `C_Cpp.workspaceSymbols` setting with default `Just My Code` to filter out system header symbols. [#1119](https://github.com/Microsoft/vscode-cpptools/issues/1119), [#2320](https://github.com/Microsoft/vscode-cpptools/issues/2320)
* Add `C_Cpp.inactiveRegionForegroundColor` and `C_Cpp.inactiveRegionBackgroundColor` settings. [#1620](https://github.com/Microsoft/vscode-cpptools/issues/1620), [#2212](https://github.com/Microsoft/vscode-cpptools/issues/2212)
* John Patterson (@john-patterson) [PR #2308](https://github.com/Microsoft/vscode-cpptools/pull/2308)
* Add `gcc-x64` `intelliSenseMode` and send the correct clang or gcc version to our parser, fixing various IntelliSense errors. [#2112](https://github.com/Microsoft/vscode-cpptools/issues/2112), [#2175](https://github.com/Microsoft/vscode-cpptools/issues/2175), [#2260](https://github.com/Microsoft/vscode-cpptools/issues/2260), [#2299](https://github.com/Microsoft/vscode-cpptools/issues/2299), [#2317](https://github.com/Microsoft/vscode-cpptools/issues/2317)
* Make `Go to Definition` on the definition go to the declaration instead. [#2298](https://github.com/Microsoft/vscode-cpptools/issues/2298)
* Add multi-pass environment variable resolution allowing variables defined in terms of other variables. [#2057](https://github.com/Microsoft/vscode-cpptools/issues/2057)
* John Patterson (@john-patterson) [PR #2322](https://github.com/Microsoft/vscode-cpptools/pull/2322)
* Allow users to use `~` for `${userProfile}` on Windows. [PR #2333](https://github.com/Microsoft/vscode-cpptools/pull/2333)
* Add support for compiler flags `-fms-extensions` and `-fno-ms-extensions` on Windows (the default for MinGW-based compilers). [#2363](https://github.com/Microsoft/vscode-cpptools/issues/2363)
* Make completion "show more results" (i.e. inaccessible members) when invoked a 2nd time. [#2386](https://github.com/Microsoft/vscode-cpptools/issues/2386)
### Bug Fixes
* Fix attach to process for systems without `bash` by using `sh` instead. [#569](https://github.com/Microsoft/vscode-cpptools/issues/569)
* Andy Neff (@andyneff) [PR #2340](https://github.com/Microsoft/vscode-cpptools/pull/2340)
* Fix IntelliSense crash after hover or completion with `_Complex` types. [#689](https://github.com/Microsoft/vscode-cpptools/issues/689), [#1112](https://github.com/Microsoft/vscode-cpptools/issues/1112)
* Fix `files.exclude` not working to exclude non-workspace folders from symbol parsing. [#1066](https://github.com/Microsoft/vscode-cpptools/issues/1066)
* Fix `Switch Header/Source` to give results that match the parent folder name before using just the file name. [#1085](https://github.com/Microsoft/vscode-cpptools/issues/1085)
* Fix incorrect IntelliSense errors caused by namespace lookup failure when instantiation template arguments in clang mode. [#1395](https://github.com/Microsoft/vscode-cpptools/issues/1395), [#1559](https://github.com/Microsoft/vscode-cpptools/issues/1559), [#1753](https://github.com/Microsoft/vscode-cpptools/issues/1753), [#2272](https://github.com/Microsoft/vscode-cpptools/issues/2272)
* Fix missing parameter help when using { for constructors. [#1667](https://github.com/Microsoft/vscode-cpptools/issues/1667)
* Fix Mac framework dependencies not being discovered. [#1913](https://github.com/Microsoft/vscode-cpptools/issues/1913)
* Fix `compilerPath` not working with `${workspaceFolder}`. [#1982](https://github.com/Microsoft/vscode-cpptools/issues/1982)
* Fix red flame getting stuck after modifying `c_cpp_properties.json`. [#2077](https://github.com/Microsoft/vscode-cpptools/issues/2077)
* Don't add empty `windowsSDKVersion` if none exists. [#2300](https://github.com/Microsoft/vscode-cpptools/issues/2300)
* Fix IntelliSense crash when the gcc-8 type_traits header is used. [#2323](https://github.com/Microsoft/vscode-cpptools/issues/2323), [#2328](https://github.com/Microsoft/vscode-cpptools/issues/2328)
* Limit configuration popups to one at a time. [#2324](https://github.com/Microsoft/vscode-cpptools/issues/2324)
* Don't show `includePath` code actions if compile commands or custom configuration providers are used. [#2334](https://github.com/Microsoft/vscode-cpptools/issues/2334)
* Fix `C_Cpp.clang_format_path` not accepting environment variables. [#2344](https://github.com/Microsoft/vscode-cpptools/issues/2344)
* Fix IntelliSense not working with non-ASCII characters in the WSL install path. [#2351](https://github.com/Microsoft/vscode-cpptools/issues/2351)
* Filter out buggy IntelliSense error `"= delete" can only appear on the first declaration of a function`. [#2352](https://github.com/Microsoft/vscode-cpptools/issues/2352)
* Fix IntelliSense failing with WSL if gcc is installed bug g++ isn't. [#2360](https://github.com/Microsoft/vscode-cpptools/issues/2360)
* Fix WSL paths starting with `/mnt/` failing to get symbols parsed. [#2361](https://github.com/Microsoft/vscode-cpptools/issues/2361)
* Fix IntelliSense process crash when hovering over a designated initializer list with an anonymous struct. [#2370](https://github.com/Microsoft/vscode-cpptools/issues/2370)
* Stop showing "File: " in completion details for internal compiler defines. [#2387](https://github.com/Microsoft/vscode-cpptools/issues/2387)
* Invoke `Edit Configurations...` when the `Configuration Help` button is clicked. [#2408](https://github.com/Microsoft/vscode-cpptools/issues/2408)
* Fix provider configuration prompt not showing for newly added workspace folders. [#2415](https://github.com/Microsoft/vscode-cpptools/issues/2415)
* Fix to allow SIGINT to be sent using the kill -2 command when using pipeTransport.
## Version 0.17.7: July 22, 2018
* Fix `Go to Definition` for code scoped with an aliased namespace. [#387](https://github.com/Microsoft/vscode-cpptools/issues/387)
* Fix incorrect IntelliSense errors with template template-arguments. [#1014](https://github.com/Microsoft/vscode-cpptools/issues/1014)
* Fix crash when using designated initializer lists. [#1440](https://github.com/Microsoft/vscode-cpptools/issues/1440)
@@ -437,7 +527,7 @@
* Switch between header and source.
* Control which files are processed under include path.
## Version 0.6.1: June 03, 2016
## Version 0.6.1: June 3, 2016
* Bug fixes.
## Version 0.6.0: May 24, 2016
+1 -1
View File
@@ -11,7 +11,7 @@ This preview release of the extension adds language support for C/C++ to Visual
* Quick Info (Hover)
* Error Squiggles
* Debugging
* Support for debugging Windows (PDB, Mingw/Cygwin), Linux and OS X applications
* Support for debugging Windows (PDB, MinGW/Cygwin), Linux and macOS applications
* Line by line code stepping
* Breakpoints (including conditional and function breakpoints)
* Variable inspection
+5 -8
View File
@@ -205,11 +205,8 @@
<tr>
<td>
<div>
<h2 class="caption">June 2018 Update</h2>
<div>Thank you for installing the C/C++ extension. In the June update, we focused on workspace configuration improvements.<br/>
<br/>
We dramatically improved the performance of recursive includes (e.g. using <code>${workspaceFolder}/**</code> in your <code>includePath</code>), we will prompt you to
use compile_commands.json if it is found in your workspace, and we made the <code>browse.path</code> setting optional in the case that it is identical to your <code>includePath</code>.<br/>
<h2 class="caption">October 2018 Update</h2>
<div>Thank you for installing the C/C++ extension. In the October update, we finished our semantic-aware implementation of Go To Definition. We also added IntegratedTerminal support for debugging.<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>
@@ -234,9 +231,9 @@
<td>
<div>
<h3 class="caption">Blog Posts</h3>
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2018/05/08/visual-studio-code-cc-extension-may-2018-update-intellisense-configuration-just-got-so-much-easier/">May 2018 Update</a></div>
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2018/03/29/visual-studio-code-cc-extension-march-2018-update/">March 2018 Update</a></div>
<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/08/23/visual-studio-code-c-c-extension-august-2018-update/">August 2018 Update</a></div>
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2018/07/25/visual-studio-code-cc-extension-july-2018-update-and-intellisense-auto-configuration-for-cmake/">July 2018 Update</a></div>
<div><a href="https://blogs.msdn.microsoft.com/vcblog/2018/06/21/visual-studio-code-cc-extension-june-2018-update/">June 2018 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>
+11 -3
View File
@@ -1,8 +1,16 @@
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
THIRD PARTY SOFTWARE NOTICES AND INFORMATION
Do Not Translate or Localize
Microsoft C/C++ Extension for Visual Studio Code incorporates components from the projects listed below. Microsoft licenses these components under the Microsoft C/C++ Extension for Visual Studio Code license terms, except as noted. The original copyright notices and the licenses under which Microsoft received such components are set forth below for informational purposes. Microsoft reserves all rights not expressly granted herein, whether by implication, estoppel or otherwise.
This Microsoft product may utilize material made available by third parties under the following license terms. Any source code that Microsoft is required to make available can be found at http://3rdpartysource.microsoft.com. You may also obtain a copy of any such source code (during the period provided by the license) by sending a check or money order for US $5.00 to:
Source Code Compliance Team
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052 USA
Please write “Source for [OSS PROJECT NAME]” in the memo line of your payment.
1. agent-base (https://github.com/TooTallNate/node-agent-base)
2. ANTLR (http://www.antlr2.org/)
-1
View File
@@ -1,6 +1,5 @@
{
"defaults": [
"--clang",
"--pack_alignment",
"8"
],
+1 -1
View File
@@ -12,7 +12,7 @@
"-D_MSC_FULL_VER=191426428",
"-D_MSC_BUILD=0",
"-D_M_X64=100",
"-D_AMD64=100"
"-D_M_AMD64=100"
],
"defaults_op" : "merge"
}
-1
View File
@@ -1,6 +1,5 @@
{
"defaults": [
"--clang",
"--pack_alignment",
"8"
],
+1 -1
View File
@@ -12,7 +12,7 @@
"-D_MSC_FULL_VER=191426428",
"-D_MSC_BUILD=0",
"-D_M_X64=100",
"-D_AMD64=100"
"-D_M_AMD64=100"
],
"defaults_op" : "merge"
}
-1
View File
@@ -1,6 +1,5 @@
{
"defaults": [
"--clang",
"--pack_alignment",
"8"
],
+1 -1
View File
@@ -12,7 +12,7 @@
"-D_MSC_FULL_VER=191426428",
"-D_MSC_BUILD=0",
"-D_M_X64=100",
"-D_AMD64=100"
"-D_M_AMD64=100"
],
"defaults_op" : "merge"
}
+3 -2
View File
@@ -71,10 +71,11 @@
}
},
"intelliSenseMode": {
"description": "If set, it overrides the default mode used by the IntelliSense engine. Windows defaults to msvc-x64 and Linux/Mac default to clang-x64.",
"description": "If set, it overrides the default mode used by the IntelliSense engine. Windows defaults to msvc-x64, Linux defaults to gcc-x64, and Mac default to clang-x64.",
"type": "string",
"enum": [
"msvc-x64",
"gcc-x64",
"clang-x64",
"${default}"
]
@@ -120,7 +121,7 @@
"type": "object",
"description": "Custom variables that can be reused anywhere in this file using the ${variable} or ${env:variable} syntax.",
"patternProperties": {
"(?!^workspaceFolder$)(?!^workspaceRoot$)(?!^default$)(^.+$)": {
"(?!^workspaceFolder$)(?!^workspaceRoot$)(?!^workspaceFolderBasename$)(?!^default$)(^.+$)": {
"oneOf": [
{
"type": "string"
+2 -1
View File
@@ -1,5 +1,6 @@
{
"intelliSenseEngine_default_percentage": 100,
"defaultIntelliSenseEngine": 100,
"recursiveIncludes": 100
"recursiveIncludes": 100,
"gotoDefIntelliSense": 100
}
+34 -31
View File
@@ -12,41 +12,39 @@ const mocha = require('gulp-mocha');
const fs = require('fs');
const optionsSchemaGenerator = require('./out/tools/GenerateOptionsSchema');
gulp.task('allTests', () => {
gulp.start('unitTests');
gulp.start('integrationTests');
});
gulp.task('unitTests', (done) => {
env.set({
CODE_TESTS_PATH: "./out/test/unitTests",
});
gulp.task('unitTests', () => {
gulp.src('./out/test/unitTests', {read: false}).pipe(
mocha({
ui: "tdd"
return gulp.src('./test/runVsCodeTestsWithAbsolutePaths.js', {read: false})
.pipe(mocha({ ui: "tdd" }))
.once('error', err => {
done();
process.exit(1);
})
).once('error', err => {
process.exit(1);
})
.once('end', () => {
process.exit();
})
.once('end', () => {
done();
process.exit();
});
});
gulp.task('integrationTests', () => {
gulp.task('integrationTests', (done) => {
env.set({
CODE_TESTS_PATH: "./out/test/integrationTests",
CODE_TESTS_WORKSPACE: "./test/integrationTests/testAssets/SimpleCppProject"
}
);
gulp.src('./test/runVsCodeTestsWithAbsolutePaths.js', {read: false}).pipe(
mocha({
ui: "tdd",
delay: true
});
return gulp.src('./test/runVsCodeTestsWithAbsolutePaths.js', {read: false})
.pipe(mocha({ ui: "tdd" }))
.once('error', err => {
done();
process.exit(1);
})
).once('error', err => {
process.exit(1);
})
.once('end', () => {
process.exit();
})
.once('end', () => {
done();
process.exit();
});
});
/// Misc Tasks
@@ -67,7 +65,7 @@ const lintReporter = (output, file, options) => {
};
gulp.task('tslint', () => {
gulp.src(allTypeScript)
return gulp.src(allTypeScript)
.pipe(tslint({
program: require('tslint').Linter.createProgram("./tsconfig.json"),
configuration: "./tslint.json"
@@ -78,14 +76,19 @@ gulp.task('tslint', () => {
}))
});
gulp.task('pr-check', () => {
gulp.task('pr-check', (done) => {
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
if (packageJson.activationEvents.length !== 1 && packageJson.activationEvents[0] !== '*') {
if (packageJson.activationEvents.length !== 1 && packageJson.activationEvents[0] !== '*') {
console.log('Please make sure to not check in package.json that has been rewritten by the extension activation. If you intended to have changes in package.json, please only check-in your changes. If you did not, please run `git checkout -- package.json`.');
done();
process.exit(1);
}
done();
});
gulp.task('generateOptionsSchema', () => {
gulp.task('generateOptionsSchema', (done) => {
optionsSchemaGenerator.generateOptionsSchema();
done();
});
+3349 -1040
View File
File diff suppressed because it is too large Load Diff
+58 -16
View File
@@ -2,7 +2,7 @@
"name": "cpptools",
"displayName": "C/C++",
"description": "C/C++ IntelliSense, debugging, and code browsing.",
"version": "0.17.7",
"version": "0.20.1",
"publisher": "ms-vscode",
"preview": true,
"icon": "LanguageCCPP_color_128x.png",
@@ -63,7 +63,7 @@
],
"configuration": {
"type": "object",
"title": "C/C++ Configuration",
"title": "C/C++",
"properties": {
"C_Cpp.clang_format_path": {
"type": [
@@ -104,10 +104,11 @@
"type": "string",
"enum": [
"Default",
"Tag Parser"
"Tag Parser",
"Disabled"
],
"default": "Default",
"description": "Controls the IntelliSense provider. \"Tag Parser\" provides \"fuzzy\" results that are not context-aware. \"Default\" provides context-aware results and is in preview mode - member list, hover tooltips, and error squiggles are currently implemented. Features not yet implemented in the new default engine will use the tag parser engine instead.",
"description": "Controls the IntelliSense provider. \"Tag Parser\" provides \"fuzzy\" results that are not context-aware. \"Default\" provides context-aware results. \"Disabled\" turns off C/C++ language service features.",
"scope": "resource"
},
"C_Cpp.intelliSenseEngineFallback": {
@@ -154,6 +155,24 @@
"minimum": 0.1,
"maximum": 1
},
"C_Cpp.inactiveRegionForegroundColor": {
"type": [
"string",
"null"
],
"default": null,
"description": "Controls the font coloring of inactive preprocessor blocks. Input is in the form a hexadecimal color code or a valid Theme Color. If not set, this defaults to the syntax coloring scheme of the editor. This setting only applies when inactive region dimming is enabled.",
"scope": "resource"
},
"C_Cpp.inactiveRegionBackgroundColor": {
"type": [
"string",
"null"
],
"default": null,
"description": "Controls the background coloring of inactive preprocessor blocks. Input is in the form a hexadecimal color code or a valid Theme Color. If not set, this defaults to transparent. This setting only applies when inactive region dimming is enabled.",
"scope": "resource"
},
"C_Cpp.formatting": {
"type": "string",
"enum": [
@@ -201,6 +220,16 @@
"description": "Controls whether parsing of the non-active workspace files uses sleeps to avoid using 100% CPU. The values highest/high/medium/low correspond to approximately 100/75/50/25% CPU usage.",
"scope": "resource"
},
"C_Cpp.workspaceSymbols": {
"type": "string",
"enum": [
"All",
"Just My Code"
],
"default": "Just My Code",
"description": "The symbols to include in the query results when 'Go to Symbol in Workspace' is invoked",
"scope": "resource"
},
"C_Cpp.exclusionPolicy": {
"type": "string",
"enum": [
@@ -334,6 +363,7 @@
],
"enum": [
"msvc-x64",
"gcc-x64",
"clang-x64"
],
"default": null,
@@ -426,6 +456,16 @@
"default": null,
"description": "The value to use for the system include path. If set, it overrides the system include path acquired via \"compilerPath\" and \"compileCommands\" settings.",
"scope": "resource"
},
"C_Cpp.updateChannel": {
"type": "string",
"enum": [
"Default",
"Insiders"
],
"default": "Default",
"description": "Set to \"Insiders\" to automatically download and install the latest Insiders builds of the extension, which include upcoming features and bug fixes.",
"scope": "resource"
}
}
},
@@ -1347,7 +1387,9 @@
"devDependencies": {
"@types/mocha": "^2.2.43",
"@types/node": "^8.0.46",
"gulp": "3.9.1",
"async-child-process": "^1.1.1",
"child-process": "^1.0.2",
"gulp": "^4.0.0",
"gulp-env": "0.4.0",
"gulp-mocha": "5.0.0",
"gulp-tslint": "8.1.2",
@@ -1366,17 +1408,17 @@
"minimatch": "~3.0.4",
"mkdirp": "~0.5.1",
"tmp": "~0.0.33",
"vscode-cpptools": "^1.2.2",
"vscode-cpptools": "2.1.1",
"vscode-debugadapter": "~1.24.0",
"vscode-debugprotocol": "~1.24.0",
"vscode-extension-telemetry": "~0.0.11",
"vscode-extension-telemetry": "~0.0.22",
"vscode-languageclient": "3.5.1",
"yauzl": "~2.8.0"
},
"runtimeDependencies": [
{
"description": "C/C++ language components (Linux / x86_64)",
"url": "https://go.microsoft.com/fwlink/?linkid=2004596",
"url": "https://go.microsoft.com/fwlink/?linkid=2036673",
"platforms": [
"linux"
],
@@ -1390,7 +1432,7 @@
},
{
"description": "C/C++ language components (Linux / x86)",
"url": "https://go.microsoft.com/fwlink/?linkid=2004498",
"url": "https://go.microsoft.com/fwlink/?linkid=2036672",
"platforms": [
"linux"
],
@@ -1406,7 +1448,7 @@
},
{
"description": "C/C++ language components (OS X)",
"url": "https://go.microsoft.com/fwlink/?linkid=2004597",
"url": "https://go.microsoft.com/fwlink/?linkid=2036674",
"platforms": [
"darwin"
],
@@ -1417,7 +1459,7 @@
},
{
"description": "C/C++ language components (Windows)",
"url": "https://go.microsoft.com/fwlink/?linkid=2004598",
"url": "https://go.microsoft.com/fwlink/?linkid=2036671",
"platforms": [
"win32"
],
@@ -1471,7 +1513,7 @@
},
{
"description": "Mono Framework Assemblies",
"url": "https://go.microsoft.com/fwlink/?LinkId=816539",
"url": "https://go.microsoft.com/fwlink/?LinkId=2027135",
"platforms": [
"linux",
"darwin"
@@ -1480,7 +1522,7 @@
},
{
"description": "Mono Runtime (Linux / x86)",
"url": "https://go.microsoft.com/fwlink/?LinkId=816540",
"url": "https://go.microsoft.com/fwlink/?LinkId=2027410",
"platforms": [
"linux"
],
@@ -1495,7 +1537,7 @@
},
{
"description": "Mono Runtime (Linux / x86_64)",
"url": "https://go.microsoft.com/fwlink/?LinkId=816541",
"url": "https://go.microsoft.com/fwlink/?LinkId=2027416",
"platforms": [
"linux"
],
@@ -1508,7 +1550,7 @@
},
{
"description": "Mono Runtime (OS X)",
"url": "https://go.microsoft.com/fwlink/?LinkId=816542",
"url": "https://go.microsoft.com/fwlink/?LinkId=2027403",
"platforms": [
"darwin"
],
@@ -1538,4 +1580,4 @@
"binaries": []
}
]
}
}
+2 -2
View File
@@ -120,10 +120,10 @@ export class RemoteAttachPicker {
private getRemoteOSAndProcesses(pipeCmd: string): Promise<AttachItem[]> {
// Commands to get OS and processes
const command: string = `bash -c 'uname && if [ $(uname) == "Linux" ] ; then ${PsProcessParser.psLinuxCommand} ; elif [ $(uname) == "Darwin" ] ; ` +
const command: string = `sh -c 'uname && if [ $(uname) = "Linux" ] ; then ${PsProcessParser.psLinuxCommand} ; elif [ $(uname) = "Darwin" ] ; ` +
`then ${PsProcessParser.psDarwinCommand}; fi'`;
return execChildProcess(`${pipeCmd} "${command}"`, null, this._channel).then(output => {
return execChildProcess(`${pipeCmd} '${command}'`, null, this._channel).then(output => {
// OS will be on first line
// Processess will follow if listed
let lines: string[] = output.split(/\r?\n/);
+37 -35
View File
@@ -31,37 +31,39 @@ abstract class CppConfigurationProvider implements vscode.DebugConfigurationProv
* Try to add all missing attributes to the debug configuration being launched.
*/
resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
// Fail if cppvsdbg type is running on non-Windows
if (config.type === 'cppvsdbg' && os.platform() !== 'win32') {
vscode.window.showErrorMessage("Debugger of type: 'cppvsdbg' is only available on Windows. Use type: 'cppdbg' on the current OS platform.");
return undefined;
}
// Modify WSL config for OpenDebugAD7
if (os.platform() === 'win32' &&
config.pipeTransport &&
config.pipeTransport.pipeProgram) {
let replacedPipeProgram: string = null;
const pipeProgramStr: string = config.pipeTransport.pipeProgram.toLowerCase().trim();
// OpenDebugAD7 is a 32-bit process. Make sure the WSL pipe transport is using the correct program.
replacedPipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(pipeProgramStr, debugUtils.ArchType.ia32);
// If pipeProgram does not get replaced and there is a pipeCwd, concatenate with pipeProgramStr and attempt to replace.
if (!replacedPipeProgram && !path.isAbsolute(pipeProgramStr) && config.pipeTransport.pipeCwd) {
const pipeCwdStr: string = config.pipeTransport.pipeCwd.toLowerCase().trim();
const newPipeProgramStr: string = path.join(pipeCwdStr, pipeProgramStr);
replacedPipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(newPipeProgramStr, debugUtils.ArchType.ia32);
if (config) {
// Fail if cppvsdbg type is running on non-Windows
if (config.type === 'cppvsdbg' && os.platform() !== 'win32') {
vscode.window.showErrorMessage("Debugger of type: 'cppvsdbg' is only available on Windows. Use type: 'cppdbg' on the current OS platform.");
return undefined;
}
if (replacedPipeProgram) {
config.pipeTransport.pipeProgram = replacedPipeProgram;
// Modify WSL config for OpenDebugAD7
if (os.platform() === 'win32' &&
config.pipeTransport &&
config.pipeTransport.pipeProgram) {
let replacedPipeProgram: string = null;
const pipeProgramStr: string = config.pipeTransport.pipeProgram.toLowerCase().trim();
// OpenDebugAD7 is a 32-bit process. Make sure the WSL pipe transport is using the correct program.
replacedPipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(pipeProgramStr, debugUtils.ArchType.ia32);
// If pipeProgram does not get replaced and there is a pipeCwd, concatenate with pipeProgramStr and attempt to replace.
if (!replacedPipeProgram && !path.isAbsolute(pipeProgramStr) && config.pipeTransport.pipeCwd) {
const pipeCwdStr: string = config.pipeTransport.pipeCwd.toLowerCase().trim();
const newPipeProgramStr: string = path.join(pipeCwdStr, pipeProgramStr);
replacedPipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(newPipeProgramStr, debugUtils.ArchType.ia32);
}
if (replacedPipeProgram) {
config.pipeTransport.pipeProgram = replacedPipeProgram;
}
}
}
return config;
}
// if config or type is not specified, return null to trigger VS Code to open a configuration file https://github.com/Microsoft/vscode/issues/54213
return config && config.type ? config : null;
}
}
export class CppVsDbgConfigurationProvider extends CppConfigurationProvider {
@@ -71,7 +73,7 @@ export class CppVsDbgConfigurationProvider extends CppConfigurationProvider {
}
export class CppDbgConfigurationProvider extends CppConfigurationProvider {
public constructor(provider: IConfigurationAssetProvider) {
public constructor(provider: IConfigurationAssetProvider) {
super(provider, DebuggerType.cppdbg);
}
}
@@ -101,12 +103,12 @@ abstract class DefaultConfigurationProvider implements IConfigurationAssetProvid
public getInitialConfigurations(debuggerType: DebuggerType): any {
let configurationSnippet: IConfigurationSnippet[] = [];
// Only launch configurations are initial configurations
this.configurations.forEach(configuration => {
configurationSnippet.push(configuration.GetLaunchConfiguration());
configurationSnippet.push(configuration.GetLaunchConfiguration());
});
let initialConfigurations: any = configurationSnippet.filter(snippet => snippet.debuggerType === debuggerType && snippet.isInitialConfiguration)
.map(snippet => JSON.parse(snippet.bodyText));
@@ -141,7 +143,7 @@ class WindowsConfigurationProvider extends DefaultConfigurationProvider {
constructor() {
super();
this.configurations = [
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
new PipeTransportConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
new WindowsConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
new WSLConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
@@ -157,7 +159,7 @@ class OSXConfigurationProvider extends DefaultConfigurationProvider {
constructor() {
super();
this.configurations = [
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram),
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram),
];
}
}
@@ -177,7 +179,7 @@ class LinuxConfigurationProvider extends DefaultConfigurationProvider {
constructor() {
super();
this.configurations = [
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
new MIConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock),
new PipeTransportConfigurations(this.MIMode, this.executable, this.pipeProgram, this.setupCommandsBlock)
];
}
@@ -220,7 +222,7 @@ export class ConfigurationSnippetProvider implements vscode.CompletionItemProvid
items.map((item) => {
item.insertText = item.insertText + ','; // Add comma
});
});
}
return Promise.resolve(new vscode.CompletionList(items, true));
+318 -143
View File
@@ -8,9 +8,9 @@ import * as path from 'path';
import * as vscode from 'vscode';
import {
LanguageClient, LanguageClientOptions, ServerOptions, NotificationType, TextDocumentIdentifier,
RequestType, ErrorAction, CloseAction, DidOpenTextDocumentParams
RequestType, ErrorAction, CloseAction, DidOpenTextDocumentParams, Range
} from 'vscode-languageclient';
import { SourceFileConfigurationItem } from 'vscode-cpptools';
import { SourceFileConfigurationItem, WorkspaceBrowseConfiguration, SourceFileConfiguration, Version } from 'vscode-cpptools';
import { Status } from 'vscode-cpptools/out/testApi';
import * as util from '../common';
import * as configs from './configurations';
@@ -28,6 +28,7 @@ import { CancellationTokenSource } from 'vscode';
import { SettingsTracker, getTracker } from './settingsTracker';
import { getTestHook, TestHook } from '../testHook';
import { getCustomConfigProviders, CustomConfigurationProviderCollection, CustomConfigurationProvider1 } from '../LanguageServer/customProviders';
import { ABTestSettings, getABTestSettings } from '../abTesting';
let ui: UI;
const configProviderTimeout: number = 2000;
@@ -92,8 +93,18 @@ interface DecorationRangesPair {
ranges: vscode.Range[];
}
// Need to convert vscode.Uri to a string before sending it to the language server.
interface SourceFileConfigurationItemAdapter {
uri: string;
configuration: SourceFileConfiguration;
}
interface CustomConfigurationParams {
configurationItems: SourceFileConfigurationItem[];
configurationItems: SourceFileConfigurationItemAdapter[];
}
interface CustomBrowseConfigurationParams {
browseConfiguration: WorkspaceBrowseConfiguration;
}
interface CompileCommandsPaths {
@@ -114,12 +125,13 @@ const ResetDatabaseNotification: NotificationType<void, void> = new Notification
const PauseParsingNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/pauseParsing');
const ResumeParsingNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/resumeParsing');
const ActiveDocumentChangeNotification: NotificationType<TextDocumentIdentifier, void> = new NotificationType<TextDocumentIdentifier, void>('cpptools/activeDocumentChange');
const TextEditorSelectionChangeNotification: NotificationType<vscode.Position, void> = new NotificationType<vscode.Position, void>('cpptools/textEditorSelectionChange');
const TextEditorSelectionChangeNotification: NotificationType<Range, void> = new NotificationType<Range, void>('cpptools/textEditorSelectionChange');
const ChangeFolderSettingsNotification: NotificationType<FolderSettingsParams, void> = new NotificationType<FolderSettingsParams, void>('cpptools/didChangeFolderSettings');
const ChangeCompileCommandsNotification: NotificationType<FileChangedParams, void> = new NotificationType<FileChangedParams, void>('cpptools/didChangeCompileCommands');
const ChangeSelectedSettingNotification: NotificationType<FolderSelectedSettingParams, void> = new NotificationType<FolderSelectedSettingParams, void>('cpptools/didChangeSelectedSetting');
const IntervalTimerNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/onIntervalTimer');
const CustomConfigurationNotification: NotificationType<CustomConfigurationParams, void> = new NotificationType<CustomConfigurationParams, void>('cpptools/didChangeCustomConfiguration');
const CustomBrowseConfigurationNotification: NotificationType<CustomBrowseConfigurationParams, void> = new NotificationType<CustomBrowseConfigurationParams, void>('cpptools/didChangeCustomBrowseConfiguration');
const ClearCustomConfigurationsNotification: NotificationType<void, void> = new NotificationType<void, void>('cpptools/clearCustomConfigurations');
// Notifications from the server
@@ -132,6 +144,35 @@ const DebugProtocolNotification: NotificationType<OutputNotificationBody, void>
const DebugLogNotification: NotificationType<OutputNotificationBody, void> = new NotificationType<OutputNotificationBody, void>('cpptools/debugLog');
const InactiveRegionNotification: NotificationType<InactiveRegionParams, void> = new NotificationType<InactiveRegionParams, void>('cpptools/inactiveRegions');
const CompileCommandsPathsNotification: NotificationType<CompileCommandsPaths, void> = new NotificationType<CompileCommandsPaths, void>('cpptools/compileCommandsPaths');
const UpdateClangFormatPathNotification: NotificationType<string, void> = new NotificationType<string, void>('cpptools/updateClangFormatPath');
class BlockingTask<T> {
private dependency: BlockingTask<any>;
private done: boolean = false;
private promise: Promise<T>;
constructor(task: () => T, dependency?: BlockingTask<any>) {
this.promise = new Promise<T>(async (resolve, reject) => {
try {
let result: T = await task();
resolve(result);
this.done = true;
} catch (err) {
reject(err);
this.done = true;
}
});
this.dependency = dependency;
}
public get Done(): boolean {
return this.done && (!this.dependency || this.dependency.Done);
}
public then(onSucceeded: (value: T) => any, onRejected: (err) => any): Promise<any> {
return this.promise.then(onSucceeded, onRejected);
}
}
let failureMessageShown: boolean = false;
@@ -153,16 +194,15 @@ export interface Client {
RootUri: vscode.Uri;
Name: string;
TrackedDocuments: Set<vscode.TextDocument>;
onDidChangeSettings(): void;
onDidChangeSettings(): { [key: string] : string };
onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]): void;
onRegisterCustomConfigurationProvider(provider: CustomConfigurationProvider1): Thenable<void>;
updateCustomConfigurations(requestingProvider?: CustomConfigurationProvider1): Thenable<void>;
updateCustomBrowseConfiguration(requestingProvider?: CustomConfigurationProvider1): Thenable<void>;
provideCustomConfiguration(document: vscode.TextDocument): Promise<void>;
getCustomConfigurationProviderId(): Thenable<string|undefined>;
getCurrentConfigName(): Thenable<string>;
takeOwnership(document: vscode.TextDocument): void;
queueTask<T>(task: () => Thenable<T>): Thenable<T>;
queueTaskWithTimeout(thenable: () => Thenable<any>, ms: number, tokenSource?: CancellationTokenSource): Thenable<any>;
requestWhenReady(request: () => Thenable<any>): Thenable<any>;
notifyWhenReady(notify: () => void): void;
requestGoToDeclaration(): Thenable<void>;
@@ -170,8 +210,7 @@ export interface Client {
requestNavigationList(document: vscode.TextDocument): Thenable<string>;
activeDocumentChanged(document: vscode.TextDocument): void;
activate(): void;
selectionChanged(selection: vscode.Position): void;
sendCustomConfigurations(configs: any): void;
selectionChanged(selection: Range): void;
resetDatabase(): void;
deactivate(): void;
pauseParsing(): void;
@@ -239,6 +278,10 @@ class DefaultClient implements Client {
return this.trackedDocuments;
}
private get AdditionalEnvironment(): { [key: string]: string | string[] } {
return { workspaceFolderBasename: this.Name };
}
private getName(workspaceFolder?: vscode.WorkspaceFolder): string {
return workspaceFolder ? workspaceFolder.name : "untitled";
}
@@ -250,8 +293,7 @@ class DefaultClient implements Client {
* @see notifyWhenReady(notify)
*/
private pendingTask: Thenable<any>;
private pendingRequests: number = 0;
private pendingTask: BlockingTask<void>;
constructor(allClients: ClientCollection, workspaceFolder?: vscode.WorkspaceFolder) {
try {
@@ -264,7 +306,7 @@ class DefaultClient implements Client {
ui.bind(this);
// requests/notifications are deferred until this.languageClient is set.
this.queueTask(() => languageClient.onReady().then(
this.queueBlockingTask(() => languageClient.onReady().then(
() => {
this.configuration = new configs.CppProperties(this.RootUri);
this.configuration.ConfigurationsChanged((e) => this.onConfigurationsChanged(e));
@@ -325,6 +367,7 @@ class DefaultClient implements Client {
storagePath = path.join(storagePath, serverName);
}
let abTestSettings: ABTestSettings = getABTestSettings();
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'file', language: 'cpp' },
@@ -336,7 +379,7 @@ class DefaultClient implements Client {
},
workspaceFolder: workspaceFolder,
initializationOptions: {
clang_format_path: settings.clangFormatPath,
clang_format_path: util.resolveVariables(settings.clangFormatPath, this.AdditionalEnvironment),
clang_format_style: settings.clangFormatStyle,
clang_format_fallbackStyle: settings.clangFormatFallbackStyle,
clang_format_sortIncludes: settings.clangFormatSortIncludes,
@@ -353,12 +396,14 @@ class DefaultClient implements Client {
dimInactiveRegions: settings.dimInactiveRegions,
loggingLevel: settings.loggingLevel,
workspaceParsingPriority: settings.workspaceParsingPriority,
workspaceSymbols: settings.workspaceSymbols,
exclusionPolicy: settings.exclusionPolicy,
preferredPathSeparator: settings.preferredPathSeparator,
default: {
systemIncludePath: settings.defaultSystemIncludePath
},
vcpkg_root: util.getVcpkgRoot()
vcpkg_root: util.getVcpkgRoot(),
gotoDefIntelliSense: abTestSettings.UseGoToDefIntelliSense
},
middleware: createProtocolFilter(this, allClients), // Only send messages directed at this client.
errorHandler: {
@@ -394,16 +439,22 @@ class DefaultClient implements Client {
return new LanguageClient(`cpptools: ${serverName}`, serverOptions, clientOptions);
}
public onDidChangeSettings(): void {
let changedSettings: { [key: string] : string} = this.settingsTracker.getChangedSettings();
public onDidChangeSettings(): { [key: string] : string } {
let changedSettings: { [key: string] : string } = this.settingsTracker.getChangedSettings();
if (Object.keys(changedSettings).length > 0) {
if (changedSettings["commentContinuationPatterns"]) {
updateLanguageConfigurations();
}
if (changedSettings["clang_format_path"]) {
let settings: CppSettings = new CppSettings(this.RootUri);
this.languageClient.sendNotification(UpdateClangFormatPathNotification, util.resolveVariables(settings.clangFormatPath, this.AdditionalEnvironment));
}
this.configuration.onDidChangeSettings();
telemetry.logLanguageServerEvent("CppSettingsChange", changedSettings, null);
}
return changedSettings;
}
public onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]): void {
@@ -420,6 +471,13 @@ class DefaultClient implements Client {
}
public onRegisterCustomConfigurationProvider(provider: CustomConfigurationProvider1): Thenable<void> {
let onRegistered: () => void = () => {
// version 2 providers control the browse.path. Avoid thrashing the tag parser database by pausing parsing until
// the provider has sent the correct browse.path value.
if (provider.version >= Version.v2) {
this.pauseParsing();
}
};
return this.notifyWhenReady(() => {
if (!this.RootPath) {
return; // There is no c_cpp_properties.json to edit because there is no folder open.
@@ -428,33 +486,41 @@ class DefaultClient implements Client {
if (!selectedProvider) {
let ask: PersistentFolderState<boolean> = new PersistentFolderState<boolean>("Client.registerProvider", true, this.RootPath);
if (ask.Value) {
let folderStr: string = (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) ? "the '" + this.Name + "'" : "this";
const message: string = `${provider.name} would like to configure IntelliSense for ${folderStr} folder.`;
const allow: string = "Allow";
const dontAllow: string = "Don't Allow";
const askLater: string = "Ask Me Later";
vscode.window.showInformationMessage(message, allow, dontAllow, askLater).then(result => {
switch (result) {
case allow: {
this.configuration.updateCustomConfigurationProvider(provider.extensionId).then(() => {
telemetry.logLanguageServerEvent("customConfigurationProvider", { "providerId": provider.extensionId });
});
ask.Value = false;
break;
ui.showConfigureCustomProviderMessage(() => {
let folderStr: string = (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) ? "the '" + this.Name + "'" : "this";
const message: string = `${provider.name} would like to configure IntelliSense for ${folderStr} folder.`;
const allow: string = "Allow";
const dontAllow: string = "Don't Allow";
const askLater: string = "Ask Me Later";
return vscode.window.showInformationMessage(message, allow, dontAllow, askLater).then(result => {
switch (result) {
case allow: {
this.configuration.updateCustomConfigurationProvider(provider.extensionId).then(() => {
onRegistered();
telemetry.logLanguageServerEvent("customConfigurationProvider", { "providerId": provider.extensionId });
});
ask.Value = false;
return true;
}
case dontAllow: {
ask.Value = false;
break;
}
default: {
break;
}
}
case dontAllow: {
ask.Value = false;
break;
}
default: {
break;
}
}
});
return false;
});
},
() => ask.Value = false);
}
} else if (selectedProvider === provider.extensionId) {
onRegistered();
telemetry.logLanguageServerEvent("customConfigurationProvider", { "providerId": provider.extensionId });
} else if (selectedProvider === provider.name) {
onRegistered();
this.configuration.updateCustomConfigurationProvider(provider.extensionId); // v0 -> v1 upgrade. Update the configurationProvider in c_cpp_properties.json
}
});
@@ -477,17 +543,47 @@ class DefaultClient implements Client {
let task: () => Thenable<SourceFileConfigurationItem[]> = () => {
return currentProvider.provideConfigurations(documentUris, tokenSource.token);
};
this.queueTaskWithTimeout(task, configProviderTimeout, tokenSource).then(configs => this.sendCustomConfigurations(configs));
this.queueTaskWithTimeout(task, configProviderTimeout, tokenSource).then(configs => this.sendCustomConfigurations(configs), () => {});
});
}
public updateCustomBrowseConfiguration(requestingProvider?: CustomConfigurationProvider1): Thenable<void> {
return this.notifyWhenReady(() => {
if (!this.configurationProvider) {
return;
}
console.log("updateCustomBrowseConfiguration");
let currentProvider: CustomConfigurationProvider1 = getCustomConfigProviders().get(this.configurationProvider);
if (!currentProvider || (requestingProvider && requestingProvider.extensionId !== currentProvider.extensionId)) {
return;
}
let tokenSource: CancellationTokenSource = new CancellationTokenSource();
let task: () => Thenable<WorkspaceBrowseConfiguration> = async () => {
if (await currentProvider.canProvideBrowseConfiguration(tokenSource.token)) {
return currentProvider.provideBrowseConfiguration(tokenSource.token);
}
if (currentProvider.version >= Version.v2) {
console.warn("failed to provide browse configuration");
}
return Promise.reject("");
};
this.queueTaskWithTimeout(task, configProviderTimeout, tokenSource).then(
async config => {
await this.sendCustomBrowseConfiguration(config);
this.resumeParsing();
},
() => {});
});
}
public async provideCustomConfiguration(document: vscode.TextDocument): Promise<void> {
let tokenSource: CancellationTokenSource = new CancellationTokenSource();
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
if (providers.size === 0) {
return Promise.resolve();
}
console.log("provideCustomConfiguration");
let providerId: string|undefined = await this.getCustomConfigurationProviderId();
if (!providerId) {
return Promise.resolve();
@@ -495,37 +591,48 @@ class DefaultClient implements Client {
let providerName: string = providerId;
let configName: string = await this.getCurrentConfigName();
const notReadyMessage: string = `${providerName} is not ready`;
let provideConfigurationAsync: () => Thenable<SourceFileConfigurationItem[]> = async () => {
// The config requests that we use a provider, try to get IntelliSense configuration info from that provider.
try {
let provider: CustomConfigurationProvider1|null = providers.get(providerId);
if (provider) {
if (!provider.isReady) {
return Promise.reject(notReadyMessage);
}
providerName = provider.name;
if (await provider.canProvideConfiguration(document.uri, tokenSource.token)) {
return provider.provideConfigurations([document.uri], tokenSource.token);
}
}
} catch {
} catch (err) {
}
console.warn("failed to provide configuration");
return Promise.reject("");
};
return this.queueTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then(
(configs: SourceFileConfigurationItem[]) => {
if (configs && configs.length > 0) {
this.sendCustomConfigurations(configs);
this.sendCustomConfigurations(configs, true);
}
},
() => {
(err) => {
if (err === notReadyMessage) {
return;
}
let settings: CppSettings = new CppSettings(this.RootUri);
if (settings.configurationWarnings === "Enabled" && !this.isExternalHeader(document) && !vscode.debug.activeDebugSession) {
const dismiss: string = "Dismiss";
const disable: string = "Disable Warnings";
vscode.window.showInformationMessage(
`'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` +
`Settings from the '${configName}' configuration will be used instead.`,
dismiss,
disable).then(response => {
let message: string = `'${providerName}' is unable to provide IntelliSense configuration information for '${document.uri.fsPath}'. ` +
`Settings from the '${configName}' configuration will be used instead.`;
if (err) {
message += ` (${err})`;
}
vscode.window.showInformationMessage(message, dismiss, disable).then(response => {
switch (response) {
case disable: {
settings.toggleSetting("configurationWarnings", "Enabled", "Disabled");
@@ -540,9 +647,9 @@ class DefaultClient implements Client {
private isExternalHeader(document: vscode.TextDocument): boolean {
return util.isHeader(document) && !document.uri.toString().startsWith(this.RootUri.toString());
}
public getCustomConfigurationProviderId(): Thenable<string|undefined> {
return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfiguration.configurationProvider));
private getCustomConfigurationProviderId(): Thenable<string|undefined> {
return this.queueTask(() => Promise.resolve(this.configuration.CurrentConfigurationProvider));
}
public getCurrentConfigName(): Thenable<string> {
@@ -575,29 +682,41 @@ class DefaultClient implements Client {
public queueTask(task: () => Thenable<any>): Thenable<any> {
if (this.isSupported) {
this.pendingRequests++;
let nextTask: () => Thenable<any> = () => {
let result: Thenable<any> = task();
this.pendingRequests--;
if (this.pendingRequests === 0) {
this.pendingTask = null;
let nextTask: () => Thenable<any> = async () => {
try {
return await task();
} catch (err) {
console.error(err);
throw err;
}
return result;
};
if (this.pendingTask) {
if (this.pendingTask && !this.pendingTask.Done) {
// We don't want the queue to stall because of a rejected promise.
return this.pendingTask.then(nextTask, nextTask);
} else {
this.pendingTask = nextTask();
return this.pendingTask;
this.pendingTask = undefined;
return nextTask();
}
} else {
return Promise.reject("Unsupported client");
}
}
public queueTaskWithTimeout(task: () => Thenable<any>, ms: number, cancelToken?: CancellationTokenSource): Thenable<any> {
/**
* Queue a task that blocks all future tasks until it completes. This is currently only intended to be used
* during language client startup and for custom configuration providers.
* @param task The task that blocks all future tasks
*/
private queueBlockingTask(task: () => Thenable<void>): Thenable<void> {
if (this.isSupported) {
this.pendingTask = new BlockingTask<void>(task, this.pendingTask);
} else {
return Promise.reject("Unsupported client");
}
}
private queueTaskWithTimeout(task: () => Thenable<any>, ms: number, cancelToken?: CancellationTokenSource): Thenable<any> {
let timer: NodeJS.Timer;
// Create a promise that rejects in <ms> milliseconds
let timeout: () => Promise<any> = () => new Promise((resolve, reject) => {
@@ -609,7 +728,7 @@ class DefaultClient implements Client {
reject("Timed out in " + ms + "ms.");
}, ms);
});
// Returns a race between our timeout and the passed in promise
return this.queueTask(() => {
return Promise.race([task(), timeout()]).then(
@@ -618,20 +737,26 @@ class DefaultClient implements Client {
return result;
},
(error: any) => {
clearTimeout(timer);
throw error;
});
});
}
public requestWhenReady(request: () => Thenable<any>): Thenable<any> {
return this.queueTask(request);
}
public notifyWhenReady(notify: () => void): Thenable<void> {
return this.queueTask(() => new Promise(resolve => {
public notifyWhenReady(notify: () => void, blockingTask?: boolean): Thenable<void> {
let task: () => Thenable<void> = () => new Promise(resolve => {
notify();
resolve();
}));
});
if (blockingTask) {
return this.queueBlockingTask(task);
} else {
return this.queueTask(task);
}
}
/**
@@ -640,7 +765,7 @@ class DefaultClient implements Client {
private registerNotifications(): void {
console.assert(this.languageClient !== undefined, "This method must not be called until this.languageClient is set in \"onReady\"");
this.languageClient.onNotification(ReloadWindowNotification, () => this.reloadWindow());
this.languageClient.onNotification(ReloadWindowNotification, () => util.promptForReloadWindowDueToSettingsChange());
this.languageClient.onNotification(LogTelemetryNotification, (e) => this.logTelemetry(e));
this.languageClient.onNotification(ReportNavigationNotification, (e) => this.navigate(e));
this.languageClient.onNotification(ReportStatusNotification, (e) => this.updateStatus(e));
@@ -711,15 +836,6 @@ class DefaultClient implements Client {
* handle notifications coming from the language server
*******************************************************/
private reloadWindow(): void {
let reload: string = "Reload";
vscode.window.showInformationMessage("Reload the workspace for the settings change to take effect.", reload).then((value: string) => {
if (value === reload) {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
}
private logTelemetry(notificationBody: TelemetryPayload): void {
telemetry.logLanguageServerEvent(notificationBody.event, notificationBody.properties, notificationBody.metrics);
}
@@ -806,27 +922,32 @@ class DefaultClient implements Client {
} else if (message.endsWith("IntelliSense Fallback")) {
let showIntelliSenseFallbackMessage: PersistentState<boolean> = new PersistentState<boolean>("CPP.showIntelliSenseFallbackMessage", true);
if (showIntelliSenseFallbackMessage.Value) {
let learnMorePanel: string = "Learn More";
let dontShowAgain: string = "Don't Show Again";
let fallbackMsg: string = this.configuration.VcpkgInstalled ?
"Update your IntelliSense settings or use Vcpkg to install libraries to help find missing headers." :
"Configure your IntelliSense settings to help find missing headers.";
vscode.window.showInformationMessage(fallbackMsg, learnMorePanel, dontShowAgain).then((value) => {
switch (value) {
case learnMorePanel:
let uri: vscode.Uri = vscode.Uri.parse(`https://go.microsoft.com/fwlink/?linkid=864631`);
vscode.commands.executeCommand('vscode.open', uri);
vscode.commands.getCommands(true).then((commands: string[]) => {
if (commands.indexOf("workbench.action.problems.focus") >= 0) {
vscode.commands.executeCommand("workbench.action.problems.focus");
}
});
break;
case dontShowAgain:
showIntelliSenseFallbackMessage.Value = false;
break;
}
});
ui.showConfigureIncludePathMessage(() => {
let learnMorePanel: string = "Configuration Help";
let dontShowAgain: string = "Don't Show Again";
let fallbackMsg: string = this.configuration.VcpkgInstalled ?
"Update your IntelliSense settings or use Vcpkg to install libraries to help find missing headers." :
"Configure your IntelliSense settings to help find missing headers.";
return vscode.window.showInformationMessage(fallbackMsg, learnMorePanel, dontShowAgain).then((value) => {
switch (value) {
case learnMorePanel:
let uri: vscode.Uri = vscode.Uri.parse(`https://go.microsoft.com/fwlink/?linkid=864631`);
vscode.commands.executeCommand('vscode.open', uri);
vscode.commands.getCommands(true).then((commands: string[]) => {
if (commands.indexOf("workbench.action.problems.focus") >= 0) {
vscode.commands.executeCommand("workbench.action.problems.focus");
}
});
this.handleConfigurationEditCommand();
break;
case dontShowAgain:
showIntelliSenseFallbackMessage.Value = false;
break;
}
return true;
});
},
() => showIntelliSenseFallbackMessage.Value = false);
}
}
}
@@ -837,9 +958,11 @@ class DefaultClient implements Client {
private updateInactiveRegions(params: InactiveRegionParams): void {
let settings: CppSettings = new CppSettings(this.RootUri);
let decoration: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({
opacity: settings.inactiveRegionOpacity.toString(),
backgroundColor: settings.inactiveRegionBackgroundColor,
color: settings.inactiveRegionForegroundColor,
rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen
});
@@ -881,8 +1004,8 @@ class DefaultClient implements Client {
return;
}
let showCompileCommandsSelection: PersistentState<boolean> = new PersistentState<boolean>("CPP.showCompileCommandsSelection", true);
if (!showCompileCommandsSelection.Value) {
let ask: PersistentState<boolean> = new PersistentState<boolean>("CPP.showCompileCommandsSelection", true);
if (!ask.Value) {
return;
}
@@ -890,30 +1013,33 @@ class DefaultClient implements Client {
let folderStr: string = (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) ? "the '" + this.Name + "'" : "this";
const message: string = `Would you like to use ${compileCommandStr} to auto-configure IntelliSense for ${folderStr} folder?`;
const yes: string = "Yes";
const notNow: string = "Not Now";
const dontAskAgain: string = "Don't Ask Again";
vscode.window.showInformationMessage(message, yes, notNow, dontAskAgain).then((value) => {
switch (value) {
case yes:
if (params.paths.length > 1) {
ui.showCompileCommands(params.paths).then((index) => {
ui.showConfigureCompileCommandsMessage(() => {
const yes: string = "Yes";
const no: string = "No";
const askLater: string = "Ask Me Later";
return vscode.window.showInformationMessage(message, yes, no, askLater).then(async (value) => {
switch (value) {
case yes:
if (params.paths.length > 1) {
let index: number = await ui.showCompileCommands(params.paths);
if (index < 0) {
return;
return false;
}
this.configuration.setCompileCommands(params.paths[index]);
});
} else {
this.configuration.setCompileCommands(params.paths[0]);
}
break;
case notNow:
break;
case dontAskAgain:
showCompileCommandsSelection.Value = false;
break;
}
});
} else {
this.configuration.setCompileCommands(params.paths[0]);
}
return true;
case askLater:
break;
case no:
ask.Value = false;
break;
}
return false;
});
},
() => ask.Value = false);
}
/*********************************************
@@ -960,7 +1086,7 @@ class DefaultClient implements Client {
this.resumeParsing();
}
public selectionChanged(selection: vscode.Position): void {
public selectionChanged(selection: Range): void {
this.notifyWhenReady(() => this.languageClient.sendNotification(TextEditorSelectionChangeNotification, selection));
}
@@ -1001,6 +1127,7 @@ class DefaultClient implements Client {
if (this.configurationProvider !== newProvider) {
this.configurationProvider = newProvider;
this.updateCustomConfigurations();
this.updateCustomBrowseConfiguration();
}
});
}
@@ -1022,29 +1149,77 @@ class DefaultClient implements Client {
this.notifyWhenReady(() => this.languageClient.sendNotification(ChangeCompileCommandsNotification, params));
}
public sendCustomConfigurations(configs: any): void {
private isSourceFileConfigurationItem(input: any): input is SourceFileConfigurationItem {
return (input && (util.isString(input.uri) || util.isUri(input.uri)) &&
input.configuration && util.isArrayOfString(input.configuration.includePath) && util.isArrayOfString(input.configuration.defines) &&
util.isString(input.configuration.intelliSenseMode) && util.isString(input.configuration.standard) && util.isOptionalString(input.configuration.compilerPath) &&
util.isOptionalArrayOfString(input.configuration.forcedInclude));
}
private sendCustomConfigurations(configs: any, blockingTask?: boolean): void {
// configs is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
if (!configs || !(configs instanceof Array)) {
console.warn("discarding invalid SourceFileConfigurationItems[]: " + configs);
return;
}
let sanitized: SourceFileConfigurationItem[] = <SourceFileConfigurationItem[]>configs;
sanitized = sanitized.filter(item => {
if (item && item.uri && item.configuration &&
item.configuration.includePath && item.configuration.defines && item.configuration.intelliSenseMode && item.configuration.standard) {
return true;
let settings: CppSettings = new CppSettings(this.RootUri);
let out: logger.Logger = logger.getOutputChannelLogger();
if (settings.loggingLevel === "Debug") {
out.appendLine("Custom configurations received:");
}
let sanitized: SourceFileConfigurationItemAdapter[] = [];
configs.forEach(item => {
if (this.isSourceFileConfigurationItem(item)) {
sanitized.push({
uri: item.uri.toString(),
configuration: item.configuration
});
if (settings.loggingLevel === "Debug") {
out.appendLine(` uri: ${item.uri.toString()}`);
out.appendLine(` config: ${JSON.stringify(item.configuration, null, 2)}`);
}
if (item.configuration.includePath.some(path => path.endsWith('**'))) {
console.warn("custom include paths should not use recursive includes ('**')");
}
} else {
console.warn("discarding invalid SourceFileConfigurationItem: " + item);
}
console.warn("discarding invalid SourceFileConfigurationItem: " + item);
return false;
});
if (sanitized.length === 0) {
return;
}
let params: CustomConfigurationParams = {
configurationItems: sanitized
};
this.notifyWhenReady(() => this.languageClient.sendNotification(CustomConfigurationNotification, params));
this.notifyWhenReady(() => this.languageClient.sendNotification(CustomConfigurationNotification, params), blockingTask);
}
private sendCustomBrowseConfiguration(config: any): Thenable<void> {
// config is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
if (!config || config instanceof Array) {
console.warn("discarding invalid WorkspaceBrowseConfiguration: " + config);
return Promise.resolve();
}
let sanitized: WorkspaceBrowseConfiguration = <WorkspaceBrowseConfiguration>config;
if (!util.isArrayOfString(sanitized.browsePath) || !util.isOptionalString(sanitized.compilerPath) ||
!util.isOptionalString(sanitized.standard) || !util.isOptionalString(sanitized.windowsSdkVersion)) {
console.warn("discarding invalid WorkspaceBrowseConfiguration: " + config);
return Promise.resolve();
}
let settings: CppSettings = new CppSettings(this.RootUri);
let out: logger.Logger = logger.getOutputChannelLogger();
if (settings.loggingLevel === "Debug") {
out.appendLine(`Custom browse configuration received: ${JSON.stringify(sanitized, null, 2)}`);
}
let params: CustomBrowseConfigurationParams = {
browseConfiguration: sanitized
};
return this.notifyWhenReady(() => this.languageClient.sendNotification(CustomBrowseConfigurationNotification, params));
}
private clearCustomConfigurations(): void {
@@ -1068,7 +1243,7 @@ class DefaultClient implements Client {
public handleConfigurationProviderSelectCommand(): void {
this.notifyWhenReady(() => {
ui.showConfigurationProviders()
ui.showConfigurationProviders(this.configuration.CurrentConfigurationProvider)
.then(extensionId => {
if (extensionId === undefined) {
// operation was cancelled.
@@ -1077,7 +1252,9 @@ class DefaultClient implements Client {
this.configuration.updateCustomConfigurationProvider(extensionId)
.then(() => {
if (extensionId) {
this.updateCustomConfigurations(getCustomConfigProviders().get(extensionId));
let provider: CustomConfigurationProvider1 = getCustomConfigProviders().get(extensionId);
this.updateCustomConfigurations(provider);
this.updateCustomBrowseConfiguration(provider);
telemetry.logLanguageServerEvent("customConfigurationProvider", { "providerId": extensionId });
} else {
this.clearCustomConfigurations();
@@ -1160,25 +1337,23 @@ class NullClient implements Client {
RootUri: vscode.Uri = vscode.Uri.file("/");
Name: string = "(empty)";
TrackedDocuments = new Set<vscode.TextDocument>();
onDidChangeSettings(): void {}
onDidChangeSettings(): { [key: string] : string } { return {}; }
onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]): void {}
onRegisterCustomConfigurationProvider(provider: CustomConfigurationProvider1): Thenable<void> { return Promise.resolve(); }
updateCustomConfigurations(requestingProvider?: CustomConfigurationProvider1): Thenable<void> { return Promise.resolve(); }
updateCustomBrowseConfiguration(requestingProvider?: CustomConfigurationProvider1): Thenable<void> { return Promise.resolve(); }
provideCustomConfiguration(document: vscode.TextDocument): Promise<void> { return Promise.resolve(); }
getCustomConfigurationProviderId(): Thenable<string|undefined> { return Promise.resolve(undefined); }
getCurrentConfigName(): Thenable<string> { return Promise.resolve(""); }
takeOwnership(document: vscode.TextDocument): void {}
queueTask<T>(task: () => Thenable<T>): Thenable<T> { return task(); }
queueTaskWithTimeout(task: () => Thenable<any>, ms: number, tokenSource?: CancellationTokenSource): Thenable<any> { return task(); }
requestWhenReady(request: () => Thenable<any>): Thenable<any> { return; }
notifyWhenReady(notify: () => void): void {}
sendCustomConfigurations(configs: any): void {}
requestGoToDeclaration(): Thenable<void> { return Promise.resolve(); }
requestSwitchHeaderSource(rootPath: string, fileName: string): Thenable<string> { return Promise.resolve(""); }
requestNavigationList(document: vscode.TextDocument): Thenable<string> { return Promise.resolve(""); }
activeDocumentChanged(document: vscode.TextDocument): void {}
activate(): void {}
selectionChanged(selection: vscode.Position): void {}
selectionChanged(selection: Range): void {}
resetDatabase(): void {}
deactivate(): void {}
pauseParsing(): void {}
@@ -1194,4 +1369,4 @@ class NullClient implements Client {
this.stringEvent.dispose();
return Promise.resolve();
}
}
}
@@ -9,6 +9,7 @@ import * as util from '../common';
import * as telemetry from '../telemetry';
import * as cpptools from './client';
import * as path from 'path';
import { getCustomConfigProviders } from './customProviders';
const defaultClientKey: string = "@@default@@";
export interface ClientKey {
@@ -158,7 +159,7 @@ export class ClientCollection {
this.activeClient = this.getClientFor(this.activeDocument.uri);
this.activeClient.activeDocumentChanged(this.activeDocument);
// may not need this, the navigation UI should not have changed.
// this.activeClient.selectionChanged(vscode.window.activeTextEditor.selection.start);
// this.activeClient.selectionChanged(Range.create(vscode.window.activeTextEditor.selection.start, vscode.window.activeTextEditor.selection.end);
}
client.dispose();
@@ -187,7 +188,9 @@ export class ClientCollection {
} else {
let key: string = util.asFolder(folder.uri);
if (!this.languageClients.has(key)) {
this.languageClients.set(key, cpptools.createClient(this, folder));
let newClient: cpptools.Client = cpptools.createClient(this, folder);
this.languageClients.set(key, newClient);
getCustomConfigProviders().forEach(provider => newClient.onRegisterCustomConfigurationProvider(provider));
}
return this.languageClients.get(key);
}
+76 -43
View File
@@ -15,6 +15,8 @@ import { ABTestSettings, getABTestSettings } from '../abTesting';
import { getCustomConfigProviders } from './customProviders';
const configVersion: number = 4;
type Environment = { [key: string]: string | string[] };
// No properties are set in the config since we want to apply vscode settings first (if applicable).
// That code won't trigger if another value is already set.
// The property defaults are moved down to applyDefaultIncludePathsAndFrameworks.
@@ -145,7 +147,7 @@ export class CppProperties {
public get Configurations(): Configuration[] { return this.configurationJson.configurations; }
public get CurrentConfigurationIndex(): number { return this.currentConfigurationIndex.Value; }
public get CurrentConfiguration(): Configuration { return this.Configurations[this.CurrentConfigurationIndex]; }
public get CurrentConfigurationProvider(): string|null {
if (this.CurrentConfiguration.configurationProvider) {
return this.CurrentConfiguration.configurationProvider;
@@ -213,6 +215,10 @@ export class CppProperties {
if (this.configurationIncomplete && this.defaultIncludes && this.defaultFrameworks && this.vcpkgPathReady) {
let configuration: Configuration = this.CurrentConfiguration;
let settings: CppSettings = new CppSettings(this.rootUri);
let isUnset: (input: any) => boolean = (input: any) => {
// default values for "default" config settings is null.
return input === null;
};
// Anything that has a vscode setting for it will be resolved in updateServerOnFolderSettingsChange.
// So if a property is currently unset, but has a vscode setting, don't set it yet, otherwise the linkage
@@ -220,38 +226,48 @@ export class CppProperties {
// Only add settings from the default compiler if user hasn't explicitly set the corresponding VS Code setting.
if (!settings.defaultIncludePath) {
if (isUnset(settings.defaultIncludePath)) {
// We don't add system includes to the includePath anymore. The language server has this information.
let abTestSettings: ABTestSettings = getABTestSettings();
let rootFolder: string = abTestSettings.UseRecursiveIncludes ? "${workspaceFolder}/**" : "${workspaceFolder}";
configuration.includePath = [rootFolder].concat(this.vcpkgIncludes);
}
// browse.path is not set by default anymore. When it is not set, the includePath will be used instead.
if (!settings.defaultDefines) {
if (isUnset(settings.defaultDefines)) {
configuration.defines = (process.platform === 'win32') ? ["_DEBUG", "UNICODE", "_UNICODE"] : [];
}
if (!settings.defaultMacFrameworkPath && process.platform === 'darwin') {
if (isUnset(settings.defaultMacFrameworkPath) && process.platform === 'darwin') {
configuration.macFrameworkPath = this.defaultFrameworks;
}
if (!settings.defaultWindowsSdkVersion && process.platform === 'win32') {
if (isUnset(settings.defaultWindowsSdkVersion) && this.defaultWindowsSdkVersion && process.platform === 'win32') {
configuration.windowsSdkVersion = this.defaultWindowsSdkVersion;
}
if (!settings.defaultCompilerPath && this.defaultCompilerPath) {
if (isUnset(settings.defaultCompilerPath) && this.defaultCompilerPath) {
configuration.compilerPath = this.defaultCompilerPath;
}
if (!settings.defaultCStandard && this.defaultCStandard) {
if (isUnset(settings.defaultCStandard) && this.defaultCStandard) {
configuration.cStandard = this.defaultCStandard;
}
if (!settings.defaultCppStandard && this.defaultCppStandard) {
if (isUnset(settings.defaultCppStandard) && this.defaultCppStandard) {
configuration.cppStandard = this.defaultCppStandard;
}
if (!settings.defaultIntelliSenseMode) {
if (isUnset(settings.defaultIntelliSenseMode)) {
configuration.intelliSenseMode = this.defaultIntelliSenseMode;
}
this.configurationIncomplete = false;
}
}
private get ExtendedEnvironment(): Environment {
let result: Environment = {};
if (this.configurationJson.env) {
Object.assign(result, this.configurationJson.env);
}
result["workspaceFolderBasename"] = this.rootUri ? path.basename(this.rootUri.fsPath) : "";
return result;
}
private async buildVcpkgIncludePath(): Promise<void> {
try {
// Check for vcpkgRoot and include relevent paths if found.
@@ -300,15 +316,19 @@ export class CppProperties {
private getIntelliSenseModeForPlatform(name: string): string {
// Do the built-in configs first.
if (name === "Linux" || name === "Mac") {
if (name === "Linux") {
return "gcc-x64";
} else if (name === "Mac") {
return "clang-x64";
} else if (name === "Win32") {
return "msvc-x64";
} else if (process.platform === 'win32') {
// Custom configs default to the OS's preference.
return "msvc-x64";
} else {
} else if (process.platform === 'darwin') {
return "clang-x64";
} else {
return "gcc-x64";
}
}
@@ -343,7 +363,11 @@ export class CppProperties {
});
} else {
let settings: CppSettings = new CppSettings(this.rootUri);
settings.update("default.configurationProvider", providerId);
if (providerId) {
settings.update("default.configurationProvider", providerId);
} else {
settings.update("default.configurationProvider", undefined); // delete the setting
}
this.CurrentConfiguration.configurationProvider = providerId;
resolve();
}
@@ -385,11 +409,11 @@ export class CppProperties {
return result;
}
private resolveAndSplit(paths: string[] | undefined, defaultValue: string[]): string[] {
private resolveAndSplit(paths: string[] | undefined, defaultValue: string[], env: Environment): string[] {
let result: string[] = [];
if (paths) {
paths.forEach(entry => {
let entries: string[] = util.resolveVariables(entry, this.configurationJson.env).split(";").filter(e => e);
let entries: string[] = util.resolveVariables(entry, env).split(";").filter(e => e);
entries = this.resolveDefaults(entries, defaultValue);
result = result.concat(entries);
});
@@ -397,29 +421,29 @@ export class CppProperties {
return result;
}
private resolveVariables(input: string | boolean, defaultValue: string | boolean): string | boolean {
private resolveVariables(input: string | boolean, defaultValue: string | boolean, env: Environment): string | boolean {
if (input === undefined || input === "${default}") {
input = defaultValue;
}
if (typeof input === "boolean") {
return input;
}
return util.resolveVariables(input, this.configurationJson.env);
return util.resolveVariables(input, env);
}
private updateConfiguration(property: string[], defaultValue: string[]): string[];
private updateConfiguration(property: string, defaultValue: string): string;
private updateConfiguration(property: string | boolean, defaultValue: boolean): boolean;
private updateConfiguration(property, defaultValue): any {
if (typeof property === "string" || typeof defaultValue === "string") {
return this.resolveVariables(property, defaultValue);
} else if (typeof property === "boolean" || typeof defaultValue === "boolean") {
return this.resolveVariables(property, defaultValue);
} else if (property instanceof Array || defaultValue instanceof Array) {
private updateConfiguration(property: string[], defaultValue: string[], env: Environment): string[];
private updateConfiguration(property: string, defaultValue: string, env: Environment): string;
private updateConfiguration(property: string | boolean, defaultValue: boolean, env: Environment): boolean;
private updateConfiguration(property, defaultValue, env): any {
if (util.isString(property) || util.isString(defaultValue)) {
return this.resolveVariables(property, defaultValue, env);
} else if (util.isBoolean(property) || util.isBoolean(defaultValue)) {
return this.resolveVariables(property, defaultValue, env);
} else if (util.isArrayOfString(property) || util.isArrayOfString(defaultValue)) {
if (property) {
return this.resolveAndSplit(property, defaultValue);
return this.resolveAndSplit(property, defaultValue, env);
} else if (property === undefined && defaultValue) {
return this.resolveAndSplit(defaultValue, []);
return this.resolveAndSplit(defaultValue, [], env);
}
}
return property;
@@ -427,20 +451,21 @@ export class CppProperties {
private updateServerOnFolderSettingsChange(): void {
let settings: CppSettings = new CppSettings(this.rootUri);
let env: Environment = this.ExtendedEnvironment;
for (let i: number = 0; i < this.configurationJson.configurations.length; i++) {
let configuration: Configuration = this.configurationJson.configurations[i];
configuration.includePath = this.updateConfiguration(configuration.includePath, settings.defaultIncludePath);
configuration.defines = this.updateConfiguration(configuration.defines, settings.defaultDefines);
configuration.macFrameworkPath = this.updateConfiguration(configuration.macFrameworkPath, settings.defaultMacFrameworkPath);
configuration.windowsSdkVersion = this.updateConfiguration(configuration.windowsSdkVersion, settings.defaultWindowsSdkVersion);
configuration.forcedInclude = this.updateConfiguration(configuration.forcedInclude, settings.defaultForcedInclude);
configuration.compileCommands = this.updateConfiguration(configuration.compileCommands, settings.defaultCompileCommands);
configuration.compilerPath = this.updateConfiguration(configuration.compilerPath, settings.defaultCompilerPath);
configuration.cStandard = this.updateConfiguration(configuration.cStandard, settings.defaultCStandard);
configuration.cppStandard = this.updateConfiguration(configuration.cppStandard, settings.defaultCppStandard);
configuration.intelliSenseMode = this.updateConfiguration(configuration.intelliSenseMode, settings.defaultIntelliSenseMode);
configuration.configurationProvider = this.updateConfiguration(configuration.configurationProvider, settings.defaultConfigurationProvider);
configuration.includePath = this.updateConfiguration(configuration.includePath, settings.defaultIncludePath, env);
configuration.defines = this.updateConfiguration(configuration.defines, settings.defaultDefines, env);
configuration.macFrameworkPath = this.updateConfiguration(configuration.macFrameworkPath, settings.defaultMacFrameworkPath, env);
configuration.windowsSdkVersion = this.updateConfiguration(configuration.windowsSdkVersion, settings.defaultWindowsSdkVersion, env);
configuration.forcedInclude = this.updateConfiguration(configuration.forcedInclude, settings.defaultForcedInclude, env);
configuration.compileCommands = this.updateConfiguration(configuration.compileCommands, settings.defaultCompileCommands, env);
configuration.compilerPath = this.updateConfiguration(configuration.compilerPath, settings.defaultCompilerPath, env);
configuration.cStandard = this.updateConfiguration(configuration.cStandard, settings.defaultCStandard, env);
configuration.cppStandard = this.updateConfiguration(configuration.cppStandard, settings.defaultCppStandard, env);
configuration.intelliSenseMode = this.updateConfiguration(configuration.intelliSenseMode, settings.defaultIntelliSenseMode, env);
configuration.configurationProvider = this.updateConfiguration(configuration.configurationProvider, settings.defaultConfigurationProvider, env);
if (!configuration.browse) {
configuration.browse = {};
@@ -459,11 +484,11 @@ export class CppProperties {
}
}
} else {
configuration.browse.path = this.updateConfiguration(configuration.browse.path, settings.defaultBrowsePath);
configuration.browse.path = this.updateConfiguration(configuration.browse.path, settings.defaultBrowsePath, env);
}
configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfiguration(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders);
configuration.browse.databaseFilename = this.updateConfiguration(configuration.browse.databaseFilename, settings.defaultDatabaseFilename);
configuration.browse.limitSymbolsToIncludedHeaders = this.updateConfiguration(configuration.browse.limitSymbolsToIncludedHeaders, settings.defaultLimitSymbolsToIncludedHeaders, env);
configuration.browse.databaseFilename = this.updateConfiguration(configuration.browse.databaseFilename, settings.defaultDatabaseFilename, env);
}
this.updateCompileCommandsFileWatchers();
@@ -513,6 +538,13 @@ export class CppProperties {
this.resetToDefaultSettings(true);
}
this.applyDefaultIncludePathsAndFrameworks();
let settings: CppSettings = new CppSettings(this.rootUri);
if (settings.defaultConfigurationProvider) {
this.configurationJson.configurations.forEach(config => {
config.configurationProvider = settings.defaultConfigurationProvider;
});
settings.update("default.configurationProvider", undefined); // delete the setting
}
edit.insert(document.uri, new vscode.Position(0, 0), JSON.stringify(this.configurationJson, null, 4));
vscode.workspace.applyEdit(edit).then((status) => {
// Fix for issue 163
@@ -595,6 +627,7 @@ export class CppProperties {
if (this.configurationJson.env) {
delete this.configurationJson.env['workspaceRoot'];
delete this.configurationJson.env['workspaceFolder'];
delete this.configurationJson.env['workspaceFolderBasename'];
delete this.configurationJson.env['default'];
}
@@ -611,7 +644,7 @@ export class CppProperties {
if (this.configurationJson.version === 2) {
this.updateToVersion3();
}
if (this.configurationJson.version === 3) {
this.updateToVersion4();
} else {
@@ -623,7 +656,7 @@ export class CppProperties {
if (dirty) {
try {
fs.writeFileSync(this.propertiesFile.fsPath, JSON.stringify(this.configurationJson, null, 4));
} catch {
} catch (err) {
// Ignore write errors, the file may be under source control. Updated settings will only be modified in memory.
vscode.window.showWarningMessage('Attempt to update "' + this.propertiesFile.fsPath + '" failed (do you have write access?)');
}
+41 -11
View File
@@ -4,15 +4,17 @@
* ------------------------------------------------------------------------------------------ */
'use strict';
import { CustomConfigurationProvider, Version, SourceFileConfigurationItem } from 'vscode-cpptools';
import * as vscode from 'vscode';
import { CustomConfigurationProvider, Version, SourceFileConfigurationItem, WorkspaceBrowseConfiguration } from 'vscode-cpptools';
import { CppSettings } from './settings';
/**
* An interface that is guaranteed to be backward compatible with version 0
*/
export interface CustomConfigurationProvider1 extends CustomConfigurationProvider {
isValid: boolean;
version: Version;
isReady: boolean;
readonly isValid: boolean;
readonly version: Version;
}
/**
@@ -20,9 +22,11 @@ export interface CustomConfigurationProvider1 extends CustomConfigurationProvide
*/
class CustomProviderWrapper implements CustomConfigurationProvider1 {
private provider: CustomConfigurationProvider;
private _isReady: boolean;
private _version: Version;
constructor(provider: CustomConfigurationProvider, version: Version) {
this._isReady = version < Version.v2;
this.provider = provider;
if (provider.extensionId && version === Version.v0) {
version = Version.v1; // provider implemented the new API but is interfacing with the extension using the old API version.
@@ -30,15 +34,21 @@ class CustomProviderWrapper implements CustomConfigurationProvider1 {
this._version = version;
}
public get isReady(): boolean {
return this._isReady;
}
public set isReady(ready: boolean) {
this._isReady = ready;
}
public get isValid(): boolean {
let valid: boolean = true;
if (!this.provider.name || !this.provider.canProvideConfiguration || !this.provider.provideConfigurations) {
valid = false;
let valid: boolean = !!(this.provider.name && this.provider.canProvideConfiguration && this.provider.provideConfigurations);
if (valid && this._version > Version.v0) {
valid = !!(this.provider.extensionId && this.provider.dispose);
}
if (this._version !== Version.v0) {
if (!this.provider.extensionId || !this.provider.dispose) {
valid = false;
}
if (valid && this._version > Version.v1) {
valid = !!(this.provider.canProvideBrowseConfiguration && this.provider.provideBrowseConfiguration);
}
return valid;
}
@@ -63,6 +73,15 @@ class CustomProviderWrapper implements CustomConfigurationProvider1 {
return this.provider.provideConfigurations(uris, token);
}
public canProvideBrowseConfiguration(token?: vscode.CancellationToken): Thenable<boolean> {
return this._version < Version.v2 ? Promise.resolve(false) : this.provider.canProvideBrowseConfiguration(token);
}
public provideBrowseConfiguration(token?: vscode.CancellationToken): Thenable<WorkspaceBrowseConfiguration> {
console.assert(this._version >= Version.v2);
return this._version < Version.v2 ? Promise.resolve({browsePath: []}) : this.provider.provideBrowseConfiguration(token);
}
public dispose(): void {
if (this._version !== Version.v0) {
this.provider.dispose();
@@ -90,6 +109,12 @@ export class CustomConfigurationProviderCollection {
if (version !== Version.v0 && !provider.dispose) {
missing.push("'dispose'");
}
if (version >= Version.v2 && !provider.canProvideBrowseConfiguration) {
missing.push("'canProvideBrowseConfiguration'");
}
if (version >= Version.v2 && !provider.provideBrowseConfiguration) {
missing.push("'provideBrowseConfiguration'");
}
console.error(`CustomConfigurationProvider was not registered. The following properties are missing from the implementation: ${missing.join(", ")}.`);
}
@@ -111,6 +136,11 @@ export class CustomConfigurationProviderCollection {
}
public add(provider: CustomConfigurationProvider, version: Version): boolean {
if (new CppSettings().intelliSenseEngine === "Disabled") {
console.warn("IntelliSense is disabled. Provider will not be registered.");
return false;
}
let wrapper: CustomProviderWrapper = new CustomProviderWrapper(provider, version);
if (!wrapper.isValid) {
this.logProblems(provider, version);
@@ -122,7 +152,7 @@ export class CustomConfigurationProviderCollection {
let existing: CustomProviderWrapper = this.providers.get(wrapper.extensionId);
exists = (existing.version === Version.v0 && wrapper.version === Version.v0);
}
if (!exists) {
this.providers.set(wrapper.extensionId, wrapper);
} else {
+167 -4
View File
@@ -17,6 +17,11 @@ import { CppSettings } from './settings';
import { PersistentWorkspaceState } from './persistentState';
import { getLanguageConfig } from './languageConfig';
import { getCustomConfigProviders } from './customProviders';
import { PlatformInformation } from '../platform';
import { Range } from 'vscode-languageclient';
import { ChildProcess, spawn, execSync } from 'child_process';
import * as tmp from 'tmp';
import { getTargetBuildInfo } from '../githubAPI';
let prevCrashFile: string;
let clients: ClientCollection;
@@ -25,9 +30,11 @@ let ui: UI;
let disposables: vscode.Disposable[] = [];
let languageConfigurations: vscode.Disposable[] = [];
let intervalTimer: NodeJS.Timer;
let insiderUpdateTimer: NodeJS.Timer;
let realActivationOccurred: boolean = false;
let tempCommands: vscode.Disposable[] = [];
let activatedPreviously: PersistentWorkspaceState<boolean>;
const insiderUpdateTimerInterval: number = 1000 * 60 * 60;
/**
* activate: set up the extension for language services
@@ -98,6 +105,10 @@ function onActivationEvent(): void {
}
function realActivation(): void {
if (new CppSettings().intelliSenseEngine === "Disabled") {
throw new Error("Do not activate the extension when IntelliSense is disabled.");
}
realActivationOccurred = true;
console.log("starting language server");
clients = new ClientCollection();
@@ -125,6 +136,12 @@ function realActivation(): void {
reportMacCrashes();
const settings: CppSettings = new CppSettings(clients.ActiveClient.RootUri);
if (settings.updateChannel === 'Insiders') {
insiderUpdateTimer = setInterval(checkAndApplyUpdate, insiderUpdateTimerInterval, settings.updateChannel);
checkAndApplyUpdate(settings.updateChannel);
}
intervalTimer = setInterval(onInterval, 2500);
}
@@ -141,7 +158,19 @@ export function updateLanguageConfigurations(): void {
*********************************************/
function onDidChangeSettings(): void {
const changedActiveClientSettings: { [key: string] : string } = clients.ActiveClient.onDidChangeSettings();
clients.forEach(client => client.onDidChangeSettings());
const newUpdateChannel: string = changedActiveClientSettings['updateChannel'];
if (newUpdateChannel) {
if (newUpdateChannel === 'Default') {
clearInterval(insiderUpdateTimer);
} else if (newUpdateChannel === 'Insiders') {
insiderUpdateTimer = setInterval(checkAndApplyUpdate, insiderUpdateTimerInterval);
}
checkAndApplyUpdate(newUpdateChannel);
}
}
let saveMessageShown: boolean = false;
@@ -169,7 +198,7 @@ function onDidChangeActiveTextEditor(editor: vscode.TextEditor): void {
} else {
activeDocument = editor.document.uri.toString();
clients.activeDocumentChanged(editor.document);
clients.ActiveClient.selectionChanged(editor.selection.start);
clients.ActiveClient.selectionChanged(Range.create(editor.selection.start, editor.selection.end));
}
ui.activeDocumentChanged();
}
@@ -187,7 +216,7 @@ function onDidChangeTextEditorSelection(event: vscode.TextEditorSelectionChangeE
clients.activeDocumentChanged(event.textEditor.document);
ui.activeDocumentChanged();
}
clients.ActiveClient.selectionChanged(event.selections[0].start);
clients.ActiveClient.selectionChanged(Range.create(event.selections[0].start, event.selections[0].end));
}
function onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]): void {
@@ -199,6 +228,134 @@ function onInterval(): void {
clients.ActiveClient.onInterval();
}
/**
* Install a VSIX package. This helper function will exist until VSCode offers a command to do so.
* @param updateChannel The user's updateChannel setting.
*/
async function installVsix(vsixLocation: string, updateChannel: string): Promise<void> {
// Get the path to the VSCode command -- replace logic later when VSCode allows calling of
// workbench.extensions.action.installVSIX from TypeScript w/o instead popping up a file dialog
return PlatformInformation.GetPlatformInformation().then((platformInfo) => {
const vsCodeScriptPath: string = function(platformInfo): string {
if (platformInfo.platform === 'win32') {
const vsCodeBinName: string = path.basename(process.execPath);
let cmdFile: string; // Windows VS Code Insiders breaks VS Code naming conventions
if (vsCodeBinName === 'Code - Insiders.exe') {
cmdFile = 'code-insiders.cmd';
} else {
cmdFile = 'code.cmd';
}
const vsCodeExeDir: string = path.dirname(process.execPath);
return path.join(vsCodeExeDir, 'bin', cmdFile);
} else if (platformInfo.platform === 'darwin') {
return path.join(process.execPath, '..', '..', '..', '..', '..',
'Resources', 'app', 'bin', 'code');
} else {
const vsCodeBinName: string = path.basename(process.execPath);
try {
const stdout: Buffer = execSync('which ' + vsCodeBinName);
return stdout.toString().trim();
} catch (error) {
return undefined;
}
}
}(platformInfo);
if (!vsCodeScriptPath) {
return Promise.reject(new Error('Failed to find VS Code script'));
}
// Install the VSIX
return new Promise<void>((resolve, reject) => {
let process: ChildProcess;
try {
process = spawn(vsCodeScriptPath, ['--install-extension', vsixLocation]);
if (process.pid === undefined) {
throw new Error();
}
} catch (error) {
reject(new Error('Failed to launch VS Code script process for installation'));
return;
}
// Timeout the process if no response is sent back. Ensures this Promise resolves/rejects
const timer: NodeJS.Timer = setTimeout(() => {
process.kill();
reject(new Error('Failed to receive response from VS Code script process for installation within 10s.'));
}, 10000);
// If downgrading, the VS Code CLI will prompt whether the user is sure they would like to downgrade.
// Respond to this by writing 0 to stdin (the option to override and install the VSIX package)
let sentOverride: boolean = false;
process.stdout.on('data', () => {
if (sentOverride) {
return;
}
process.stdin.write('0\n');
sentOverride = true;
clearInterval(timer);
resolve();
});
});
});
}
/**
* Query package.json and the GitHub API to determine whether the user should update, if so then install the update.
* The update can be an upgrade or downgrade depending on the the updateChannel setting.
* @param updateChannel The user's updateChannel setting.
*/
async function checkAndApplyUpdate(updateChannel: string): Promise<void> {
// Wrap in new Promise to allow tmp.file callback to successfully resolve/reject
// as tmp.file does not do anything with the callback functions return value
const p: Promise<void> = new Promise<void>((resolve, reject) => {
getTargetBuildInfo(updateChannel).then(buildInfo => {
if (!buildInfo) {
resolve();
return;
}
// Create a temporary file, download the VSIX to it, then install the VSIX
tmp.file({postfix: '.vsix'}, async (err, vsixPath, fd, cleanupCallback) => {
if (err) {
reject(new Error('Failed to create vsix file'));
return;
}
// Place in try/catch as the .catch call catches a rejection in downloadFileToDestination
// then the .catch call will return a resolved promise
// Thusly, the .catch call must also throw, as a return would simply return an unused promise
// instead of returning early from this function scope
try {
await util.downloadFileToDestination(buildInfo.downloadUrl, vsixPath)
.catch(() => { throw new Error('Failed to download VSIX package'); });
await installVsix(vsixPath, updateChannel)
.catch((error: Error) => { throw error; });
} catch (error) {
reject(error);
return;
}
clearInterval(insiderUpdateTimer);
const message: string =
`The C/C++ Extension has been updated to version ${buildInfo.name}. Please reload the window for the changes to take effect.`;
util.promptReloadWindow(message);
telemetry.logLanguageServerEvent('installVsix', { 'success': 'true' });
resolve();
});
}, (error: Error) => {
// Handle getTargetBuildInfo rejection
reject(error);
});
});
await p.catch((error: Error) => {
// Handle .then following getTargetBuildInfo rejection
if (error.message.indexOf('/') !== -1 || error.message.indexOf('\\') !== -1) {
error.message = "Potential PII hidden";
}
telemetry.logLanguageServerEvent('installVsix', { 'error': error.message, 'success': 'false' });
});
}
/*********************************************
* registered commands
*********************************************/
@@ -504,9 +661,14 @@ function handleCrashFileRead(err: NodeJS.ErrnoException, data: string): void {
endCrash = data.length - 1;
}
data = data.substr(startCrash, endCrash - startCrash);
if (data.length > 16384) {
data = data.substr(0, 16384) + "...";
if (data.length > 8192) { // The API has an 8k limit.
data = data.substr(0, 8189) + "...";
}
if (data.length < 2) {
return; // Don't send telemetry if there's no call stack.
}
// Get rid of the memory addresses (which breaks being able get a hit count for each crash call stack).
data = data.replace(/0x................ /g, "");
crashObject["CrashingThreadCallStack"] = data;
telemetry.logLanguageServerEvent("MacCrash", crashObject, null);
}
@@ -515,6 +677,7 @@ export function deactivate(): Thenable<void> {
console.log("deactivating extension");
telemetry.logLanguageServerEvent("LanguageServerShutdown");
clearInterval(intervalTimer);
clearInterval(insiderUpdateTimer);
disposables.forEach(d => d.dispose());
languageConfigurations.forEach(d => d.dispose());
ui.dispose();
@@ -20,12 +20,16 @@ class PersistentStateBase<T> {
}
public get Value(): T {
return this.state.get<T>(this.key, this.defaultvalue);
return this.state.get<T>(this.key, this.defaultvalue);
}
public set Value(newValue: T) {
this.state.update(this.key, newValue);
}
public get DefaultValue(): T {
return this.defaultvalue;
}
}
// Abstraction for global state that persists across activations but is not present in a settings file
+4
View File
@@ -41,15 +41,19 @@ export class CppSettings extends Settings {
public get errorSquiggles(): string { return super.Section.get<string>("errorSquiggles"); }
public get dimInactiveRegions(): boolean { return super.Section.get<boolean>("dimInactiveRegions"); }
public get inactiveRegionOpacity(): number { return super.Section.get<number>("inactiveRegionOpacity"); }
public get inactiveRegionForegroundColor(): string { return super.Section.get<string>("inactiveRegionForegroundColor"); }
public get inactiveRegionBackgroundColor(): string { return super.Section.get<string>("inactiveRegionBackgroundColor"); }
public get autoComplete(): string { return super.Section.get<string>("autocomplete"); }
public get loggingLevel(): string { return super.Section.get<string>("loggingLevel"); }
public get navigationLength(): number { return super.Section.get<number>("navigation.length", 60); }
public get autoAddFileAssociations(): boolean { return super.Section.get<boolean>("autoAddFileAssociations"); }
public get workspaceParsingPriority(): boolean { return super.Section.get<boolean>("workspaceParsingPriority"); }
public get workspaceSymbols(): string { return super.Section.get<string>("workspaceSymbols"); }
public get exclusionPolicy(): boolean { return super.Section.get<boolean>("exclusionPolicy"); }
public get commentContinuationPatterns(): (string | CommentPattern)[] { return super.Section.get<(string | CommentPattern)[]>("commentContinuationPatterns"); }
public get configurationWarnings(): string { return super.Section.get<string>("configurationWarnings"); }
public get preferredPathSeparator(): string { return super.Section.get<string>("preferredPathSeparator"); }
public get updateChannel(): string { return super.Section.get<string>("updateChannel"); }
public get defaultIncludePath(): string[] { return super.Section.get<string[]>("default.includePath"); }
public get defaultDefines(): string[] { return super.Section.get<string[]>("default.defines"); }
public get defaultMacFrameworkPath(): string[] { return super.Section.get<string[]>("default.macFrameworkPath"); }
+62 -2
View File
@@ -17,11 +17,24 @@ interface KeyedQuickPickItem extends vscode.QuickPickItem {
key: string;
}
// Higher numbers mean greater priority.
enum ConfigurationPriority {
IncludePath = 1,
CompileCommands = 2,
CustomProvider = 3,
}
interface ConfigurationResult {
configured: boolean;
priority: ConfigurationPriority;
}
export class UI {
private navigationStatusBarItem: vscode.StatusBarItem;
private configStatusBarItem: vscode.StatusBarItem;
private browseEngineStatusBarItem: vscode.StatusBarItem;
private intelliSenseStatusBarItem: vscode.StatusBarItem;
private configurationUIPromise: Thenable<ConfigurationResult>;
constructor() {
// 1000 = priority, it needs to be high enough to be on the left of the Ln/Col.
@@ -164,14 +177,18 @@ export class UI {
.then(selection => (selection) ? selection.index : -1);
}
public showConfigurationProviders(): Thenable<string|undefined> {
public showConfigurationProviders(currentProvider: string|null): Thenable<string|undefined> {
let options: vscode.QuickPickOptions = {};
options.placeHolder = "Select a Configuration Provider...";
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
let items: KeyedQuickPickItem[] = [];
providers.forEach(provider => {
items.push({ label: provider.name, description: "", key: provider.extensionId });
let label: string = provider.name;
if (provider.extensionId === currentProvider) {
label += " (active)";
}
items.push({ label: label, description: "", key: provider.extensionId });
});
items.push({ label: "(none)", description: "Disable the active configuration provider, if applicable.", key: "" });
@@ -219,6 +236,49 @@ export class UI {
.then(selection => (selection) ? selection.index : -1);
}
public showConfigureIncludePathMessage(prompt: () => Thenable<boolean>, onSkip: () => void): void {
setTimeout(() => {
this.showConfigurationPrompt(ConfigurationPriority.IncludePath, prompt, onSkip);
}, 10000);
}
public showConfigureCompileCommandsMessage(prompt: () => Thenable<boolean>, onSkip: () => void): void {
setTimeout(() => {
this.showConfigurationPrompt(ConfigurationPriority.CompileCommands, prompt, onSkip);
}, 5000);
}
public showConfigureCustomProviderMessage(prompt: () => Thenable<boolean>, onSkip: () => void): void {
this.showConfigurationPrompt(ConfigurationPriority.CustomProvider, prompt, onSkip);
}
private showConfigurationPrompt(priority: ConfigurationPriority, prompt: () => Thenable<boolean>, onSkip: () => void): void {
let showPrompt: () => Thenable<ConfigurationResult> = async () => {
let configured: boolean = await prompt();
return Promise.resolve({
priority: priority,
configured: configured
});
};
if (this.configurationUIPromise) {
this.configurationUIPromise = this.configurationUIPromise.then(result => {
if (priority > result.priority) {
return showPrompt();
} else if (!result.configured) {
return showPrompt();
}
onSkip();
return Promise.resolve({
priority: result.priority,
configured: true
});
});
} else {
this.configurationUIPromise = showPrompt();
}
}
public dispose(): void {
this.configStatusBarItem.dispose();
this.browseEngineStatusBarItem.dispose();
@@ -118,6 +118,7 @@ function copyBinaryDependencies(): void {
copy(miEngineRoot, DebugAdapterBinPath, "Microsoft.MIDebugEngine.dll");
copy(miEngineRoot, DebugAdapterBinPath, "Microsoft.MIDebugEngine.dll.mdb");
copy(miEngineRoot, DebugAdapterBinPath, "osxlaunchhelper.scpt");
copy(miEngineRoot, DebugAdapterBinPath, "Microsoft.VisualStudio.Debugger.Interop.15.0.dll");
copy(openDebugRoot, DebugAdapterBinPath, "Microsoft.VisualStudio.Debugger.Interop.10.0.dll");
copy(openDebugRoot, DebugAdapterBinPath, "Microsoft.VisualStudio.Debugger.Interop.11.0.dll");
@@ -129,6 +130,8 @@ function copyBinaryDependencies(): void {
copy(openDebugRoot, DebugAdapterBinPath, "OpenDebugAD7.exe.config");
copy(openDebugRoot, DebugAdapterBinPath, "OpenDebugAD7.exe.mdb");
copy(openDebugRoot, DebugAdapterBinPath, "Newtonsoft.Json.dll");
copy(openDebugRoot, DebugAdapterBinPath, "WindowsDebugLauncher.exe");
copy(openDebugRoot, DebugAdapterBinPath, "Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.dll");
}
function copyMonoDependencies(): void {
+28 -61
View File
@@ -4,15 +4,10 @@
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as url from 'url';
import * as https from 'https';
import { ClientRequest } from 'http';
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as util from './common';
import * as Telemetry from './telemetry';
import { PersistentState } from './LanguageServer/persistentState';
import * as fs from 'fs';
const userBucketMax: number = 100;
const userBucketString: string = "CPP.UserBucket";
@@ -21,61 +16,66 @@ const localConfigFile: string = "cpptools.json";
interface Settings {
defaultIntelliSenseEngine?: number;
recursiveIncludes?: number;
gotoDefIntelliSense?: number;
}
export class ABTestSettings {
private settings: Settings;
private intelliSenseEngineDefault: PersistentState<number>;
private recursiveIncludesDefault: PersistentState<number>;
private gotoDefIntelliSenseDefault: PersistentState<number>;
private bucket: PersistentState<number>;
constructor() {
this.intelliSenseEngineDefault = new PersistentState<number>("ABTest.1", 100);
this.recursiveIncludesDefault = new PersistentState<number>("ABTest.2", 100);
this.gotoDefIntelliSenseDefault = new PersistentState<number>("ABTest.3", 100);
this.settings = {
defaultIntelliSenseEngine: this.intelliSenseEngineDefault.Value,
recursiveIncludes: this.recursiveIncludesDefault.Value
recursiveIncludes: this.recursiveIncludesDefault.Value,
gotoDefIntelliSense: this.gotoDefIntelliSenseDefault.Value
};
this.bucket = new PersistentState<number>(userBucketString, -1);
if (this.bucket.Value === -1) {
this.bucket.Value = Math.floor(Math.random() * userBucketMax) + 1; // Range is [1, userBucketMax].
}
this.updateSettingsAsync().then(() => {
// Redownload cpptools.json after initialization so it's not blocked.
// It'll be used the next time the extension reloads.
this.downloadCpptoolsJsonPkgAsync();
});
this.updateSettings();
// Redownload cpptools.json after initialization so it's not blocked.
// It'll be used the next time the extension reloads.
this.downloadCpptoolsJsonPkgAsync();
// Redownload occasionally to prevent an extra reload during long sessions.
setInterval(() => { this.downloadCpptoolsJsonPkgAsync(); }, 30 * 60 * 1000); // 30 minutes.
}
public get UseDefaultIntelliSenseEngine(): boolean {
return this.settings.defaultIntelliSenseEngine ? this.settings.defaultIntelliSenseEngine >= this.bucket.Value : true;
return util.isNumber(this.settings.defaultIntelliSenseEngine) ? this.settings.defaultIntelliSenseEngine >= this.bucket.Value : true;
}
public get UseRecursiveIncludes(): boolean {
return this.settings.recursiveIncludes ? this.settings.recursiveIncludes >= this.bucket.Value : true;
return util.isNumber(this.settings.recursiveIncludes) ? this.settings.recursiveIncludes >= this.bucket.Value : true;
}
private async updateSettingsAsync(): Promise<void> {
public get UseGoToDefIntelliSense(): boolean {
return util.isNumber(this.settings.gotoDefIntelliSense) ? this.settings.gotoDefIntelliSense >= this.bucket.Value : true;
}
private updateSettings(): void {
const cpptoolsJsonFile: string = util.getExtensionFilePath(localConfigFile);
try {
const exists: boolean = await util.checkFileExists(cpptoolsJsonFile);
const exists: boolean = fs.existsSync(cpptoolsJsonFile);
if (exists) {
const fileContent: string = await util.readFileText(cpptoolsJsonFile);
const fileContent: string = fs.readFileSync(cpptoolsJsonFile).toString();
let newSettings: Settings = <Settings>JSON.parse(fileContent);
if (newSettings.defaultIntelliSenseEngine) {
this.intelliSenseEngineDefault.Value = newSettings.defaultIntelliSenseEngine;
}
if (newSettings.recursiveIncludes) {
this.recursiveIncludesDefault.Value = newSettings.recursiveIncludes;
}
this.intelliSenseEngineDefault.Value = util.isNumber(newSettings.defaultIntelliSenseEngine) ? newSettings.defaultIntelliSenseEngine : this.intelliSenseEngineDefault.DefaultValue;
this.recursiveIncludesDefault.Value = util.isNumber(newSettings.recursiveIncludes) ? newSettings.recursiveIncludes : this.recursiveIncludesDefault.DefaultValue;
this.gotoDefIntelliSenseDefault.Value = util.isNumber(newSettings.gotoDefIntelliSense) ? newSettings.gotoDefIntelliSense : this.gotoDefIntelliSenseDefault.DefaultValue;
this.settings = {
defaultIntelliSenseEngine: this.intelliSenseEngineDefault.Value,
recursiveIncludes: this.recursiveIncludesDefault.Value
recursiveIncludes: this.recursiveIncludesDefault.Value,
gotoDefIntelliSense: this.gotoDefIntelliSenseDefault.Value
};
}
} catch (error) {
@@ -83,50 +83,17 @@ export class ABTestSettings {
}
}
// NOTE: Code is copied from DownloadPackage in packageManager.ts, but with ~75% fewer lines.
private downloadCpptoolsJsonAsync(urlString): Promise<void> {
return new Promise<void>((resolve, reject) => {
let parsedUrl: url.Url = url.parse(urlString);
let request: ClientRequest = https.request({
host: parsedUrl.host,
path: parsedUrl.path,
agent: util.getHttpsProxyAgent(),
rejectUnauthorized: vscode.workspace.getConfiguration().get("http.proxyStrictSSL", true)
}, (response) => {
if (response.statusCode === 301 || response.statusCode === 302) {
let redirectUrl: string | string[];
if (typeof response.headers.location === "string") {
redirectUrl = response.headers.location;
} else {
redirectUrl = response.headers.location[0];
}
return resolve(this.downloadCpptoolsJsonAsync(redirectUrl)); // Redirect - download from new location
}
if (response.statusCode !== 200) {
return reject();
}
let downloadedBytes = 0; // tslint:disable-line
let cppToolsJsonFile: fs.WriteStream = fs.createWriteStream(util.getExtensionFilePath(localConfigFile));
response.on('data', (data) => { downloadedBytes += data.length; });
response.on('end', () => { cppToolsJsonFile.close(); });
cppToolsJsonFile.on('close', () => { resolve(); this.updateSettingsAsync(); });
response.on('error', (error) => { reject(); });
response.pipe(cppToolsJsonFile, { end: false });
});
request.on('error', (error) => { reject(); });
request.end();
});
}
private downloadCpptoolsJsonPkgAsync(): Promise<void> {
let hasError: boolean = false;
let telemetryProperties: { [key: string]: string } = {};
return this.downloadCpptoolsJsonAsync("https://go.microsoft.com/fwlink/?linkid=852750")
const localConfigPath: string = util.getExtensionFilePath(localConfigFile);
return util.downloadFileToDestination("https://go.microsoft.com/fwlink/?linkid=2026205", localConfigPath)
.catch((error) => {
// More specific error info is not likely to be helpful, and we get detailed download data from the initial install.
hasError = true;
})
.then(() => {
this.updateSettings();
telemetryProperties['success'] = (!hasError).toString();
Telemetry.logDebuggerEvent("cpptoolsJsonDownload", telemetryProperties);
});
+9
View File
@@ -11,6 +11,7 @@ class TemporaryCommandRegistrar {
// Used to save/re-execute commands used before the extension has activated (e.g. delayed by dependency downloading).
private delayedCommandsToExecute: Set<string>;
private tempCommands: vscode.Disposable[]; // Need to save this to unregister/dispose the temporary commands.
private isLanguageServerDisabled: boolean;
private commandsToRegister: string[] = [
"C_Cpp.ConfigurationEdit",
@@ -44,10 +45,18 @@ class TemporaryCommandRegistrar {
public registerTempCommand(command: string): void {
this.tempCommands.push(vscode.commands.registerCommand(command, () => {
if (this.isLanguageServerDisabled) {
vscode.window.showInformationMessage("The command is disabled because \"C_Cpp.intelliSenseEngine\" is set to \"Disabled\".");
return;
}
this.delayedCommandsToExecute.add(command);
}));
}
public disableLanguageServer(): void {
this.isLanguageServerDisabled = true;
}
public activateLanguageServer(): void {
// Main activation code.
this.tempCommands.forEach((command) => {
+162 -43
View File
@@ -14,6 +14,8 @@ import * as url from 'url';
import { PlatformInformation } from './platform';
import { getOutputChannelLogger, showOutputChannel } from './logger';
import * as assert from 'assert';
import * as https from 'https';
import { ClientRequest, OutgoingHttpHeaders } from 'http';
export let extensionContext: vscode.ExtensionContext;
export function setExtensionContext(context: vscode.ExtensionContext): void {
@@ -169,6 +171,38 @@ export function showReleaseNotes(): void {
vscode.commands.executeCommand('vscode.previewHtml', vscode.Uri.file(getExtensionFilePath("ReleaseNotes.html")), vscode.ViewColumn.One, "C/C++ Extension Release Notes");
}
export function isUri(input: any): input is vscode.Uri {
return input && input instanceof vscode.Uri;
}
export function isString(input: any): input is string {
return typeof(input) === "string";
}
export function isNumber(input: any): input is number {
return typeof(input) === "number";
}
export function isBoolean(input: any): input is boolean {
return typeof(input) === "boolean";
}
export function isArray(input: any): input is any[] {
return input instanceof Array;
}
export function isOptionalString(input: any): input is string|undefined {
return input === undefined || isString(input);
}
export function isArrayOfString(input: any): input is string[] {
return isArray(input) && input.every(item => isString(item));
}
export function isOptionalArrayOfString(input: any): input is string[]|undefined {
return input === undefined || isArrayOfString(input);
}
export function resolveVariables(input: string, additionalEnvironment: {[key: string]: string | string[]}): string {
if (!input) {
return "";
@@ -178,55 +212,60 @@ export function resolveVariables(input: string, additionalEnvironment: {[key: st
}
// Replace environment and configuration variables.
let regexp: RegExp = /\$\{((env|config|workspaceFolder)(.|:))?(.*?)\}/g;
let ret: string = input.replace(regexp, (match: string, ignored1: string, varType: string, ignored2: string, name: string) => {
// Historically, if the variable didn't have anything before the "." or ":"
// it was assumed to be an environment variable
if (varType === undefined) {
varType = "env";
}
let newValue: string = undefined;
switch (varType) {
case "env": {
let v: string | string[] = additionalEnvironment[name];
if (typeof v === "string") {
newValue = v;
} else if (input === match && v instanceof Array) {
newValue = v.join(";");
}
if (!newValue) {
newValue = process.env[name];
}
break;
let regexp: () => RegExp = () => /\$\{((env|config|workspaceFolder)(\.|:))?(.*?)\}/g;
let ret: string = input;
let cycleCache: Set<string> = new Set();
while (!cycleCache.has(ret)) {
cycleCache.add(ret);
ret = ret.replace(regexp(), (match: string, ignored1: string, varType: string, ignored2: string, name: string) => {
// Historically, if the variable didn't have anything before the "." or ":"
// it was assumed to be an environment variable
if (varType === undefined) {
varType = "env";
}
case "config": {
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration();
if (config) {
newValue = config.get<string>(name);
}
break;
}
case "workspaceFolder": {
// Only replace ${workspaceFolder:name} variables for now.
// We may consider doing replacement of ${workspaceFolder} here later, but we would have to update the language server and also
// intercept messages with paths in them and add the ${workspaceFolder} variable back in (e.g. for light bulb suggestions)
if (name && vscode.workspace && vscode.workspace.workspaceFolders) {
let folder: vscode.WorkspaceFolder = vscode.workspace.workspaceFolders.find(folder => folder.name.toLocaleLowerCase() === name.toLocaleLowerCase());
if (folder) {
newValue = folder.uri.fsPath;
let newValue: string;
switch (varType) {
case "env": {
let v: string | string[] = additionalEnvironment[name];
if (isString(v)) {
newValue = v;
} else if (input === match && isArrayOfString(v)) {
newValue = v.join(";");
}
if (!isString(newValue)) {
newValue = process.env[name];
}
break;
}
break;
case "config": {
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration();
if (config) {
newValue = config.get<string>(name);
}
break;
}
case "workspaceFolder": {
// Only replace ${workspaceFolder:name} variables for now.
// We may consider doing replacement of ${workspaceFolder} here later, but we would have to update the language server and also
// intercept messages with paths in them and add the ${workspaceFolder} variable back in (e.g. for light bulb suggestions)
if (name && vscode.workspace && vscode.workspace.workspaceFolders) {
let folder: vscode.WorkspaceFolder = vscode.workspace.workspaceFolders.find(folder => folder.name.toLocaleLowerCase() === name.toLocaleLowerCase());
if (folder) {
newValue = folder.uri.fsPath;
}
}
break;
}
default: { assert.fail("unknown varType matched"); }
}
default: { assert.fail("unknown varType matched"); }
}
return (newValue) ? newValue : match;
});
return (isString(newValue)) ? newValue : match;
});
}
// Resolve '~' at the start of the path.
regexp = /^\~/g;
ret = ret.replace(regexp, (match: string, name: string) => {
let newValue: string = process.env.HOME;
regexp = () => /^\~/g;
ret = ret.replace(regexp(), (match: string, name: string) => {
let newValue: string = (process.platform === 'win32') ? process.env.USERPROFILE : process.env.HOME;
return (newValue) ? newValue : match;
});
@@ -543,3 +582,83 @@ export async function renamePromise(oldName: string, newName: string): Promise<v
});
});
}
export function promptForReloadWindowDueToSettingsChange(): void {
promptReloadWindow("Reload the workspace for the settings change to take effect.");
}
export function promptReloadWindow(message: string): void {
let reload: string = "Reload";
vscode.window.showInformationMessage(message, reload).then((value: string) => {
if (value === reload) {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
}
export function downloadFileToDestination(urlStr: string, destinationPath: string, headers?: OutgoingHttpHeaders): Promise<void> {
return new Promise<void>((resolve, reject) => {
let parsedUrl: url.Url = url.parse(urlStr);
let request: ClientRequest = https.request({
host: parsedUrl.host,
path: parsedUrl.path,
agent: getHttpsProxyAgent(),
rejectUnauthorized: vscode.workspace.getConfiguration().get('http.proxyStrictSSL', true),
headers: headers
}, (response) => {
if (response.statusCode === 301 || response.statusCode === 302) { // If redirected
// Download from new location
let redirectUrl: string;
if (typeof response.headers.location === 'string') {
redirectUrl = response.headers.location;
} else {
redirectUrl = response.headers.location[0];
}
return resolve(downloadFileToDestination(redirectUrl, destinationPath, headers));
}
if (response.statusCode !== 200) { // If request is not successful
return reject();
}
// Write file using downloaded data
let createdFile: fs.WriteStream = fs.createWriteStream(destinationPath);
createdFile.on('finish', () => { resolve(); });
response.on('error', (error) => { reject(); });
response.pipe(createdFile);
});
request.on('error', (error) => { reject(); });
request.end();
});
}
export function downloadFileToStr(urlStr: string, headers?: OutgoingHttpHeaders): Promise<any> {
return new Promise<string>((resolve, reject) => {
let parsedUrl: url.Url = url.parse(urlStr);
let request: ClientRequest = https.request({
host: parsedUrl.host,
path: parsedUrl.path,
agent: getHttpsProxyAgent(),
rejectUnauthorized: vscode.workspace.getConfiguration().get('http.proxyStrictSSL', true),
headers: headers
}, (response) => {
if (response.statusCode === 301 || response.statusCode === 302) { // If redirected
// Download from new location
let redirectUrl: string;
if (typeof response.headers.location === 'string') {
redirectUrl = response.headers.location;
} else {
redirectUrl = response.headers.location[0];
}
return resolve(downloadFileToStr(redirectUrl, headers));
}
if (response.statusCode !== 200) { // If request is not successful
return reject();
}
let downloadedData: string = '';
response.on('data', (data) => { downloadedData += data; });
response.on('error', (error) => { reject(); });
response.on('end', () => { resolve(downloadedData); });
});
request.on('error', (error) => { reject(); });
request.end();
});
}
+124 -52
View File
@@ -1,52 +1,124 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import { CustomConfigurationProvider, Version } from 'vscode-cpptools';
import { CppToolsTestApi, CppToolsTestHook } from 'vscode-cpptools/out/testApi';
import { CustomConfigurationProvider1, getCustomConfigProviders, CustomConfigurationProviderCollection } from './LanguageServer/customProviders';
import * as LanguageServer from './LanguageServer/extension';
import * as test from './testHook';
export class CppTools implements CppToolsTestApi {
private version: Version;
private providers: CustomConfigurationProvider1[] = [];
constructor(version: Version) {
this.version = version;
}
registerCustomConfigurationProvider(provider: CustomConfigurationProvider): void {
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
if (providers.add(provider, this.version)) {
let added: CustomConfigurationProvider1 = providers.get(provider);
this.providers.push(added);
LanguageServer.getClients().forEach(client => client.onRegisterCustomConfigurationProvider(added));
}
}
didChangeCustomConfiguration(provider: CustomConfigurationProvider): void {
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
let p: CustomConfigurationProvider1 = providers.get(provider);
if (p) {
LanguageServer.getClients().forEach(client => client.updateCustomConfigurations(p));
} else {
console.assert(false, "provider should be registered before sending config change messages");
}
}
dispose(): void {
this.providers.forEach(provider => {
getCustomConfigProviders().remove(provider);
provider.dispose();
});
this.providers = [];
}
getTestHook(): CppToolsTestHook {
return test.getTestHook();
}
}
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import { CustomConfigurationProvider, Version } from 'vscode-cpptools';
import { CppToolsTestApi, CppToolsTestHook } from 'vscode-cpptools/out/testApi';
import { CustomConfigurationProvider1, getCustomConfigProviders, CustomConfigurationProviderCollection } from './LanguageServer/customProviders';
import { getOutputChannel } from './logger';
import * as LanguageServer from './LanguageServer/extension';
import * as test from './testHook';
export class CppTools implements CppToolsTestApi {
private version: Version;
private providers: CustomConfigurationProvider1[] = [];
private failedRegistrations: CustomConfigurationProvider[] = [];
private timers = new Map<string, NodeJS.Timer>();
constructor(version: Version) {
if (version > Version.latest) {
console.warn(`version ${version} is not supported by this version of cpptools`);
console.warn(` using ${Version.latest} instead`);
version = Version.latest;
}
this.version = version;
}
private addNotifyReadyTimer(provider: CustomConfigurationProvider1): void {
if (this.version >= Version.v2) {
const timeout: number = 30;
let timer: NodeJS.Timer = setTimeout(() => {
console.warn(`registered provider ${provider.extensionId} did not call 'notifyReady' within ${timeout} seconds`);
}, timeout * 1000);
this.timers.set(provider.extensionId, timer);
}
}
private removeNotifyReadyTimer(provider: CustomConfigurationProvider1): void {
if (this.version >= Version.v2) {
let timer: NodeJS.Timer = this.timers.get(provider.extensionId);
if (timer) {
this.timers.delete(provider.extensionId);
clearTimeout(timer);
}
}
}
public getVersion(): Version {
return this.version;
}
public registerCustomConfigurationProvider(provider: CustomConfigurationProvider): void {
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
if (providers.add(provider, this.version)) {
let added: CustomConfigurationProvider1 = providers.get(provider);
getOutputChannel().appendLine(`Custom configuration provider '${added.name}' registered`);
this.providers.push(added);
LanguageServer.getClients().forEach(client => client.onRegisterCustomConfigurationProvider(added));
this.addNotifyReadyTimer(added);
} else {
this.failedRegistrations.push(provider);
}
}
public notifyReady(provider: CustomConfigurationProvider): void {
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
let p: CustomConfigurationProvider1 = providers.get(provider);
if (p) {
this.removeNotifyReadyTimer(p);
p.isReady = true;
LanguageServer.getClients().forEach(client => {
client.updateCustomConfigurations(p);
client.updateCustomBrowseConfiguration(p);
});
} else if (this.failedRegistrations.find(p => p === provider)) {
console.warn("provider not successfully registered, 'notifyReady' ignored");
} else {
console.warn("provider should be registered before signaling it's ready to provide configurations");
}
}
public didChangeCustomConfiguration(provider: CustomConfigurationProvider): void {
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
let p: CustomConfigurationProvider1 = providers.get(provider);
if (p) {
if (!p.isReady) {
console.warn("didChangeCustomConfiguration was invoked before notifyReady");
}
LanguageServer.getClients().forEach(client => client.updateCustomConfigurations(p));
} else if (this.failedRegistrations.find(p => p === provider)) {
console.warn("provider not successfully registered, 'didChangeCustomConfiguration' ignored");
} else {
console.warn("provider should be registered before sending config change messages");
}
}
public didChangeCustomBrowseConfiguration(provider: CustomConfigurationProvider): void {
let providers: CustomConfigurationProviderCollection = getCustomConfigProviders();
let p: CustomConfigurationProvider1 = providers.get(provider);
if (p) {
LanguageServer.getClients().forEach(client => client.updateCustomBrowseConfiguration(p));
} else if (this.failedRegistrations.find(p => p === provider)) {
console.warn("provider not successfully registered, 'didChangeCustomBrowseConfiguration' ignored");
} else {
console.warn("provider should be registered before sending config change messages");
}
}
public dispose(): void {
this.providers.forEach(provider => {
getCustomConfigProviders().remove(provider);
provider.dispose();
});
this.providers = [];
}
public getTestHook(): CppToolsTestHook {
return test.getTestHook();
}
}
+13 -4
View File
@@ -27,11 +27,8 @@ export class CppTools1 implements CppToolsTestApi, CppToolsTestExtension {
case Version.v0:
return this.BackupApi;
case Version.v1:
return new CppTools(version);
default:
throw new RangeError(`Invalid version: ${version}`);
return new CppTools(version);
}
}
@@ -39,14 +36,26 @@ export class CppTools1 implements CppToolsTestApi, CppToolsTestExtension {
return <CppToolsTestApi>this.getApi(version);
}
getVersion(): Version {
return this.BackupApi.getVersion();
}
registerCustomConfigurationProvider(provider: CustomConfigurationProvider): void {
this.BackupApi.registerCustomConfigurationProvider(provider);
}
notifyReady(provider: CustomConfigurationProvider): void {
this.BackupApi.notifyReady(provider);
}
didChangeCustomConfiguration(provider: CustomConfigurationProvider): void {
this.BackupApi.didChangeCustomConfiguration(provider);
}
didChangeCustomBrowseConfiguration(provider: CustomConfigurationProvider): void {
this.BackupApi.didChangeCustomBrowseConfiguration(provider);
}
dispose(): void {
}
+265
View File
@@ -0,0 +1,265 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import { PackageVersion } from './packageVersion';
import * as util from './common';
import { PlatformInformation } from './platform';
import { OutgoingHttpHeaders } from 'http';
/**
* The object representation of a Build Asset. Each Asset corresponds to information about a release file on GitHub.
*/
interface Asset {
name: string;
browser_download_url: string;
}
/**
* The object representation of a release in the GitHub API's release JSON.
* Named Build so as to reduce confusion between a "Release" release and "Insiders" release.
*/
interface Build {
name: string;
assets: Asset[];
}
/**
* Search each Asset by name to retrieve the download URL for a VSIX package
* @param vsixName The name of the VSIX to search for
* @return The download URL of the VSIX
*/
function getVsixDownloadUrl(build: Build, vsixName: string): string {
const downloadUrl: string = build.assets.find(asset => {
return asset.name === vsixName;
}).browser_download_url;
if (!downloadUrl) {
throw new Error('Failed to find VSIX: ' + vsixName + ' in build: ' + build.name);
}
return downloadUrl;
}
/**
* Determine whether an object is of type Asset.
* @param input Incoming object.
* @return Whether input is of type Asset.
*/
function isAsset(input: any): input is Asset {
return input && input.name && typeof(input.name) === "string" &&
input.browser_download_url && typeof(input.browser_download_url) === "string";
}
/**
* Determine whether an object is of type Build. Note that earlier releases of the extension
* do not have 4 or greater Assets (Mac, Win, Linux 32/64). Only call this on more recent Builds.
* @param input Incoming object.
* @return Whether input is of type Build.
*/
function isBuild(input: any): input is Build {
return input && input.name && typeof(input.name) === "string" && isArrayOfAssets(input.assets) && input.assets.length >= 4;
}
/**
* Determine whether an object is of type Asset[].
* @param input Incoming object.
* @return Whether input is of type Asset[].
*/
function isArrayOfAssets(input: any): input is Asset[] {
return input instanceof Array && input.every(item => isAsset(item));
}
/**
* Determine whether an object is of type Build[].
* @param input Incoming object.
* @return Whether input is of type Build[].
*/
function isArrayOfBuilds(input: any): input is Build[] {
if (!input || !(input instanceof Array) || input.length === 0) {
return false;
}
// Only check the five most recent builds for validity -- no need to check all of them
for (let i: number = 0; i < 5 && i < input.length; i++) {
if (!isBuild(input[i])) {
return false;
}
}
return true;
}
/**
* Match the user's platform information to the VSIX name relevant to them.
* @param info Information about the user's operating system.
* @return VSIX filename for the extension's releases matched to the user's platform.
*/
function vsixNameForPlatform(info: PlatformInformation): string {
const vsixName: string = function(platformInfo): string {
switch (platformInfo.platform) {
case 'win32': return 'cpptools-win32.vsix';
case 'darwin': return 'cpptools-osx.vsix';
default: {
switch (platformInfo.architecture) {
case 'x86_64': return 'cpptools-linux.vsix';
case 'x86':
case 'i386':
case 'i686': return 'cpptools-linux32.vsix';
}
}
}
}(info);
if (!vsixName) {
throw new Error('Failed to match VSIX name for: ' + info.platform + ':' + info.architecture);
}
return vsixName;
}
/**
* Interface for return value of getTargetBuildInfo containing the download URL and version of a Build.
*/
export interface BuildInfo {
downloadUrl: string;
name: string;
}
/**
* Use the GitHub API to retrieve the download URL of the extension version the user should update to, if any.
* @param updateChannel The user's updateChannel setting.
* @return Download URL for the extension VSIX package that the user should install. If the user
* does not need to update, resolves to undefined.
*/
export async function getTargetBuildInfo(updateChannel: string): Promise<BuildInfo> {
return getReleaseJson()
.then(builds => {
if (!builds || builds.length === 0) {
return undefined;
}
// If the user version is greater than or incomparable to the latest available verion then there is no need to update
// Allows testing pre-releases without accidentally downgrading to the latest version
const userVersion: PackageVersion = new PackageVersion(util.packageJson.version);
const latestVersion: PackageVersion = new PackageVersion(builds[0].name);
if (userVersion.isGreaterThan(latestVersion) || (userVersion.suffix && userVersion.suffix !== 'insiders')) {
return undefined;
}
return getTargetBuild(builds, userVersion, updateChannel);
})
.then(async build => {
if (!build) {
return Promise.resolve(undefined);
}
try {
const platformInfo: PlatformInformation = await PlatformInformation.GetPlatformInformation();
const vsixName: string = vsixNameForPlatform(platformInfo);
const downloadUrl: string = getVsixDownloadUrl(build, vsixName);
return { downloadUrl: downloadUrl, name: build.name };
} catch (error) {
return Promise.reject(error);
}
});
}
/**
* Determines whether there exists a Build in the given Build[] that should be installed.
* @param builds The GitHub release list parsed as an array of Builds.
* @param userVersion The verion of the extension that the user is running.
* @param updateChannel The user's updateChannel setting.
* @return The Build if the user should update to it, otherwise undefined.
*/
function getTargetBuild(builds: Build[], userVersion: PackageVersion, updateChannel: string): Build {
// Get predicates to determine the build to install, if any
let needsUpdate: (installed: PackageVersion, target: PackageVersion) => boolean;
let useBuild: (build: Build) => boolean;
if (updateChannel === 'Insiders') {
needsUpdate = (installed: PackageVersion, target: PackageVersion) => { return target.isGreaterThan(installed); };
useBuild = (build: Build): boolean => { return true; };
} else if (updateChannel === 'Default') {
needsUpdate = function(installed: PackageVersion, target: PackageVersion): boolean { return installed.isGreaterThan(target); };
useBuild = (build: Build): boolean => { return build.name.indexOf('-') === -1; };
} else {
throw new Error('Incorrect updateChannel setting provided');
}
// Get the build to install
const targetBuild: Build = builds.find((build) => useBuild(build));
if (!targetBuild) {
throw new Error('Failed to determine installation candidate');
}
// Check current version against target's version to determine if the installation should happen
const targetVersion: PackageVersion = new PackageVersion(targetBuild.name);
return needsUpdate(userVersion, targetVersion) ? targetBuild : undefined;
}
interface Rate {
remaining: number;
}
interface RateLimit {
rate: Rate;
}
function isRate(input: any): input is Rate {
return input && input.remaining && util.isNumber(input.remaining);
}
function isRateLimit(input: any): input is RateLimit {
return input && isRate(input.rate);
}
async function getRateLimit(): Promise<RateLimit> {
const header: OutgoingHttpHeaders = { 'User-Agent': 'vscode-cpptools' };
const data: string = await util.downloadFileToStr('https://api.github.com/rate_limit', header)
.catch(() => { throw new Error('Failed to download rate limit JSON'); });
let rateLimit: any;
try {
rateLimit = JSON.parse(data);
} catch (error) {
throw new Error('Failed to parse rate limit JSON');
}
if (isRateLimit(rateLimit)) {
return Promise.resolve(rateLimit);
} else {
throw new Error('Rate limit JSON is not of type RateLimit');
}
}
async function rateLimitExceeded(): Promise<boolean> {
const rateLimit: RateLimit = await getRateLimit();
return rateLimit.rate.remaining <= 0;
}
/**
* Download and parse the release list JSON from the GitHub API into a Build[].
* @return Information about the released builds of the C/C++ extension.
*/
async function getReleaseJson(): Promise<Build[]> {
if (await rateLimitExceeded()) {
throw new Error('Failed to stay within GitHub API rate limit');
}
// Download release JSON
const releaseUrl: string = 'https://api.github.com/repos/Microsoft/vscode-cpptools/releases';
const header: OutgoingHttpHeaders = { 'User-Agent': 'vscode-cpptools' };
const data: string = await util.downloadFileToStr(releaseUrl, header)
.catch(() => { throw new Error('Failed to download release JSON'); });
// Parse the file
let releaseJson: any;
try {
releaseJson = JSON.parse(data);
} catch (error) {
throw new Error('Failed to parse release JSON');
}
// Type check
if (isArrayOfBuilds(releaseJson)) {
return releaseJson;
} else {
throw new Error('Release JSON is not of type Build[]');
}
}
+32 -12
View File
@@ -16,7 +16,7 @@ import * as vscode from 'vscode';
import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools';
import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands';
import { PlatformInformation } from './platform';
import { PackageManager, PackageManagerError, PackageManagerWebResponseError, IPackage } from './packageManager';
import { PackageManager, PackageManagerError, IPackage } from './packageManager';
import { PersistentState } from './LanguageServer/persistentState';
import { getInstallationInformation, InstallationInformation, setInstallationStage } from './installationInformation';
import { Logger, getOutputChannelLogger, showOutputChannel } from './logger';
@@ -24,6 +24,9 @@ import { CppTools1 } from './cppTools1';
const releaseNotesVersion: number = 3;
const cppTools: CppTools1 = new CppTools1();
let languageServiceDisabled: boolean = false;
let reloadMessageShown: boolean = false;
let disposables: vscode.Disposable[] = [];
export async function activate(context: vscode.ExtensionContext): Promise<CppToolsApi & CppToolsExtension> {
initializeTemporaryCommandRegistrar();
@@ -42,6 +45,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
export function deactivate(): Thenable<void> {
DebuggerExtension.dispose();
Telemetry.deactivate();
disposables.forEach(d => d.dispose());
if (languageServiceDisabled) {
return;
}
return LanguageServer.deactivate();
}
@@ -184,17 +192,6 @@ function handleError(error: any): void {
let errorMessage: string;
if (error instanceof PackageManagerError) {
// If this is a WebResponse error, log the IP that it resolved from the package URL
if (error instanceof PackageManagerWebResponseError) {
let webRequestPackageError: PackageManagerWebResponseError = error;
if (webRequestPackageError.socket) {
let address: any = webRequestPackageError.socket.address();
if (address) {
installationInformation.telemetryProperties['error.targetIP'] = address.address + ':' + address.port;
}
}
}
let packageError: PackageManagerError = error;
installationInformation.telemetryProperties['error.methodName'] = packageError.methodName;
@@ -279,6 +276,23 @@ async function postInstall(info: PlatformInformation): Promise<void> {
}
async function finalizeExtensionActivation(): Promise<void> {
if (vscode.workspace.getConfiguration("C_Cpp", null).get<string>("intelliSenseEngine") === "Disabled") {
languageServiceDisabled = true;
getTemporaryCommandRegistrarInstance().disableLanguageServer();
disposables.push(vscode.workspace.onDidChangeConfiguration(() => {
if (!reloadMessageShown && vscode.workspace.getConfiguration("C_Cpp", null).get<string>("intelliSenseEngine") !== "Disabled") {
reloadMessageShown = true;
util.promptForReloadWindowDueToSettingsChange();
}
}));
return;
}
disposables.push(vscode.workspace.onDidChangeConfiguration(() => {
if (!reloadMessageShown && vscode.workspace.getConfiguration("C_Cpp", null).get<string>("intelliSenseEngine") === "Disabled") {
reloadMessageShown = true;
util.promptForReloadWindowDueToSettingsChange();
}
}));
getTemporaryCommandRegistrarInstance().activateLanguageServer();
// Update default for C_Cpp.intelliSenseEngine based on A/B testing settings.
@@ -297,6 +311,12 @@ async function finalizeExtensionActivation(): Promise<void> {
if (prevIntelliSenseEngineDefault !== packageJson.contributes.configuration.properties["C_Cpp.intelliSenseEngine"].default) {
return util.writeFileText(util.getPackageJsonPath(), util.stringifyPackageJson(packageJson));
}
} else {
let packageJson: any = util.getRawPackageJson();
if (packageJson.contributes.configuration.properties['C_Cpp.updateChannel'].default === 'Default') {
packageJson.contributes.configuration.properties['C_Cpp.updateChannel'].default = 'Insiders';
return util.writeFileText(util.getPackageJsonPath(), util.stringifyPackageJson(packageJson));
}
}
}
+1 -1
View File
@@ -197,7 +197,7 @@ export class PackageManager {
if (retryCount !== 0) {
// Log telemetry to see if retrying helps.
let telemetryProperties: { [key: string]: string } = {};
telemetryProperties["success"] = `OnRetry${retryCount}`;
telemetryProperties["success"] = success ? `OnRetry${retryCount}` : 'false';
if (lastError instanceof PackageManagerError) {
let packageError: PackageManagerError = lastError;
telemetryProperties['error.methodName'] = packageError.methodName;
+62
View File
@@ -0,0 +1,62 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
export class PackageVersion {
major: number;
minor: number;
patch: number;
suffix?: string;
suffixVersion: number;
constructor(version: string) {
const tokens: string[] = version.split(new RegExp('[-\\.]', 'g')); // Match against dots and dashes
if (tokens.length < 3) {
throw new Error('Failed to parse version string: ' + version);
}
this.major = parseInt(tokens[0]);
this.minor = parseInt(tokens[1]);
this.patch = parseInt(tokens[2]);
if (tokens.length > 3) {
const firstDigitOffset: number = tokens[3].search(new RegExp(/(\d)/)); // Find first occurrence of 0-9
if (firstDigitOffset !== -1) {
this.suffix = tokens[3].substring(0, firstDigitOffset);
this.suffixVersion = parseInt(tokens[3].substring(firstDigitOffset));
} else {
this.suffix = tokens[3];
this.suffixVersion = 1;
}
} else {
this.suffix = undefined;
this.suffixVersion = 0;
}
if (this.major === undefined || this.minor === undefined || this.patch === undefined) {
throw new Error('Failed to parse version string: ' + version);
}
}
public isGreaterThan(other: PackageVersion): boolean {
// PackageVersions cannot be compared if either have a suffix that is not 'insiders'
if ((this.suffix && !this.suffix.startsWith('insiders')) || (other.suffix && !other.suffix.startsWith('insiders'))) {
return false;
}
let diff: number = this.major - other.major;
if (diff) {
return diff > 0;
} else if (diff = this.minor - other.minor) {
return diff > 0;
} else if (diff = this.patch - other.patch) {
return diff > 0;
} else if (this.suffix) {
return (other.suffix && this.suffixVersion > other.suffixVersion);
} else {
return other.suffix ? true : false;
}
}
}
@@ -82,6 +82,8 @@ suite("multiline comment setting tests", function(): void {
});
/******************************************************************************/
function cppPropertiesPath(): string {
return vscode.workspace.workspaceFolders[0].uri.fsPath + "/.vscode/c_cpp_properties.json";
}
@@ -103,6 +105,99 @@ async function changeCppProperties(cppProperties: config.ConfigurationJson, disp
return promise;
}
/******************************************************************************/
suite("extensibility tests v2", function(): void {
let cpptools: apit.CppToolsTestApi;
let lastResult: api.SourceFileConfigurationItem[];
let defaultConfig: api.SourceFileConfiguration = {
includePath: [ "${workspaceFolder}", "/v2/folder" ],
defines: [ "${workspaceFolder}" ],
intelliSenseMode: "msvc-x64",
standard: "c++17"
};
let lastBrowseResult: api.WorkspaceBrowseConfiguration;
let defaultBrowseConfig: api.WorkspaceBrowseConfiguration = {
browsePath: [ "/v2/folder" ],
compilerPath: "",
standard: "c++14",
windowsSdkVersion: "8.1"
};
// Has to be 'any' instead of api.CustomConfigurationProvider because of missing interface members.
let provider: api.CustomConfigurationProvider = {
name: "cpptoolsTest-v2",
extensionId: "ms-vscode.cpptools-test2",
canProvideConfiguration(document: vscode.Uri): Thenable<boolean> {
return Promise.resolve(true);
},
provideConfigurations(uris: vscode.Uri[]): Thenable<api.SourceFileConfigurationItem[]> {
let result: api.SourceFileConfigurationItem[] = [];
uris.forEach(uri => {
result.push({
uri: uri.toString(),
configuration: defaultConfig
});
});
lastResult = result;
return Promise.resolve(result);
},
canProvideBrowseConfiguration(): Thenable<boolean> {
return Promise.resolve(true);
},
provideBrowseConfiguration(): Thenable<api.WorkspaceBrowseConfiguration> {
lastBrowseResult = defaultBrowseConfig;
return Promise.resolve(defaultBrowseConfig);
},
dispose(): void {
console.log(" disposed");
}
};
let disposables: vscode.Disposable[] = [];
suiteSetup(async function(): Promise<void> {
cpptools = await apit.getCppToolsTestApi(api.Version.v2);
cpptools.registerCustomConfigurationProvider(provider);
cpptools.notifyReady(provider);
disposables.push(cpptools);
await changeCppProperties({
configurations: [ {name: "test2", configurationProvider: provider.extensionId} ],
version: 4
},
disposables);
});
suiteTeardown(function(): void {
disposables.forEach(d => d.dispose());
});
test("Check provider", async () => {
// Open a c++ file to start the language server.
let path: string = vscode.workspace.workspaceFolders[0].uri.fsPath + "/main2.cpp";
let uri: vscode.Uri = vscode.Uri.file(path);
let testHook: apit.CppToolsTestHook = cpptools.getTestHook();
let testResult: any = new Promise<void>((resolve, reject) => {
disposables.push(testHook.StatusChanged(status => {
if (status === apit.Status.IntelliSenseReady) {
let expected: api.SourceFileConfigurationItem[] = [ {uri: uri.toString(), configuration: defaultConfig} ];
assert.deepEqual(lastResult, expected);
assert.deepEqual(lastBrowseResult, defaultBrowseConfig);
resolve();
}
}));
setTimeout(() => { reject(new Error("timeout")); }, 2500);
});
disposables.push(testHook);
await vscode.workspace.openTextDocument(path);
await testResult;
});
});
/******************************************************************************/
suite("extensibility tests v1", function(): void {
let cpptools: apit.CppToolsTestApi;
let lastResult: api.SourceFileConfigurationItem[];
@@ -112,7 +207,9 @@ suite("extensibility tests v1", function(): void {
intelliSenseMode: "msvc-x64",
standard: "c++17"
};
let provider: api.CustomConfigurationProvider = {
// Has to be 'any' instead of api.CustomConfigurationProvider because of missing interface members.
let provider: any = {
name: "cpptoolsTest-v1",
extensionId: "ms-vscode.cpptools-test",
canProvideConfiguration(document: vscode.Uri): Thenable<boolean> {
@@ -153,7 +250,7 @@ suite("extensibility tests v1", function(): void {
test("Check provider", async () => {
// Open a c++ file to start the language server.
let path: string = vscode.workspace.workspaceFolders[0].uri.fsPath + "/main.cpp";
let path: string = vscode.workspace.workspaceFolders[0].uri.fsPath + "/main1.cpp";
let uri: vscode.Uri = vscode.Uri.file(path);
let testHook: apit.CppToolsTestHook = cpptools.getTestHook();
@@ -174,6 +271,8 @@ suite("extensibility tests v1", function(): void {
});
});
/******************************************************************************/
suite("extensibility tests v0", function(): void {
let cpptools: apit.CppToolsTestApi;
let lastResult: api.SourceFileConfigurationItem[];
@@ -184,7 +283,7 @@ suite("extensibility tests v0", function(): void {
standard: "c++17"
};
// Has to be 'any' instead of api.CustomConfigurationProvider because dispose is missing on the old interface version
// Has to be 'any' instead of api.CustomConfigurationProvider because of missing interface members.
let provider: any = {
name: "cpptoolsTest-v0",
canProvideConfiguration(document: vscode.Uri): Thenable<boolean> {
@@ -210,7 +309,7 @@ suite("extensibility tests v0", function(): void {
disposables.push(cpptools); // This is a no-op for v0, but do it anyway to make sure nothing breaks.
await changeCppProperties({
configurations: [ { name: "test2", configurationProvider: provider.name } ],
configurations: [ { name: "test0", configurationProvider: provider.name } ],
version: 4
},
disposables);
@@ -223,7 +322,7 @@ suite("extensibility tests v0", function(): void {
test("Check provider", async () => {
// Open a C++ file to start the language server.
let path: string = vscode.workspace.workspaceFolders[0].uri.fsPath + "/main2.cpp";
let path: string = vscode.workspace.workspaceFolders[0].uri.fsPath + "/main.cpp";
let uri: vscode.Uri = vscode.Uri.file(path);
let testHook: apit.CppToolsTestHook = cpptools.getTestHook();
@@ -0,0 +1,3 @@
int main(int argc, char* arv[]) {
return 0;
}
@@ -5,11 +5,23 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
child_process = require('child_process');
path = require('path');
async_child_process = require('async-child-process');
if (process.env.CODE_TESTS_PATH
&& process.env.CODE_TESTS_PATH.startsWith('.')){
process.env.CODE_TESTS_PATH = path.join(process.cwd(), process.env.CODE_TESTS_PATH.substr(2));
}
require(path.resolve(__dirname, '../node_modules/vscode/bin/test'));
let optionsWithFullEnvironment = {
cwd: path.resolve(__dirname, '..'),
stdio: 'inherit',
env: {
...process.env,
}
};
spawn = child_process.spawn('node', [path.resolve(__dirname, '../node_modules/vscode/bin/test')], optionsWithFullEnvironment);
return async_child_process.join(spawn);
+234
View File
@@ -0,0 +1,234 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved.
* See 'LICENSE' in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import * as assert from "assert";
import { resolveVariables } from "../../src/common";
suite("Common Utility validation", () => {
suite("resolveVariables", () => {
const success: string = "success";
const home: string = process.env.HOME || process.env.USERPROFILE;
test("raw input", () => {
const input: string = "test";
inputAndEnvironment(input, {})
.shouldResolveTo(input);
});
test("raw input with tilde", () => {
inputAndEnvironment("~/test", {})
.shouldResolveTo(`${home}/test`);
});
test("env input with tilde", () => {
inputAndEnvironment("${path}/test", {
path: home
})
.shouldResolveTo(`${home}/test`);
});
test("solo env input resulting in array", () => {
inputAndEnvironment("${test}", {
test: ["foo", "bar"]
})
.shouldResolveTo("foo;bar");
});
test("solo env input with empty array env value", () => {
resolveVariablesWithInput("${empty}")
.withEnvironment({
"empty": []
})
.shouldResolveTo("");
});
test("mixed raw and env input resulting in array", () => {
const input: string = "baz${test}";
resolveVariablesWithInput(input)
.withEnvironment({
test: ["foo", "bar"]
})
.shouldResolveTo(input);
});
test("solo env input not in env config finds process env", () => {
const processKey: string = `cpptoolstests_${Date.now()}`;
const input: string = "foo${" + processKey + "}";
let actual: string;
try {
process.env[processKey] = "bar";
actual = resolveVariables(input, {});
} finally {
delete process.env[processKey];
}
assert.equal(actual, "foobar");
});
test("env input", () => {
resolveVariablesWithInput("${test}")
.withEnvironment({
"test": success
})
.shouldResolveTo(success);
});
test("env input mixed with plain text", () => {
resolveVariablesWithInput("${test}bar")
.withEnvironment({
"test": "foo"
})
.shouldResolveTo("foobar");
});
test("env input with two variables", () => {
resolveVariablesWithInput("f${a}${b}r")
.withEnvironment({
a: "oo",
b: "ba"
})
.shouldResolveTo("foobar");
});
test("env input not in env", () => {
const input: string = "${test}";
resolveVariablesWithInput(input)
.withEnvironment({})
.shouldResolveTo(input);
});
test("env with macro inside environment definition", () => {
resolveVariablesWithInput("${arm6.include}")
.withEnvironment({
"envRoot": "apps/tool/buildenv",
"arm6.include": "${envRoot}/arm6/include"
})
.shouldResolveTo("apps/tool/buildenv/arm6/include");
});
test("env nested with half open variable", () => {
resolveVariablesWithInput("${arm6.include}")
.withEnvironment({
"envRoot": "apps/tool/buildenv",
"arm6.include": "${envRoot/arm6/include"
})
.shouldResolveTo("${envRoot/arm6/include");
});
test("env nested with half closed variable", () => {
resolveVariablesWithInput("${arm6.include}")
.withEnvironment({
"envRoot": "apps/tool/buildenv",
"arm6.include": "envRoot}/arm6/include"
})
.shouldResolveTo("envRoot}/arm6/include");
});
test("env nested with a cycle", () => {
resolveVariablesWithInput("${a}")
.withEnvironment({
"a": "${b}",
"b": "${c}",
"c": "${a}"
})
.shouldResolveTo("${a}");
});
test("env input with 1 level of nested variables anchored at end", () => {
resolveVariablesWithInput("${foo${test}}")
.withEnvironment({
"foobar": success,
"test": "bar"
})
.shouldResolveTo("${foo${test}}");
});
test("env input with 1 level of nested variables anchored in the middle", () => {
resolveVariablesWithInput("${f${test}r}")
.withEnvironment({
"foobar": success,
"test": "ooba"
})
.shouldResolveTo("${f${test}r}");
});
test("env input with 1 level of nested variable anchored at front", () => {
resolveVariablesWithInput("${${test}bar}")
.withEnvironment({
"foobar": success,
"test": "foo"
})
.shouldResolveTo("${${test}bar}");
});
test("env input with 3 levels of nested variables", () => {
resolveVariablesWithInput("${foo${a${b${c}}}}")
.withEnvironment({
"foobar": success,
"a1": "bar",
"b2": "1",
"c": "2"
})
.shouldResolveTo("${foo${a${b${c}}}}");
});
test("env input contains env", () => {
resolveVariablesWithInput("${envRoot}")
.shouldLookupSymbol("envRoot");
});
test("env input contains config", () => {
resolveVariablesWithInput("${configRoot}")
.shouldLookupSymbol("configRoot");
});
test("env input contains workspaceFolder", () => {
resolveVariablesWithInput("${workspaceFolderRoot}")
.shouldLookupSymbol("workspaceFolderRoot");
});
test("input contains env.", () => {
resolveVariablesWithInput("${env.Root}")
.shouldLookupSymbol("Root");
});
test("input contains env:", () => {
resolveVariablesWithInput("${env:Root}")
.shouldLookupSymbol("Root");
});
interface ResolveTestFlowEnvironment {
withEnvironment(additionalEnvironment: {[key: string]: string | string[]}): ResolveTestFlowAssert;
shouldLookupSymbol: (key: string) => void;
}
interface ResolveTestFlowAssert {
shouldResolveTo: (x: string) => void;
}
function resolveVariablesWithInput(input: string): ResolveTestFlowEnvironment {
return {
withEnvironment: (additionalEnvironment: {[key: string]: string | string[]}) => {
return inputAndEnvironment(input, additionalEnvironment);
},
shouldLookupSymbol: (symbol: string) => {
const environment: {[key: string]: string | string[]} = {};
environment[symbol] = success;
return inputAndEnvironment(input, environment)
.shouldResolveTo(success);
}
};
}
function inputAndEnvironment(input: string, additionalEnvironment: {[key: string]: string | string[]}): ResolveTestFlowAssert {
return {
shouldResolveTo: (expected: string) => {
const actual: string = resolveVariables(input, additionalEnvironment);
const msg: string = `Expected ${expected}. Got ${actual} with input ${input} and environment ${JSON.stringify(additionalEnvironment)}.`;
assert.equal(actual, expected, msg);
}
};
}
});
});
+12 -10
View File
@@ -2,27 +2,29 @@
The **launch.json** file is used to configure the debugger in Visual Studio Code.
Visual Studio Code generates a **launch.json** with almost all of the required information. To get started
Visual Studio Code generates a **launch.json** with almost all of the required information. To get started
debugging you need to fill in the `program` field with the path to the executable you plan to debug. This must be specified for
both the launch and attach (if you plan to attach to a running instance at any point) configurations.
The generated file contains two sections. One that configures debugging for launch and a second that configures debugging for attach.
The generated file contains two sections. One that configures debugging for launch and a second that configures debugging for attach.
# Configure VS Code's debugging behavior
Set or change the following options to control VS Code's behavior during debugging
Set or change the following options to control VS Code's behavior during debugging:
* #### `program` (required)
Specifies the full path to executable the debugger will launch or attach to.
* #### `symbolSearchPath`
Tells the _Visual Studio Windows Debugger_ what paths to search for symbol (.pdb) files. Separate multiple paths with a semicolon. Example `"C:\\Symbols;C:\\SymbolDir2"`
Tells the _Visual Studio Windows Debugger_ what paths to search for symbol (.pdb) files. Separate multiple paths with a semicolon. Example `"C:\\Symbols;C:\\SymbolDir2"`.
* #### `additionalSOLibSearchPath`
Tells _GDB or LLDB_ what paths to search for .so files. Separate multiple paths with a semicolon. Example: `"/Users/user/dir1;/Users/user/dir2"`.
* #### `externalConsole`
If set to `true`, launches an external console for the application. If `false`, no console is launched and VS Code's debugging console is used. Note this option is ignored in some cases for technical reasons.
Windows: When set to true, it will spawn an external console. When set to false, it will use VS Code's integratedTerminal.
Linux: When set to true, it will notify VS Code to spawn an external console. When set to false, it will use VS Code's integratedTerminal.
macOS: When set to true, it will spawn an external console through `lldb-mi`. When set to false, the output can be seen in VS Code's debugConsole. Due to limitations within `lldb-mi`, integratedTerminal support is not available.
* #### `logging`
Optional flags to determine what types of messages should be logged to the Debug Console.
@@ -94,10 +96,10 @@ The following options enable you to modify the state of the target application w
## Customizing GDB or LLDB
You can change the behavior of GDB or LLDB by setting the following options.
You can change the behavior of GDB or LLDB by setting the following options:
* #### `MIMode`
Indicates the debugger that VS Code will connect to. Must be set to `gdb` or `lldb`. This is pre-configured on a per-operating system basis and can be changed as needed.
Indicates the debugger that VS Code will connect to. Must be set to `gdb` or `lldb`. This is pre-configured on a per-operating system basis and can be changed as needed.
* #### `miDebuggerPath`
The path to the debugger (such as gdb). When only the executable is specified, it will search the operating system's PATH variable for a debugger (GDB on Linux and Windows, LLDB on OS X).
@@ -152,7 +154,7 @@ The C/C++ extension enables debugging dump files on Windows and core dump files
If you want to debug a Windows dump file, set this to the path to the dump file to start debugging in the `launch` configuration.
* #### `coreDumpPath`
Full path to a core dump file to debug for the specified program. Set this to the path to the core dump file to start debugging in the `launch` configuration.
Full path to a core dump file to debug for the specified program. Set this to the path to the core dump file to start debugging in the `launch` configuration.
_Note: core dump debugging is not supported with MinGw._
## Remote debugging or debugging with a local debugger server
@@ -175,7 +177,7 @@ _Note: core dump debugging is not supported with MinGw._
## Additional properties
* #### `processId`
Defaults to `${command.pickProcess}` which will display a list of available processes the debugger can attach to. It is recommended to leave this default, but the property can be explicitly set to a specific process ID for the debugger to attach to.
Defaults to `${command.pickProcess}` which will display a list of available processes the debugger can attach to. It is recommended to leave this default, but the property can be explicitly set to a specific process ID for the debugger to attach to.
* #### `request`
Indicates whether the configuration section is intended to `launch` the program or `attach` to an already running instance.
@@ -184,7 +186,7 @@ _Note: core dump debugging is not supported with MinGw._
`Deprecated` This option is no longer needed as the target architecture is automatically detected.
* #### `type`
Indicates the underlying debugger being used. Must be `cppvsdbg` when using the Visual Studio Windows debugger, and `cppdbg` when using GDB or LLDB. This is automatically set to the correct value when the
Indicates the underlying debugger being used. Must be `cppvsdbg` when using the Visual Studio Windows debugger, and `cppdbg` when using GDB or LLDB. This is automatically set to the correct value when the
**launch.json** file is created.
* #### `sourceFileMap`