public void Start(CancellationToken token) { try { var code = RewriteAndPreprocess(); token.ThrowIfCancellationRequested(); var attributes = _attributeParser.Parse(_component); token.ThrowIfCancellationRequested(); // temporal coupling... comments must be acquired before we walk the parse tree for declarations // otherwise none of the annotations get associated to their respective Declaration var commentListener = new CommentListener(); var annotationListener = new AnnotationListener(new VBAParserAnnotationFactory(), _qualifiedName); var stopwatch = Stopwatch.StartNew(); ITokenStream stream; var tree = ParseInternal(_component.Name, code, new IParseTreeListener[] { commentListener, annotationListener }, out stream); stopwatch.Stop(); if (tree != null) { _logger.Trace("IParseTree for component '{0}' acquired in {1}ms (thread {2})", _component.Name, stopwatch.ElapsedMilliseconds, Thread.CurrentThread.ManagedThreadId); } var comments = QualifyAndUnionComments(_qualifiedName, commentListener.Comments, commentListener.RemComments); token.ThrowIfCancellationRequested(); ParseCompleted.Invoke(this, new ParseCompletionArgs { ParseTree = tree, Tokens = stream, Attributes = attributes, Comments = comments, Annotations = annotationListener.Annotations }); } catch (COMException exception) { _logger.Error(exception, "Exception thrown in thread {0}.", Thread.CurrentThread.ManagedThreadId); ParseFailure.Invoke(this, new ParseFailureArgs { Cause = exception }); } catch (SyntaxErrorException exception) { _logger.Error(exception, "Exception thrown in thread {0}.", Thread.CurrentThread.ManagedThreadId); ParseFailure.Invoke(this, new ParseFailureArgs { Cause = exception }); } catch (OperationCanceledException) { _logger.Debug("Component {0}: Operation was Cancelled", _component.Name); // no results to be used, so no results "returned" //ParseCompleted.Invoke(this, new ParseCompletionArgs()); } }
private void DoParseAndTransfer() { this.WebBrowserInstance.Document.InvokeScript("parse"); this.WebBrowserInstance.Document.InvokeScript("transfer"); if (this.ParseCompleted != null) { ParseCompleted.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Parse C# XML Document /// </summary> /// <returns type="Element">Parsed tree structure elements.</returns> public Element Parse() { var members = FirstParse(XmlPath); ParseCompleted?.Invoke(this, new XmlDocumentParseProgressEventArgs(ParseType.First, 0, 0, null)); var treeElement = SecondParse(members); ParseCompleted?.Invoke(this, new XmlDocumentParseProgressEventArgs(ParseType.Second, 0, 0, null)); return(treeElement); }
/// <summary> /// Parses from text. /// </summary> /// <returns>The from text.</returns> public Element ParseFromText() { var reader = new Reader(); reader.LoadFromText(XmlPath); var members = FirstParse(reader); ParseCompleted?.Invoke(this, new XmlDocumentParseProgressEventArgs(ParseType.First, 0, 0, null)); var treeElement = SecondParse(members); ParseCompleted?.Invoke(this, new XmlDocumentParseProgressEventArgs(ParseType.Second, 0, 0, null)); return(treeElement); }
protected override void OnOperationCompleted(ITextSnapshot input, TParseResult output) { ParseCompleted?.Invoke(this, new ParseCompletedEventArgs <TParseResult> (output, input)); }
protected override void OnOperationCompleted(XmlParseResult input, MSBuildParseResult output) { ParseCompleted?.Invoke(this, new ParseCompletedEventArgs <MSBuildParseResult> (output, output.Snapshot)); }
protected virtual void OnParseCompleted(T parseResult, ITextSnapshot2 snapshot) { ParseCompleted?.Invoke(this, new ParseCompletedEventArgs <T> (parseResult, snapshot)); }