microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

rename function name doesn't work in C project #12238

Open jishihao-001 opened 6 months ago

jishihao-001 commented 6 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary:

In a c project, when I try to rename function name or variables, i got : A definition for the selected symbol could not be located.

even the function is only defined and used in merely one file.

I do the "rescan", disable and enable the cpptools and restart VSCode, none works.

Steps to reproduce:

  1. rename a function
  2. gives me "A definition for the selected symbol could not be located."

Expected behavior: renaming should success

Configuration and Logs

c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\Program Files\\LLVM\\bin\\clang.exe",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "windows-clang-x64"
        }
    ],
    "version": 4
}

Other Extensions

Extension | Author (truncated) | Version doxdocgen | csc | 1.4.0 cpptools | ms- | 1.20.1 vscode-typings | typ | 0.0.5 clang-format | xav | 1.9.0

Additional context

No response

browntarik commented 6 months ago

Could you provide a screenshot of the error? I am unable to reproduce the issue as it is able to find my symbols (see below):

image

Could you also provide the output of the C/C++: Log Diagnostics command when you are in the file?

jishihao-001 commented 6 months ago

renaming sure, I add a gif

jishihao-001 commented 6 months ago

the output of the C/C++: Log Diagnostics command

-------- Diagnostics - 4/25/2024, 8:53:17 AM

Version: 1.20.1
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "e:/project/esl/05-fw-RFv2/FW-RFv2/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "compilerPath": "C:\\Program Files\\LLVM\\bin\\clang.exe",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "windows-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "C:\\Program Files\\LLVM\\bin\\clang.exe",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "e:/project/esl/05-fw-RFv2/FW-RFv2/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": "${default}"
    }
}
cpptools version (native): 1.20.1.0
Translation Unit Mappings:
[ C:\Users\lenovo\Desktop\lab\main.c - source TU]:
Translation Unit Configurations:
[ C:\Users\lenovo\Desktop\lab\main.c ]:
    Process ID: 3604
    Memory Usage: 51 MB
    Compiler Path: C:\Program Files\LLVM\bin\clang.exe
    Includes:
        C:\Program Files\LLVM\lib\clang\15.0.3\include
        G:\ProgramFiles\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include
        G:\ProgramFiles\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c17
    IntelliSense Mode: windows-clang-x64
    Other Flags:
        --clang
        --clang_version=150003
        --ms_compatibility
Total Memory Usage: 51 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8181
browntarik commented 6 months ago

Thank you for the extra information!

Colengms commented 6 months ago

Hi @jishihao-001 . Would you be able to enable the setting "C_Cpp.loggingLevel": "Debug", and make another repro video with the Output channel open and set to the C/C++ output channel, as well as having the "Outline" view (on the left) open? That should provide a bunch of information about what's going on in your particular repro.

jishihao-001 commented 6 months ago

renaming03 Sure, please check

sean-mcmanus commented 6 months ago

@jishihao-001 You don't have the Outline view open. You may need to run the "C/C++: Reset IntelliSense Database" command if the Outline view is missing the symbol you're trying to rename. And also make sure the file is not being excluded via any exclude setting. If you make an edit to main.c, your logging should show a "tag parsing" message if it's not excluded.

image

jishihao-001 commented 5 months ago

renaming04 sorry for late reply, it was a vacation.

MyZQL commented 2 months ago

I also met this problem... Do you have any idea now? I tried to find some running logs of the extension in the installation folder but nothing valuable was found.