L-I-V / MQL-Tools

42 stars 15 forks source link

String type reported as error-type by IntelliSense suggestions #7

Closed kaloworx closed 1 year ago

kaloworx commented 1 year ago

Hi their L-I-V,

Me again :)

I just notice that when calling a function that has a string type variable declared such as in the screenshots below, IntelliSense does not refer to it as a string, but rather an error-type.

image

image

image

Also, is there a way to override the CLANG behaviour of adding a space between C and '20,20,20' when formatting the document. For example, C'20,20,20' refers to a custom colour, but when applying document wide formatting, a space is automatically added between the C and the colour string which breaks the formatting and then the code can't compile as it creates lots of errors everywhere a custom colour was used in this way.

L-I-V commented 1 year ago

In this case, the error with types has nothing to do with the 'MQL Tools' extension. This IntelliSense from the extension 'C/C++' does not know the type 'string'. 'MQL Tools' associates files '.mq4', '.mq5' and '.mqh' as '.cpp'. Thus, part of the actions with the document is performed by the extension 'C/C++'. IntelliSense from 'MQL Tools' displays only the 'standard' functions, variables, types and constants of MQL5 (For MQL4 I will add later). Regarding the gaps after formatting the document in custom colors C'20,20,20' and date D'1980.09.19 12:30:23', in the future I plan to create a clang-format for MQL files. In the meantime, there is a function in the extension that removes spaces in colors and dates when checking syntax or compiling, so there are no errors due to spaces.

kaloworx commented 1 year ago

I suspected that much, thanks for confirming the IntelliSense situation. Do you think this also explains why in certain situations, the suggestions for functions also does not work for example like in this screenshot. The function is right there, yet IntelliSense does not "see" it nor suggest it for code completion.

image

Thanks once more for your time and effort you have put into this most useful extensions for MT coders.

kaloworx commented 1 year ago

In respect of the above, the issue seems to only apply to certain MQL4 files, I can't really figure out what the diffs are, but for one it seems that files with #includes in the header causes this, I'm still checking....because if a creation a blank mq4 file and put some functions in it, the suggestions works just fine, but when I open my larger projects which have lots of includes to function libraries, no suggestions any more.... very strange....

kaloworx commented 1 year ago

Further in addition to the above....I tried inserting MQH includes using your context menu, but it seems to be using forward slashes in the path name and not backslashes as it is supposed to...

image

No biggy, I don't use it, but just thought I'd mention this as a possible extra bug perhaps?

kaloworx commented 1 year ago

Uuugh, for now I will be giving up.... #includes seem to be a huge problem and works intermittently, I just can't spot a pattern. If there is a special way to include mqh libraries please let me know....thanks for now.

In the meantime, I have gotten a lot of includes to work by actually changing the regular \ that I always used in MetaEditor to a / ....the only two includes I am now still battling have import's in their headers eg....

import "user32.dll"

import "wininet.dll"

The two MQH libraries with those imports do work when compiling, but when I #include them in a MQ4 file, intellisense suggestions stop working again....so almost there....If perhaps you have a tip to get around this, I would be most grateful.

kaloworx commented 1 year ago

Good news, I got all my #includes working accept for the two MQH libraries who have #import functions in them....MetaEditor requires a #import statement to be closed by issuing another second #import at the end of the declaration, like in the screenshot below....When done like this, Intellisense does not make code suggestions if such a MQH files is included which has such an import in it...if I leave the second import out, suggestions work fine, but obviously the code does not compile.... any suggestions ?

image

L-I-V commented 1 year ago

Hi kalotech, at the moment I have two solutions and both are not perfect. In my case, the cause of the problem was the 'string' type with the modifier 'input' ('input string'). I replaced 'input' with 'extern' and added a line to the "settings.json" extension settings file: "C_Cpp.default.intelliSenseMode": "windows-gcc-x64". But this way is not very good because it limits the choice of modifier for 'string' type and I can't say it will work for you. In the second method, it is necessary to install the C ++ compiler. This way still needs to be tested because I tested it on one or two files.

kaloworx commented 1 year ago

Hi L-I_V, thanks for getting back to me about this....I will definitely look into these suggestions of yours and get back to you.... this thing is so close to being perfect, I just can't let it go, LOL.... best wishes!

kaloworx commented 1 year ago

Hi @L-I-V ,

I tried your trick with the "C_Cpp.default.intelliSenseMode": "windows-gcc-x64", but regrettably, it did not resolve the problem.

I then installed MinGW and tested the install with the standard HelloWorld cp :) So I know it works and compiles and the path is set correctly etc....

I then created the "C_Cpp.default.intelliSenseMode" json file in the workspace folder and have it set like this:

image

Yet still intellisense does not seem to work for STRING's, works fine for INT, DOUBLE etc...

image image image

It also happens that intellisense does not list/recognize all available functions in a MQL file...for example in the screenshot below, on the left in the Outline window there are clearly many functions that start with the letters "btn...", yet intellisense only list one of them....

image

I know intellisense is a thing on its own and actually has nothing to do with your project, but if you have any other tips or suggestions I could try out, please let me know, and I'll dig in.

Best wishes!

L-I-V commented 1 year ago

Hi kalotech, I managed to add variables and functions with MQL(string, color, datetime) types to the list of IntelliSense suggestions. Cl Sf CR In the next update I will try to solve most of the problems with IntelliSense, but the update will not be before January 2023.

kaloworx commented 1 year ago

Hi @L-I-V ,

That is absolutely AWESOME!!!! How would I go about to get this update, should I just pull it from here? If it is only going to be part of the next update, I totally understand.

Thanks once more for your generous contribution to the Metatrader coding community—you rock!

L-I-V commented 1 year ago

Hi kalotech, This will be part of the next update that will be published in the Marketplace.

Ruslan618 commented 1 year ago

For visible string and other vars type I use in head: 2022-12-09_1-24-40