未验证 提交 127aa50f 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #46227 from CyrusNajmabadi/renameTypes

Rename types to not collide with the much more relevant Workspace equivalents
...@@ -28,11 +28,11 @@ public Generator(ILsifJsonWriter lsifJsonWriter) ...@@ -28,11 +28,11 @@ public Generator(ILsifJsonWriter lsifJsonWriter)
public void GenerateForCompilation(Compilation compilation, string projectPath, HostLanguageServices languageServices) public void GenerateForCompilation(Compilation compilation, string projectPath, HostLanguageServices languageServices)
{ {
var projectVertex = new Graph.Project(kind: GetLanguageKind(compilation.Language), new Uri(projectPath), _idFactory); var projectVertex = new Graph.LsifProject(kind: GetLanguageKind(compilation.Language), new Uri(projectPath), _idFactory);
_lsifJsonWriter.Write(projectVertex); _lsifJsonWriter.Write(projectVertex);
_lsifJsonWriter.Write(new Event(Event.EventKind.Begin, projectVertex.GetId(), _idFactory)); _lsifJsonWriter.Write(new Event(Event.EventKind.Begin, projectVertex.GetId(), _idFactory));
var documentIds = new ConcurrentBag<Id<Graph.Document>>(); var documentIds = new ConcurrentBag<Id<Graph.LsifDocument>>();
// We create a ResultSetTracker to track all top-level symbols in the project. We don't want all writes to immediately go to // We create a ResultSetTracker to track all top-level symbols in the project. We don't want all writes to immediately go to
// the JSON file -- we support parallel processing, so we'll accumulate them and then apply at once to avoid a lot // the JSON file -- we support parallel processing, so we'll accumulate them and then apply at once to avoid a lot
...@@ -74,7 +74,7 @@ public void GenerateForCompilation(Compilation compilation, string projectPath, ...@@ -74,7 +74,7 @@ public void GenerateForCompilation(Compilation compilation, string projectPath,
/// lets us link symbols across files, and will only talk about "top level" symbols that aren't things like locals that can't /// lets us link symbols across files, and will only talk about "top level" symbols that aren't things like locals that can't
/// leak outside a file. /// leak outside a file.
/// </remarks> /// </remarks>
private static Id<Graph.Document> GenerateForDocument( private static Id<Graph.LsifDocument> GenerateForDocument(
SemanticModel semanticModel, SemanticModel semanticModel,
HostLanguageServices languageServices, HostLanguageServices languageServices,
IResultSetTracker topLevelSymbolsResultSetTracker, IResultSetTracker topLevelSymbolsResultSetTracker,
...@@ -86,7 +86,7 @@ public void GenerateForCompilation(Compilation compilation, string projectPath, ...@@ -86,7 +86,7 @@ public void GenerateForCompilation(Compilation compilation, string projectPath,
var syntaxFactsService = languageServices.GetRequiredService<ISyntaxFactsService>(); var syntaxFactsService = languageServices.GetRequiredService<ISyntaxFactsService>();
var semanticFactsService = languageServices.GetRequiredService<ISemanticFactsService>(); var semanticFactsService = languageServices.GetRequiredService<ISemanticFactsService>();
var documentVertex = new Graph.Document(new Uri(syntaxTree.FilePath), GetLanguageKind(semanticModel.Language), idFactory); var documentVertex = new Graph.LsifDocument(new Uri(syntaxTree.FilePath), GetLanguageKind(semanticModel.Language), idFactory);
lsifJsonWriter.Write(documentVertex); lsifJsonWriter.Write(documentVertex);
lsifJsonWriter.Write(new Event(Event.EventKind.Begin, documentVertex.GetId(), idFactory)); lsifJsonWriter.Write(new Event(Event.EventKind.Begin, documentVertex.GetId(), idFactory));
......
...@@ -23,13 +23,13 @@ private Event(EventKind kind, string scope, Id<Element> data, IdFactory idFactor ...@@ -23,13 +23,13 @@ private Event(EventKind kind, string scope, Id<Element> data, IdFactory idFactor
this.Data = data; this.Data = data;
} }
public Event(EventKind kind, Id<Project> data, IdFactory idFactory) public Event(EventKind kind, Id<LsifProject> data, IdFactory idFactory)
: this(kind, "project", data.As<Project, Element>(), idFactory) : this(kind, "project", data.As<LsifProject, Element>(), idFactory)
{ {
} }
public Event(EventKind kind, Id<Document> data, IdFactory idFactory) public Event(EventKind kind, Id<LsifDocument> data, IdFactory idFactory)
: this(kind, "document", data.As<Document, Element>(), idFactory) : this(kind, "document", data.As<LsifDocument, Element>(), idFactory)
{ {
} }
......
...@@ -10,10 +10,10 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph ...@@ -10,10 +10,10 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// </summary> /// </summary>
internal sealed class Item : Edge internal sealed class Item : Edge
{ {
public Id<Document> Document { get; } public Id<LsifDocument> Document { get; }
public string? Property { get; } public string? Property { get; }
public Item(Id<Vertex> outVertex, Id<Range> range, Id<Document> document, IdFactory idFactory, string? property = null) public Item(Id<Vertex> outVertex, Id<Range> range, Id<LsifDocument> document, IdFactory idFactory, string? property = null)
: base(label: "item", outVertex, new[] { range.As<Range, Vertex>() }, idFactory) : base(label: "item", outVertex, new[] { range.As<Range, Vertex>() }, idFactory)
{ {
Document = document; Document = document;
......
...@@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph ...@@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// <summary> /// <summary>
/// Represents the document vertex that contains all the <see cref="Range"/>s. See https://github.com/Microsoft/language-server-protocol/blob/master/indexFormat/specification.md#ranges for examples. /// Represents the document vertex that contains all the <see cref="Range"/>s. See https://github.com/Microsoft/language-server-protocol/blob/master/indexFormat/specification.md#ranges for examples.
/// </summary> /// </summary>
internal sealed class Document : Vertex internal sealed class LsifDocument : Vertex
{ {
public Uri Uri { get; } public Uri Uri { get; }
public string LanguageId { get; } public string LanguageId { get; }
public Document(Uri uri, string languageId, IdFactory idFactory) public LsifDocument(Uri uri, string languageId, IdFactory idFactory)
: base(label: "document", idFactory) : base(label: "document", idFactory)
{ {
this.Uri = uri; this.Uri = uri;
......
...@@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph ...@@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// <summary> /// <summary>
/// Represents a top-level project. See https://github.com/Microsoft/language-server-protocol/blob/master/indexFormat/specification.md#the-project-vertex for further details. /// Represents a top-level project. See https://github.com/Microsoft/language-server-protocol/blob/master/indexFormat/specification.md#the-project-vertex for further details.
/// </summary> /// </summary>
internal sealed class Project : Vertex internal sealed class LsifProject : Vertex
{ {
public string Kind { get; } public string Kind { get; }
public Uri? Resource { get; } public Uri? Resource { get; }
public Project(string kind, Uri? resource, IdFactory idFactory) public LsifProject(string kind, Uri? resource, IdFactory idFactory)
: base(label: "project", idFactory) : base(label: "project", idFactory)
{ {
Kind = kind; Kind = kind;
......
...@@ -19,8 +19,8 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests ...@@ -19,8 +19,8 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
</Project> </Project>
</Workspace>)) </Workspace>))
Dim projectVertex = Assert.Single(lsif.Vertices.OfType(Of Graph.Project)) Dim projectVertex = Assert.Single(lsif.Vertices.OfType(Of Graph.LsifProject))
Dim documentVertices = lsif.GetLinkedVertices(Of Graph.Document)(projectVertex, "contains") Dim documentVertices = lsif.GetLinkedVertices(Of Graph.LsifDocument)(projectVertex, "contains")
Assert.Single(documentVertices, Function(d) d.Uri.LocalPath = "Z:\A.cs") Assert.Single(documentVertices, Function(d) d.Uri.LocalPath = "Z:\A.cs")
Assert.Single(documentVertices, Function(d) d.Uri.LocalPath = "Z:\B.cs") Assert.Single(documentVertices, Function(d) d.Uri.LocalPath = "Z:\B.cs")
......
...@@ -162,11 +162,11 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests ...@@ -162,11 +162,11 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
Continue For Continue For
End If End If
Dim documents As New HashSet(Of Graph.Document) Dim documents As New HashSet(Of Graph.LsifDocument)
' Let's now enumerate all the documents and ranges to see which documents contain a range that links to ' Let's now enumerate all the documents and ranges to see which documents contain a range that links to
' this resultSet ' this resultSet
For Each document In lsif.Vertices.OfType(Of Graph.Document) For Each document In lsif.Vertices.OfType(Of Graph.LsifDocument)
For Each range In lsif.GetLinkedVertices(Of Graph.Range)(document, "contains") For Each range In lsif.GetLinkedVertices(Of Graph.Range)(document, "contains")
If lsif.GetLinkedVertices(Of Graph.ResultSet)(range, "next").Contains(resultSetVertex) Then If lsif.GetLinkedVertices(Of Graph.ResultSet)(range, "next").Contains(resultSetVertex) Then
documents.Add(document) documents.Add(document)
......
...@@ -63,7 +63,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.U ...@@ -63,7 +63,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.U
For Each testDocument In _workspace.Documents For Each testDocument In _workspace.Documents
Dim documentVertex = _testLsifJsonWriter.Vertices _ Dim documentVertex = _testLsifJsonWriter.Vertices _
.OfType(Of Graph.Document) _ .OfType(Of Graph.LsifDocument) _
.Where(Function(d) d.Uri.LocalPath = testDocument.FilePath) _ .Where(Function(d) d.Uri.LocalPath = testDocument.FilePath) _
.Single() .Single()
Dim rangeVertices = GetLinkedVertices(Of Range)(documentVertex, "contains") Dim rangeVertices = GetLinkedVertices(Of Range)(documentVertex, "contains")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册