iarsystems / iar-vsc-build

Visual Studio Code extension for developing and building IAR projects
https://marketplace.visualstudio.com/items?itemName=iarsystems.iar-build
Mozilla Public License 2.0
38 stars 5 forks source link

Project can be built but IntelliSense cannot find the definitions #8

Open mulleandreas opened 2 years ago

mulleandreas commented 2 years ago

I have multiple projects that compile flawlessly, but IntelliSense detects multiple issues. The error messages point in the direction that IntelliSense cannot find the definitions. If I change the order of the includes, IntelliSense can resolve them. I broke one of the projects down to a minimum sample and checked the includes and I'm quite sure that there are no issues with them.

Also, if I re-add the previously used c_cpp_properties.json file to the project and remove the line "C_Cpp.default.configurationProvider": "iarsystems.iar-build" from the settings.json file, IntelliSense works regardless of the order of the includes and detects no errors. c_cpp_properties.json.txt

This issue might be related to Incorrect intellisense configuration #6.

I would also be happy to provide the sample project privately.

IAR Build Log

[23.6.2022, 14:58:29][Debug] Activating extension
[23.6.2022, 14:58:29][Debug] Collected 5 toolchains
[23.6.2022, 14:58:29][Debug] Toolchain: selected 'Embedded Workbench 9.1 (Arm)' (index 3)
[23.6.2022, 14:58:29][Debug] Loading thrift workbench 'Embedded Workbench 9.1 (Arm)'...
[23.6.2022, 14:58:29][Debug] 4 new toolchain(s) added
[23.6.2022, 14:58:29][Debug] Found 3 project(s) in the workspace
[23.6.2022, 14:58:29][Debug] Project: selected 'bootloader-ra6m5' (index 0)
[23.6.2022, 14:58:29][Debug] Configuration: selected 'Debug' (index 0)
[23.6.2022, 14:58:29][Debug] Generating intellisense config for 'bootloader-ra6m5':'Debug'...
[23.6.2022, 14:58:29][Debug] Loaded thrift workbench 'Embedded Workbench 9.1 (Arm)'
[23.6.2022, 14:58:29][Debug] Loading project 'bootloader-ra6m5' using thrift...
[23.6.2022, 14:58:29][Debug] Loading project context for 'bootloader-ra6m5'
[23.6.2022, 14:58:29][Debug] Loading project 'bootloader-ra6m5' using thrift...
[23.6.2022, 14:58:30][Debug] Intellisense config changed. Notifying cpptools.
[23.6.2022, 14:58:30][Debug] Providing intellisense configuration(s) for: c:\Projekte\test\src\main.cpp

IAR Config Generator Log

Generating compilation database...

     IAR Command Line Build Utility V9.1.1.9611
     Copyright 2002-2022 IAR Systems AB.

bootloader-ra6m5 - Debug
Build description written to C:\Users\102-anmu\AppData\Local\Temp\iar-jsondbabcda958c3e05e627317c4b1d245b754.json

Done!
Generating intellisense information for c:\Projekte\test\src\main.cpp

C/C++ Extension Log

c_cpp_extension_log.log

HampusAdolfsson commented 2 years ago

Hi,

This is probably a separate bug from #6. There is nothing that sticks out to me in the logs you provided, so if you could provide the project that would be very helpful. You can email it to me at: hampus.adolfsson@iar.com

HampusAdolfsson commented 2 years ago

This seems to be a problem with the parsing or caching of symbols, rather than with the configuration. I've reported the problem to cpptools: https://github.com/microsoft/vscode-cpptools/issues/9540

JackHerRrer commented 2 years ago

I don't know if this will help, but i had similar issues because of the now deprecated "IAR For Visual Studio Code" package by pluyckx. Simply disabling it was not enough. To solve the issue, I disabled both extensions and deleted every configuration related to both extensions in all the config files of the project (c_cpp_properties.json, iar-vsc.json, settings.json). Then, I re-enabled the official IAR extension. From that moment it started to work properly

omisys commented 1 year ago

This is not an issue with cpptools. The issue is that only the folders that are set in either the additional include directories, Preinclude files or defines are being sent to the cpptools plugin as browse path. If your source(c) files are not in the same directory as the header files they will not be indexed. The source(c) files that are added to the IAR project should also be added to the browse path. If your project is setup like this:

proj/include proj/src

And the proj/include folder is added to the include directories in the preprocessor, only the include files will be indexed. You can work around this problem by added the src folder to the include directories as well so it will be sent to cpptools. But I think this should be fixed in this addon.

The C files that are used in the project are known to the EWP file so it should be possible to add them to browse path as well. I don't have the TS knowledge to make a pull request but I hope @HampusAdolfsson can pick this up?

public provideBrowseInfo(): IntellisenseInfo { const config = this.workspaceIntellisenseInfo?.getBrowseInfo(); return { defines: config?.defines ?? [], includes: config?.includes ?? [], preincludes: config?.preincludes ?? [], }; }

HampusAdolfsson commented 1 year ago

@omisys Thanks a lot. We'll work on a fix in the extension.

HampusAdolfsson commented 1 year ago

As I wrote in #17, @omisys solution fixes that issue. However, this is not the same issue and it is unfortunately not fixed by adding source folders to the browse path (in fact the example I sent to the cpptools developers already has the correct browse path).

That means that this issue is still most likely a problem in cpptools.