Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to main-vs-deps #54452

Merged
merged 26 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ea41f07
Check the experiment service
Cosifne Jun 24, 2021
87735a2
Add telemtry to count time
Cosifne Jun 24, 2021
5c00bcd
Change the trace level to information
Cosifne Jun 24, 2021
39f4e23
Remove unused using
Cosifne Jun 24, 2021
9a7ddac
Expose completion options to IntelliCode
sharwell Jun 25, 2021
c4ec845
Define IIntelliCodeArgumentDefaultsSource for IntelliCode integration…
sharwell Jun 25, 2021
5cb76b7
Use binding instead of tri state check box
Cosifne Jun 25, 2021
41734a7
Query IDocumentTrackingService for active document when we are not
dibarbet Jun 24, 2021
ee53ed3
Avoid costly calls to GetAllStateSets inside ContainsDiagnostics
sharwell Jun 25, 2021
a935a8d
Clean code
Cosifne Jun 25, 2021
5605038
Switch to correct workspace api to get active context
dibarbet Jun 26, 2021
59140f9
Insertion depends on DARC publishing (#54420)
RikkiGibson Jun 27, 2021
41b2da7
Set AutoComplete based on CreateDraftPR
RikkiGibson Jun 28, 2021
c5bbdd9
Merge pull request #54428 from RikkiGibson/insert-later-backport
RikkiGibson Jun 28, 2021
4dd5744
Merge branch 'main' into dev/shech/InheritanceMarginExperiment
Cosifne Jun 28, 2021
695b279
Fix window missing title. Move string to resources
ryzngard Jun 28, 2021
21a4b69
Move string to resources
ryzngard Jun 28, 2021
b24e9ad
Merge pull request #54397 from dibarbet/active_context_16
dibarbet Jun 28, 2021
fdd54dd
Merge pull request #54371 from Cosifne/dev/shech/InheritanceMarginExp…
Cosifne Jun 28, 2021
fa2d408
Merge pull request #54449 from ryzngard/issues/vt_fixes
ryzngard Jun 28, 2021
3844415
Merge pull request #54453 from davidwengier/FixBuild
davidwengier Jun 28, 2021
2458e17
Merge pull request #54444 from dotnet/merges/release/dev16.11-to-main
Jun 28, 2021
88dd36f
Merge remote-tracking branch 'upstream/main-vs-deps' into merges/main…
ryzngard Jun 29, 2021
1902e7a
Merge pull request #54380 from sharwell/pythia-features
sharwell Jun 29, 2021
d12580c
Merge pull request #54401 from sharwell/faster-state-sets
sharwell Jun 29, 2021
446caeb
Merge branch 'main' of github.com:dotnet/roslyn into merges/main-to-m…
RikkiGibson Jun 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,15 @@ stages:
Write-Host "##vso[task.setvariable variable=Insertion.InsertToolset]$($branchData.insertToolset)"
}

Write-Host "##vso[task.setvariable variable=Insertion.AutoComplete]$(-not $branchData.insertionCreateDraftPR)"
Write-Host "##vso[task.setvariable variable=ComponentBranchName]$branchName"
Write-Host "##vso[task.setvariable variable=VSBranchName]$($branchData.vsBranch)"
displayName: Set Insertion Variables

- powershell: |
mv RoslynTools.VisualStudioInsertionTool.* RIT
.\RIT\tools\OneOffInsertion.ps1 `
-autoComplete "false" `
-autoComplete "$(Insertion.AutoComplete)" `
-buildQueueName "$(Build.DefinitionName)" `
-cherryPick "(default)" `
-clientId "$(ClientId)" `
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Immutable;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;

namespace Microsoft.CodeAnalysis.ExternalAccess.IntelliCode.Api
{
/// <summary>
/// Provides a list of possible default arguments for method calls.
/// </summary>
/// <remarks>
/// This is a MEF component and should be exported with <see cref="ContentTypeAttribute"/> and <see cref="NameAttribute"/> attributes
/// and optional <see cref="OrderAttribute"/> and <see cref="TextViewRoleAttribute"/> attributes.
/// An instance of <see cref="IIntelliCodeArgumentDefaultsSource"/> is selected
/// first by matching ContentType with content type of the <see cref="ITextView.TextBuffer"/>, and then by order.
/// Only one <see cref="IIntelliCodeArgumentDefaultsSource"/> is used in a given view.
/// <para>
/// Only one <see cref="IIntelliCodeArgumentDefaultsSource"/> will used for any given <see cref="ITextView"/>. The sources are
/// ordered by the Order attribute. The first source (if any) that satisfies the ContentType and TextViewRoles
/// attributes will be the source used to provide defaults.
/// </para>
/// <example>
/// <code>
/// [Export(typeof(IIntelliCodeArgumentDefaultsSource))]
/// [Name(nameof(IntelliCodeArgumentDefaultsSource))]
/// [ContentType("text")]
/// [TextViewRoles(PredefinedTextViewRoles.Editable)]
/// [Order(Before = "OtherCompletionDefaultsSource")]
/// public class IntelliCodeArgumentDefaultsSource : IIntelliCodeArgumentDefaultsSource
/// </code>
/// </example>
/// </remarks>
internal interface IIntelliCodeArgumentDefaultsSource
{
/// <summary>
/// Gets a list of possible default arguments for a method signature.
/// </summary>
/// <param name="view">View for which the defaults are desired.</param>
/// <returns>A list of possible default arguments for a method signature.</returns>
/// <remarks>
/// <para>The returned value will always be in the form of a "complete" set of arguments, including the leading and trailing parenthesis.</para>
/// <para>For example:
/// <code>
/// ()
/// (args[0])
/// (args.Length)
/// (value: args.Length)
/// </code>
/// </para>
/// <para>Some of the proposals may be syntactically/semantically invalid (and can be ignored by the caller).</para>
/// </remarks>
Task<ImmutableArray<string>> GetArgumentDefaultsAsync(ITextView view);
}
}
4 changes: 2 additions & 2 deletions src/EditorFeatures/Core/Shared/Options/FeatureOnOffOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ internal static class FeatureOnOffOptions
nameof(FeatureOnOffOptions), nameof(OfferRemoveUnusedReferences), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation($"TextEditor.{nameof(OfferRemoveUnusedReferences)}"));

public static readonly PerLanguageOption2<bool> ShowInheritanceMargin =
public static readonly PerLanguageOption2<bool?> ShowInheritanceMargin =
new(nameof(FeatureOnOffOptions),
nameof(ShowInheritanceMargin),
defaultValue: false,
defaultValue: null,
new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.ShowInheritanceMargin"));

public static readonly Option2<bool> AutomaticallyCompleteStatementOnSemicolon = new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,52 @@ public ImmutableArray<StateSet> CreateBuildOnlyProjectStateSet(Project project)
return stateSets.ToImmutable();
}

/// <summary>
/// Determines if any of the state sets in <see cref="GetAllHostStateSets()"/> match a specified predicate.
/// </summary>
/// <remarks>
/// This method avoids the performance overhead of calling <see cref="GetAllHostStateSets()"/> for the
/// specific case where the result is only used for testing if any element meets certain conditions.
/// </remarks>
public bool HasAnyHostStateSet<TArg>(Func<StateSet, TArg, bool> match, TArg arg)
{
foreach (var (_, hostStateSet) in _hostAnalyzerStateMap)
{
foreach (var stateSet in hostStateSet.OrderedStateSets)
{
if (match(stateSet, arg))
return true;
}
}

return false;
}

/// <summary>
/// Determines if any of the state sets in <see cref="_projectAnalyzerStateMap"/> for a specific project
/// match a specified predicate.
/// </summary>
/// <remarks>
/// <para>This method avoids the performance overhead of calling <see cref="GetStateSets(Project)"/> for the
/// specific case where the result is only used for testing if any element meets certain conditions.</para>
///
/// <para>Note that host state sets (i.e. ones retured by <see cref="GetAllHostStateSets()"/> are not tested
/// by this method.</para>
/// </remarks>
public bool HasAnyProjectStateSet<TArg>(ProjectId projectId, Func<StateSet, TArg, bool> match, TArg arg)
{
if (_projectAnalyzerStateMap.TryGetValue(projectId, out var entry))
{
foreach (var (_, stateSet) in entry.StateSetMap)
{
if (match(stateSet, arg))
return true;
}
}

return false;
}

public bool OnProjectRemoved(IEnumerable<StateSet> stateSets, ProjectId projectId)
{
var removed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
Expand Down Expand Up @@ -64,17 +63,11 @@ public DiagnosticIncrementalAnalyzer(

internal DiagnosticAnalyzerInfoCache DiagnosticAnalyzerInfoCache => _diagnosticAnalyzerRunner.AnalyzerInfoCache;

[PerformanceSensitive("https://github.com/dotnet/roslyn/issues/54400", Constraint = "Avoid calling GetAllHostStateSets on this hot path.")]
public bool ContainsDiagnostics(ProjectId projectId)
{
foreach (var stateSet in _stateManager.GetStateSets(projectId))
{
if (stateSet.ContainsAnyDocumentOrProjectDiagnostics(projectId))
{
return true;
}
}

return false;
return _stateManager.HasAnyHostStateSet(static (stateSet, arg) => stateSet.ContainsAnyDocumentOrProjectDiagnostics(arg), projectId)
|| _stateManager.HasAnyProjectStateSet(projectId, static (stateSet, arg) => stateSet.ContainsAnyDocumentOrProjectDiagnostics(arg), projectId);
}

public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Options;

namespace Microsoft.CodeAnalysis.ExternalAccess.IntelliCode.Api
{
internal static class IntelliCodeCompletionOptions
{
public static PerLanguageOption<bool> TriggerOnTyping { get; } = (PerLanguageOption<bool>)CompletionOptions.TriggerOnTyping;

public static PerLanguageOption<bool> TriggerOnTypingLetters { get; } = (PerLanguageOption<bool>)CompletionOptions.TriggerOnTypingLetters2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.CodeSense.ReferencesProvider" Key="$(VisualStudioKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35086" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.CodeSense.TestsProvider" Key="$(VisualStudioKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35086" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode" Partner="IntelliCode" Key="$(IntelliCodeKey)" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp.Extraction" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" />
<RestrictedInternalsVisibleTo Include="dotnet-watch" Partner="Watch" Key="$(AspNetCoreKey)" />
Expand Down
27 changes: 17 additions & 10 deletions src/Features/LanguageServer/Protocol/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,31 @@ private static ImmutableArray<Document> FilterDocumentsByClientName(ImmutableArr
return documents.FindDocumentInProjectContext(documentIdentifier);
}

public static T FindDocumentInProjectContext<T>(this ImmutableArray<T> documents, TextDocumentIdentifier documentIdentifier) where T : TextDocument
public static Document FindDocumentInProjectContext(this ImmutableArray<Document> documents, TextDocumentIdentifier documentIdentifier)
{
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)
if (documentIdentifier is VSTextDocumentIdentifier vsDocumentIdentifier && vsDocumentIdentifier.ProjectContext != null)
{
if (vsDocumentIdentifier.ProjectContext != null)
{
var projectId = ProtocolConversions.ProjectContextToProjectId(vsDocumentIdentifier.ProjectContext);
var matchingDocument = documents.FirstOrDefault(d => d.Project.Id == projectId);
var projectId = ProtocolConversions.ProjectContextToProjectId(vsDocumentIdentifier.ProjectContext);
var matchingDocument = documents.FirstOrDefault(d => d.Project.Id == projectId);

if (matchingDocument != null)
{
return matchingDocument;
}
if (matchingDocument != null)
{
return matchingDocument;
}
}
else
{
// We were not passed a project context. This can happen when the LSP powered NavBar is not enabled.
// This branch should be removed when we're using the LSP based navbar in all scenarios.

var solution = documents.First().Project.Solution;
// Lookup which of the linked documents is currently active in the workspace.
var documentIdInCurrentContext = solution.Workspace.GetDocumentIdInCurrentContext(documents.First().Id);
return solution.GetRequiredDocument(documentIdInCurrentContext);
}
}

// We either have only one document or have multiple, but none of them matched our context. In the
Expand Down
Loading