espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
652 stars 153 forks source link

Intellisense fail - Ubuntu & VSCode (CON-831) #684

Open baylf2000 opened 11 months ago

baylf2000 commented 11 months ago

Intellisense is largely broken when using Matter examples in VSCode on Ubuntu.

It seems to be unable to recognise files or their contents from Matter or the current project. The project builds correctly though.

Environment

Intellisense errors from "Light" example project:

[{
    "resource": "/home/lf/Documents/esp_projects/MATTER_PROJECTS/light/main/app_driver.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "1696",
    "severity": 8,
    "message": "cannot open source file \"device.h\"",
    "source": "C/C++",
    "startLineNumber": 13,
    "startColumn": 1,
    "endLineNumber": 13,
    "endColumn": 20
},{
    "resource": "/home/lf/Documents/esp_projects/MATTER_PROJECTS/light/main/app_driver.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "1696",
    "severity": 8,
    "message": "cannot open source file \"esp_matter.h\"",
    "source": "C/C++",
    "startLineNumber": 14,
    "startColumn": 1,
    "endLineNumber": 14,
    "endColumn": 24
},{
    "resource": "/home/lf/Documents/esp_projects/MATTER_PROJECTS/light/main/app_driver.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "1696",
    "severity": 8,
    "message": "cannot open source file \"led_driver.h\"",
    "source": "C/C++",
    "startLineNumber": 15,
    "startColumn": 1,
    "endLineNumber": 15,
    "endColumn": 24
},{
    "resource": "/home/lf/Documents/esp_projects/MATTER_PROJECTS/light/main/app_driver.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "1696",
    "severity": 8,
    "message": "#include errors detected. Consider updating your compile_commands.json or includePath. Squiggles are disabled for this translation unit (/home/lachlan/Documents/esp_projects/MATTER_PROJECTS/light/main/app_driver.cpp).",
    "source": "C/C++",
    "startLineNumber": 17,
    "startColumn": 1,
    "endLineNumber": 17,
    "endColumn": 22
},{
    "resource": "/home/lf/Documents/esp_projects/MATTER_PROJECTS/light/main/app_driver.cpp",
    "owner": "C/C++: IntelliSense",
    "code": "1696",
    "severity": 8,
    "message": "cannot open source file \"esp_matter.h\" (dependency of \"app_priv.h\")",
    "source": "C/C++",
    "startLineNumber": 17,
    "startColumn": 1,
    "endLineNumber": 17,
    "endColumn": 22
}]
jonsmirl commented 11 months ago

c-cpp-properties

{
    "configurations": [
        {
            "name": "ESP-IDF",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "includePath": [
                "${default}",
                "/home/jonsmirl/aosp/esp-matter"
            ],
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}
baylf2000 commented 11 months ago

@jonsmirl Thank you. That fixes it! Perhaps the maintainers could add that fix to the example projects?

jonsmirl commented 11 months ago

There is VSCode command called "ESP-IDF: Add vscode configuration folder" but what I sent you will work better.

bamnet commented 10 months ago

FWIW I ended up just adding "${config:idf.espMatterPath}/**", as a line, resulting in the following config --

{
    "configurations": [
        {
            "name": "ESP-IDF",
            "compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc",
            "includePath": [
                "${config:idf.espIdfPath}/components/**",
                "${config:idf.espIdfPathWin}/components/**",
                "${config:idf.espAdfPath}/components/**",
                "${config:idf.espAdfPathWin}/components/**",
                "${config:idf.espMatterPath}/**",
                "${workspaceFolder}/**"
            ],
            "browse": {
                "path": [
                    "${config:idf.espIdfPath}/components",
                    "${config:idf.espIdfPathWin}/components",
                    "${config:idf.espAdfPath}/components/**",
                    "${config:idf.espAdfPathWin}/components/**",
                    "${config:idf.espMatterPath}/**",
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": false
            }
        }
    ],
    "version": 4
}
sayondeep commented 10 months ago

@baylf2000 can you please close the issue if it is resolved.

baylf2000 commented 10 months ago

@sayondeep No this issue is not resolved. The maintainers need to fix the example projects. There are several possible solutions described above, but until the source code is corrected the issue will remain.

sayondeep commented 9 months ago

@baylf2000 vs code configuration related information is available here. You can use them for your reference and configure vs code.