Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 95df8b5

Browse files
committed
Decouple document management in ProjectWorkspace from physical I/O.
Closes #78.
1 parent 95c04bc commit 95df8b5

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/language/tooling/Workspaces/ProjectWorkspace.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ public sealed class ProjectWorkspace : Workspace
88

99
public ProjectConfiguration Configuration { get; }
1010

11-
private readonly DirectoryInfo _sourceDirectory;
12-
1311
private readonly bool _disableAnalysis;
1412

1513
private ProjectWorkspace(
1614
string path, SourceTextProvider textProvider, ProjectConfiguration configuration, bool disableAnalysis)
1715
: base(path, textProvider)
1816
{
1917
Configuration = configuration;
20-
_sourceDirectory = new(System.IO.Path.Join(path, configuration.SourcePath));
2118
_disableAnalysis = disableAnalysis;
2219
}
2320

@@ -57,26 +54,13 @@ protected internal override IEnumerable<DiagnosticAnalyzer> GetDiagnosticAnalyze
5754

5855
protected override WorkspaceDocumentAttributes GetDocumentAttributes(string path)
5956
{
60-
var file = new FileInfo(System.IO.Path.Join(Path, path));
61-
var srcAttrs = _disableAnalysis
62-
? WorkspaceDocumentAttributes.DisableAnalyzers | WorkspaceDocumentAttributes.SuppressDiagnostics
57+
var attrs = path == WorkspaceDocument.EntryPointPath
58+
? WorkspaceDocumentAttributes.EntryPoint
6359
: WorkspaceDocumentAttributes.None;
6460

65-
if ((file.DirectoryName, file.Name) == (_sourceDirectory.FullName, WorkspaceDocument.EntryPointPath))
66-
return WorkspaceDocumentAttributes.EntryPoint | srcAttrs;
67-
68-
var current = file.Directory;
69-
70-
while (current != null)
71-
{
72-
// Is the document within the configured source directory?
73-
if (current.FullName == _sourceDirectory.FullName)
74-
return srcAttrs;
75-
76-
current = current.Parent;
77-
}
61+
if (_disableAnalysis || System.IO.Path.GetDirectoryName(path) != Configuration.SourcePath)
62+
attrs |= WorkspaceDocumentAttributes.DisableAnalyzers | WorkspaceDocumentAttributes.SuppressDiagnostics;
7863

79-
// It must be a loose document or a dependency document, so no analyzers and diagnostics.
80-
return WorkspaceDocumentAttributes.DisableAnalyzers | WorkspaceDocumentAttributes.SuppressDiagnostics;
64+
return attrs;
8165
}
8266
}

0 commit comments

Comments
 (0)