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

Please add renaming

Open tinganho opened this issue 10 years ago • 142 comments

It would be very useful if this tool also supported renaming of variables.

tinganho avatar Oct 18 '16 16:10 tinganho

I agree.

sean-mcmanus avatar Oct 18 '16 16:10 sean-mcmanus

@tinganho, Renaming is a feature that we consider part of a much larger work-item to implement more intelligent auto-complete (aka Intellisense(tm) in the Visual Studio world) for our extension. We hope to roll that out in the coming months.

greazer avatar Oct 21 '16 00:10 greazer

I agree too. Is there some roadmap or state of the rename symbol feature? The greazer's comment is old and doesn't make sense now, when intelligent auto-complete aka Intellisense is already in VS Code using C/C++ extension. Just the rename symbol is missing :( How is it going?

salda avatar May 03 '17 21:05 salda

Actually, the IntelliSenseEngine features we have so far are just error squiggles and hover (quick info). We are currently working on getting auto-complete added (it's currently using the old implementation that has issues, such as no local variables and too many invalid results). Unfortunately, we don't have a roadmap for when rename will be implemented.

sean-mcmanus avatar May 03 '17 23:05 sean-mcmanus

Now that reference highlighting is implemented in the September cpptools update, it seems quite awkward that Change All Occurrences changes a different set of occurrences to what are highlighted. Is the rename feature the intended way to do that in other languages? It almost feels like a bug in VSCode now that this inconsistency is created.

antcodd avatar Oct 03 '17 05:10 antcodd

Hmm... I never thought about that. Reference highlighting only ever applies to a single file at a time but rename works across the entire project so I never made that connection. Unfortunately, "rename" is correlated to "find all references" - which we have not implemented yet - so the addition of reference highlighting doesn't get us much closer to the implementation of rename.

bobbrow avatar Oct 03 '17 17:10 bobbrow

Hi guys - the extension works great! - just wondering if there are any updates on this issue?

dprandle avatar Mar 26 '18 06:03 dprandle

@dprandle There are no updates on renaming. When we decide to start working on renaming it will be added to a milestone. It looks like our 5th top up-voted issue: https://github.com/Microsoft/vscode-cpptools/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc .

sean-mcmanus avatar Mar 26 '18 11:03 sean-mcmanus

@sean-mcmanus @dprandle I want to add, that from my point of view, it's highly coupled with 1st top up-voted issue (if you can find all references, then you just rename them all). I know, it's a bit different, but solving that moves it forward a lot I think.

salda avatar Mar 26 '18 11:03 salda

@salda Yeah, most of the top features are dependent on the multiple translation unit IntelliSense component, which hasn't been ported from VS 2017 yet. We want to fix the major problems with configuration for single translation unit IntelliSense before starting work on that, e.g. recursive includePath, compilerPath for WSL/cl.exe (better guessing/defaults), global settings, etc.

sean-mcmanus avatar Mar 27 '18 00:03 sean-mcmanus

When you do bring over intellisense please base it on libclang. In the current intellisense (in VisualStudio 2017) I have code that compiles correctly (I am using the clang tools extension with clang 6.0: https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain) but according to intellisense the source has errors, because (I presume) it uses a faulty msvc front end (it is conformant c++17 code that will not compile with the current trunk of msvc). It is annoying to have red squiggles through source that actually compiles without error or warnings.

rtosman avatar Sep 03 '18 14:09 rtosman

I think it's better to just say not to use VS2017's compiler. I have the same problem from the start of VSCode project. I would prefer GCC.

sumonero avatar Sep 03 '18 16:09 sumonero

I'm not using msvc, I am using clang, however, intellisense still uses the msvc front end apparently, which leads to a disconnect between what is actually compilable and what intellisense thinks is compilable. If intellisense is based on libclang (for vscode) then everything will be good, if it is based on msvc then it will be bad. I can live with the issue in Visual Studio, but I would like to not have the same issue in vscode when it gets full intellisense (i.e. intellisense == good, intellisense based on msvc == not so good).

rtosman avatar Sep 03 '18 17:09 rtosman

@rtosman, our IntelliSense engine has clang and gcc compatibility modes. If you are seeing incorrect error squiggles with those modes, please open a new issue and we'll investigate getting them fixed. This issue is about support for renaming.

bobbrow avatar Sep 04 '18 16:09 bobbrow

@bobbrow , I was referring to what visual studio does, in the context of this discussion with reference to the comment from @sean-mcmanus "Yeah, most of the top features are dependent on the multiple translation unit IntelliSense component, which hasn't been ported from VS 2017 yet."

I have compatibility mode in vscode set to "clang-x64" and it works fine within the limitations discussed. My point was that the intellisense that visual studio has does not correctly operate with clang, which I presume is because the intellisense engine in visual studio is based on msvc (I presume this to be the case, since the errors it "squiggles" are the same errors I would get if I did compile the code with msvc. The errors in question are clearly out-of-scope for the current level of intellisense support in vscode and I do not see squiggles with the same code in vscode.

I was simply asking that when you do bring over full blown intellisense to vscode (part of getting renaming working) to please base it on libclang so that it doesn't suffer from the problems that visual studio intellisense currently does when using clang as the toolchain.

rtosman avatar Sep 04 '18 16:09 rtosman

I would like to base it on GCC.

sumonero avatar Sep 04 '18 17:09 sumonero

@sumonero sure, that works as well. The specific code in question compiles fine with gcc as well, so I have no hard data to prefer clang over gcc in that respect.

rtosman avatar Sep 04 '18 17:09 rtosman

We actually do not use MSVC for IntelliSense (nor does Visual Studio). We use a different front-end which supports msvc, gcc, and clang modes. If you can open an new issue and show us which cases are providing incorrect squiggles for you, we can work to improve our existing implementation.

The errors in question are clearly out-of-scope for the current level of intellisense support in vscode and I do not see squiggles with the same code in vscode.

I'm not following you. Our goal is to provide an accurate linting experience, so if there are false errors reported, we'd like to know about them so we can fix our implementation. And is there a typo here? I thought the complaint was that there were incorrect squiggles in vscode.

Using libclang as an additional engine is not out of the question, but it is also not a trivial change and not on the schedule at this point. I can pretty much promise you that when we do finish porting all the features they will not be implemented with libclang as the front-end.

bobbrow avatar Sep 04 '18 17:09 bobbrow

@bobbrow my apologies, I didn't think this was a forum where it would be appropriate to report issues with Visual Studio (and they really don't bother me that much as I use vscode predominantly).

No, I have not had issues with vscode (I wasn't surprised as I didn't believe that it was doing sufficient analysis to detect the type of error that is being reported by intellisense on Visual Studio).

In any case, I have the code that fails to compile with msvc here (reduced test case): https://godbolt.org/z/j5mJJ0

On intellisense (under Visual Studio not under vscode) the intellisense error is the same as the compiler error (which is what lead me to believed the front end is the same). As you can see the code compiles fine with gcc (trunk and 8.2) as well as clang (trunk and 6.0). I tested with msvc pre 2018 and msvc 2017

I was holding out libclang merely as a possible solution, anything that produces the same results is fine.

rtosman avatar Sep 04 '18 17:09 rtosman

@rtosman You're supposed to be able to get IntelliSense to work with clang in VS via setting the CppProperties.json correctly -- see https://docs.microsoft.com/en-us/cpp/ide/non-msbuild-projects?view=vs-2017#configure-intellisense-with-cpppropertiesjson . If you have problems getting that to work, I would recommend using the "Report a Problem..." feature in VS (I created an issue at https://developercommunity.visualstudio.com/content/problem/327884/c-compiler-fails-to-compile-lambda-that-captures-a.html ). The IntelliSense errors attempts to mimic the compiler used, so if it's set to msvc mode, it's more likely to give the errors that msvc (cl.exe) gives.

sean-mcmanus avatar Sep 04 '18 19:09 sean-mcmanus