public SetModuleState ( |
||
state | ||
return | void |
private void ProcessComponentParseResults(QualifiedModuleName module, Task <ComponentParseTask.ParseCompletionArgs> finishedParseTask, CancellationToken token) { if (finishedParseTask.IsFaulted) { //In contrast to the situation in the success scenario, the overall parser state is reevaluated immediately. //This sets the state directly on the state because it is the sole instance where we have to pass the potential SyntaxErorException. _state.SetModuleState(module, ParserState.Error, token, finishedParseTask.Exception?.InnerException as SyntaxErrorException); } else { var result = finishedParseTask.Result; lock (_state) { token.ThrowIfCancellationRequested(); //This has to come first because it creates the module state if not present. _state.SetModuleAttributes(module, result.Attributes); _state.AddTokenStream(module, result.Tokens); _state.AddParseTree(module, result.ParseTree); _state.AddParseTree(module, result.AttributesTree, ParsePass.AttributesPass); _state.SetModuleComments(module, result.Comments); _state.SetModuleAnnotations(module, result.Annotations); _state.AddAttributesRewriter(module, result.AttributesRewriter); // This really needs to go last //It does not reevaluate the overall parer state to avoid concurrent evaluation of all module states and for performance reasons. //The evaluation has to be triggered manually in the calling procedure. StateManager.SetModuleState(module, ParserState.Parsed, token, false); //Note that this is ok because locks allow re-entrancy. } } }
/// <summary> /// For the use of tests only /// </summary> public void Parse() { if (_state.Projects.Count == 0) { foreach (var project in _vbe.VBProjects.UnprotectedProjects()) { _state.AddProject(project); } } var components = new List <VBComponent>(); foreach (var project in _state.Projects) { foreach (VBComponent component in project.VBComponents) { components.Add(component); } } SyncComReferences(_state.Projects); foreach (var component in components) { _state.SetModuleState(component, ParserState.Pending); } // invalidation cleanup should go into ParseAsync? foreach (var key in _componentAttributes.Keys) { if (!components.Contains(key)) { _componentAttributes.Remove(key); } } var parseTasks = new Task[components.Count]; for (var i = 0; i < components.Count; i++) { parseTasks[i] = ParseAsync(components[i], CancellationToken.None); } Task.WaitAll(parseTasks); if (_state.Status != ParserState.Error) { Logger.Trace("Starting resolver task"); Resolve(_central.Token); // Tests expect this to be synchronous } }
public void SetModuleState(QualifiedModuleName module, ParserState parserState, CancellationToken token, bool evaluateOverallParserState = true) { _state.SetModuleState(module, parserState, token, null, evaluateOverallParserState); }