未验证 提交 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)
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(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
// 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,
/// 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.
/// </remarks>
private static Id<Graph.Document> GenerateForDocument(
private static Id<Graph.LsifDocument> GenerateForDocument(
SemanticModel semanticModel,
HostLanguageServices languageServices,
IResultSetTracker topLevelSymbolsResultSetTracker,
......@@ -86,7 +86,7 @@ public void GenerateForCompilation(Compilation compilation, string projectPath,
var syntaxFactsService = languageServices.GetRequiredService<ISyntaxFactsService>();
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(new Event(Event.EventKind.Begin, documentVertex.GetId(), idFactory));
......
......@@ -23,13 +23,13 @@ private Event(EventKind kind, string scope, Id<Element> data, IdFactory idFactor
this.Data = data;
}
public Event(EventKind kind, Id<Project> data, IdFactory idFactory)
: this(kind, "project", data.As<Project, Element>(), idFactory)
public Event(EventKind kind, Id<LsifProject> data, IdFactory idFactory)
: this(kind, "project", data.As<LsifProject, Element>(), idFactory)
{
}
public Event(EventKind kind, Id<Document> data, IdFactory idFactory)
: this(kind, "document", data.As<Document, Element>(), idFactory)
public Event(EventKind kind, Id<LsifDocument> data, IdFactory idFactory)
: this(kind, "document", data.As<LsifDocument, Element>(), idFactory)
{
}
......
......@@ -10,10 +10,10 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// </summary>
internal sealed class Item : Edge
{
public Id<Document> Document { get; }
public Id<LsifDocument> Document { 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)
{
Document = document;
......
......@@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// <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.
/// </summary>
internal sealed class Document : Vertex
internal sealed class LsifDocument : Vertex
{
public Uri Uri { 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)
{
this.Uri = uri;
......
......@@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph
/// <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.
/// </summary>
internal sealed class Project : Vertex
internal sealed class LsifProject : Vertex
{
public string Kind { 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)
{
Kind = kind;
......
......@@ -19,8 +19,8 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
</Project>
</Workspace>))
Dim projectVertex = Assert.Single(lsif.Vertices.OfType(Of Graph.Project))
Dim documentVertices = lsif.GetLinkedVertices(Of Graph.Document)(projectVertex, "contains")
Dim projectVertex = Assert.Single(lsif.Vertices.OfType(Of Graph.LsifProject))
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:\B.cs")
......
......@@ -162,11 +162,11 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
Continue For
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
' 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")
If lsif.GetLinkedVertices(Of Graph.ResultSet)(range, "next").Contains(resultSetVertex) Then
documents.Add(document)
......
......@@ -63,7 +63,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.U
For Each testDocument In _workspace.Documents
Dim documentVertex = _testLsifJsonWriter.Vertices _
.OfType(Of Graph.Document) _
.OfType(Of Graph.LsifDocument) _
.Where(Function(d) d.Uri.LocalPath = testDocument.FilePath) _
.Single()
Dim rangeVertices = GetLinkedVertices(Of Range)(documentVertex, "contains")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册