microsoft / vscode-cpptools

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

Goto does not work #3286

Closed ghost closed 4 years ago

ghost commented 5 years ago

Goto definition is unstable. One minute it works, and the other it tells no definition found. When you hover over a var/function, it displays a tip, other minute it does not.

I have set up MQL lang over CPP for intellisence/goto,etc. (.mqh, .mq5) I have set up the includes folder as instructed. The includes folder is just 10 Mb. This cpp extension is so unreliable.

sean-mcmanus commented 5 years ago

We need more info because we have not witnessed this problem. What is your OS? What version of the C/C++ extension are you using? Do you see any crash error messages in the logs? What actions are causing the Go to Def to fail? Does it repro with even a simple project or only with certain projects?

jonas-printzen commented 5 years ago

I have seen this too. Initially whenever I make many changes in a short while. Recently code often start with goto-def not working and just sometimes it appears to fix itself while I'm working. Actually it just happened since I switch my attention between writing this and looking in my code. At start it didnt work, now it does!

My impression is that the behavior changes a little every code-update.

I Run Ubuntu 18.04. Ext: C++ 0.21.0

ghost commented 5 years ago

Version: 1.32.3 (user setup) Commit: a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4 Date: 2019-03-14T23:43:35.476Z Electron: 3.1.6 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17134

Name: C/C++ Id: ms-vscode.cpptools Description: C/C++ IntelliSense, debugging, and code browsing. Version: 0.21.0 Publisher: Microsoft VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

This error is floating. It looks like the extension is spending all its effort to scan for vars, but provides no result. On a freshly opened code file it says no definition found for anything. When i move the mouse over i sometimes see a tooltip Loading... - but again this is rare.

bobbrow commented 5 years ago

@dmipec, correct me if I'm wrong, but MQL is not C++. By default, that means that there is no guarantee that our extension will work with it.

There are non-C++ literals in MQL that our extension knows nothing about. (e.g. uchar, ushort, string, color, datetime). If you use any of those, our extension wouldn't know what they were unless you create aliases for them in the c_cpp_properties.json file. You can use the "defines" property for this. For example:

    "defines": [
        "uchar": "unsigned char",
        "ushort": "unsigned short"
    ]

For string you might need to use a combination of "defines" and "forceIncludes" to alias it to std::string and have #include <string> auto included everywhere.

I'm not super familiar with this dialect as I've only spent about 10 minutes in the documentation, but these are the kinds of tricks you will need to employ to get MQL working better with our extension. And if you do get it working, we would accept a PR to add a page to our documentation about it so that other users of MQL can benefit from your research.