Ask a questionAsk a question
 

AnswerLanguageService for built-in language

  • Sunday, May 11, 2008 1:20 PMAnthony Beane Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi!

    How could one associate his custom language service with an extension already supported by Visual Studio? I would like to implement custom language service for JavaScript. However this simply doesn't work:

    [ProvideLanguageExtension(typeof(MyLanguageService), ".js")]

    I am sure my language service works because it is successfully loaded if I change the extension. What else needs to be done? Is there any example I can look at?

    Thanks.


Answers

  • Monday, May 12, 2008 7:32 AMRustam Kulenov Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    Can you give an example of using your language service with already registered extension?
    I suppose, that users of JavaScript Language Service might use it by explicitly specifying it's GUID.
    You can also provide [ProvideEditorExtension(typeof(...), ".js", 100)] attribute and create your own editor factory for javaScript files.
  • Tuesday, May 13, 2008 8:56 PMAnthony Beane Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thank you guys!

    I followed the example for instantiating the CoreEditor from the MSDN and voila - everyting is up and running now! Now my language service is successfully being instantiated for .js files and I can proceed with my work. Thank you once again!

All Replies

  • Monday, May 12, 2008 7:32 AMRustam Kulenov Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

    Can you give an example of using your language service with already registered extension?
    I suppose, that users of JavaScript Language Service might use it by explicitly specifying it's GUID.
    You can also provide [ProvideEditorExtension(typeof(...), ".js", 100)] attribute and create your own editor factory for javaScript files.
  • Monday, May 12, 2008 7:19 PMAnthony Beane Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Rustam!

    Thank you for you response.

     Rustam Kulenov wrote:

    Can you give an example of using your language service with already registered extension?


    I suppose I didn't express myself correctly. What I meant was that my language service worked ok for other (unregistered) extensions such as ".jsx". What I really need is to hook my language service for the .js extension.
     Rustam Kulenov wrote:

    I suppose, that users of JavaScript Language Service might use it by explicitly specifying it's GUID.

    I want to completely override the existing (built-in) JavaScript language service. I don't plan to rely on it.
     Rustam Kulenov wrote:

    You can also provide [ProvideEditorExtension(typeof(...), ".js", 100)] attribute and create your own editor factory for javaScript files.

    I have to try that out and see if it works for me. Thank you for the suggestion.

    Best regards.
  • Tuesday, May 13, 2008 6:49 PMMichael Hanson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Each editor determines the language service it uses, so I think your only option is as suggested to create a custom editor and register this with a higher priority than the default of 40 registered for .js (at least this is the default on my system).

     

    You can do this fairly simply by creating an EditorFactory that instantiates the CoreEditor.

     

    Mike

  • Tuesday, May 13, 2008 8:56 PMAnthony Beane Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Thank you guys!

    I followed the example for instantiating the CoreEditor from the MSDN and voila - everyting is up and running now! Now my language service is successfully being instantiated for .js files and I can proceed with my work. Thank you once again!