public void Resolve() { foreach (var componentParseResult in _parseResults) { OnProgress(componentParseResult); try { var resolver = new IdentifierReferenceResolver(componentParseResult.QualifiedName, _declarations); var listener = new IdentifierReferenceListener(resolver); var walker = new ParseTreeWalker(); walker.Walk(listener, componentParseResult.ParseTree); } catch (InvalidOperationException) { // could not resolve all identifier references in this module. } } }
private void ResolveReferences(DeclarationFinder finder, VBComponent component, IParseTree tree) { var state = _state.GetModuleState(component); if (_state.Status == ParserState.ResolverError || (state != ParserState.Parsed)) { return; } Debug.WriteLine("Resolving '{0}'... (thread {1})", component.Name, Thread.CurrentThread.ManagedThreadId); var qualifiedName = new QualifiedModuleName(component); var resolver = new IdentifierReferenceResolver(qualifiedName, finder); var listener = new IdentifierReferenceListener(resolver); if (!string.IsNullOrWhiteSpace(tree.GetText().Trim())) { var walker = new ParseTreeWalker(); try { walker.Walk(listener, tree); state = ParserState.Ready; } catch (Exception exception) { Debug.Print("Exception thrown resolving '{0}' (thread {2}): {1}", component.Name, exception, Thread.CurrentThread.ManagedThreadId); state = ParserState.ResolverError; } } _state.SetModuleState(component, state); Debug.Print("'{0}' is {1}. Resolver took {2}ms to complete (thread {3})", component.Name, _state.GetModuleState(component), /*_resolverTimer[component].ElapsedMilliseconds*/0, Thread.CurrentThread.ManagedThreadId); }