maddouri / vscode-cmake-tools-helper

VSCode extension that enables cpptools to automatically know the information parsed by CMake Tools (e.g. include directories and defines)
https://marketplace.visualstudio.com/items?itemName=maddouri.cmake-tools-helper
BSD 3-Clause "New" or "Revised" License
16 stars 6 forks source link

doesn't work for me - no changes in cpp json #1

Closed amigo421 closed 6 years ago

amigo421 commented 7 years ago

just tried to use, VSCode 1.12.

for sure, select delete and reconfgiure for cmaketools, but no changes in c_cpp_properties.json in other hand , this (by default ) doesn't contain the path to standard libraries and vscode/cpptools can't recognize standard headers location

maddouri commented 7 years ago

Thanks for reporting the issue.

Could you please try with the latest version of VS Code Insiders and the latest version of the extension?

Also, it could help if you would check what's happening in the JavaScript console (Help > Toggle Developer Tools > Console)

As for the standard libs' includes... you're right! I couldn't find how to extract them from CMake Tools :/ If you have ideas, feel free to submit them. I will do my best to implement them.

amigo421 commented 7 years ago

initially I didn't understand whats happened, and even raised the request for cpptools developers. don't know how but problem with standard headers was resolved.

but damaged c_cpp_properties.json file is a real problem yet.

okay I'll try insiders version and let you know

maddouri commented 7 years ago

Ok. Sorry about that. But please note that this behavior is mentioned in the extension's README:

Mirroring the Information in cpptools

Each time CMake Tools Helper is notified, the following happens:

1.CMake Tools Helper

  1. Gets the current configuration and target name from CMake Tools
  2. Overrides the content of c_cpp_properties.json using the information from step 1

About https://github.com/Microsoft/vscode-cpptools/issues/795 , the "null" configuration is set when you select a "non typical" CMake target (e.g. "ALL" or "ZERO_CHECK", "clean", etc.) using CMake Toos or if CMake Tools fails to get a list of valid targets (e.g. when the configuration fails)

To have a valid c_cpp_properties.json, select a typical target (i.e. a target that was declared using CMake's add_executable or add_library) using CMake Tools.

Again, please check the Developer Tools Console for relevant messages.

maddouri commented 7 years ago

@amigo421 I was going over CMake Tools' code when I remembered that the current implementation of CMake Tools Helper relies on the cmake.experimental.useCMakeServer option to be true.

Please make sure that this option is enabled.

maddouri commented 7 years ago

Hi @amigo421

Do you still face the issue after enabling CMake Server?

amigo421 commented 7 years ago

sorry for delay, insiders build didn't solve the problem, the same issue, cmake server is enabled in CMakeTools by default. do you need dev console from vscode hel[p menu?

maddouri commented 7 years ago

Thanks for the feedback.

That's odd.. I did a few tests but couldn't find out why you would get such a problem.

If you have:

  1. cmake.useCMakeServer set to true (restarting VSCode is necessary to apply this change)
  2. Reconfigured the project (by erasing the cache then regenerating the project)
  3. Selected a target (other than "all", "zero_check", etc.)

then, this extension should write a valid configuration to the cpptools' json file.

Sure, the dev console log might help, please consider sending it.

Also, if you're familiar with VSCode extension development, you could:

  1. Clone this repo
  2. Open it in VSCode
  3. Press F5 to debug
  4. If an exception is raised, VSCode should pinpoint its exact location with some info on why it happened
amigo421 commented 7 years ago

okay, I'll try to debug and let you know about the results

vasilevp commented 7 years ago

Same thing happened to me literally 5 minutes ago. Fixed it by changing build target from "all" (which was set by default for some reason) to "ALL_BUILD" (which was suggested in the dropdown). Setting target to the one created with add_executable also works.

maddouri commented 7 years ago

@exploser Great! Thanks for the feedback.

I'd suggest selecting the targets created by add_executable or add_library. This way, this extension will set the proper includes and defines in cpptools' c_cpp_properties.json ;)

ghita commented 7 years ago

I get this, same problem with missing includes [Extension Host] rejected promise not handled within 1 second h.logExtensionHostMessage @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:29 /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:29 Invalid backend promise: Error: Invalid backend promise at new CMakeToolsWrapper (/Users/gheorghem/.vscode/extensions/vector-of-bool.cmake-tools-0.10.1/out/src/wrapper.js:46:40) at /Users/gheorghem/.vscode/extensions/vector-of-bool.cmake-tools-0.10.1/out/src/extension.js:17:23 at Generator.next () at /Users/gheorghem/.vscode/extensions/vector-of-bool.cmake-tools-0.10.1/out/src/extension.js:7:65 at __awaiter (/Users/gheorghem/.vscode/extensions/vector-of-bool.cmake-tools-0.10.1/out/src/extension.js:3:12) at activate (/Users/gheorghem/.vscode/extensions/vector-of-bool.cmake-tools-0.10.1/out/src/extension.js:15:12) at Function.t._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:23:417918) at Function.t._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:23:417703) at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:23:417478 at Object.m [as _notify] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:23:41973)

Using latest official vscode && pluggins. Points to s cmake-tools though

mtgrasse commented 7 years ago

I'm seeing the same symptoms but slightly different backtrace in the developer console: [Extension Host] rejected promise not handled within 1 second h.logExtensionHostMessage @ extensionHost.ts:320 shell.ts:443 Cannot read property 'forEach' of undefined: TypeError: Cannot read property 'forEach' of undefined at target (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:29:34) at configuration.parse (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:37:11) at new configuration (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:22:14) at prj.targets.forEach.tgt (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:75:54) at Array.forEach (native) at cfg.projects.forEach.prj (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:73:33) at Array.forEach (native) at configs.forEach.cfg (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:72:30) at Array.forEach (native) at c_cpp_properties.parse (/Users/matgra01/.vscode/extensions/maddouri.cmake-tools-helper-0.1.1/out/src/c_cpp_properties.js:71:21) e.onUnexpectedError @ shell.ts:443

tmchartrand commented 7 years ago

I have the same error as above: "TypeError: Cannot read property 'forEach' of undefined"

tmchartrand commented 7 years ago

Looks like just need to check if target has filegroups at line 29 of c_cpp_properties. Will test out if I get a chance.

vadimcn commented 7 years ago

Having the same issue: TypeError: Cannot read property 'forEach' of undefined

vadimcn commented 7 years ago

Yeah, looks like some targets just don't have the fileGroups property. Can confirm that PR #7 fixes the issue.

el-robo commented 6 years ago

PR #7 fixes the issues for me as well.

maddouri commented 6 years ago

v0.2.0 includes #7

Is this issue still present?

nergnezor commented 6 years ago

Works well now!