ParseResultHandler Delegate


Used to define a delegate for a parsing operation completion handler in a language service.

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public delegate void ParseResultHandler(
	ParseRequest request


Type: Microsoft.VisualStudio.Package.ParseRequest

[in] A ParseRequest object that describes what the parsing operation did.

This delegate describes a handler that is called when a parsing operation is complete. The ParseRequest object provides access to the results of the parsing operation. This delegate is passed to the BeginParse method in the LanguageService class.

Here is an example of how this delegate is used. This code is based on the code in the Source class that handles a parse for a completion operation.

namespace Microsoft.VisualStudio.Package
    public class Source :
        private LanguageService service;
        private CompletionSet completionSet;

        public virtual void Completion(IVsTextView textView,
                                       TokenInfo info,
                                       ParseReason reason)
            int line;
            int idx;

            int hr = textView.GetCaretPos(out line, out idx));
            if (hr == VSConstants.S_OK)
                bool synchronous = (reason == ParseReason.CompleteWord ||
                                    reason == ParseReason.DisplayMemberList);
                                new ParseResultHandler(this.HandleCompletionResponse),

        internal void HandleCompletionResponse(ParseRequest req)
                if (this.service == null || req.Scope == null || this.completionSet == null)

                ParseReason reason = req.Reason;
                Declarations decls = req.Scope.GetDeclarations(req.View,
                bool completeWord = (reason == ParseReason.CompleteWord);
                if ( decls.GetCount() > 0 &&
                    (this.service.Preferences.AutoListMembers || completeWord))
                    this.completionSet.Init(req.View, decls, completeWord);
            } catch (Exception e) {
Return to top