private void SaveModuleParseResultsOnState(QualifiedModuleName module, ModuleParseResults results, CancellationToken token) { lock (_state) { token.ThrowIfCancellationRequested(); //This has to come first because it creates the module state if not present. _state.AddModuleStateIfNotPresent(module); _state.SaveContentHash(module); _state.AddParseTree(module, results.CodePaneParseTree); _state.AddParseTree(module, results.AttributesParseTree, CodeKind.AttributesCode); _state.SetModuleComments(module, results.Comments); _state.SetModuleAnnotations(module, results.Annotations); _state.SetModuleAttributes(module, results.Attributes); _state.SetMembersAllowingAttributes(module, results.MembersAllowingAttributes); _state.SetCodePaneTokenStream(module, results.CodePaneTokenStream); _state.SetAttributesTokenStream(module, results.AttributesTokenStream); // 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. } }