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

Add UI to provide args for templates, to enable template IntelliSense

Open rdlaner opened this issue 7 years ago • 34 comments

* Operating System and version

MacOS 10.13.4

* VS Code version and if you are using the Insiders build

VSCode 1.24.0-Insiders #2404210629c744e6237a14d7b5fa852e24c6e898

* C/C++ extension version

0.16.1

* step-by-step instructions to reproduce the issue

Create at least one class declaration in a header file. Use a template on this class Intentionally create a syntax error Note that no error squiggles are generated and no error or warning given in the Problems pane. In the example below, I am showing quite a few compiler errors (there are plenty in this file). One in particular is the errant use of override. This shows up in the compiler output, but not in the error squiggles or in the Problems pane: screen shot 2018-05-06 at 10 56 09 pm

* A small code sample, zipped up project, or open source repo we can use to verify the bug

Errant header file attached LinkedList.h.zip

* Any log messages present in the Output window (use "C_Cpp.loggingLevel": "Information" in settings.json)

The logs indicate that it thinks it is looking for syntax errors: IntelliSense Engine = Default. The extension will use the Tag Parser for IntelliSense when #includes don't resolve. Autocomplete is enabled. Error squiggles are enabled. File exclude: **/.git File exclude: **/.svn File exclude: **/.hg File exclude: **/CVS File exclude: **/.DS_Store File exclude: **/.o File exclude: **/.d File exclude: **/.vscode Search exclude: **/node_modules Search exclude: **/bower_components Search exclude: **/.vscode Code browsing service initialized Folder: /usr/local/include/ will be indexed Folder: /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/ will be indexed Folder: /Users/dustinlane/Desktop/VSCode_Test/ will be indexed Folder: /System/Library/Frameworks/ will be indexed Folder: /Library/Frameworks/ will be indexed Discovering files... Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.h Processing folder (recursive): /usr/local/include/ Processing folder (recursive): /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/ Processing folder (recursive): /Users/dustinlane/Desktop/VSCode_Test/ Processing folder (recursive): /System/Library/Frameworks/ Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.h Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.h Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.cpp Shutting down IntelliSense server: /Users/dustinlane/Desktop/VSCode_Test/C++_Test/main.cpp Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.h Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.h Processing folder (recursive): /Library/Frameworks/ Discovering files: 301712 file(s) processed 0 file(s) removed from database Done discovering files. Parsing open files... Parsing remaining files... Parsing: 0 files(s) processed Done parsing remaining files. Done parsing open files. Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/main.cpp Checking for syntax errors: file:///Users/dustinlane/Desktop/VSCode_Test/C%2B%2B_Test/LinkedList.h

rdlaner avatar May 07 '18 06:05 rdlaner

I'm also able to repro this bug with VS 2017, so I'll look into filing a bug with them and update this issue when I get more info...

sean-mcmanus avatar May 07 '18 08:05 sean-mcmanus

Thanks, @sean-mcmanus .

rdlaner avatar May 07 '18 16:05 rdlaner

It turns out this is a "by design" limitation -- templates have errors turned off, because the type info is not known for the template args. We would have to add some UI that enables users to set the actual types of the template args.

sean-mcmanus avatar May 07 '18 19:05 sean-mcmanus

VS added the feature in 15.8: https://devblogs.microsoft.com/cppblog/template-intellisense/ .

sean-mcmanus avatar Apr 25 '19 20:04 sean-mcmanus

@sean-mcmanus I think you can bring this iteratively - even without a UI you can do this as a feasible solution. Setting the template argument manually (e.g. using default value, or by adding a comment with a predefined format) could at least help initial authoring and debugging tremendously.I for one would certainly be open to adding a default value temporarily, or adding a comment before/after the template declaration just to get autocompletion, error highlighting, etc.

Since concepts will be added in C++20, you can also use those.

Adding a UI is certainly the long-term solution (GitLens adds so much information I think there could be a potential solution in a similar component), but if that's the toughest part, let's workaround that :)

chibidev avatar Apr 26 '19 19:04 chibidev

Any schedule about that yet?

SpyrosMourelatos avatar Dec 02 '20 08:12 SpyrosMourelatos

@DrunkenMastah Not yet...if it gets on our schedule, you'll see it added to a specific Milestone and/or Project instead of the "Backlog" milestone.

sean-mcmanus avatar Dec 04 '20 20:12 sean-mcmanus

Any possible temporary remedies to address this issue? It seems it's on a very long backburner and it's very annoying writing code just to get a compiler error that could've otherwise been avoided with intellisense.

SpeedyCraftah avatar Aug 20 '21 22:08 SpeedyCraftah

@SpeedyCraftah I don't know of any temporary remedy. I think it just needs to be implemented.

sean-mcmanus avatar Aug 20 '21 23:08 sean-mcmanus

Any possible temporary remedies to address this issue? It seems it's on a very long backburner and it's very annoying writing code just to get a compiler error that could've otherwise been avoided with intellisense.

@SpeedyCraftah A workaround that seems to be working for me is to temporarily do a typedef of your template class type parameter to provide the linter with a concrete type to use. For example, replace

template <typename T>
class MyClass {
...
}

with

typedef MyType T;
class MyClass {
...
}

This will at least get you linting within the template class, but you'll need to revert back to the template for proper linting on anything that actually uses the template class.

albee avatar Oct 13 '21 17:10 albee

Is there any way to make this issue higher priority to get solved? It seems like this issue has been lying around for quite a while, and the lack of IntelliSense really slows down implementation compared to when IntelliSense is working.

Rishi-V avatar Jun 08 '22 23:06 Rishi-V

@Rishi-V You could try asking @bobbrow if there's any ETA estimate. It is number 11 when sorted by upvotes: https://github.com/Microsoft/vscode-cpptools/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3A%22Language+Service%22 .

sean-mcmanus avatar Jun 08 '22 23:06 sean-mcmanus

@sean-mcmanus Can the "bug" tag be added to this issue? I feel like the current -> behavior of recommending smart pointer object functions are invalid/buggy (and bug inducing) and not a missing feature. I.e. recommending non-existing functions ->get() is a bug as opposed to not recommending anything when doing -> which would be more like a missing feature. PS: Thanks for your previous timely and informative responses!

Rishi-V avatar Jun 09 '22 18:06 Rishi-V

@Rishi-V We could potentially add the bug tag, but it doesn't have any impact on anything in terms of the priority. The "bug" versus "enhancement" versus "feature request" tags are mostly just used when determine which section to place it in the changelog (https://github.com/microsoft/vscode-cpptools/blob/main/Extension/CHANGELOG.md) and there is lots of precedence for "feature request" and "enhancement" type issues that could be considered bugs as well, but from our perspective we could consider them not a bug due to the amount of work involved in implementing it and the fact that the buggy behavior is a direct result of a case not being implemented. Also, in this particular case, if the VS UI isn't used to set the T, then the "buggy" behavior still occurs, but the VS team doesn't consider it a bug.

And also, if it's placed in the bug section of our changelog then it would tend to be "lost" among the many other bug fixes while we'd want such a major improvement to be more easily noticed in our "New Features" section, and we'd probably blog about it too.

sean-mcmanus avatar Jun 09 '22 19:06 sean-mcmanus

You could try asking @bobbrow if there's any ETA estimate.

I don't have an estimate as to when this feature will be implemented. When we know, we will assign it to a project.

bobbrow avatar Jun 10 '22 18:06 bobbrow

There are some syntax errors that do not depend on type yet those aren't detected. I think at least that part should be fixed first.

PythonCoderAS avatar Nov 09 '22 12:11 PythonCoderAS

Dear vscode-powers-that-be, this is much, much needed. What will it take to prioritize this? Any rudimentary solution (if UI is complicated) is welcome. Templates are getting to be a huge pain in VSCode, tempting me to fall back to VStudio.

ssg3d avatar Jan 06 '23 09:01 ssg3d

I don't think anything can be done to increase the priority other than wait. If it really bothers you, and other remedies here don't work for you, you can try using the extension clangd instead of the vscode one. The intellisense feedback is also faster and more responsive 😁

On Fri, 6 Jan 2023, 09:04 ssg, @.***> wrote:

Dear vscode-powers-that-be, this is much, much needed. What will it take to prioritize this? Any rudimentary solution (if UI is complicated) is welcome. Templates are getting to be a huge pain in VSCode, tempting me to fall back to VStudio.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-cpptools/issues/1946#issuecomment-1373369614, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKYNEOH2RZZOBQ3CP6LV46TWQ7NYDANCNFSM4E6RYZEA . You are receiving this because you were mentioned.Message ID: @.***>

SpeedyCraftah avatar Jan 06 '23 09:01 SpeedyCraftah

and other remedies here don't work for you

You say there are "other remedies", could you point me to those? I did scour the page here to look for workarounds before posting, but maybe I missed spotting them.

ssg3d avatar Jan 07 '23 03:01 ssg3d

@ssg3d Depending on the templated code, you could potentially temporarily replace the templated code with specific types.

sean-mcmanus avatar Jan 09 '23 19:01 sean-mcmanus

Surprised it is still in backlog and not been taken up. I thought templates are more heavily used by programmers today and this would get a higher priority.

ssg3d avatar Apr 16 '23 00:04 ssg3d

Any ETA when this will be implemented? The current UX in VS Code when working with templated code is horrible :(

Marqin avatar Aug 01 '23 15:08 Marqin

Any ETA when this will be implemented? The current UX in VS Code when working with templated code is horrible :(

I'm surprised this still hasn't been implemented. Templates are a massive part of C++ and having such a feature on the backlog makes the extension quite undesirable, so as I said before I use clangd from now on for any C++ work in vscode which supports templates. Also vscode please stop asking me to provide feedback on the extension every time I open a C++ file, this is the only feedback I'll provide :)

SpeedyCraftah avatar Aug 01 '23 15:08 SpeedyCraftah

Also vscode please stop asking me to provide feedback on the extension every time I open a C++ file, this is the only feedback I'll provide :)

I'm sorry if you're getting spammed with requests for feedback. We don't control this experience, the VS Code team does, but if you're hitting a problem here, it means others are too. Would you be willing to help provide information to the VS Code team if we (or you) open an issue in their repo? It is not our intent to annoy people with survey requests and there's supposed to be a mechanism to prevent that. Do you happen to be using Codespaces or Remote SSH to connect to various Virtual Machines? I believe each of those get a unique id and might be considered as separate users.

bobbrow avatar Aug 01 '23 17:08 bobbrow

Any ETA when this will be implemented? The current UX in VS Code when working with templated code is horrible :( Yes, please, when @bobbrow ?

ssg3d avatar Aug 02 '23 03:08 ssg3d

I'm sorry I don't have an ETA for this feature right now. When it is added to a milestone/project, that means we have a target date set for it.

bobbrow avatar Aug 02 '23 15:08 bobbrow

Using Clion but would happily move to VSCode if this feature was implemented

coxjonc avatar Aug 17 '23 06:08 coxjonc

Is there any update on this feature yet? this is the main thing stopping me from completely switching to VSCode for everything.

redixhumayun avatar Dec 30 '23 18:12 redixhumayun

This issue inspired me to look for alternatives. clangd is actually really nice.

ktbarrett avatar Dec 31 '23 02:12 ktbarrett