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

Add option for LSP based auto-insert #74485

Closed
wants to merge 19 commits into from
49 changes: 49 additions & 0 deletions azure-pipelines-integration-dartlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ resources:
trigger:
- main

parameters:
- name: prNumber
type: string
default: ''
- name: sha
type: string
default: ''

variables:
- name: XUNIT_LOGS
value: $(Build.SourcesDirectory)\artifacts\log\$(_configuration)
Expand All @@ -33,8 +41,21 @@ variables:
value: true

stages:
- ${{ if ne(parameters.prNumber, '') }}:
- stage: GitHubCommentFirst
jobs:
- job: GitHubCommentFirstJob
steps:
- task: GitHubComment@0
inputs:
gitHubConnection: 'dotnet-comment-bot-service-connection'
repositoryName: '$(Build.Repository.Name)'
id: ${{ parameters.prNumber }}
comment: 'Started DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) for ${{ parameters.sha }}'

- template: \stages\visual-studio\agent.yml@DartLabTemplates
parameters:
name: VSIntegration
displayName: VS Integration
testLabPoolName: VS-Platform
visualStudioBootstrapperURI: https://vsdrop.corp.microsoft.com/file/v1/$(VisualStudio.BuildUnderTest.ProductsDropName);bootstrappers/Enterprise/vs_enterprise.exe
Expand Down Expand Up @@ -67,9 +88,37 @@ stages:
arguments: -DropNamePrefix 'Products' -VstsDropUrlsJson '$(Pipeline.Workspace)\VisualStudioBuildUnderTest\BuildArtifacts\VstsDropUrls.json' -OutVariableName 'VisualStudio.BuildUnderTest.ProductsDropName'
deployAndRunTestsStepList:
- checkout: RoslynMirror
fetchDepth: 1
fetchTags: false
- template: eng/pipelines/test-integration-job.yml
parameters:
configuration: $(_configuration)
oop64bit: $(_oop64bit)
lspEditor: false
skipCheckout: true

- ${{ if ne(parameters.prNumber, '') }}:
- stage: GitHubCommentCompleted
condition: always()
dependsOn: VSIntegration
jobs:
- job: GitHubCommentCompletedSuccessfullyJob
condition: eq(stageDependencies.VSIntegration.result, 'Succeeded')
steps:
- checkout: none
- task: GitHubComment@0
inputs:
gitHubConnection: 'dotnet-comment-bot-service-connection'
repositoryName: '$(Build.Repository.Name)'
id: ${{ parameters.prNumber }}
comment: 'DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) completed successfully for ${{ parameters.sha }}'
- job: GitHubCommentCompletedUnsuccessfullyJob
condition: ne(stageDependencies.VSIntegration.result, 'Succeeded')
steps:
- checkout: none
- task: GitHubComment@0
inputs:
gitHubConnection: 'dotnet-comment-bot-service-connection'
repositoryName: '$(Build.Repository.Name)'
id: ${{ parameters.prNumber }}
comment: 'DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) did not complete successfully for ${{ parameters.sha }}'
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ internal partial class DidChangeConfigurationNotificationHandler
SolutionCrawlerOptionsStorage.CompilerDiagnosticsScopeOption,
LspOptionsStorage.LspEnableReferencesCodeLens,
LspOptionsStorage.LspEnableTestsCodeLens,
LspOptionsStorage.LspEnableOnAutoInsert,
LanguageServerProjectSystemOptionsStorage.BinaryLogPath,
LanguageServerProjectSystemOptionsStorage.EnableAutomaticRestore,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ internal sealed class OnAutoInsertHandler(
if (document == null)
return SpecializedTasks.Null<LSP.VSInternalDocumentOnAutoInsertResponseItem>();

var onAutoInsertEnabled = _globalOptions.GetOption(LspOptionsStorage.LspEnableOnAutoInsert, document.Project.Language);
if (!onAutoInsertEnabled)
return SpecializedTasks.Null<LSP.VSInternalDocumentOnAutoInsertResponseItem>();

var servicesForDocument = _braceCompletionServices.Where(s => s.Metadata.Language == document.Project.Language).SelectAsArray(s => s.Value);
var isRazorRequest = context.ServerKind == WellKnownLspServerKinds.RazorLspServer;
var position = ProtocolConversions.PositionToLinePosition(request.Position);
Expand Down
7 changes: 7 additions & 0 deletions src/LanguageServer/Protocol/LspOptionsStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ internal sealed class LspOptionsStorage

private static readonly OptionGroup s_codeLensOptionGroup = new(name: "code_lens", description: "");

private static readonly OptionGroup s_onAutoInsertOptionGroup = new(name: "on_auto_insert", description: "");

/// <summary>
/// Flag indicating whether or not references should be returned in LSP codelens.
/// </summary>
Expand All @@ -41,5 +43,10 @@ internal sealed class LspOptionsStorage
/// Flag indicating whether or not test and debug code lens items should be returned.
/// </summary>
public static readonly PerLanguageOption2<bool> LspEnableTestsCodeLens = new("dotnet_enable_tests_code_lens", defaultValue: true, group: s_codeLensOptionGroup);

/// <summary>
/// Flag indicating whether or not auto-insert should be abled by default in LSP.
/// </summary>
public static readonly PerLanguageOption2<bool> LspEnableOnAutoInsert = new("dotnet_enable_on_auto_insert", defaultValue: true, group: s_onAutoInsertOptionGroup);
}
}
Loading