Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-vs-deps' into merges/rele…
Browse files Browse the repository at this point in the history
…ase/dev16.7-preview2-vs-deps-to-master-vs-deps
  • Loading branch information
JoeRobich committed May 19, 2020
2 parents 75674ed + c8d525c commit 17e815b
Show file tree
Hide file tree
Showing 38 changed files with 389 additions and 134 deletions.
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MajorVersion>3</MajorVersion>
<MinorVersion>7</MinorVersion>
<PatchVersion>0</PatchVersion>
<PreReleaseVersionLabel>2</PreReleaseVersionLabel>
<PreReleaseVersionLabel>3</PreReleaseVersionLabel>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<!--
By default the assembly version in official builds is "$(MajorVersion).$(MinorVersion).0.0".
Expand All @@ -33,7 +33,7 @@
<CodeStyleAnalyzerVersion>3.7.0-1.20210.7</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>16.4.248</VisualStudioEditorPackagesVersion>
<ILToolsPackageVersion>5.0.0-alpha1.19409.1</ILToolsPackageVersion>
<MicrosoftVisualStudioLanguageServerPackagesVersion>16.7.12-g74a1f6f85d</MicrosoftVisualStudioLanguageServerPackagesVersion>
<MicrosoftVisualStudioLanguageServerPackagesVersion>16.7.29</MicrosoftVisualStudioLanguageServerPackagesVersion>
</PropertyGroup>
<!--
Dependency versions
Expand Down
8 changes: 4 additions & 4 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@
"vsBranch": "rel/d16.6",
"vsMajorVersion": 16
},
"release/dev16.7-preview1-vs-deps": {
"release/dev16.7-preview2-vs-deps": {
"nugetKind": ["Shipping", "NonShipping"],
"version": "3.7.*",
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dev16.7", "dev16.7p1" ],
"vsBranch": "rel/d16.7",
"channels": [ "dev16.7", "dev16.7p2" ],
"vsBranch": "master",
"vsMajorVersion": 16
},
"master-vs-deps": {
"nugetKind": ["Shipping", "NonShipping"],
"version": "3.7.*",
"nuget": [ "https://dotnet.myget.org/F/roslyn/api/v2/package" ],
"vsix": [ "https://dotnet.myget.org/F/roslyn/vsix/upload" ],
"channels": [ "dev16.7", "dev16.7p2" ],
"channels": [ "dev16.7", "dev16.7p3" ],
"vsBranch": "master",
"vsMajorVersion": 16
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public static void Method<TClass>(Func<TClass, Func<string, string>> method) { }
comp.VerifyDiagnostics();
}

[Fact, WorkItem(35949, "https://github.com/dotnet/roslyn/issues/35949")]
[WorkItem(35949, "https://github.com/dotnet/roslyn/issues/35949")]
[ConditionalFact(typeof(IsRelease))]
public void NotNull_Complexity()
{
var source = @"
Expand Down
65 changes: 0 additions & 65 deletions src/Compilers/CSharp/Test/Semantic/Semantics/SlowTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,23 @@ protected static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind ki
ContainerName = containerName
};

protected static LSP.TextDocumentIdentifier CreateTextDocumentIdentifier(Uri uri)
=> new LSP.TextDocumentIdentifier()
protected static LSP.TextDocumentIdentifier CreateTextDocumentIdentifier(Uri uri, ProjectId projectContext = null)
{
var documentIdentifier = new LSP.VSTextDocumentIdentifier() { Uri = uri };

if (projectContext != null)
{
Uri = uri
};
documentIdentifier.ProjectContext =
new LSP.ProjectContext { Id = ProtocolConversions.ProjectIdToProjectContextId(projectContext) };
}

protected static LSP.TextDocumentPositionParams CreateTextDocumentPositionParams(LSP.Location caret)
return documentIdentifier;
}

protected static LSP.TextDocumentPositionParams CreateTextDocumentPositionParams(LSP.Location caret, ProjectId projectContext = null)
=> new LSP.TextDocumentPositionParams()
{
TextDocument = CreateTextDocumentIdentifier(caret.Uri),
TextDocument = CreateTextDocumentIdentifier(caret.Uri, projectContext),
Position = caret.Range.Start
};

Expand Down Expand Up @@ -203,7 +210,7 @@ protected Workspace CreateTestWorkspace(string[] markups, out Dictionary<string,
return workspace;
}

protected Workspace CreateXmlTestWorkspace(string xmlContent, out Dictionary<string, IList<LSP.Location>> locations)
protected TestWorkspace CreateXmlTestWorkspace(string xmlContent, out Dictionary<string, IList<LSP.Location>> locations)
{
var workspace = TestWorkspace.Create(xmlContent, exportProvider: GetExportProvider());
locations = GetAnnotatedLocations(workspace, workspace.CurrentSolution);
Expand Down
61 changes: 51 additions & 10 deletions src/Features/LanguageServer/Protocol/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#nullable enable

using System;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.FindUsages;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Text.Adornments;
Expand All @@ -23,31 +25,70 @@ public static Uri GetURI(this Document document)
return ProtocolConversions.GetUriFromFilePath(document.FilePath);
}

public static Document? GetDocumentFromURI(this Solution solution, Uri fileName, string? clientName = null)
public static ImmutableArray<Document> GetDocuments(this Solution solution, Uri uri, string? clientName = null)
{
// TODO: we need to normalize this. but for now, we check both absolute and local path
// right now, based on who calls this, solution might has "/" or "\\" as directory
// separator
var documentId = solution.GetDocumentIdsWithFilePath(fileName.AbsolutePath).FirstOrDefault() ??
solution.GetDocumentIdsWithFilePath(fileName.LocalPath).FirstOrDefault();
var documentIds = solution.GetDocumentIdsWithFilePath(uri.AbsolutePath);

var document = solution.GetDocument(documentId);
if (!documentIds.Any())
{
documentIds = solution.GetDocumentIdsWithFilePath(uri.LocalPath);
}

var documents = documentIds.SelectAsArray(id => solution.GetRequiredDocument(id));

if (clientName != null)
// If we don't have a client name, then we're done filtering
if (clientName == null)
{
var documentPropertiesService = document?.Services.GetService<DocumentPropertiesService>();
return documents;
}

// We have a client name, so we need to filter to only documents that match that name
return documents.WhereAsArray(document =>
{
var documentPropertiesService = document.Services.GetService<DocumentPropertiesService>();
// When a client name is specified, only return documents that have a matching client name.
// Allows the razor lsp server to return results only for razor documents.
// This workaround should be removed when https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1106064/
// is fixed (so that the razor language server is only asked about razor buffers).
if (!Equals(documentPropertiesService?.DiagnosticsLspClientName, clientName))
return Equals(documentPropertiesService?.DiagnosticsLspClientName, clientName);
});
}

public static Document? GetDocument(this Solution solution, TextDocumentIdentifier documentIdentifier, string? clientName = null)
{
var documents = solution.GetDocuments(documentIdentifier.Uri, clientName);

if (documents.Length == 0)
{
return null;
}

if (documents.Length > 1)
{
// We have more than one document; try to find the one that matches the right context
if (documentIdentifier is VSTextDocumentIdentifier vsDocumentIdentifier)
{
return null;
if (vsDocumentIdentifier.ProjectContext != null)
{
var projectId = ProtocolConversions.ProjectContextToProjectId(vsDocumentIdentifier.ProjectContext);
var matchingDocument = documents.FirstOrDefault(d => d.Project.Id == projectId);

if (matchingDocument != null)
{
return matchingDocument;
}
}
}
}

return document;

// We either have only one document or have multiple, but none of them matched our context. In the
// latter case, we'll just return the first one arbitrarily since this might just be some temporary mis-sync
// of client and server state.
return documents[0];
}

public static async Task<int> GetPositionFromLinePositionAsync(this Document document, LinePosition linePosition, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.NavigateTo;
using Microsoft.CodeAnalysis.Tags;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Text.Adornments;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;
Expand Down Expand Up @@ -443,5 +444,19 @@ public static LSP.ReferenceKind[] SymbolUsageInfoToReferenceKinds(SymbolUsageInf

return referenceKinds.ToArrayAndFree();
}

public static string ProjectIdToProjectContextId(ProjectId id)
{
return id.Id + "|" + id.DebugName;
}

public static ProjectId ProjectContextToProjectId(ProjectContext projectContext)
{
int delimiter = projectContext.Id.IndexOf('|');

return ProjectId.CreateFromSerialized(
Guid.Parse(projectContext.Id.Substring(0, delimiter)),
debugName: projectContext.Id.Substring(delimiter + 1));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CodeActionsHandler(ICodeFixService codeFixService, ICodeRefactoringServic
LSP.ClientCapabilities clientCapabilities, string? clientName, CancellationToken cancellationToken)
{
var codeActions = await GetCodeActionsAsync(solution,
request.TextDocument.Uri,
request.TextDocument,
request.Range,
clientName, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public CodeActionsHandlerBase(ICodeFixService codeFixService, ICodeRefactoringSe
_codeRefactoringService = codeRefactoringService ?? throw new ArgumentNullException(nameof(codeRefactoringService));
}

public async Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Solution solution, Uri documentUri, LSP.Range selection, string? clientName, CancellationToken cancellationToken)
public async Task<IEnumerable<CodeAction>> GetCodeActionsAsync(Solution solution, LSP.TextDocumentIdentifier documentIdentifier, LSP.Range selection, string? clientName, CancellationToken cancellationToken)
{
var document = solution.GetDocumentFromURI(documentUri, clientName);
var document = solution.GetDocument(documentIdentifier, clientName);
if (document == null)
{
return ImmutableArray<CodeAction>.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CompletionHandler()
public async Task<LSP.CompletionItem[]> HandleRequestAsync(Solution solution, LSP.CompletionParams request, LSP.ClientCapabilities clientCapabilities,
string? clientName, CancellationToken cancellationToken)
{
var document = solution.GetDocumentFromURI(request.TextDocument.Uri, clientName);
var document = solution.GetDocument(request.TextDocument, clientName);
if (document == null)
{
return Array.Empty<LSP.CompletionItem>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public CompletionResolveHandler()

var request = data.CompletionParams;

var document = solution.GetDocumentFromURI(request.TextDocument.Uri, clientName);
var document = solution.GetDocument(request.TextDocument, clientName);
if (document == null)
{
return completionItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public GoToDefinitionHandlerBase(IMetadataAsSourceFileService metadataAsSourceFi
{
var locations = ArrayBuilder<LSP.Location>.GetInstance();

var document = solution.GetDocumentFromURI(request.TextDocument.Uri, clientName);
var document = solution.GetDocument(request.TextDocument, clientName);
if (document == null)
{
return locations.ToArrayAndFree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<FoldingRange[]> HandleRequestAsync(Solution solution, FoldingR
{
var foldingRanges = ArrayBuilder<FoldingRange>.GetInstance();

var document = solution.GetDocumentFromURI(request.TextDocument.Uri, clientName);
var document = solution.GetDocument(request.TextDocument, clientName);
if (document == null)
{
return foldingRanges.ToArrayAndFree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public FormatDocumentHandler()
public async Task<LSP.TextEdit[]> HandleRequestAsync(Solution solution, LSP.DocumentFormattingParams request, LSP.ClientCapabilities clientCapabilities,
string? clientName, CancellationToken cancellationToken)
{
return await GetTextEditsAsync(solution, request.TextDocument.Uri, clientName, cancellationToken).ConfigureAwait(false);
return await GetTextEditsAsync(solution, request.TextDocument, clientName, cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand All @@ -18,10 +17,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
{
internal abstract class FormatDocumentHandlerBase
{
protected async Task<LSP.TextEdit[]> GetTextEditsAsync(Solution solution, Uri documentUri, string? clientName, CancellationToken cancellationToken, LSP.Range? range = null)
protected async Task<LSP.TextEdit[]> GetTextEditsAsync(Solution solution, LSP.TextDocumentIdentifier documentIdentifier, string? clientName, CancellationToken cancellationToken, LSP.Range? range = null)
{
var edits = new ArrayBuilder<LSP.TextEdit>();
var document = solution.GetDocumentFromURI(documentUri, clientName);
var document = solution.GetDocument(documentIdentifier, clientName);

if (document != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task<TextEdit[]> HandleRequestAsync(Solution solution, DocumentOnTy
string? clientName, CancellationToken cancellationToken)
{
var edits = new ArrayBuilder<TextEdit>();
var document = solution.GetDocumentFromURI(request.TextDocument.Uri, clientName);
var document = solution.GetDocument(request.TextDocument, clientName);
if (document != null)
{
var formattingService = document.Project.LanguageServices.GetRequiredService<IEditorFormattingService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public FormatDocumentRangeHandler()
public async Task<TextEdit[]> HandleRequestAsync(Solution solution, DocumentRangeFormattingParams request, ClientCapabilities clientCapabilities,
string? clientName, CancellationToken cancellationToken)
{
return await GetTextEditsAsync(solution, request.TextDocument.Uri, clientName, cancellationToken, range: request.Range).ConfigureAwait(false);
return await GetTextEditsAsync(solution, request.TextDocument, clientName, cancellationToken, range: request.Range).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DocumentHighlightsHandler()
public async Task<DocumentHighlight[]> HandleRequestAsync(Solution solution, TextDocumentPositionParams request,
ClientCapabilities clientCapabilities, string? clientName, CancellationToken cancellationToken)
{
var document = solution.GetDocumentFromURI(request.TextDocument.Uri, clientName);
var document = solution.GetDocument(request.TextDocument, clientName);
if (document == null)
{
return Array.Empty<DocumentHighlight>();
Expand Down
Loading

0 comments on commit 17e815b

Please sign in to comment.