Compartilhar via


ParseResultHandler Delegate

Definition

Important

This API is not CLS-compliant.

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

public delegate void ParseResultHandler(ParseRequest ^ request);
[System.CLSCompliant(false)]
public delegate void ParseResultHandler(ParseRequest request);
public delegate void ParseResultHandler(ParseRequest request);
[<System.CLSCompliant(false)>]
type ParseResultHandler = delegate of ParseRequest -> unit
type ParseResultHandler = delegate of ParseRequest -> unit
Public Delegate Sub ParseResultHandler(request As ParseRequest)

Parameters

request
ParseRequest

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

Attributes

Examples

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  
{  
    [CLSCompliant(false)]  
    public class Source :  
        IDisposable,  
        IVsTextLinesEvents,  
        IVsFinalTextChangeCommitEvents,  
        IVsHiddenTextClient  
    {  
        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);  
                this.BeginParse(line,  
                                idx,  
                                info,  
                                reason,  
                                textView,  
                                new ParseResultHandler(this.HandleCompletionResponse),  
                                synchronous);  
            }  
        }  

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

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

Remarks

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.

Applies to