protected void ResolveDeclarations(QualifiedModuleName module, IParseTree tree, IDictionary <string, ProjectDeclaration> projects, CancellationToken token) { var stopwatch = Stopwatch.StartNew(); try { if (!projects.TryGetValue(module.ProjectId, out var projectDeclaration)) { Logger.Error($"Tried to add module {module} with projectId {module.ProjectId} for which no project declaration exists."); } Logger.Debug($"Creating declarations for module {module.Name}."); var annotationsOnWhiteSpaceLines = _state.GetAnnotations(module) .Where(a => a.AnnotatedLine.HasValue) .GroupBy(a => a.AnnotatedLine.Value) .ToDictionary(); var attributes = _state.GetModuleAttributes(module); var membersAllowingAttributes = _state.GetMembersAllowingAttributes(module); var moduleDeclaration = NewModuleDeclaration(module, tree, annotationsOnWhiteSpaceLines, attributes, projectDeclaration); _state.AddDeclaration(moduleDeclaration); var controlDeclarations = DeclarationsFromControls(moduleDeclaration); foreach (var declaration in controlDeclarations) { _state.AddDeclaration(declaration); } var declarationsListener = new DeclarationSymbolsListener(moduleDeclaration, annotationsOnWhiteSpaceLines, attributes, membersAllowingAttributes); ParseTreeWalker.Default.Walk(declarationsListener, tree); foreach (var createdDeclaration in declarationsListener.CreatedDeclarations) { _state.AddDeclaration(createdDeclaration); } } catch (Exception exception) { Logger.Error(exception, $"Exception thrown acquiring declarations for '{module.Name}' (thread {Thread.CurrentThread.ManagedThreadId})."); _parserStateManager.SetModuleState(module, ParserState.ResolverError, token); } stopwatch.Stop(); Logger.Debug($"{stopwatch.ElapsedMilliseconds}ms to resolve declarations for component {module.Name}"); }