Skip to content

Commit

Permalink
Merge pull request #46227 from CyrusNajmabadi/renameTypes
Browse files Browse the repository at this point in the history
Rename types to not collide with the much more relevant Workspace equivalents
  • Loading branch information
msftbot[bot] authored Jul 22, 2020
2 parents d5fafa1 + 26ca10b commit 127aa50
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/Features/Lsif/Generator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions src/Features/Lsif/Generator/Graph/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Features/Lsif/Generator/Graph/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Features/Lsif/GeneratorTest/ProjectStructureTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/Features/Lsif/GeneratorTest/RangeResultSetTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 127aa50

Please sign in to comment.