Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Using VaX features from a VS extension
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dcastonguay
Junior Member

Canada
13 Posts

Posted - Nov 27 2015 :  2:14:41 PM  Show Profile  Reply with Quote
Hello,

I apologise in advance for the long post... here it goes!

Is it possible to use some Visual Assist features (for now, I'm only wondering about the "goto implementation" feature) from within another Visual Studio Extension, which acts as Language Service for files with a specific file extension (and which are not C++ code)?

I am using VS2012 and VA_X.dll file version 10.9.2076.0 built 2015.09.15.




More context



We have created our own language, let's call it MyLanguage (with .myl files), which generates C++ under the hood, but it is not C++ itself. We also added a Visual Studio Package which acts as a Language Service, so we can provide Intellisense, code navigation, and other features to our developers.

In MyLanguage, we can import classes and functions from C++ using an import clause in a .myl file.

When the user requests navigation to the declaration or definition of a symbol imported from C++, we would like to let Visual Assist handle the request (i.e. similar to what VAssistX.GotoImplementation does).

However, since our language uses a custom file extension (.myl) and since a language service is registered for that extension, Visual Assist doesn't seem to be available for these files.

The attempts



I have tried several things to make this work:

1. Manually calling VAssistX.GotoImplementation


First, I tried manually calling Visual Assist just like any user can.

In a .myl file, with the caret in the middle of an imported C++ symbol, I tried manually calling the following from the Immediate Window:
> VAssistX.GotoImplementation

The result was as follows:
Command "VAssistX.GotoImplementation" is not available.


Trying the same thing in a C++ file works properly. I have also tested this in a plain .txt file, and it also works (and so does the keyboard shortcut).

2. Meddling with the command chain


In a hackish attempt to make the VAssistX.GotoImplementation be executed, I tried to intercept requests for that specific command in the QueryStatus method our own command filter, and always return "enabled and supported".

Executing the command with this code through the Immediate window outputs the following text:
Visual Studio has encountered an unexpected error.


Using the keyboard shortcut makes Visual Studio show a simple error message box with the same text.

However, it is worth noting that if I forcefully set Visual Studio's Edit.GoToDefinition to "enabled and supported", like above, using that command through a keyboard shortcut works, but entering it in the Immediate Window doesn't (which is weird). Also, entering the following also works in the Immediate Window, whatever the selected symbol is:
> Edit.GoToDefinition <anySymbolName>


Still, I reverted these hackish changes in the command chain.

3. Disabling our Language Service


Since the VAssistX.GotoImplementation command works on text files, I tried disabling the Language Service to see if it was interfering with Visual Assist in some way.

Doing the same steps as in section 1 still did not work. More attempts down below...

4. Meddling with Visual Assist's registry keys



While the Language Service is disabled, I tried changing some registry keys.

Since MyLanguage is not C++, I did not want to follow the steps in the "Allow C/C++ files with a non-standard extension" article, even though they probably would have worked. I don't want our Language Service and Visual Assist actively competing on .myl files.

However, I still tried following the steps mentioned in the "Adding files with additional extensions to the Open File in Solution dialog" article, and added the .myl extension to the "Extensions to ignore" and the ExtSource registry key. With this setup, the VAssistX.GotoImplementation command still didn't work (I guess because the file is ignored).

Following the "Allow non-C/C++ files with non-standard extensions" article, I added the .myl extension to HKEY_CURRENT_USER\\Software\\Whole Tomato\\Visual Assist X\\VANet11\\ExtPlainText (which already existed). I rebooted VS, and it worked: I could use the "goto implementation" command!

However, when re-enabling our Language Service, that last solution stopped working.

5. Changing the Language Service's ContentTypeDefinition


Since changing the ExtPlainText registry key seemed to work without our extension being enabled, I tried to make sure that the Language Service's ContentTypeDefinition's base definitions included "text" and "plaintext" (along with the "code" base definition it already had). This didn't change anything.

6. Accessing directly Visual Assist functionality/database from the Language Service



I thought about trying to bypass the command system of Visual Studio and directly access the Visual Assist extension and/or objects and call the appropriate methods, but no amount of Googling or searching in these forums told me how to do this (and some amount of searching told me this was not possible (e.g. this forum thread) :)).

The possible workarounds


Since my attempts at getting Visual Assist to work in a .myl file while our extension is enabled have failed, I tried to think of some alternatives. I came up with only one:

Since the user has to specify which file a symbol is imported from, I could open that file first, then try to call Visual Assist's commands. This has some drawbacks, though:

  • I can't use VAssistX.GotoImplementation with an argument, so I'd have to open the file and manually search for the symbol, to then (maybe) run the command.

  • However, the user could specify a file which actually #includes another file, which is where the symbol itself is. In this situation, the above "search and execute" operation would fail.







I'm somewhat at my wit's end... :)

Any help would be greatly appreciated. Thanks for your time!

Daniel

feline
Whole Tomato Software

United Kingdom
15984 Posts

Posted - Nov 27 2015 :  2:44:27 PM  Show Profile  Reply with Quote
VA is not designed to be called by another tool, as you have discovered.

I understand that you don't want VA and your tool both scanning your code files at the same time, but have you tried telling VA that your code is C++ anyway? VA is designed to have a low overhead, and to parse quickly. Unless you have a massive pile of code, the system load from having both tools running at once should be fairly low.

zen is the art of being at one with the two'ness
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Nov 27 2015 :  2:57:15 PM  Show Profile  Reply with Quote
Thanks for the quick reply!

I just tried following the steps in Allow C/C++ files with a non-standard extension (except for the Visual-Studio-specific settings) and it still does not work. Unless I absolutely have to rebuild my database? I would think not, since I got it working in plain text files...

Daniel
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15984 Posts

Posted - Nov 27 2015 :  10:36:24 PM  Show Profile  Reply with Quote
Are you seeing the VA Context and Definition fields in your .myl files? I have tested this here, with VS2012 and VA 2076, and a simple .myl file. Adding ".myl;" to the ExtSource and doing the VA symbol database rebuild, but without telling VS2012 to treat these files as C++, I am getting VA semi-active in the file.

The context and definition fields are showing, and alt-g works. But there is no syntax highlighting.

So are you seeing the same thing at your end? If not, did you add the semi-colon to the end of the registry value?

Did you exit all instances of the IDE before editing the registry? You need to do this to make sure nothing is overwritten when the IDE is closed.

If this is still not working, a full symbol database rebuild should only take a few minutes, unless you have a lot of code in your stable include directories.

zen is the art of being at one with the two'ness
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Nov 30 2015 :  7:07:20 PM  Show Profile  Reply with Quote
Hello,

So, I've tried disabling our language service, adding the .myl extension to ExtSource without telling VS2012 to treat those files as C++, and even without rebuilding the database, I do get VA semi-active.

However, when re-enabling our extension, I do not get the context and definition bars, and Alt + G does not work anymore.

I've spent most of my day today trying to figure out if there was something wrong with our extension. I tried stripping it down to almost nothing, and it still didn't work.

I finally ended up creating a new bare bones language service extension for .myl files by going through VS2012 SDK's "Visual Studio Package" template, located in New Project -> Templates -> Other Project Types -> Extensibility. To this template, I simply added the ContentTypeDefinition and FileExtensionToContentTypeDefinition exports, made sure to add the MefComponent asset to the manifest, and installed it. This minimal extension did not work with VA either; I didn't get the bars, nor could I use the Alt + G shortcut.

This led me to believe that the simple fact of registering a new language with a new file extension is not compatible with VA at the moment. Do you believe I am right in this? If so, could limited support be added for such a feature?

Also, when registering a new language through a ContentTypeDefinition, we can provide zero or more BaseDefinitions (for example, MyLanguage's base content definition is "code", as mentioned in my first post). Maybe VA could provide limited functionality for all ContentTypeDefinitions which "inherit" from certain base definitions, like "code" ?

If those requests are impractical, I could also make the navigation work in our extension if VA offered a command similar to VAssistX.GotoImplementation which would always be available and would take the symbol to navigate to as a parameter. Is that already available?

Thanks for your time and your help,
Daniel
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15984 Posts

Posted - Nov 30 2015 :  10:26:10 PM  Show Profile  Reply with Quote
I am out of my depth when it comes to language extensions, to be honest, so I have asked our developers about this, to see if they have any thoughts:

case=93581

I may have a partial work around for now though. If you select some text in the editor, even in a .myl file that VA knows nothing about, and then use Alt-Shift-S to open VA's Find Symbol dialog, the current selection is used as the default filter for the symbol.

This gives you a global alt-g. A "full" alt-g won't work unless VA is able to correctly parse the current file, since alt-g understands local variables, but if I understand correctly you are interested in jumping to symbols defined in another file, which will be listed in the Find Symbol dialog.

Since the current selection is being picked up and used even when VA does not know about the .myl extension, you might be able to select the current symbol and then trigger VA's Find Symbol dialog, the command VAssistX.FindSymbolDialog. Not as direct, but perhaps a useful option all the same.

zen is the art of being at one with the two'ness
Go to Top of Page

holedigger
Whole Tomato Software

145 Posts

Posted - Dec 01 2015 :  12:30:51 AM  Show Profile  Reply with Quote
Hi Daniel, I suspect the issue is with the ContentType. We do support the "plaintext" ContentType, but we don't check BaseDefinitions, so we are most likely ignoring your "mylang" ContentType.

Please contact us through the support form, and we can try other options.
http://www.wholetomato.com/support/contact.asp

Whole Tomato Software
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Dec 01 2015 :  09:37:56 AM  Show Profile  Reply with Quote
Thank you both, I will go though the support form for further options.

I just wanted to point out that the VAssistX.FindSymbolInDialog workaround does not work either in .myl files when our extension is enabled; the window shows up, but the selected text is not used in it. It works fine in plain text files and C++ files, but not in our own.

Daniel

Edited by - dcastonguay on Dec 01 2015 09:38:47 AM
Go to Top of Page

holedigger
Whole Tomato Software

145 Posts

Posted - Dec 04 2015 :  12:10:58 PM  Show Profile  Reply with Quote
Daniel, I've responded via email. Please confirm you've received it. Thanks.

Whole Tomato Software
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Dec 04 2015 :  12:15:11 PM  Show Profile  Reply with Quote
Hello,

I've received your e-mail and instructions. I'll try them out immediately.

Thanks,
Daniel
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Dec 04 2015 :  12:53:10 PM  Show Profile  Reply with Quote
Hi again,

I tested with the instructions enclosed in the e-mail, but I got a crash in VS.

I sent an e-mail with the details to support.

Daniel
Go to Top of Page

sean
Whole Tomato Software

USA
2641 Posts

Posted - Dec 17 2015 :  12:43:25 PM  Show Profile  Reply with Quote
support case=93581 became dev case=93718

case=93718 is implemented in build 2086 via a registry string value named CustomContentTypes

You must create the string value.
Set the value to the name of your custom content type and terminate with a semi-colon.
Add your custom file extension to the ExtPlainText registry string value (terminate with a semi-colon).
Set RestrictVaToPrimaryFileTypes to 00.
see http://support.wholetomato.com/default.asp?W407 for registry location.
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Dec 17 2015 :  12:50:24 PM  Show Profile  Reply with Quote
Thanks a lot, I'll try that one out right away, and let you know how it goes.
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Dec 17 2015 :  1:11:31 PM  Show Profile  Reply with Quote
Works like a charm. Thanks a lot!

Also, can anyone tell me precisely what type of functionality is enabled when a file extension is added to ExtPlainText? I've seen it makes GoToImplementation work, but what else if there?

I've already asked Mark (holedigger?) this question, and he told me "it [was] kind of a happy accident the Alt+G works in text files at all", so I'm just wondering :)

Daniel
Go to Top of Page

sean
Whole Tomato Software

USA
2641 Posts

Posted - Dec 17 2015 :  1:47:36 PM  Show Profile  Reply with Quote
Minor things:
highlight current line
highlight matching word when caret is in comments and strings (applies to all text in plain text files)
indicator column
some of the surround selection commands
paste history menu
va snippets
prepopulation of edit field when invoking Find Symbol in Solution with text selected in editor

Edited by - sean on Dec 17 2015 2:54:20 PM
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Jan 07 2016 :  6:58:55 PM  Show Profile  Reply with Quote
Hello again,

So I've deployed our Language Service with Visual Assist "integration" to our users, and everything works properly.

However, one user came back to me with a gripe: the VAssistX.GotoImplementaiton doesn't work the same in non-C++ code as it does in C++ code, especially regarding how to choose the symbol to go to: if the caret is immediately before the symbol, the goto operation will fail in non-C++ code.

Let's assume we have the following line of code (written in MyLanguage):

    int i = m_MyVariable;


Here are a few examples (in which the pipe character "|" represents the caret):

    int i = m|_MyVariable; // Goto operation works
    int i = m_My|Variable; // Goto operation works
    int i = m_MyVariable|; // Goto operation works
    int i = |m_MyVariable; // Goto operation DOES NOT WORK (but it works in C++)


Note that the goto operation also works when the symbol is selected.

Do you think this last example could be fixed?

Thanks, and happy new year!
Daniel
Go to Top of Page

sean
Whole Tomato Software

USA
2641 Posts

Posted - Jan 07 2016 :  10:36:32 PM  Show Profile  Reply with Quote
We support GotoImplementation in comments in C++ source. It suffers from the same behavior you noted -- the command does not work when the caret is at the start of the word. case=94296

Hopefully fixing the goto in comment behavior will have the side-effect of fixing it in your scenario.
Go to Top of Page

sean
Whole Tomato Software

USA
2641 Posts

Posted - Feb 02 2016 :  7:48:51 PM  Show Profile  Reply with Quote
case=94296 is fixed in build 2089.
Go to Top of Page

dcastonguay
Junior Member

Canada
13 Posts

Posted - Feb 04 2016 :  12:43:05 PM  Show Profile  Reply with Quote
I can confirm it also work in a custom language.

Thanks!
Daniel
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000