Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / July 2006

Tip: Looking for answers? Try searching our database.

LanguageService.ParseSource(...) not being called?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nospam@starsphere.net - 21 Jul 2006 17:38 GMT
I am attempting to extend visual studio functionality by adding support
for a language I frequently need to use.

I am trying to setup outlining (collapsible regions) for code written
in the editor. I have set AutoOutlining to true. The VS SDK documents
say that this should then cause VS to automatically call ParseSource
and provide the AuthoringSink for my code to then fill with the hidden
(collapsible) regions. My problem is that ParseSource is never being
called.

Have I misunderstood what to do? Or am I just missing something? It
appears the *only* time I can get ParseSource to fire, is when I right
click some of the code in the editor, and chose "goto definition", it
then correctly calls ParseSource with "Goto" as the reason. This is the
only time it seems to fire. It is not being automatically called when
the document loads as the SDK documentation suggests.

Any help would be appreciated.
Andy Savage.

Related sections of code follow:

public override LanguagePreferences GetLanguagePreferences()
       {
           LanguagePreferences preferences = new
LanguagePreferences(this.Site, typeof(ASLanguageService).GUID,
this.Name);
           preferences.Init();
           preferences.AutoOutlining = true;
           // <.. Other preferences cut from here to make this
snippet shorter ...>

           return preferences;
       }

public override AuthoringScope ParseSource(ParseRequest req)
       {
           Debug.WriteLine(String.Format("ParseSource at ({0}:{1}),
reason {2}", req.Line, req.Col, req.Reason));

            // <... code to generate and walk AST here ommited in
snippet ...>

           // Always Need To Return A Valid Authoring Scope
           return new ASAuthoringScope();
       }
nospam@starsphere.net - 22 Jul 2006 03:24 GMT
After a day of searching I seem to have found the answer. There are
several steps you need to do:

1) Implement the IOleComponent interface as part of your VSPackage.
2) Register your package with the OleComponentManager with parameters
indicating idle time.
3) Implement your FDoIdle method (from the IOleComponent interface) to
call your language service's DoIdle(...) method.

More information on steps 1-3 can be found at:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=192211&SiteID=1

4) Override your language service OnIdle function to tell the Source
object it has not been parsed. Something like:

public override void OnIdle(bool periodic)
       {
           Source src = GetSource(this.LastActiveTextView);
           if (src != null && src.LastParseTime == Int32.MaxValue)
           {
               src.LastParseTime = 0;
           }
           base.OnIdle(periodic);
       }

This will then cause the ParseSource(...) to be called as expected.

Most of this is shown in the IronPythonIntegration\LanguageService
example. However it is not at all documented in the SDK help. I feel it
should be mentioned, particularly in the MPF section steps specifically
to add outlining.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.