Rubberduck.Parsing.VBA.RubberduckParser.ParseAsyncInternal C# (CSharp) Method

ParseAsyncInternal() private method

private ParseAsyncInternal ( VBComponent component, CancellationToken token, TokenStreamRewriter rewriter = null ) : void
component VBComponent
token System.Threading.CancellationToken
rewriter TokenStreamRewriter
return void
        private void ParseAsyncInternal(VBComponent component, CancellationToken token, TokenStreamRewriter rewriter = null)
        {
            var preprocessor = new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture));
            var parser = new ComponentParseTask(component, preprocessor, _attributeParser, rewriter);
            parser.ParseFailure += (sender, e) => _state.SetModuleState(component, ParserState.Error, e.Cause as SyntaxErrorException);
            parser.ParseCompleted += (sender, e) =>
            {
                // possibly lock _state
                _state.SetModuleAttributes(component, e.Attributes);
                _state.AddParseTree(component, e.ParseTree);
                _state.AddTokenStream(component, e.Tokens);
                _state.SetModuleComments(component, e.Comments);
                _state.SetModuleAnnotations(component, e.Annotations);

                // This really needs to go last
                _state.SetModuleState(component, ParserState.Parsed);
            };
            _state.SetModuleState(component, ParserState.Parsing);
            parser.Start(token);
        }