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

rename function name doesn't work in C project

Open jishihao-001 opened this issue 1 year ago • 9 comments

Environment

  • OS and Version: Windows_NT x64 10.0.18362
  • VS Code Version: Code 1.88.1
  • C/C++ Extension Version: 1.20.1
  • If using SSH remote, specify OS of remote machine: none

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

jishihao-001 avatar Apr 22 '24 09:04 jishihao-001

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?

browntarik avatar Apr 22 '24 16:04 browntarik

renaming sure, I add a gif

jishihao-001 avatar Apr 24 '24 05:04 jishihao-001

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

jishihao-001 avatar Apr 25 '24 00:04 jishihao-001

Thank you for the extra information!

browntarik avatar Apr 25 '24 17:04 browntarik

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.

Colengms avatar Apr 25 '24 19:04 Colengms

renaming03 Sure, please check

jishihao-001 avatar Apr 30 '24 07:04 jishihao-001

@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

sean-mcmanus avatar Apr 30 '24 19:04 sean-mcmanus

renaming04 sorry for late reply, it was a vacation.

jishihao-001 avatar May 06 '24 02:05 jishihao-001

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.

MyZQL avatar Aug 12 '24 14:08 MyZQL