Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rdlaner opened this issue May 7, 2018 · 33 comments
Open

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

rdlaner opened this issue May 7, 2018 · 33 comments
Labels
Feature: Find All References Find All References, Peek References, Rename Feature Request Language Service Works in VS So we'd need to fix it for VS Code to reach parity.
Milestone

Comments

@rdlaner
Copy link

rdlaner commented May 7, 2018

* 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

@sean-mcmanus
Copy link
Collaborator

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...

@rdlaner
Copy link
Author

rdlaner commented May 7, 2018

Thanks, @sean-mcmanus .

@sean-mcmanus
Copy link
Collaborator

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
Copy link
Collaborator

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

@chibidev
Copy link

@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 :)

@sean-mcmanus sean-mcmanus added this to the Backlog milestone Sep 13, 2019
@sean-mcmanus sean-mcmanus added the Works in VS So we'd need to fix it for VS Code to reach parity. label Sep 13, 2019
@sean-mcmanus sean-mcmanus added the Feature: Find All References Find All References, Peek References, Rename label Sep 13, 2019
@Colengms Colengms changed the title Missing error squiggles when using templates Add UI to provide args for templates, to enable template IntelliSense Oct 14, 2020
@SpyrosMourelatos
Copy link

Any schedule about that yet?

@sean-mcmanus
Copy link
Collaborator

@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.

@Rishi-V
Copy link

Rishi-V commented Jun 8, 2022

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.

@sean-mcmanus
Copy link
Collaborator

@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 .

@Rishi-V
Copy link

Rishi-V commented Jun 9, 2022

@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!

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jun 9, 2022

@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.

@bobbrow
Copy link
Member

bobbrow commented Jun 10, 2022

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.

@PythonCoderAS
Copy link

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.

@ssg3d
Copy link

ssg3d commented Jan 6, 2023

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.

@SpeedyCraftah
Copy link

SpeedyCraftah commented Jan 6, 2023 via email

@ssg3d
Copy link

ssg3d commented Jan 7, 2023

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.

@sean-mcmanus
Copy link
Collaborator

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

@starball5
Copy link

Related question asked on Stack Overflow: Why doesn't Intellisense provide suggestions for templates inside templates that use parameters from the outer template?

@ssg3d
Copy link

ssg3d commented Apr 16, 2023

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.

@Marqin
Copy link

Marqin commented Aug 1, 2023

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

@SpeedyCraftah
Copy link

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 :)

@bobbrow
Copy link
Member

bobbrow commented Aug 1, 2023

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.

@ssg3d
Copy link

ssg3d commented Aug 2, 2023

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

@bobbrow
Copy link
Member

bobbrow commented Aug 2, 2023

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.

@coxjonc
Copy link

coxjonc commented Aug 17, 2023

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

@redixhumayun
Copy link

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

@ktbarrett
Copy link

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

@SpeedyCraftah
Copy link

SpeedyCraftah commented Dec 31, 2023

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

Yeah, clangd handles templates a lot better than the vscode extension and doesn't just outright refuse to lint any code with the template keyword - although it's not perfect, it still doesn't catch a lot of errors, but it usually catches them all in the end when you instantiate the template in code.

@starball5
Copy link

starball5 commented Dec 31, 2023

but it usually catches them all in the end when you instantiate the template in code

@SpeedyCraftah cpptools doesn't do that for you? Because I'm pretty sure it should. At least- it does for me when using CMake Tools as the configuration provider.

@redixhumayun
Copy link

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

Seconding this. Just tried out clangd and it seems a lot better. I don't have to keep switching to CLion anytime I want to write templated code now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Find All References Find All References, Peek References, Rename Feature Request Language Service Works in VS So we'd need to fix it for VS Code to reach parity.
Projects
None yet
Development

No branches or pull requests