public async Task GetTopLevelTypesAsync( Project project, Action <TypeImportCompletionItemInfo> handleItem, CancellationToken cancellationToken) { if (!project.SupportsCompilation) { throw new ArgumentException(nameof(project)); } var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); // Since we only need top level types from source, therefore we only care if source symbol checksum changes. var checksum = await SymbolTreeInfo.GetSourceSymbolsChecksumAsync(project, cancellationToken).ConfigureAwait(false); GetAccessibleTopLevelTypesWorker( project.Id, compilation.Assembly, checksum, handleItem, _projectItemsCache, cancellationToken); }
/// <summary> /// Force create all relevant indices /// </summary> public static Task PopulateIndicesAsync(Project?project, IImportCompletionCacheService <CacheEntry, object> cacheService, CancellationToken cancellationToken) { if (project is null) { return(Task.CompletedTask); } using var _ = ArrayBuilder <Task> .GetInstance(out var tasks); foreach (var relevantProject in GetAllRelevantProjects(project)) { tasks.Add(Task.Run(() => GetCacheEntryAsync(relevantProject, loadOnly: false, cacheService, cancellationToken), cancellationToken)); } foreach (var peReference in GetAllRelevantPeReferences(project)) { tasks.Add(Task.Run(() => SymbolTreeInfo.GetInfoForMetadataReferenceAsync(project.Solution, peReference, loadOnly: false, cancellationToken).AsTask(), cancellationToken)); } return(Task.WhenAll(tasks.ToImmutable())); }
private async Task UpdateSymbolTreeInfoAsync(Project project, CancellationToken cancellationToken) { if (project.Solution.Workspace.Kind != WorkspaceKind.RemoteWorkspace && project.Solution.Workspace.Options.GetOption(NavigateToOptions.OutOfProcessAllowed)) { // if GoTo feature is set to run on remote host, then we don't need to build inproc cache. // remote host will build this cache in remote host. return; } if (!project.SupportsCompilation) { return; } // Check the semantic version of this project. The semantic version will change // if any of the source files changed, or if the project version itself changed. // (The latter happens when something happens to the project like metadata // changing on disk). var version = await project.GetSemanticVersionAsync(cancellationToken).ConfigureAwait(false); if (!_projectToInfo.TryGetValue(project.Id, out var projectInfo) || projectInfo.VersionStamp != version) { var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); // Update the symbol tree infos for metadata and source in parallel. var referencesTask = UpdateReferencesAync(project, compilation, cancellationToken); var projectTask = SymbolTreeInfo.GetInfoForSourceAssemblyAsync(project, cancellationToken); await Task.WhenAll(referencesTask, projectTask).ConfigureAwait(false); // Mark that we're up to date with this project. Future calls with the same // semantic version can bail out immediately. projectInfo = new ProjectInfo(version, await projectTask.ConfigureAwait(false)); _projectToInfo.AddOrUpdate(project.Id, projectInfo, (_1, _2) => projectInfo); } }
public void GetTopLevelTypesFromPEReference( Solution solution, Compilation compilation, PortableExecutableReference peReference, SyntaxContext syntaxContext, Action <CompletionItem, bool> handleItem, CancellationToken cancellationToken) { var key = GetReferenceKey(peReference); if (key == null) { // Can't cache items for reference with null key. We don't want risk potential perf regression by // making those items repeatedly, so simply not returning anything from this assembly, until // we have a better understanding on this sceanrio. // TODO: Add telemetry return; } if (!(compilation.GetAssemblyOrModuleSymbol(peReference) is IAssemblySymbol assemblySymbol)) { return; } var checksum = SymbolTreeInfo.GetMetadataChecksum(solution, peReference, cancellationToken); GetAccessibleTopLevelTypesWorker( key, assemblySymbol, checksum, syntaxContext, handleItem, CacheService.PEItemsCache, cancellationToken); return;
public MetadataInfo(SymbolTreeInfo info, HashSet <ProjectId> referencingProjects) { SymbolTreeInfo = info; ReferencingProjects = referencingProjects; }
public MetadataInfo(SymbolTreeInfo info, HashSet <ProjectId> referencingProjects) { Contract.ThrowIfNull(info); SymbolTreeInfo = info; ReferencingProjects = referencingProjects; }
public MetadataInfo(DateTime timeStamp, SymbolTreeInfo info, HashSet <ProjectId> referencingProjects) { TimeStamp = timeStamp; SymbolTreeInfo = info; ReferencingProjects = referencingProjects; }
public ProjectInfo(VersionStamp versionStamp, SymbolTreeInfo info) { VersionStamp = versionStamp; SymbolTreeInfo = info; }