public void ResolveReferences(IReadOnlyCollection <QualifiedModuleName> toResolve, CancellationToken token) { token.ThrowIfCancellationRequested(); _toResolve.UnionWith(toResolve); token.ThrowIfCancellationRequested(); if (!_toResolve.Any()) { return; } PerformPreResolveCleanup(_toResolve.AsReadOnly(), token); token.ThrowIfCancellationRequested(); var parsingStageTimer = ParsingStageTimer.StartNew(); ExecuteCompilationPasses(_toResolve.AsReadOnly(), token); token.ThrowIfCancellationRequested(); parsingStageTimer.Stop(); parsingStageTimer.Log("Executed compilation passes in {0}ms."); parsingStageTimer.Restart(); AddSupertypesForDocumentModules(_toResolve.AsReadOnly(), _state); token.ThrowIfCancellationRequested(); parsingStageTimer.Stop(); parsingStageTimer.Log("Added supertypes for document modules in {0}ms."); var parseTreesToResolve = _state.ParseTrees.Where(kvp => _toResolve.Contains(kvp.Key)).ToList(); token.ThrowIfCancellationRequested(); parsingStageTimer.Restart(); ResolveReferences(parseTreesToResolve, token); token.ThrowIfCancellationRequested(); parsingStageTimer.Stop(); parsingStageTimer.Log("Resolved references in {0}ms."); parsingStageTimer.Restart(); AddModuleToModuleReferences(_state.DeclarationFinder, token); token.ThrowIfCancellationRequested(); parsingStageTimer.Stop(); parsingStageTimer.Log("Determined module to module references in {0}ms."); parsingStageTimer.Restart(); AddNewUndeclaredVariablesToDeclarations(); AddNewUnresolvedMemberDeclarations(); _toResolve.Clear(); }
public void ParseModules(IReadOnlyCollection <QualifiedModuleName> modules, CancellationToken token) { var parsingStageTimer = ParsingStageTimer.StartNew(); var parseResults = ModuleParseResults(modules, token); SaveModuleParseResultsOnState(parseResults, token); parsingStageTimer.Stop(); parsingStageTimer.Log("Parsed user modules in {0}ms."); }
public void RefreshUserComProjects(IReadOnlyCollection <string> projectIdsToReload) { var parsingStageTimer = ParsingStageTimer.StartNew(); RemoveNoLongerExistingProjects(); RemoveProjects(projectIdsToReload); var loadTask = _uiDispatcher.StartTask(() => { AddUnprotectedUserProjects(projectIdsToReload); AddLockedProjects(); }); loadTask.Wait(); parsingStageTimer.Stop(); parsingStageTimer.Log("Loaded ComProjects for user projects in {0}ms."); }
public void SyncUserComProjects() { var parsingStateTimer = ParsingStageTimer.StartNew(); _lastSyncLoadedDeclaration = false; _unloadedProjectIds.Clear(); var projectIdsToBeLoaded = _projectsToResolveFromComProjectSelector.ProjectsToResolveFromComProjects; var newProjectIdsToBeLoaded = projectIdsToBeLoaded.Where(projectId => !_currentlyLoadedProjectIds.Contains(projectId)).ToList(); var projectsToBeUnloaded = _currentlyLoadedProjectIds.Where(projectId => !projectIdsToBeLoaded.Contains(projectId)).ToList(); LoadProjects(newProjectIdsToBeLoaded); UnloadProjects(projectsToBeUnloaded); parsingStateTimer.Stop(); parsingStateTimer.Log("Loaded declarations from ComProjects for user projects in {0}ms."); }
protected override void ResolveDeclarations(IReadOnlyCollection <QualifiedModuleName> modules, IDictionary <string, ProjectDeclaration> projects, CancellationToken token) { if (!modules.Any()) { return; } var parsingStageTimer = ParsingStageTimer.StartNew(); token.ThrowIfCancellationRequested(); var options = new ParallelOptions(); options.CancellationToken = token; options.MaxDegreeOfParallelism = _maxDegreeOfDeclarationResolverParallelism; try { Parallel.ForEach(modules, options, module => { ResolveDeclarations(module, _state.ParseTrees.Find(s => s.Key == module).Value, projects, token); } ); } catch (AggregateException exception) { if (exception.Flatten().InnerExceptions.All(ex => ex is OperationCanceledException)) { //This rethrows the exception with the original stack trace. ExceptionDispatchInfo.Capture(exception.InnerException ?? exception).Throw(); } _parserStateManager.SetStatusAndFireStateChanged(this, ParserState.ResolverError, token); throw; } parsingStageTimer.Stop(); parsingStageTimer.Log("Resolved user declaration in {0}ms."); }
public override void ResolveDeclarations(IReadOnlyCollection <QualifiedModuleName> modules, CancellationToken token) { if (!modules.Any()) { return; } var parsingStageTimer = ParsingStageTimer.StartNew(); _projectDeclarations.Clear(); token.ThrowIfCancellationRequested(); var options = new ParallelOptions(); options.CancellationToken = token; options.MaxDegreeOfParallelism = _maxDegreeOfDeclarationResolverParallelism; try { Parallel.ForEach(modules, options, module => { ResolveDeclarations(module, _state.ParseTrees.Find(s => s.Key == module).Value, token); } ); } catch (AggregateException exception) { if (exception.Flatten().InnerExceptions.All(ex => ex is OperationCanceledException)) { throw exception.InnerException ?? exception; //This eliminates the stack trace, but for the cancellation, this is irrelevant. } _parserStateManager.SetStatusAndFireStateChanged(this, ParserState.ResolverError, token); throw; } parsingStageTimer.Stop(); parsingStageTimer.Log("Resolved user declaration in {0}ms."); }