locked
VS 2012-2013 Extension, goto definition, reformatting RRS feed

  • Question

  • Hello,

    I am in a newbie in the realm of Visual Studio…

    We have a C++ project , plus some script text files ( referenced by the project, at this time as simple text files).

    We want to extend Visual Studio to have syntax highlighting, outlining, code completion, text reformatting on these script files.

    In addition to this, some of the functions of the C++ project are directly referenced in the script file (their name is written as a param).

    We would like to be able, in the script file, to press "Goto definition" and go to the corresponding C++ definition.

    I've already written a Visual Studio extension(not a language extension), which provides some syntax highlighting, outlining, and completion.

    However, it seems that without a language extension, it is not possible to highlight multiline comments, do text formatting, ... ? Or am I mistaken ? Would I be better with a language extension ?

    Which way should I go to implement a “Goto Definition” command available on my script files, which would be able to find the correct C++ definition ?

    Thank you in advance for your help and advice!


    Monday, April 20, 2015 9:32 AM

Answers

  •  Hi Caillen,

    Thanks alot for that answer!

    Do you suggest that the thread you reference offers a workaround solution for my needs, but that the real clean way to go would be to implement my own language service ?

    And that with a language service, the built-in Edit.GotoDefinition function would automatically do the job and find a C++ definition for a token written in my script language ?

    Thanks!

    Yes, I think to create a language service is a more "clean" way in your case.  But if you create your own language service, you still need to implement the GotoDefinition by yourself. If it's not a standard C++ editor, the built-in Edit.GotoDefinition function will not be triggered properly.

    Check this documentation for more about the LanguageService and the GoTo function:

    Implementing a Language Service (Managed Package Framework)


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Caillen Monday, April 27, 2015 10:16 AM
    Wednesday, April 22, 2015 9:32 AM

All replies

  • Hi fred,

    Try the solution in this thread:

    How can I perform “Go To Definition” programmatically in Visual Studio?

    The built-in Edit.GoToDefinition command does not work in the custom editor in your case. if you don't want to implement your own language service, you could try to utilize the IVsObjectManager to find the object you want. But this may need to firstly find the selected object in the current editor.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 21, 2015 6:05 AM
  •  Hi Caillen,

    Thanks alot for that answer!

    Do you suggest that the thread you reference offers a workaround solution for my needs, but that the real clean way to go would be to implement my own language service ?

    And that with a language service, the built-in Edit.GotoDefinition function would automatically do the job and find a C++ definition for a token written in my script language ?

    Thanks!

    Tuesday, April 21, 2015 8:11 AM
  •  Hi Caillen,

    Thanks alot for that answer!

    Do you suggest that the thread you reference offers a workaround solution for my needs, but that the real clean way to go would be to implement my own language service ?

    And that with a language service, the built-in Edit.GotoDefinition function would automatically do the job and find a C++ definition for a token written in my script language ?

    Thanks!

    Yes, I think to create a language service is a more "clean" way in your case.  But if you create your own language service, you still need to implement the GotoDefinition by yourself. If it's not a standard C++ editor, the built-in Edit.GotoDefinition function will not be triggered properly.

    Check this documentation for more about the LanguageService and the GoTo function:

    Implementing a Language Service (Managed Package Framework)


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Caillen Monday, April 27, 2015 10:16 AM
    Wednesday, April 22, 2015 9:32 AM
  • I agree with the other posts that the best way here would certainly be to implement a language service. Depending on your needs, the interfaces you are interested in are just a few:

    There is the VsPackage, in which wou register your LanguageService. The latter hast some methods that need implementations, but most importantly there is a method called ParseSource, which is called whenever the user wants to "goto definition". You need to create an AuthoringScope as return-value, which actually implements the Goto()-method. It still will be some significant work, but there are plenty of tutorials out there which will help you.

    Wednesday, May 6, 2015 5:45 AM