vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

0.22.0-insiders2: Intellisense not finding class information as expected

Open alexmcgilvery opened this issue 7 years ago • 16 comments

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 Pro - 1809 - 17763.348
  • VS Code Version: 1.31.1
  • C/C++ Extension Version: 0.22.0-insiders2
  • Other extensions you installed (and if the issue persists after disabling them): { CMake, CmakeTools, Bracket-Pair Colorizer, One Dark Pro, Output Colorizer, Todo+ } Issue persists after disabling all except CMakeTools. (used to build and provide include details)

A clear and concise description of what the bug is:

Source .cpp files not finding some class (Functions, members) information for classes (excluding the first) declared in a .hpp header file when using CMakeTools build system.

To Reproduce Sample code following same structure as project currently experiencing the issue: Test app.zip

  • Open Folder in VSCode and say yes to all prompts by CMakeTools during configuration of project.
  • Browse to .cpp under Test/src folder and check for any intellisense errors.

This sample code yields

"i2" is undefined

  • and

name followed by '::' must be a class or namespace name

intellisense errors for me, while my main project is mainly "incomplete type is not allowed" on function implementations.

Expected behavior That information that is declared in header to be recognized in source (.cpp) files.

Screenshots image image

Additional context

  • No reported intellisense errors on 0.21.0.
  • Code builds and runs as expected on both 0.21.0 and 0.22.0-insiders2.
  • C++.log after some browsing of the sample code.
  • New to C++ and CMake, very well could be a PICNIC.

alexmcgilvery avatar Mar 06 '19 23:03 alexmcgilvery

Hmm...I'm not able to repro the problem and your logs seem okay to me. @bobbrow Do you see what is going wrong? Maybe it's related to https://github.com/Microsoft/vscode-cpptools/issues/3229 ?

sean-mcmanus avatar Mar 07 '19 00:03 sean-mcmanus

Indeed, I cannot reproduce the issue on another computer, only on the same computer using different code bases.

alexmcgilvery avatar Mar 07 '19 02:03 alexmcgilvery

Does the workspace folder where it repros have case sensitive file paths enabled? Even if that was the case we wouldn't expect it to work on older versions though. You could try setting your C_Cpp.intelliSenseCacheSize setting to 0, if for some unexpected reason that new feature is causing the failure.

sean-mcmanus avatar Mar 07 '19 02:03 sean-mcmanus

Setting C_Cpp.intelliSenseCacheSize to 0 seems like it fixed the issue.

I also updated to VSCode 1.32 before changing the setting (and I think I saw that the issue was still present, but cannot say for sure)

Removing the C_Cpp.intelliSenseCacheSize = 0 (causing it to revert to default I guess) does not reintroduce the issue

alexmcgilvery avatar Mar 07 '19 20:03 alexmcgilvery

Opened the sample code/project I created to reproduce and the issue was still present (so not resolved by VsCode update).

  • Set C_Cpp.intelliSenseCacheSize to 0 in this workspace.

  • Restarted VsCode and reopened workspace and issue is resolved.

  • Removed C_Cpp.intelliSenseCacheSize = 0 setting and reopened folder and still no issue.

alexmcgilvery avatar Mar 07 '19 20:03 alexmcgilvery

Which workspaceFolder do you open in VS Code from the sample project? "Test app" or "Test app\Test"

Sample project folder structure with "Test app" as workspaceFolder currently opened: image

To help further determine if this is an issue with using cached precompiled headers or if it's some other issue with initial opening of a workspaceFolder, could you see if the issue reproduces with the following two scenarios:

Open the project folder with "C_Cpp.intelliSenseCacheSize" set to 0. 1.) prior to opening your workspaceFolder, delete any contents under all "ipch" folders: -- Delete contents under "Test app.vscode\ipch" and "Test app\Test.vscode\ipch" folders. -- Note: these folders contain cached precompiled headers (PCH).

2.) Add theses C++ settings to "Test app/.vscode/settings.json" to disable creating/using PCH and to ensure IntelliSense does not fallback to tag parser.

"C_Cpp.intelliSenseCacheSize": 0,
"C_Cpp.intelliSenseEngineFallback": "Disabled"

3.) Open the workspaceFolder from VSCode. See if issue reproduces and verify that no PCH files are created under "..\ipch" folder. Note: if "C_Cpp.intelliSenseCacheSize" is not 0, PCH files will only be created under the top level .vscode folder for the the current workspaceFolder that was opened, and not under .vscode subfolders.

4.) If the issue reproduces, try reopening the same workspaceFolder without changing any settings and verify issue again.

Open the project folder without "C_Cpp.intelliSenseCacheSize" 1.) Do step 1 from above if needed.

2.) Remove "C_Cpp.intelliSenseCacheSize" from "Test app/.vscode/settings.json" to enable creating/using PCH. Removing this setting will cause the extension to use the default value of 5120 MB for the cache size.

3.) Open the workspaceFolder from VSCode. See if issue reproduces and verify that PCH files are created under "..\ipch" folder. Note: PCH files will only be created under the top level .vscode folder for the current workspaceFolder that was opened, and not under .vscode subfolders.

4.) If the issue reproduces, try reopening the same workspaceFolder without changing any settings and verify issue again.

michelleangela avatar Mar 07 '19 22:03 michelleangela

I open the highest folder as the workspace folder generally. I must have opened the Test subfolder accidently which generated the .vscode folder. I don't have multiple .vscode folders in my working project.

Before performing the steps I deleted the .vscode under Test folder.

Open the project folder with "C_Cpp.intelliSenseCacheSize" set to 0. Issue does not reproduce following steps 1-3

Open the project folder without "C_Cpp.intelliSenseCacheSize" Issue does not reproduce following steps 1-3 (PCH files are created)

Continuing from Open the project folder without "C_Cpp.intelliSenseCacheSize" (settings are now only {"C_Cpp.intelliSenseEngineFallback": "Disabled"}

I've found that I can reproduce the issue by adding another class TestClass3 , and if I unorthodoxly code the int Core::TestClass3::GetNumber() { return i3; } before declaring the class in the .hpp the error returns.

image image

Classes defined properly in the .hpp before implementing their functions in .cpp after this error occurs will also experience the same problems.

In the following image I:

  1. Defined TestClass3 properly in .hpp
  2. Coded TestClass4::GetNumber() in the .cpp file
  3. Defined TestClass4 in .hpp
  4. Defined TestClass5 properly in .hpp
  5. Coded TestClass5::GetNumber() in the .cpp

image

alexmcgilvery avatar Mar 07 '19 23:03 alexmcgilvery

This appears to be the existing bug https://github.com/Microsoft/vscode-cpptools/issues/1779 , where changes to the header file aren't updating the squiggles correctly in the source file. It repros with 0.21.0 as well. Does that seem like the same issue or are you experiencing something else that only repros with 0.22.0-insiders2?

sean-mcmanus avatar Mar 07 '19 23:03 sean-mcmanus

I cannot reproduce this exact issue in 0.21.0 following the steps I gave above.

(I change update channel back to default, then right click and install another version (0.21.0) and reload VsCode)

However this does seem to be very close (an extension of perhaps) to https://github.com/Microsoft/vscode-cpptools/issues/1779, except the experience in 0.22.0-insiders2 is that the issue is not resolved (for me at least) by editing or re-opening the file.

alexmcgilvery avatar Mar 07 '19 23:03 alexmcgilvery

Okay, thanks a lot for your help understanding this bug -- we're able to repro the issue, and the situation did get worse with 0.22.0-insiders2 with the intelliSenseCache enabled. I think we'll need to fix this before shipping 0.22.0.

sean-mcmanus avatar Mar 08 '19 00:03 sean-mcmanus

Glad to be of help, hopefully this helps narrow down https://github.com/Microsoft/vscode-cpptools/issues/1779 as a fix would be a nice QoL improvement.

alexmcgilvery avatar Mar 08 '19 01:03 alexmcgilvery

The regression was fixed when AutoPCH is used, but https://github.com/Microsoft/vscode-cpptools/issues/1779 still exists, i.e. editing or re-opening the source file fixes the squiggles (we're doing work to fix that might fix it, but don't have an ETA yet). We might release 0.22.0-insiders3 Friday and/or 0.22.0 early next week.

sean-mcmanus avatar Mar 08 '19 02:03 sean-mcmanus

Thank you for the work, great to hear it's been fixed so soon. I'm unfamiliar with the issue sign off procedure, so I'll hold off from closing the issue.

alexmcgilvery avatar Mar 08 '19 02:03 alexmcgilvery

Yeah, we usually keep issues Open until it ships in a non-Insiders release.

UPDATE: I think https://github.com/Microsoft/vscode-cpptools/issues/1779 got fixed as well, but I was only able to repro that bug on Linux. We plan to ship the fix with 0.22.0 early next week.

sean-mcmanus avatar Mar 08 '19 03:03 sean-mcmanus

Squiggle bugs should be fixed with 0.22.0-insiders3 -- let us know if you hit any issues still.

sean-mcmanus avatar Mar 15 '19 02:03 sean-mcmanus

Just got the update and the issue is not present and I cannot reproduce it.

In respect to #1779, squiggles are updating in my source files automatically now (without edits or re-opening) so in my case #1779 is also resolved.

alexmcgilvery avatar Mar 15 '19 02:03 alexmcgilvery