VisualD's Intellisense not workign with gtk

Johnson Jones via Digitalmars-d-ide digitalmars-d-ide at puremagic.com
Sun Aug 6 09:31:28 PDT 2017


On Sunday, 6 August 2017 at 11:43:17 UTC, Rainer Schuetze wrote:
>
>
> On 05.08.2017 14:20, Johnson Jones wrote:
>> On Friday, 4 August 2017 at 07:27:54 UTC, Rainer Schuetze 
>> wrote:
>>>
>>>
>>> On 04.08.2017 04:31, Johnson Jones wrote:
>>>> On Friday, 4 August 2017 at 01:33:53 UTC, Johnson Jones 
>>>> wrote:
>>>>> On Thursday, 13 July 2017 at 06:30:07 UTC, Rainer Schuetze 
>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> On 13.07.2017 01:55, FoxyBrown wrote:
>>>>>>> [...]
>>>>>>
>>>>>> It works for me, but takes a couple of seconds to digest 
>>>>>> all the gtk files. There is no completion before that 
>>>>>> finishes. I've tried it with a file looking like this:
>>>>>>
>>>>>> module gtkAll;
>>>>>>
>>>>>> public import gtk.AboutDialog;
>>>>>> public import gtk.AccelGroup;
>>>>>> ...
>>>>>>
>>>>>>
>>>>>>>     [...]
>>>>>> ...
>>>>>>> [...]
>>>>>>
>>>>>> The project built JSON file only covers the files actually 
>>>>>> in the project. You can create a full JSON file with the 
>>>>>> help of rdmd, e.g.
>>>>>>
>>>>>> rdmd -X gtkd\gtkAll.d
>>>>>>
>>>>>> That will likely fail due to object file generation or 
>>>>>> link errors, but should still build the JSON file.
>>>>>
>>>>> What do I do with the json file when it is created? Where 
>>>>> does it go? I'd like to get intellisense to work with gtkD. 
>>>>> I tried adding the gtkD but it locked up VS. The files are 
>>>>> 10MB+. There are two files.
>>>>>
>>>>> gtkD_all.exe.json
>>>>> gtkD_all.json
>>>>>
>>>>> How do I tell visual D to look in those files to use for 
>>>>> intellisense?
>>>>>
>>>>> Visual D has a "Build Phobos Browse Info". Is that 
>>>>> essentially what it does but on the phobos src directory?
>>>>
>>>> I put the files in a dir and told that under the JSON edit 
>>>> box in properties in visual D/studio and eventually it seems 
>>>> that intelligent started working. (it didn't work at first 
>>>> but after a few hours I noticed that I was getting 
>>>> intellisense, not sure if that is what did it or something 
>>>> else I might have fiddled with).
>>>>
>>>> How does Visual D use those files? Does the file name have 
>>>> anything to do with it or does it just load any files inside 
>>>> the dir and then search the json for a match?
>>>
>>> Yes, more or less the latter. You can also browse the loaded 
>>> JSON files in the "Object Browser" window.
>> 
>> It seems to be working. I haven't done any thorough testing 
>> but what I have noticed is that it seems to list any functions 
>> that match rather than reduce the number.
>> 
>> e.g.,
>> 
>> I have a gtkApplicationWindow called mainWindow.
>> 
>> I do
>> 
>> mainWindow.getSize(...)
>> 
>> It lists all the getSizes that exist. There are 11... but only 
>> one for mainWindow. e.g., it shows one for glib, one for atk, 
>> etc.
>> 
>> Not sure if the json is incomplete or visual D does not try to 
>> match the function to the object type it is used on?
>> 
>> Not a huge deal but through me off for a second until I 
>> realized what was going on. Not ideal but better than nothing. 
>> Maybe a simple fix?
>
> As noted before, the JSON support predates semantic analysis. 
> It doesn't have any scope/symbol lookup information so it just 
> lists matching identifiers. That's sometimes useful (e.g. if an 
> import is still missing), but the semantic analysis result is 
> often more accurate (but much harder to implement).
>
> It might be nice to integrate these two approaches, so that 
> Visual D could insert an import automatically when selecting a 
> completion without appropriate import. That's unlikely to 
> happen very soon, though.


(this is a bit long of a post so take your time(when you have 
time, I'm in no rush) and get some coffee ;)


What about locals not seeming to show up? Not sure if my question 
got answered or not?

separator.addOnButtonPress((Event e, Widget w)
										{
         // no intellisense on e and w										   
											return true;
										});


I can follow Event and Widget to peek at the code but that is 
pretty time consuming. Also, listing all matches does no good.

Surely the json output of dmd could be updated so that it gives 
the hierarchy of the type and then that can simply be matched and 
only those members that match the hierarchy are shown(or shown 
first)?

e.g.,

Event e;

when I type e. The compiler/debugger must know that Event is of 
type gdk.Event. If the debugger cannot get that, then I guess 
everything is fubar'ed.

Once it knows that, it should be able to look that up in the 
json. If not, then the json generation should be updated to add 
that.

This is the gdk.Event listing in the json file I generated for 
gdk:

  {
   "name" : "gdk.Event",
   "kind" : "module",
   "file" : "gtkd\\gdk\\Event.d",
   "members" : [
    {
     "name" : "gdk.Device",
     "kind" : "import",
     "line" : 27,
     "char" : 16,
     "protection" : "private"
    },
    {
... other imports ...
}
   {
     "name" : "gtkd.Loader",
     "kind" : "import",
     "line" : 38,
     "char" : 16,
     "protection" : "private"
    },
    {
     "name" : "Event",
     "kind" : "class",
     "line" : 73,
     "char" : 8,
     "members" : [
      {
       "name" : "gdkEvent",
       "kind" : "variable",
       "protection" : "protected",
       "line" : 76,
       "char" : 22,
       "deco" : "PS4gtkc8gdktypes8GdkEvent",
       "offset" : 8
      },
      {
      ... other members ...
      }

and it seems that pretty much the json lists all the members that 
exist.

So it should be quite simple for the debugger to figure out what 
to list rather than just blinding searching the json!?

Basically instead of searching the full json, we restrict it to 
the sub-hierarchy of gdk.Event. This limits the search results 
and everything is good.

That does require us to know that e and Event are suppose to use

  {
   "name" : "gdk.Event",
   "kind" : "module",
   "file" : "gtkd\\gdk\\Event.d",


And I must assume that is where the problem is at. How do we know 
Event and/or e are gdk.Events during editing?

Well, obviously "go to reference" gets it right! so somehow 
visual D is figuring it out. Since it can open the module when 
that is done(I use that feature all the time as that seems to be 
my "intellisense" that works best currently).

Since it can open that module it should just have to find that 
match in the json modules(like the one above) then use the 
reduced json tree instead of the full tree.

It doesn't seem too complicated and all the code seems to be 
there to do it effectively?

While, I guess, module names are not unique and one might have to 
do a bit more parsing, all that should be pretty direct and basic.

Am I on the right track here?  I guess I could try to download 
visual D source and see if I could do that but I imagine I'd 
waste a lot of my own time unless it's pretty obvious in the 
source code what is going on.

Basically visual D should have, internally, a tree corresponding 
to the json where it can search to return the proper results and 
it is just a matter of proper searching?(it seems to just return 
all results in some cases or no results in others).


------------------------------Part 2----------------------------
I just tried downloading the source code and get

"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Enterprise\\Common7\Tools\vsvars32.bat"

when building build.

There is no vsvars32.bat in that directory.

There is

VsDevCmd
and
VsMSBuildCmd

which I'm not sure if it is a new build system or what.

I copyed VsDevCmd to vsvars32 since I do not find that string 
anywhere in the solution(might be a M$ issue?).

I then get

"..\bin\Debug\tlb2idl.exe" does not exist

which !!!fails!!! the build.

Looking at **build.bat** I get

c:\l\dmd-1.056\windows\bin\dmd.exe -g tlb2idl.d oleaut32.lib 
uuid.lib snn.lib kernel32.lib

which is definitely not where my dmd is installed. **That seems 
to be hard coded.**

Also in that same file is

m:\s\d\cv2pdb\trunk\bin\debug\cv2pdb -D1 tlb2idl.exe 
tlb2idl_pdb.exe

which, I think I have no m drive. Using the installed VisualD's 
cv2pdb, and running build.

I get

---------
D:\Repos\visuald-master\tools>c:\d\dmd2\windows\bin\dmd.exe -g 
tlb2idl.d oleaut32.lib uuid.lib snn.lib kernel32.lib
tlb2idl.d(4): Deprecation: module std.c.windows.com is deprecated 
- Import core.sys.windows.com instead

D:\Repos\visuald-master\tools>if errorlevel 1 goto xit

D:\Repos\visuald-master\tools>"C:\Program Files 
(x86)\VisualD\cv2pdb\cv2pdb.exe" -D1 tlb2idl.exe tlb2idl_pdb.exe
D:\Repos\visuald-master\tools\tlb2idl_pdb.pdb: cannot load PDB 
helper DLL
------

There is a tlb2idl.exe now. Copied that to bin\debug. Reran build 
solution and now it is translating...


after that is finished I get

------
WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\
Error: cannot execute coffimplib, please add to PATH
------

which seems to be !!hardcoded!! set 
COFFIMPLIB=c:\l\dmc\bin\coffimplib.exe
at line 30 in sdk_libs.

I don't even have that in my dmc(using dmd2 installer, which 
wanted to install dmc, but I guess that needs to be updated to 
install that. I'll hunt for it online).


After all that, the build project built without errors.

Now trying to build VisualD project I get

Building ..\bin\Debug\vsi.lib...
win32\handleapi.d(40): Error: found 'hObject' when expecting ')'
win32\handleapi.d(41): Error: semicolon expected following 
function declaration
win32\handleapi.d(41): Error: declaration expected, not ')'


I remove the _Post_ptr_invalid_ and tried to rebuilt again and 
got the errors

win32\rpcdce.d(1717): Error: undefined identifier 
`RpcBindingInqAuthClientW`, did you mean alias 
`RpcBindingInqAuthClient`?
win32\rpcdce.d(1718): Error: undefined identifier 
`RpcBindingInqAuthClientExW`, did you mean alias 
`RpcBindingInqAuthClientEx`?
vsi\vsregkeynames.d(29): Error: undefined identifier 
`REGKEY_BLENDROOT_CURRENT`
vsi\vsregkeynames.d(30): Error: undefined identifier 
`LREGKEY_BLENDROOT_CURRENT`

I imagine this will continue ;/ Seems to be something wonky with 
the project. These errors seem to be releated to win32?

Have you been able to get Visual D to build on a completely fresh 
install(That is basically what I'm using) or are you using the 
same system that you've been using since the start?

Maybe all these problems is why no one is helping with it? Seems 
like a lot of trouble(not blaming you or anything, just saying it 
might be worth fixing these issues).



-----------------------------
Fixes:

Paths that are hard coded - Either add some type of intelligent 
search algorithm or put all the hard coded paths in one spot so 
the user can easily find and build them. Put in the docs the 
things that are required to build and modify to get things to 
work.



"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Enterprise\\Common7\Tools\vsvars32.bat"
Try to use others if this doesn't exist.



build.bat:

Hard coded dmd - simply try to use path first and see if dmd.exe 
exists in it. Most people using visual D will have dmd installed 
and it will have added itself to the path
c:\l\dmd-1.056\windows\bin\dmd.exe

Hard coded cv2pdb
m:\s\d\cv2pdb\trunk\bin\debug\cv2pdb -D1 tlb2idl.exe 
tlb2idl_pdb.exe
(change this to standard visual D install C:\Program Files (x86) 
since most likely the end user will have Visual D installed to 
the default path. Do not hard code in build.bat though)



sdk_libs:

Hard coded coffimplib. Not sure what to do here but probably use 
the dmd.exe as a reference then back track since the dmd2 
installer installs dmc relative to it. It doesn't come with 
coffimplib but maybe it could be added so it exists.

set COFFIMPLIB=c:\l\dmc\bin\coffimplib.exe
at line 30 in sdk_libs.


When these files are missing good error messages should report 
they are missing(probably checked at the start rather than 
failing in the middle of the build process.

All these errors are from hard coded paths an missing files. 
Should be easy fixes.








More information about the Digitalmars-d-ide mailing list