Skip to content
3 changes: 0 additions & 3 deletions src/EditorFeatures/Test2/Compilation/CompilationTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces

Namespace Microsoft.CodeAnalysis.Editor.Implementation.Compilation.UnitTests

<[UseExportProvider]>
Public Class CompilationTests
Private Shared Function GetProject(snapshot As Solution, assemblyName As String) As Project
Expand Down Expand Up @@ -36,9 +35,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Compilation.UnitTests

Assert.Null(Await project.GetCompilationAsync())
Assert.False(Await project.ContainsSymbolsWithNameAsync(Function(dummy) True, SymbolFilter.TypeAndMember, CancellationToken.None))
Assert.Empty(Await project.GetDocumentsWithNameAsync(Function(dummy) True, SymbolFilter.TypeAndMember, CancellationToken.None))
End Using
End Function
End Class

End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Dispose()
}

public int CreateEditorInstance(uint grfCreateDoc,
string pszMkDocument,
string filePath,
string pszPhysicalView,
IVsHierarchy pvHier,
uint itemid,
Expand All @@ -88,6 +88,12 @@ public int CreateEditorInstance(uint grfCreateDoc,
return VSConstants.VS_E_UNSUPPORTEDFORMAT;
}

if (!_workspace.CurrentSolution.Projects.Any(p => p.AnalyzerConfigDocuments.Any(editorconfig => StringComparer.OrdinalIgnoreCase.Equals(editorconfig.FilePath, filePath))))
{
// If the user is simply opening an editorconfig file that does not apply to the current solution we just want to show the text view
return VSConstants.VS_E_UNSUPPORTEDFORMAT;
}

// Validate inputs
if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
{
Expand Down Expand Up @@ -138,7 +144,7 @@ public int CreateEditorInstance(uint grfCreateDoc,
_settingsDataProviderFactory,
_controlProvider,
_tableMangerProvider,
pszMkDocument,
filePath,
textBuffer,
_workspace);
ppunkDocView = Marshal.GetIUnknownForObject(newEditor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using System;
using System.ComponentModel.Design;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings;
using Microsoft.CodeAnalysis.Editor.EditorConfigSettings.Data;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host;
using Microsoft.Internal.VisualStudio.PlatformUI;
using Microsoft.Internal.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Editor;
Expand Down Expand Up @@ -94,6 +96,19 @@ protected override void Initialize()
}
}

var statusService = _workspace.Services.GetService<IWorkspaceStatusService>();
if (statusService is not null)
{
// This will show the 'Waiting for Intellisense to initalize' message until the workspace is loaded.
_threadingContext.JoinableTaskFactory.Run(async () =>
{
if (!await statusService.IsFullyLoadedAsync(CancellationToken.None).ConfigureAwait(false))
{
await statusService.WaitUntilFullyLoadedAsync(CancellationToken.None).ConfigureAwait(false);
}
});
}

// hook up our panel
_control = new SettingsEditorControl(
GetWhitespaceView(),
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions src/Workspaces/Core/Portable/Workspace/Solution/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ internal async Task<bool> ContainsSymbolsWithNameAsync(Func<string, bool> predic
await _solution.State.ContainsSymbolsWithNameAsync(Id, predicate, filter, cancellationToken).ConfigureAwait(false);
}

internal async Task<IEnumerable<Document>> GetDocumentsWithNameAsync(Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken)
=> (await _solution.State.GetDocumentsWithNameAsync(Id, predicate, filter, cancellationToken).ConfigureAwait(false)).Select(s => _solution.GetDocument(s.Id)!);

private static readonly Func<DocumentId, Project, Document?> s_tryCreateDocumentFunction =
(documentId, project) => project._projectState.DocumentStates.TryGetState(documentId, out var state) ? new Document(project, state) : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,24 +1093,6 @@ private async Task<MetadataReference> GetMetadataOnlyImageReferenceAsync(
: state.DeclarationOnlyCompilation.ContainsSymbolsWithName(predicate, filter, cancellationToken);
}

/// <summary>
/// get all syntax trees that contain declaration node with the given name
/// </summary>
public IEnumerable<SyntaxTree>? GetSyntaxTreesWithNameFromDeclarationOnlyCompilation(Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken)
{
var state = this.ReadState();
if (state.DeclarationOnlyCompilation == null)
{
return null;
}

// DO NOT expose declaration only compilation to outside since it can be held alive long time, we don't want to create any symbol from the declaration only compilation.

// use cloned compilation since this will cause symbols to be created.
var clone = state.DeclarationOnlyCompilation.Clone();
return clone.GetSymbolsWithName(predicate, filter, cancellationToken).SelectMany(s => s.DeclaringSyntaxReferences.Select(r => r.SyntaxTree));
}

public Task<bool> HasSuccessfullyLoadedAsync(SolutionState solution, CancellationToken cancellationToken)
{
var state = this.ReadState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ public async ValueTask<TextDocumentStates<SourceGeneratedDocumentState>> GetSour
}
}

public IEnumerable<SyntaxTree>? GetSyntaxTreesWithNameFromDeclarationOnlyCompilation(Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken)
{
return _underlyingTracker.GetSyntaxTreesWithNameFromDeclarationOnlyCompilation(predicate, filter, cancellationToken);
}

public Task<bool> HasSuccessfullyLoadedAsync(SolutionState solution, CancellationToken cancellationToken)
{
return _underlyingTracker.HasSuccessfullyLoadedAsync(solution, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ private interface ICompilationTracker
Task<MetadataReference> GetMetadataReferenceAsync(SolutionState solution, ProjectState fromProject, ProjectReference projectReference, CancellationToken cancellationToken);
CompilationReference? GetPartialMetadataReference(ProjectState fromProject, ProjectReference projectReference);
ValueTask<TextDocumentStates<SourceGeneratedDocumentState>> GetSourceGeneratedDocumentStatesAsync(SolutionState solution, CancellationToken cancellationToken);
IEnumerable<SyntaxTree>? GetSyntaxTreesWithNameFromDeclarationOnlyCompilation(Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken);
Task<bool> HasSuccessfullyLoadedAsync(SolutionState solution, CancellationToken cancellationToken);
bool TryGetCompilation([NotNullWhen(true)] out Compilation? compilation);
SourceGeneratedDocumentState? TryGetSourceGeneratedDocumentStateForAlreadyGeneratedId(DocumentId documentId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1976,46 +1976,6 @@ public async Task<bool> ContainsSymbolsWithNameAsync(ProjectId id, Func<string,
return compilation.ContainsSymbolsWithName(predicate, filter, cancellationToken);
}

public async Task<ImmutableArray<DocumentState>> GetDocumentsWithNameAsync(
ProjectId id, Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken)
{
// this will be used to find documents that contain declaration information in IDE cache such as DeclarationSyntaxTreeInfo for "NavigateTo"
var trees = GetCompilationTracker(id).GetSyntaxTreesWithNameFromDeclarationOnlyCompilation(predicate, filter, cancellationToken);
if (trees != null)
{
return ConvertTreesToDocuments(id, trees);
}

// it looks like declaration compilation doesn't exist yet. we have to build full compilation
var compilation = await GetCompilationAsync(id, cancellationToken).ConfigureAwait(false);
if (compilation == null)
{
// some projects don't support compilations (e.g., TypeScript) so there's nothing to check
return ImmutableArray<DocumentState>.Empty;
}

return ConvertTreesToDocuments(
id, compilation.GetSymbolsWithName(predicate, filter, cancellationToken).SelectMany(s => s.DeclaringSyntaxReferences.Select(r => r.SyntaxTree)));
}

private ImmutableArray<DocumentState> ConvertTreesToDocuments(ProjectId id, IEnumerable<SyntaxTree> trees)
{
var result = ArrayBuilder<DocumentState>.GetInstance();
foreach (var tree in trees)
{
var document = GetDocumentState(tree, id);
if (document == null)
{
// ignore trees that are not known to solution such as VB synthesized trees made by compilation.
continue;
}

result.Add(document);
}

return result.ToImmutableAndFree();
}

/// <summary>
/// Gets a <see cref="ProjectDependencyGraph"/> that details the dependencies between projects for this solution.
/// </summary>
Expand Down