Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
<SystemRuntimeCompilerServicesUnsafeVersion>5.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<!-- VisualStudio package versions -->
<VisualStudioImplementationPackagesVersion>17.0.154-preview</VisualStudioImplementationPackagesVersion>
<VisualStudioContractPackagesVersion>17.0.0-previews-2-31423-289</VisualStudioContractPackagesVersion>
<VisualStudioImplementationPackagesVersion>17.0.391-preview-g5e248c9073</VisualStudioImplementationPackagesVersion>
<VisualStudioContractPackagesVersion>17.0.0-previews-4-31709-430</VisualStudioContractPackagesVersion>
<VisualStudioProjectSystemPackagesVersion>17.0.77-pre-g62a6cb5699</VisualStudioProjectSystemPackagesVersion>
<MicrosoftVisualStudioInteropVersion>$(VisualStudioContractPackagesVersion)</MicrosoftVisualStudioInteropVersion>
<MicrosoftInternalVisualStudioInteropVersion>$(VisualStudioContractPackagesVersion)</MicrosoftInternalVisualStudioInteropVersion>
Expand All @@ -134,7 +134,7 @@
<EnvDTEVersion>$(VisualStudioContractPackagesVersion)</EnvDTEVersion>
<EnvDTE80Version>$(VisualStudioContractPackagesVersion)</EnvDTE80Version>
<!-- Roslyn packages -->
<RoslynVersion>4.0.0-1.21181.18</RoslynVersion>
<RoslynVersion>4.1.0-1.21511.14</RoslynVersion>
<MicrosoftCodeAnalysisEditorFeaturesVersion>$(RoslynVersion)</MicrosoftCodeAnalysisEditorFeaturesVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextVersion>$(RoslynVersion)</MicrosoftCodeAnalysisEditorFeaturesTextVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfVersion>$(RoslynVersion)</MicrosoftCodeAnalysisEditorFeaturesWpfVersion>
Expand Down Expand Up @@ -168,7 +168,7 @@
<MicrosoftVisualStudioShellFrameworkVersion>$(VisualStudioContractPackagesVersion)</MicrosoftVisualStudioShellFrameworkVersion>
<MicrosoftVisualStudioPackageLanguageService150Version>$(VisualStudioContractPackagesVersion)</MicrosoftVisualStudioPackageLanguageService150Version>
<!-- Misc. Visual Studio packages -->
<MicrosoftVisualStudioRpcContractsVersion>17.0.50-preview-0002-0002</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioRpcContractsVersion>17.0.50-preview-0002-0025</MicrosoftVisualStudioRpcContractsVersion>
<MicrosoftVisualStudioComponentModelHostVersion>$(VisualStudioImplementationPackagesVersion)</MicrosoftVisualStudioComponentModelHostVersion>
<MicrosoftVisualFSharpMicrosoftVisualStudioShellUIInternalVersion>17.0.0</MicrosoftVisualFSharpMicrosoftVisualStudioShellUIInternalVersion>
<MicrosoftVisualStudioDesignerInterfacesVersion>$(VisualStudioContractPackagesVersion)</MicrosoftVisualStudioDesignerInterfacesVersion>
Expand All @@ -184,9 +184,9 @@
<MicrosoftVisualStudioShellImmutable150Version>15.0.25123-Dev15Preview</MicrosoftVisualStudioShellImmutable150Version>
<MicrosoftVisualStudioShellInterop160DesignTimeVersion>16.0.1</MicrosoftVisualStudioShellInterop160DesignTimeVersion>
<MicrosoftVisualStudioShellInterop16DesignTimeVersion>16.0.28924.11111</MicrosoftVisualStudioShellInterop16DesignTimeVersion>
<MicrosoftVisualStudioThreadingVersion>17.0.26-alpha</MicrosoftVisualStudioThreadingVersion>
<MicrosoftVisualStudioThreadingVersion>17.0.46-alpha</MicrosoftVisualStudioThreadingVersion>
<MicrosoftVisualStudioUtilitiesVersion>$(VisualStudioContractPackagesVersion)</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioValidationVersion>17.0.1-alpha</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioValidationVersion>17.0.23-alpha</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioWCFReferenceInteropVersion>9.0.30729</MicrosoftVisualStudioWCFReferenceInteropVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>5.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<VSSDKDebuggerVisualizersVersion>12.0.4</VSSDKDebuggerVisualizersVersion>
Expand All @@ -209,12 +209,13 @@
<MicrosoftNETCoreILAsmVersion>5.0.0-preview.7.20364.11</MicrosoftNETCoreILAsmVersion>
<MicrosoftNETTestSdkVersion>16.11.0</MicrosoftNETTestSdkVersion>
<MicrosoftWin32RegistryVersion>4.3.0</MicrosoftWin32RegistryVersion>
<NewtonsoftJsonVersion>12.0.2</NewtonsoftJsonVersion>
<NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
<NUnitVersion>3.13.2</NUnitVersion>
<NUnit3TestAdapterVersion>4.1.0</NUnit3TestAdapterVersion>
<NunitXmlTestLoggerVersion>2.1.80</NunitXmlTestLoggerVersion>
<RoslynToolsSignToolVersion>1.0.0-beta2-dev3</RoslynToolsSignToolVersion>
<StreamJsonRpcVersion>2.8.3-alpha</StreamJsonRpcVersion>
<StreamJsonRpcVersion>2.8.21</StreamJsonRpcVersion>
<NerdbankStreamsVersion>2.7.74</NerdbankStreamsVersion>
<XUnitVersion>2.4.1</XUnitVersion>
<XUnitRunnerVersion>2.4.2</XUnitRunnerVersion>
<FluentAssertionsVersion>5.10.3</FluentAssertionsVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ open System.Threading.Tasks

open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.Completion
open Microsoft.CodeAnalysis.Options
open Microsoft.CodeAnalysis.Text
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion

Expand All @@ -31,7 +30,7 @@ type internal FSharpCompletionProvider
assemblyContentProvider: AssemblyContentProvider
) =

inherit CompletionProvider()
inherit FSharpCompletionProviderBase()

// Save the backing data in a cache, we need to save for at least the length of the completion session
// See https://github.com/Microsoft/visualfsharp/issues/4714
Expand Down Expand Up @@ -196,7 +195,7 @@ type internal FSharpCompletionProvider
return results
}

override _.ShouldTriggerCompletion(sourceText: SourceText, caretPosition: int, trigger: CompletionTrigger, _: OptionSet) =
override _.ShouldTriggerCompletionImpl(sourceText: SourceText, caretPosition: int, trigger: CompletionTrigger) =
use _logBlock = Logger.LogBlock LogEditorFunctionId.Completion_ShouldTrigger

let getInfo() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type internal FSharpCompletionService
assemblyContentProvider: AssemblyContentProvider,
settings: EditorOptions
) =
inherit CompletionServiceWithProviders(workspace)
inherit FSharpCompletionServiceWithProviders(workspace)

let projectInfoManager = workspace.Services.GetRequiredService<IFSharpWorkspaceService>().FSharpProjectOptionsManager

Expand All @@ -31,7 +31,7 @@ type internal FSharpCompletionService

override _.Language = FSharpConstants.FSharpLanguageName
override _.GetBuiltInProviders() = builtInProviders
override _.GetRules() =
override _.GetRulesImpl() =
let enterKeyRule =
match settings.IntelliSense.EnterKeySetting with
| NeverNewline -> EnterKeyRule.Never
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ type internal HashCompletion =
AllowableExtensions = allowableExtensions
UseIncludeDirectives = useIncludeDirectives }

type internal HashDirectiveCompletionProvider(workspace: Workspace, projectInfoManager: FSharpProjectOptionsManager, completions: HashCompletion list) =
type internal HashDirectiveCompletionProvider
(
workspace: Workspace,
projectInfoManager: FSharpProjectOptionsManager,
completions: HashCompletion list
) =

inherit FSharpCommonCompletionProviderBase()

let [<Literal>] NetworkPath = "\\\\"
let commitRules = ImmutableArray.Create(CharacterSetModificationRule.Create(CharacterSetModificationKind.Replace, '"', '\\', ',', '/'))
Expand Down Expand Up @@ -91,77 +98,75 @@ type internal HashDirectiveCompletionProvider(workspace: Workspace, projectInfoM
]
HashDirectiveCompletionProvider(workspace, projectInfoManager, completions)

interface IFSharpCommonCompletionProvider with

member _.ProvideCompletionsAsync(context) =
asyncMaybe {
let document = context.Document
let position = context.Position
do! let extension = Path.GetExtension document.FilePath
Option.guard (extension = ".fsx" || extension = ".fsscript")

let! ct = liftAsync Async.CancellationToken
let! text = document.GetTextAsync(ct)
do! Option.guard (isInStringLiteral(text, position))
let line = text.Lines.GetLineFromPosition(position)
let lineText = text.ToString(TextSpan.FromBounds(line.Start, position))
override _.ProvideCompletionsAsync(context) =
asyncMaybe {
let document = context.Document
let position = context.Position
do! let extension = Path.GetExtension document.FilePath
Option.guard (extension = ".fsx" || extension = ".fsscript")

let! ct = liftAsync Async.CancellationToken
let! text = document.GetTextAsync(ct)
do! Option.guard (isInStringLiteral(text, position))
let line = text.Lines.GetLineFromPosition(position)
let lineText = text.ToString(TextSpan.FromBounds(line.Start, position))

let! completion, quotedPathGroup =
completions |> List.tryPick (fun completion ->
match completion.DirectiveRegex.Match lineText with
| m when m.Success ->
let quotedPathGroup = m.Groups.["literal"]
let endsWithQuote = PathCompletionUtilities.EndsWithQuote(quotedPathGroup.Value)
if endsWithQuote && (position >= line.Start + m.Length) then
None
else
Some (completion, quotedPathGroup)
| _ -> None)

let snapshot = text.FindCorrespondingEditorTextSnapshot()
let! completion, quotedPathGroup =
completions |> List.tryPick (fun completion ->
match completion.DirectiveRegex.Match lineText with
| m when m.Success ->
let quotedPathGroup = m.Groups.["literal"]
let endsWithQuote = PathCompletionUtilities.EndsWithQuote(quotedPathGroup.Value)
if endsWithQuote && (position >= line.Start + m.Length) then
None
else
Some (completion, quotedPathGroup)
| _ -> None)

let snapshot = text.FindCorrespondingEditorTextSnapshot()

do! Option.guard (not (isNull snapshot))

let extraSearchPaths =
if completion.UseIncludeDirectives then
getIncludeDirectives (text, position)
else []

let defaultSearchPath = Path.GetDirectoryName document.FilePath
let searchPaths = defaultSearchPath :: extraSearchPaths

let helper =
FSharpFileSystemCompletionHelper(
Glyph.OpenFolder,
completion.AllowableExtensions |> List.tryPick getFileGlyph |> Option.defaultValue Glyph.None,
Seq.toImmutableArray searchPaths,
null,
completion.AllowableExtensions |> Seq.toImmutableArray,
rules)
do! Option.guard (not (isNull snapshot))

let extraSearchPaths =
if completion.UseIncludeDirectives then
getIncludeDirectives (text, position)
else []

let defaultSearchPath = Path.GetDirectoryName document.FilePath
let searchPaths = defaultSearchPath :: extraSearchPaths

let helper =
FSharpFileSystemCompletionHelper(
Glyph.OpenFolder,
completion.AllowableExtensions |> List.tryPick getFileGlyph |> Option.defaultValue Glyph.None,
Seq.toImmutableArray searchPaths,
null,
completion.AllowableExtensions |> Seq.toImmutableArray,
rules)

let pathThroughLastSlash = getPathThroughLastSlash(text, position, quotedPathGroup)
let! items = helper.GetItemsAsync(pathThroughLastSlash, ct) |> Async.AwaitTask |> liftAsync
context.AddItems(items)
}
|> Async.Ignore
|> RoslynHelpers.StartAsyncUnitAsTask context.CancellationToken
let pathThroughLastSlash = getPathThroughLastSlash(text, position, quotedPathGroup)
let! items = helper.GetItemsAsync(pathThroughLastSlash, ct) |> Async.AwaitTask |> liftAsync
context.AddItems(items)
}
|> Async.Ignore
|> RoslynHelpers.StartAsyncUnitAsTask context.CancellationToken

member _.IsInsertionTrigger(text, position, _) =
// Bring up completion when the user types a quote (i.e.: #r "), or if they type a slash
// path separator character, or if they type a comma (#r "foo,version...").
// Also, if they're starting a word. i.e. #r "c:\W
let ch = text.[position]
let isTriggerChar =
ch = '"' || ch = '\\' || ch = ',' || ch = '/' ||
FSharpCommonCompletionUtilities.IsStartingNewWord(text, position, (fun x -> Char.IsLetter x), (fun x -> Char.IsLetterOrDigit x))
isTriggerChar && isInStringLiteral(text, position)
override _.IsInsertionTrigger(text, position) =
// Bring up completion when the user types a quote (i.e.: #r "), or if they type a slash
// path separator character, or if they type a comma (#r "foo,version...").
// Also, if they're starting a word. i.e. #r "c:\W
let ch = text.[position]
let isTriggerChar =
ch = '"' || ch = '\\' || ch = ',' || ch = '/' ||
FSharpCommonCompletionUtilities.IsStartingNewWord(text, position, (fun x -> Char.IsLetter x), (fun x -> Char.IsLetterOrDigit x))
isTriggerChar && isInStringLiteral(text, position)

member _.GetTextChangeAsync(baseGetTextChangeAsync, selectedItem, ch, cancellationToken) =
// When we commit "\\" when the user types \ we have to adjust for the fact that the
// controller will automatically append \ after we commit. Because of that, we don't
// want to actually commit "\\" as we'll end up with "\\\". So instead we just commit
// "\" and know that controller will append "\" and give us "\\".
if selectedItem.DisplayText = NetworkPath && ch = Nullable '\\' then
Task.FromResult(Nullable(TextChange(selectedItem.Span, "\\")))
else
baseGetTextChangeAsync.Invoke(selectedItem, ch, cancellationToken)
override _.GetTextChangeAsync(baseGetTextChangeAsync, selectedItem, ch, cancellationToken) =
// When we commit "\\" when the user types \ we have to adjust for the fact that the
// controller will automatically append \ after we commit. Because of that, we don't
// want to actually commit "\\" as we'll end up with "\\\". So instead we just commit
// "\" and know that controller will append "\" and give us "\\".
if selectedItem.DisplayText = NetworkPath && ch = Nullable '\\' then
Task.FromResult(Nullable(TextChange(selectedItem.Span, "\\")))
else
baseGetTextChangeAsync.Invoke(selectedItem, ch, cancellationToken)
1 change: 1 addition & 0 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" PrivateAssets="all" ExcludeAssets="runtime;contentFiles;build;analyzers;native" />
<PackageReference Include="System.Design" Version="$(SystemDesignVersion)" />
<PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" />
<PackageReference Include="Nerdbank.Streams" Version="$(NerdbankStreamsVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,11 @@ type internal FSharpLanguageService(package : FSharpPackage) =
override this.Initialize() =
base.Initialize()

this.Workspace.Options <- this.Workspace.Options.WithChangedOption(Completion.FSharpCompletionOptions.BlockForCompletionItems, FSharpConstants.FSharpLanguageName, false)
this.Workspace.Options <- this.Workspace.Options.WithChangedOption(Shared.Options.FSharpServiceFeatureOnOffOptions.ClosedFileDiagnostic, FSharpConstants.FSharpLanguageName, Nullable false)

let globalOptions = package.ComponentModel.DefaultExportProvider.GetExport<FSharpGlobalOptions>().Value
globalOptions.BlockForCompletionItems <- false

let theme = package.ComponentModel.DefaultExportProvider.GetExport<ISetThemeColors>().Value
theme.SetColors()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" PrivateAssets="all" ExcludeAssets="runtime;contentFiles;build;analyzers;native" />
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="$(MicrosoftVisualStudioValidationVersion)" PrivateAssets="all" ExcludeAssets="runtime;contentFiles;build;analyzers;native" />
<PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" />
<PackageReference Include="Nerdbank.Streams" Version="$(NerdbankStreamsVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="$(MicrosoftVisualStudioThreadingVersion)" PrivateAssets="all" ExcludeAssets="runtime;contentFiles;build;analyzers;native" />
<PackageReference Update="Microsoft.VSSDK.BuildTools" Version="$(MicrosoftVSSDKBuildToolsVersion)" />
<PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" />
<PackageReference Include="Nerdbank.Streams" Version="$(NerdbankStreamsVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<PackageReference Include="Microsoft.VisualStudio.ProjectSystem.Managed" Version="$(MicrosoftVisualStudioProjectSystemManagedVersion)" />
<PackageReference Include="NUnit" Version="$(NUnitVersion)" />
<PackageReference Include="StreamJsonRpc" Version="$(StreamJsonRpcVersion)" />
<PackageReference Include="Nerdbank.Streams" Version="$(NerdbankStreamsVersion)" />
</ItemGroup>

</Project>