locked
How to run my LanguageService when file opened programmatically RRS feed

  • Question

  • Hello,
    I have created simple Package for JavaScript(.js file extension). I have used simply EditorFactory,
    to override default LanguageService. But it's works fine only when I open JavaScript file using option
    File->Open->File...->Select .js file from OpenFileDialog.
    When I try open .js file programmatically - default LanguageService is loaded.
    Source code:

    Window window = _dte.OpenFile(Constants.vsViewKindTextView, jsFileName);
    if (window != null )
    window.Activate();
    How to run my LanguageService for this case?

    I noticed: when I open JavaScript file by double-click on file node
    in Solution Explorer - my LanguageService has been properly started.

    How to "Solution Explorer" opens file by double-click?

    Environment:
    Visual Studio 2008
    OS Vista

    Sincerely,

    Mykhaylo

    • Edited by Mykhaylo Zober Sunday, August 9, 2009 6:22 PM Add more information(noticed)
    Sunday, August 9, 2009 1:19 AM

Answers

  • Hi Mykhaylo,

    As I know, it's determined by the text buffer of the Core Editor, when you open a .js file from the OpenFileDialog, the text buffer check the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Editors\{YourLanguageService GUID}\Extensions to find out the language service associated with this file extension, and then load the VSPackage and create a instance of your Language Service.
    I think DTE.OpenFile will also follow this step, what if you open the file with Constants.vsViewKindCode or Constants.vsViewKindPrimary?

    Sincerely,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, August 11, 2009 5:35 AM

All replies

  • Hi Mykhaylo,

    As I know, it's determined by the text buffer of the Core Editor, when you open a .js file from the OpenFileDialog, the text buffer check the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Editors\{YourLanguageService GUID}\Extensions to find out the language service associated with this file extension, and then load the VSPackage and create a instance of your Language Service.
    I think DTE.OpenFile will also follow this step, what if you open the file with Constants.vsViewKindCode or Constants.vsViewKindPrimary?

    Sincerely,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, August 11, 2009 5:35 AM
  • Hi Wesley,

    Great Thanks for hint.
    With Constants.vsViewKindPrimary works well.

    Sincerely,
    Mykhaylo
    Tuesday, August 11, 2009 5:12 PM