From 6abb12fd5614dd39a1b411a246c16dd2ea4806d7 Mon Sep 17 00:00:00 2001 From: TIHan Date: Mon, 6 May 2019 18:56:13 -0700 Subject: [PATCH 01/22] Added fsharp shims over document diagnostic analyzers --- ...oft.CodeAnalysis.EditorFeatures.Wpf.csproj | 1 - ...crosoft.CodeAnalysis.EditorFeatures.csproj | 1 - ...ft.CodeAnalysis.EditorFeatures.Text.csproj | 2 - .../Microsoft.CodeAnalysis.Features.csproj | 1 - .../FSharpDocumentDiagnosticAnalyzer.cs | 69 +++++ .../FSharpProjectDiagnosticAnalyzer.cs | 34 +++ .../FSharpSimplifyNameDiagnosticAnalyzer.cs | 51 ++++ .../FSharpUnusedDeclarationsAnalyzer.cs | 53 ++++ .../FSharpUnusedOpensDiagnosticAnalyzer.cs | 51 ++++ .../IFSharpDocumentDiagnosticAnalyzer.cs | 16 + .../IFSharpProjectDiagnosticAnalyzer.cs | 14 + .../IFSharpSimplifyNameDiagnosticAnalyzer.cs | 14 + ...arpUnusedDeclarationsDiagnosticAnalyzer.cs | 14 + .../IFSharpUnusedOpensDiagnosticAnalyzer.cs | 14 + .../ExternalAccessFSharpResources.Designer.cs | 288 ++++++++++++++++++ .../FSharp/ExternalAccessFSharpResources.resx | 195 ++++++++++++ .../xlf/ExternalAccessFSharpResources.cs.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.de.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.es.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.fr.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.it.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.ja.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.ko.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.pl.xlf | 132 ++++++++ .../ExternalAccessFSharpResources.pt-BR.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.ru.xlf | 132 ++++++++ .../xlf/ExternalAccessFSharpResources.tr.xlf | 132 ++++++++ .../ExternalAccessFSharpResources.zh-Hans.xlf | 132 ++++++++ .../ExternalAccessFSharpResources.zh-Hant.xlf | 132 ++++++++ 29 files changed, 2529 insertions(+), 5 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpDocumentDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpProjectDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpSimplifyNameDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedDeclarationsDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedOpensDiagnosticAnalyzer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/ExternalAccessFSharpResources.Designer.cs create mode 100644 src/Tools/ExternalAccess/FSharp/ExternalAccessFSharpResources.resx create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.cs.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.de.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.es.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.fr.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.it.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ja.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ko.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pl.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pt-BR.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ru.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.tr.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hans.xlf create mode 100644 src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hant.xlf diff --git a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj index bf5a5cee6d8d6..bb1a6da9181e4 100644 --- a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj +++ b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj @@ -54,7 +54,6 @@ - diff --git a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj index 31035f8a9247e..4e8a92e1e73c7 100644 --- a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj +++ b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj @@ -102,7 +102,6 @@ - diff --git a/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj b/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj index 811fe8efea028..0497ca3e848fc 100644 --- a/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj +++ b/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj @@ -51,8 +51,6 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Add an assembly reference to '{0}' + + + Add 'new' keyword + + + Add a project reference to '{0}' + + + Cannot determine the symbol under the caret + + + Cannot navigate to the requested location + + + Exceptions: + + + F# Disposable Types + + + F# Functions / Methods + + + F# Mutable Variables / Reference Cells + + + F# Printf Format + + + F# Properties + + + Generic parameters: + + + Implement interface + + + Implement interface without type annotation + + + Locating the symbol under the caret... + + + Name can be simplified. + + + Navigate to symbol failed: {0} + + + Navigating to symbol... + + + Prefix '{0}' with underscore + + + Remove unused open declarations + + + Rename '{0}' to '__' + + + Rename '{0}' to '_' + + + Simplify name + + + The value is unused + + + Open declaration can be removed. + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.cs.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.cs.xlf new file mode 100644 index 0000000000000..42ef58b308cab --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.cs.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.de.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.de.xlf new file mode 100644 index 0000000000000..f978efb3d2893 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.de.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.es.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.es.xlf new file mode 100644 index 0000000000000..563123a994995 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.es.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.fr.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.fr.xlf new file mode 100644 index 0000000000000..91d0dca07bc85 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.fr.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.it.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.it.xlf new file mode 100644 index 0000000000000..b439af9ecfd27 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.it.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ja.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ja.xlf new file mode 100644 index 0000000000000..be4cb1a7bb962 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ja.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ko.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ko.xlf new file mode 100644 index 0000000000000..ee7b880ac81fe --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ko.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pl.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pl.xlf new file mode 100644 index 0000000000000..f11a2d22f02ef --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pl.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pt-BR.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pt-BR.xlf new file mode 100644 index 0000000000000..ef35520ae22dc --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.pt-BR.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ru.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ru.xlf new file mode 100644 index 0000000000000..fc57cf5d5dee6 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.ru.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.tr.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.tr.xlf new file mode 100644 index 0000000000000..0500d617763ac --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.tr.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hans.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hans.xlf new file mode 100644 index 0000000000000..8467efdbe14f8 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hans.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hant.xlf b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hant.xlf new file mode 100644 index 0000000000000..608a49cb90560 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/xlf/ExternalAccessFSharpResources.zh-Hant.xlf @@ -0,0 +1,132 @@ + + + + + + Add an assembly reference to '{0}' + Add an assembly reference to '{0}' + + + + Add 'new' keyword + Add 'new' keyword + + + + Add a project reference to '{0}' + Add a project reference to '{0}' + + + + Cannot determine the symbol under the caret + Cannot determine the symbol under the caret + + + + Cannot navigate to the requested location + Cannot navigate to the requested location + + + + Exceptions: + Exceptions: + + + + F# Disposable Types + F# Disposable Types + + + + F# Functions / Methods + F# Functions / Methods + + + + F# Mutable Variables / Reference Cells + F# Mutable Variables / Reference Cells + + + + F# Printf Format + F# Printf Format + + + + F# Properties + F# Properties + + + + Generic parameters: + Generic parameters: + + + + Implement interface + Implement interface + + + + Implement interface without type annotation + Implement interface without type annotation + + + + Locating the symbol under the caret... + Locating the symbol under the caret... + + + + Name can be simplified. + Name can be simplified. + + + + Navigate to symbol failed: {0} + Navigate to symbol failed: {0} + + + + Navigating to symbol... + Navigating to symbol... + + + + Prefix '{0}' with underscore + Prefix '{0}' with underscore + + + + Remove unused open declarations + Remove unused open declarations + + + + Rename '{0}' to '__' + Rename '{0}' to '__' + + + + Rename '{0}' to '_' + Rename '{0}' to '_' + + + + Simplify name + Simplify name + + + + The value is unused + The value is unused + + + + Open declaration can be removed. + Open declaration can be removed. + + + + + \ No newline at end of file From 2b30e7268458a36bfd5fa451b6e4a237d9e8b39f Mon Sep 17 00:00:00 2001 From: TIHan Date: Tue, 7 May 2019 19:09:41 -0700 Subject: [PATCH 02/22] Added shims for completion and sig help. Also added tests. --- Roslyn.sln | 7 + ...oft.CodeAnalysis.EditorFeatures.Wpf.csproj | 1 + ...crosoft.CodeAnalysis.EditorFeatures.csproj | 2 +- ...ft.CodeAnalysis.EditorFeatures.Text.csproj | 1 + .../Microsoft.CodeAnalysis.Features.csproj | 1 + .../Portable/Roslyn.Test.Utilities.csproj | 1 + .../Completion/FSharpCommonCompletionItem.cs | 29 ++ .../FSharpCommonCompletionProvider.cs | 15 + .../FSharpCommonCompletionUtilities.cs | 16 + .../FSharpFileSystemCompletionHelper.cs | 38 +++ .../FSharpInternalCommonCompletionProvider.cs | 36 ++ .../IFSharpCommonCompletionProvider.cs | 24 ++ .../FSharp/Editor/FSharpContentTypeNames.cs | 1 + .../FSharp/FSharpGlyphHelpers.cs | 315 ++++++++++++++++- .../FSharp/FSharpGlyphHelpersObsolete.cs | 321 ------------------ ....CodeAnalysis.ExternalAccess.FSharp.csproj | 16 + .../SignatureHelp/FSharpSignatureHelpItem.cs | 80 +++++ .../SignatureHelp/FSharpSignatureHelpItems.cs | 103 ++++++ .../FSharpSignatureHelpParameter.cs | 88 +++++ .../FSharpSignatureHelpProvider.cs | 68 ++++ .../FSharpSignatureHelpTriggerInfo.cs | 20 ++ .../FSharpSignatureHelpTriggerReason.cs | 22 ++ ...FSharpSignatureHelpTriggerReasonHelpers.cs | 35 ++ .../IFSharpSignatureHelpProvider.cs | 27 ++ .../FSharpSignatureHelpClassifierProvider.cs | 33 ++ .../FSharpSignatureHelpTriggerReasonTests.cs | 55 +++ ...sis.ExternalAccess.FSharp.UnitTests.csproj | 39 +++ ...osoft.VisualStudio.LanguageServices.csproj | 1 + ...dio.LanguageServices.Implementation.csproj | 1 + .../Microsoft.CodeAnalysis.Workspaces.csproj | 2 +- 30 files changed, 1073 insertions(+), 325 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionItem.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionProvider.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionUtilities.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Completion/FSharpFileSystemCompletionHelper.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Completion/FSharpInternalCommonCompletionProvider.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Completion/IFSharpCommonCompletionProvider.cs delete mode 100644 src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpersObsolete.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItem.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItems.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpParameter.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpProvider.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReason.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs create mode 100644 src/Tools/ExternalAccess/FSharp/SignatureHelp/IFSharpSignatureHelpProvider.cs create mode 100644 src/Tools/ExternalAccess/FSharp/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs create mode 100644 src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs create mode 100644 src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj diff --git a/Roslyn.sln b/Roslyn.sln index bc9a3e6941222..486cbf9f266c2 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -404,6 +404,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Exte EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup.ServiceHub", "src\Setup\DevDivVsix\ServiceHubConfig\Roslyn.VisualStudio.Setup.ServiceHub.csproj", "{3D33BBFD-EC63-4E8C-A714-0A48A3809A87}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests", "src\Tools\ExternalAccess\FSharpTest\Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj", "{BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4 @@ -1069,6 +1071,10 @@ Global {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D33BBFD-EC63-4E8C-A714-0A48A3809A87}.Release|Any CPU.Build.0 = Release|Any CPU + {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1258,6 +1264,7 @@ Global {FA51A3CB-5174-4D99-B76E-DC31C5361DF3} = {8977A560-45C2-4EC2-A849-97335B382C74} {DE53934B-7FC1-48A0-85AB-C519FBBD02CF} = {8977A560-45C2-4EC2-A849-97335B382C74} {3D33BBFD-EC63-4E8C-A714-0A48A3809A87} = {BE25E872-1667-4649-9D19-96B83E75A44E} + {BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5} = {8977A560-45C2-4EC2-A849-97335B382C74} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29} diff --git a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj index bb1a6da9181e4..2ea712bbacf21 100644 --- a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj +++ b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj @@ -55,6 +55,7 @@ + diff --git a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj index 4e8a92e1e73c7..fe60697fb37c9 100644 --- a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj +++ b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj @@ -53,7 +53,6 @@ - diff --git a/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj b/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj index 0497ca3e848fc..895015360c9cd 100644 --- a/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj +++ b/src/EditorFeatures/Text/Microsoft.CodeAnalysis.EditorFeatures.Text.csproj @@ -37,6 +37,7 @@ + diff --git a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj index 43711d1316bcf..02e3a2235b06a 100644 --- a/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj +++ b/src/Features/Core/Portable/Microsoft.CodeAnalysis.Features.csproj @@ -77,6 +77,7 @@ + diff --git a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj index 936643d6694a0..8a7dc472962dd 100644 --- a/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj +++ b/src/Test/Utilities/Portable/Roslyn.Test.Utilities.csproj @@ -65,6 +65,7 @@ + diff --git a/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionItem.cs b/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionItem.cs new file mode 100644 index 0000000000000..553ec3bb1b8ab --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionItem.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion +{ + internal static class FSharpCommonCompletionItem + { + public static CompletionItem Create( + string displayText, + string displayTextSuffix, + CompletionItemRules rules, + FSharpGlyph? glyph = null, + ImmutableArray description = default, + string sortText = null, + string filterText = null, + bool showsWarningIcon = false, + ImmutableDictionary properties = null, + ImmutableArray tags = default, + string inlineDescription = null) + { + var roslynGlyph = glyph.HasValue ? FSharpGlyphHelpers.ConvertTo(glyph.Value) : (Glyph?)null; + return CommonCompletionItem.Create( + displayText, displayTextSuffix, rules, roslynGlyph, description, sortText, filterText, showsWarningIcon, properties, tags, inlineDescription); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionProvider.cs b/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionProvider.cs new file mode 100644 index 0000000000000..01550453a9e00 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionProvider.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Completion; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion +{ + internal static class FSharpCommonCompletionProvider + { + public static CompletionProvider Create(IFSharpCommonCompletionProvider fsharpCommonCompletionProvider) + { + return new FSharpInternalCommonCompletionProvider(fsharpCommonCompletionProvider); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionUtilities.cs b/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionUtilities.cs new file mode 100644 index 0000000000000..5a9bb1f58b259 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Completion/FSharpCommonCompletionUtilities.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion +{ + internal static class FSharpCommonCompletionUtilities + { + public static bool IsStartingNewWord(SourceText text, int characterPosition, Func isWordStartCharacter, Func isWordCharacter) + { + return CommonCompletionUtilities.IsStartingNewWord(text, characterPosition, isWordStartCharacter, isWordCharacter); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Completion/FSharpFileSystemCompletionHelper.cs b/src/Tools/ExternalAccess/FSharp/Completion/FSharpFileSystemCompletionHelper.cs new file mode 100644 index 0000000000000..a9e4f83161b37 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Completion/FSharpFileSystemCompletionHelper.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion +{ + internal class FSharpFileSystemCompletionHelper + { + private readonly FileSystemCompletionHelper _fileSystemCompletionHelper; + + public FSharpFileSystemCompletionHelper( + FSharpGlyph folderGlyph, + FSharpGlyph fileGlyph, + ImmutableArray searchPaths, + string baseDirectoryOpt, + ImmutableArray allowableExtensions, + CompletionItemRules itemRules) + { + _fileSystemCompletionHelper = + new FileSystemCompletionHelper( + FSharpGlyphHelpers.ConvertTo(folderGlyph), + FSharpGlyphHelpers.ConvertTo(fileGlyph), + searchPaths, + baseDirectoryOpt, + allowableExtensions, + itemRules); + } + + public Task> GetItemsAsync(string directoryPath, CancellationToken cancellationToken) + { + return _fileSystemCompletionHelper.GetItemsAsync(directoryPath, cancellationToken); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Completion/FSharpInternalCommonCompletionProvider.cs b/src/Tools/ExternalAccess/FSharp/Completion/FSharpInternalCommonCompletionProvider.cs new file mode 100644 index 0000000000000..768a6cef675bc --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Completion/FSharpInternalCommonCompletionProvider.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Completion +{ + internal sealed class FSharpInternalCommonCompletionProvider : CommonCompletionProvider + { + private readonly IFSharpCommonCompletionProvider _provider; + + public FSharpInternalCommonCompletionProvider(IFSharpCommonCompletionProvider provider) + { + _provider = provider; + } + + public override Task ProvideCompletionsAsync(CompletionContext context) + { + return _provider.ProvideCompletionsAsync(context); + } + + protected override Task GetTextChangeAsync(CompletionItem selectedItem, char? ch, CancellationToken cancellationToken) + { + return _provider.GetTextChangeAsync(base.GetTextChangeAsync, selectedItem, ch, cancellationToken); + } + + internal override bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, OptionSet options) + { + return _provider.IsInsertionTrigger(text, insertedCharacterPosition, options); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Completion/IFSharpCommonCompletionProvider.cs b/src/Tools/ExternalAccess/FSharp/Completion/IFSharpCommonCompletionProvider.cs new file mode 100644 index 0000000000000..b2333e8c54003 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Completion/IFSharpCommonCompletionProvider.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Completion +{ + internal interface IFSharpCommonCompletionProvider + { + Task ProvideCompletionsAsync(CompletionContext context); + + bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, OptionSet options); + + Task GetTextChangeAsync( + Func> baseGetTextChangeAsync, + CompletionItem selectedItem, + char? ch, + CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpContentTypeNames.cs b/src/Tools/ExternalAccess/FSharp/Editor/FSharpContentTypeNames.cs index 93fe0fe63205b..10c753731b1d2 100644 --- a/src/Tools/ExternalAccess/FSharp/Editor/FSharpContentTypeNames.cs +++ b/src/Tools/ExternalAccess/FSharp/Editor/FSharpContentTypeNames.cs @@ -6,5 +6,6 @@ internal static class FSharpContentTypeNames { public const string RoslynContentType = Microsoft.CodeAnalysis.Editor.ContentTypeNames.RoslynContentType; public const string FSharpContentType = "F#"; + public const string FSharpSignatureHelpContentType = "F# Signature Help"; } } diff --git a/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpers.cs b/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpers.cs index 2f1f1a17d7201..2577bfc438799 100644 --- a/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpers.cs @@ -1,8 +1,8 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal { - internal static class GlyphHelpers + internal static class FSharpGlyphHelpers { - public static FSharpGlyph Convert(Microsoft.CodeAnalysis.Glyph glyph) + public static FSharpGlyph ConvertFrom(Microsoft.CodeAnalysis.Glyph glyph) { switch (glyph) { @@ -312,5 +312,316 @@ public static FSharpGlyph Convert(Microsoft.CodeAnalysis.Glyph glyph) } } } + + public static Microsoft.CodeAnalysis.Glyph ConvertTo(FSharpGlyph glyph) + { + switch (glyph) + { + case FSharpGlyph.None: + { + return Microsoft.CodeAnalysis.Glyph.None; + } + case FSharpGlyph.Assembly: + { + return Microsoft.CodeAnalysis.Glyph.Assembly; + } + case FSharpGlyph.BasicFile: + { + return Microsoft.CodeAnalysis.Glyph.BasicFile; + } + case FSharpGlyph.BasicProject: + { + return Microsoft.CodeAnalysis.Glyph.BasicProject; + } + case FSharpGlyph.ClassPublic: + { + return Microsoft.CodeAnalysis.Glyph.ClassPublic; + } + case FSharpGlyph.ClassProtected: + { + return Microsoft.CodeAnalysis.Glyph.ClassProtected; + } + case FSharpGlyph.ClassPrivate: + { + return Microsoft.CodeAnalysis.Glyph.ClassPrivate; + } + case FSharpGlyph.ClassInternal: + { + return Microsoft.CodeAnalysis.Glyph.ClassInternal; + } + case FSharpGlyph.CSharpFile: + { + return Microsoft.CodeAnalysis.Glyph.CSharpFile; + } + case FSharpGlyph.CSharpProject: + { + return Microsoft.CodeAnalysis.Glyph.CSharpProject; + } + case FSharpGlyph.ConstantPublic: + { + return Microsoft.CodeAnalysis.Glyph.ConstantPublic; + } + case FSharpGlyph.ConstantProtected: + { + return Microsoft.CodeAnalysis.Glyph.ConstantProtected; + } + case FSharpGlyph.ConstantPrivate: + { + return Microsoft.CodeAnalysis.Glyph.ConstantPrivate; + } + case FSharpGlyph.ConstantInternal: + { + return Microsoft.CodeAnalysis.Glyph.ConstantInternal; + } + case FSharpGlyph.DelegatePublic: + { + return Microsoft.CodeAnalysis.Glyph.DelegatePublic; + } + case FSharpGlyph.DelegateProtected: + { + return Microsoft.CodeAnalysis.Glyph.DelegateProtected; + } + case FSharpGlyph.DelegatePrivate: + { + return Microsoft.CodeAnalysis.Glyph.DelegatePrivate; + } + case FSharpGlyph.DelegateInternal: + { + return Microsoft.CodeAnalysis.Glyph.DelegateInternal; + } + case FSharpGlyph.EnumPublic: + { + return Microsoft.CodeAnalysis.Glyph.EnumPublic; + } + case FSharpGlyph.EnumProtected: + { + return Microsoft.CodeAnalysis.Glyph.EnumProtected; + } + case FSharpGlyph.EnumPrivate: + { + return Microsoft.CodeAnalysis.Glyph.EnumPrivate; + } + case FSharpGlyph.EnumInternal: + { + return Microsoft.CodeAnalysis.Glyph.EnumInternal; + } + case FSharpGlyph.EnumMemberPublic: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberPublic; + } + case FSharpGlyph.EnumMemberProtected: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberProtected; + } + case FSharpGlyph.EnumMemberPrivate: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberPrivate; + } + case FSharpGlyph.EnumMemberInternal: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberInternal; + } + case FSharpGlyph.Error: + { + return Microsoft.CodeAnalysis.Glyph.Error; + } + case FSharpGlyph.StatusInformation: + { + return Microsoft.CodeAnalysis.Glyph.StatusInformation; + } + case FSharpGlyph.EventPublic: + { + return Microsoft.CodeAnalysis.Glyph.EventPublic; + } + case FSharpGlyph.EventProtected: + { + return Microsoft.CodeAnalysis.Glyph.EventProtected; + } + case FSharpGlyph.EventPrivate: + { + return Microsoft.CodeAnalysis.Glyph.EventPrivate; + } + case FSharpGlyph.EventInternal: + { + return Microsoft.CodeAnalysis.Glyph.EventInternal; + } + case FSharpGlyph.ExtensionMethodPublic: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodPublic; + } + case FSharpGlyph.ExtensionMethodProtected: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodProtected; + } + case FSharpGlyph.ExtensionMethodPrivate: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodPrivate; + } + case FSharpGlyph.ExtensionMethodInternal: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodInternal; + } + case FSharpGlyph.FieldPublic: + { + return Microsoft.CodeAnalysis.Glyph.FieldPublic; + } + case FSharpGlyph.FieldProtected: + { + return Microsoft.CodeAnalysis.Glyph.FieldProtected; + } + case FSharpGlyph.FieldPrivate: + { + return Microsoft.CodeAnalysis.Glyph.FieldPrivate; + } + case FSharpGlyph.FieldInternal: + { + return Microsoft.CodeAnalysis.Glyph.FieldInternal; + } + case FSharpGlyph.InterfacePublic: + { + return Microsoft.CodeAnalysis.Glyph.InterfacePublic; + } + case FSharpGlyph.InterfaceProtected: + { + return Microsoft.CodeAnalysis.Glyph.InterfaceProtected; + } + case FSharpGlyph.InterfacePrivate: + { + return Microsoft.CodeAnalysis.Glyph.InterfacePrivate; + } + case FSharpGlyph.InterfaceInternal: + { + return Microsoft.CodeAnalysis.Glyph.InterfaceInternal; + } + case FSharpGlyph.Intrinsic: + { + return Microsoft.CodeAnalysis.Glyph.Intrinsic; + } + case FSharpGlyph.Keyword: + { + return Microsoft.CodeAnalysis.Glyph.Keyword; + } + case FSharpGlyph.Label: + { + return Microsoft.CodeAnalysis.Glyph.Label; + } + case FSharpGlyph.Local: + { + return Microsoft.CodeAnalysis.Glyph.Local; + } + case FSharpGlyph.Namespace: + { + return Microsoft.CodeAnalysis.Glyph.Namespace; + } + case FSharpGlyph.MethodPublic: + { + return Microsoft.CodeAnalysis.Glyph.MethodPublic; + } + case FSharpGlyph.MethodProtected: + { + return Microsoft.CodeAnalysis.Glyph.MethodProtected; + } + case FSharpGlyph.MethodPrivate: + { + return Microsoft.CodeAnalysis.Glyph.MethodPrivate; + } + case FSharpGlyph.MethodInternal: + { + return Microsoft.CodeAnalysis.Glyph.MethodInternal; + } + case FSharpGlyph.ModulePublic: + { + return Microsoft.CodeAnalysis.Glyph.ModulePublic; + } + case FSharpGlyph.ModuleProtected: + { + return Microsoft.CodeAnalysis.Glyph.ModuleProtected; + } + case FSharpGlyph.ModulePrivate: + { + return Microsoft.CodeAnalysis.Glyph.ModulePrivate; + } + case FSharpGlyph.ModuleInternal: + { + return Microsoft.CodeAnalysis.Glyph.ModuleInternal; + } + case FSharpGlyph.OpenFolder: + { + return Microsoft.CodeAnalysis.Glyph.OpenFolder; + } + case FSharpGlyph.Operator: + { + return Microsoft.CodeAnalysis.Glyph.Operator; + } + case FSharpGlyph.Parameter: + { + return Microsoft.CodeAnalysis.Glyph.Parameter; + } + case FSharpGlyph.PropertyPublic: + { + return Microsoft.CodeAnalysis.Glyph.PropertyPublic; + } + case FSharpGlyph.PropertyProtected: + { + return Microsoft.CodeAnalysis.Glyph.PropertyProtected; + } + case FSharpGlyph.PropertyPrivate: + { + return Microsoft.CodeAnalysis.Glyph.PropertyPrivate; + } + case FSharpGlyph.PropertyInternal: + { + return Microsoft.CodeAnalysis.Glyph.PropertyInternal; + } + case FSharpGlyph.RangeVariable: + { + return Microsoft.CodeAnalysis.Glyph.RangeVariable; + } + case FSharpGlyph.Reference: + { + return Microsoft.CodeAnalysis.Glyph.Reference; + } + case FSharpGlyph.StructurePublic: + { + return Microsoft.CodeAnalysis.Glyph.StructurePublic; + } + case FSharpGlyph.StructureProtected: + { + return Microsoft.CodeAnalysis.Glyph.StructureProtected; + } + case FSharpGlyph.StructurePrivate: + { + return Microsoft.CodeAnalysis.Glyph.StructurePrivate; + } + case FSharpGlyph.StructureInternal: + { + return Microsoft.CodeAnalysis.Glyph.StructureInternal; + } + case FSharpGlyph.TypeParameter: + { + return Microsoft.CodeAnalysis.Glyph.TypeParameter; + } + case FSharpGlyph.Snippet: + { + return Microsoft.CodeAnalysis.Glyph.Snippet; + } + case FSharpGlyph.CompletionWarning: + { + return Microsoft.CodeAnalysis.Glyph.CompletionWarning; + } + case FSharpGlyph.AddReference: + { + return Microsoft.CodeAnalysis.Glyph.AddReference; + } + case FSharpGlyph.NuGet: + { + return Microsoft.CodeAnalysis.Glyph.NuGet; + } + default: + { + return Microsoft.CodeAnalysis.Glyph.None; + } + } + } } } diff --git a/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpersObsolete.cs b/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpersObsolete.cs deleted file mode 100644 index 79d013b7bb133..0000000000000 --- a/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpersObsolete.cs +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp -{ - internal static class FSharpGlyphHelpersObsolete - { - [Obsolete("Only used to allow IVTs to work temporarily, will be removed when IVTs are fully removed.")] - public static Microsoft.CodeAnalysis.Glyph Convert(FSharpGlyph glyph) - { - switch (glyph) - { - case FSharpGlyph.None: - { - return Microsoft.CodeAnalysis.Glyph.None; - } - case FSharpGlyph.Assembly: - { - return Microsoft.CodeAnalysis.Glyph.Assembly; - } - case FSharpGlyph.BasicFile: - { - return Microsoft.CodeAnalysis.Glyph.BasicFile; - } - case FSharpGlyph.BasicProject: - { - return Microsoft.CodeAnalysis.Glyph.BasicProject; - } - case FSharpGlyph.ClassPublic: - { - return Microsoft.CodeAnalysis.Glyph.ClassPublic; - } - case FSharpGlyph.ClassProtected: - { - return Microsoft.CodeAnalysis.Glyph.ClassProtected; - } - case FSharpGlyph.ClassPrivate: - { - return Microsoft.CodeAnalysis.Glyph.ClassPrivate; - } - case FSharpGlyph.ClassInternal: - { - return Microsoft.CodeAnalysis.Glyph.ClassInternal; - } - case FSharpGlyph.CSharpFile: - { - return Microsoft.CodeAnalysis.Glyph.CSharpFile; - } - case FSharpGlyph.CSharpProject: - { - return Microsoft.CodeAnalysis.Glyph.CSharpProject; - } - case FSharpGlyph.ConstantPublic: - { - return Microsoft.CodeAnalysis.Glyph.ConstantPublic; - } - case FSharpGlyph.ConstantProtected: - { - return Microsoft.CodeAnalysis.Glyph.ConstantProtected; - } - case FSharpGlyph.ConstantPrivate: - { - return Microsoft.CodeAnalysis.Glyph.ConstantPrivate; - } - case FSharpGlyph.ConstantInternal: - { - return Microsoft.CodeAnalysis.Glyph.ConstantInternal; - } - case FSharpGlyph.DelegatePublic: - { - return Microsoft.CodeAnalysis.Glyph.DelegatePublic; - } - case FSharpGlyph.DelegateProtected: - { - return Microsoft.CodeAnalysis.Glyph.DelegateProtected; - } - case FSharpGlyph.DelegatePrivate: - { - return Microsoft.CodeAnalysis.Glyph.DelegatePrivate; - } - case FSharpGlyph.DelegateInternal: - { - return Microsoft.CodeAnalysis.Glyph.DelegateInternal; - } - case FSharpGlyph.EnumPublic: - { - return Microsoft.CodeAnalysis.Glyph.EnumPublic; - } - case FSharpGlyph.EnumProtected: - { - return Microsoft.CodeAnalysis.Glyph.EnumProtected; - } - case FSharpGlyph.EnumPrivate: - { - return Microsoft.CodeAnalysis.Glyph.EnumPrivate; - } - case FSharpGlyph.EnumInternal: - { - return Microsoft.CodeAnalysis.Glyph.EnumInternal; - } - case FSharpGlyph.EnumMemberPublic: - { - return Microsoft.CodeAnalysis.Glyph.EnumMemberPublic; - } - case FSharpGlyph.EnumMemberProtected: - { - return Microsoft.CodeAnalysis.Glyph.EnumMemberProtected; - } - case FSharpGlyph.EnumMemberPrivate: - { - return Microsoft.CodeAnalysis.Glyph.EnumMemberPrivate; - } - case FSharpGlyph.EnumMemberInternal: - { - return Microsoft.CodeAnalysis.Glyph.EnumMemberInternal; - } - case FSharpGlyph.Error: - { - return Microsoft.CodeAnalysis.Glyph.Error; - } - case FSharpGlyph.StatusInformation: - { - return Microsoft.CodeAnalysis.Glyph.StatusInformation; - } - case FSharpGlyph.EventPublic: - { - return Microsoft.CodeAnalysis.Glyph.EventPublic; - } - case FSharpGlyph.EventProtected: - { - return Microsoft.CodeAnalysis.Glyph.EventProtected; - } - case FSharpGlyph.EventPrivate: - { - return Microsoft.CodeAnalysis.Glyph.EventPrivate; - } - case FSharpGlyph.EventInternal: - { - return Microsoft.CodeAnalysis.Glyph.EventInternal; - } - case FSharpGlyph.ExtensionMethodPublic: - { - return Microsoft.CodeAnalysis.Glyph.ExtensionMethodPublic; - } - case FSharpGlyph.ExtensionMethodProtected: - { - return Microsoft.CodeAnalysis.Glyph.ExtensionMethodProtected; - } - case FSharpGlyph.ExtensionMethodPrivate: - { - return Microsoft.CodeAnalysis.Glyph.ExtensionMethodPrivate; - } - case FSharpGlyph.ExtensionMethodInternal: - { - return Microsoft.CodeAnalysis.Glyph.ExtensionMethodInternal; - } - case FSharpGlyph.FieldPublic: - { - return Microsoft.CodeAnalysis.Glyph.FieldPublic; - } - case FSharpGlyph.FieldProtected: - { - return Microsoft.CodeAnalysis.Glyph.FieldProtected; - } - case FSharpGlyph.FieldPrivate: - { - return Microsoft.CodeAnalysis.Glyph.FieldPrivate; - } - case FSharpGlyph.FieldInternal: - { - return Microsoft.CodeAnalysis.Glyph.FieldInternal; - } - case FSharpGlyph.InterfacePublic: - { - return Microsoft.CodeAnalysis.Glyph.InterfacePublic; - } - case FSharpGlyph.InterfaceProtected: - { - return Microsoft.CodeAnalysis.Glyph.InterfaceProtected; - } - case FSharpGlyph.InterfacePrivate: - { - return Microsoft.CodeAnalysis.Glyph.InterfacePrivate; - } - case FSharpGlyph.InterfaceInternal: - { - return Microsoft.CodeAnalysis.Glyph.InterfaceInternal; - } - case FSharpGlyph.Intrinsic: - { - return Microsoft.CodeAnalysis.Glyph.Intrinsic; - } - case FSharpGlyph.Keyword: - { - return Microsoft.CodeAnalysis.Glyph.Keyword; - } - case FSharpGlyph.Label: - { - return Microsoft.CodeAnalysis.Glyph.Label; - } - case FSharpGlyph.Local: - { - return Microsoft.CodeAnalysis.Glyph.Local; - } - case FSharpGlyph.Namespace: - { - return Microsoft.CodeAnalysis.Glyph.Namespace; - } - case FSharpGlyph.MethodPublic: - { - return Microsoft.CodeAnalysis.Glyph.MethodPublic; - } - case FSharpGlyph.MethodProtected: - { - return Microsoft.CodeAnalysis.Glyph.MethodProtected; - } - case FSharpGlyph.MethodPrivate: - { - return Microsoft.CodeAnalysis.Glyph.MethodPrivate; - } - case FSharpGlyph.MethodInternal: - { - return Microsoft.CodeAnalysis.Glyph.MethodInternal; - } - case FSharpGlyph.ModulePublic: - { - return Microsoft.CodeAnalysis.Glyph.ModulePublic; - } - case FSharpGlyph.ModuleProtected: - { - return Microsoft.CodeAnalysis.Glyph.ModuleProtected; - } - case FSharpGlyph.ModulePrivate: - { - return Microsoft.CodeAnalysis.Glyph.ModulePrivate; - } - case FSharpGlyph.ModuleInternal: - { - return Microsoft.CodeAnalysis.Glyph.ModuleInternal; - } - case FSharpGlyph.OpenFolder: - { - return Microsoft.CodeAnalysis.Glyph.OpenFolder; - } - case FSharpGlyph.Operator: - { - return Microsoft.CodeAnalysis.Glyph.Operator; - } - case FSharpGlyph.Parameter: - { - return Microsoft.CodeAnalysis.Glyph.Parameter; - } - case FSharpGlyph.PropertyPublic: - { - return Microsoft.CodeAnalysis.Glyph.PropertyPublic; - } - case FSharpGlyph.PropertyProtected: - { - return Microsoft.CodeAnalysis.Glyph.PropertyProtected; - } - case FSharpGlyph.PropertyPrivate: - { - return Microsoft.CodeAnalysis.Glyph.PropertyPrivate; - } - case FSharpGlyph.PropertyInternal: - { - return Microsoft.CodeAnalysis.Glyph.PropertyInternal; - } - case FSharpGlyph.RangeVariable: - { - return Microsoft.CodeAnalysis.Glyph.RangeVariable; - } - case FSharpGlyph.Reference: - { - return Microsoft.CodeAnalysis.Glyph.Reference; - } - case FSharpGlyph.StructurePublic: - { - return Microsoft.CodeAnalysis.Glyph.StructurePublic; - } - case FSharpGlyph.StructureProtected: - { - return Microsoft.CodeAnalysis.Glyph.StructureProtected; - } - case FSharpGlyph.StructurePrivate: - { - return Microsoft.CodeAnalysis.Glyph.StructurePrivate; - } - case FSharpGlyph.StructureInternal: - { - return Microsoft.CodeAnalysis.Glyph.StructureInternal; - } - case FSharpGlyph.TypeParameter: - { - return Microsoft.CodeAnalysis.Glyph.TypeParameter; - } - case FSharpGlyph.Snippet: - { - return Microsoft.CodeAnalysis.Glyph.Snippet; - } - case FSharpGlyph.CompletionWarning: - { - return Microsoft.CodeAnalysis.Glyph.CompletionWarning; - } - case FSharpGlyph.AddReference: - { - return Microsoft.CodeAnalysis.Glyph.AddReference; - } - case FSharpGlyph.NuGet: - { - return Microsoft.CodeAnalysis.Glyph.NuGet; - } - default: - { - return Microsoft.CodeAnalysis.Glyph.None; - } - } - } - } -} diff --git a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj index c0599fa40be40..ddd66fe4c293a 100644 --- a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj +++ b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj @@ -21,6 +21,7 @@ --> + @@ -80,4 +81,19 @@ + + + True + True + ExternalAccessFSharpResources.resx + + + + + + ResXFileCodeGenerator + ExternalAccessFSharpResources.Designer.cs + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItem.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItem.cs new file mode 100644 index 0000000000000..69d2519335b7e --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItem.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp +{ + internal class FSharpSignatureHelpItem + { + /// + /// True if this signature help item can have an unbounded number of arguments passed to it. + /// If it is variadic then the last parameter will be considered selected, even if the + /// selected parameter index strictly goes past the number of defined parameters for this + /// item. + /// + public bool IsVariadic { get; } + + public ImmutableArray PrefixDisplayParts { get; } + public ImmutableArray SuffixDisplayParts { get; } + + // TODO: This probably won't be sufficient for VB query signature help. It has + // arbitrary separators between parameters. + public ImmutableArray SeparatorDisplayParts { get; } + + public ImmutableArray Parameters { get; } + + public ImmutableArray DescriptionParts { get; internal set; } + + public Func> DocumentationFactory { get; } + + private static readonly Func> s_emptyDocumentationFactory = + _ => SpecializedCollections.EmptyEnumerable(); + + public FSharpSignatureHelpItem( + bool isVariadic, + Func> documentationFactory, + IEnumerable prefixParts, + IEnumerable separatorParts, + IEnumerable suffixParts, + IEnumerable parameters, + IEnumerable descriptionParts) + { + if (isVariadic && !parameters.Any()) + { + throw new ArgumentException(FeaturesResources.Variadic_SignatureHelpItem_must_have_at_least_one_parameter); + } + + this.IsVariadic = isVariadic; + this.DocumentationFactory = documentationFactory ?? s_emptyDocumentationFactory; + this.PrefixDisplayParts = prefixParts.ToImmutableArrayOrEmpty(); + this.SeparatorDisplayParts = separatorParts.ToImmutableArrayOrEmpty(); + this.SuffixDisplayParts = suffixParts.ToImmutableArrayOrEmpty(); + this.Parameters = parameters.ToImmutableArrayOrEmpty(); + this.DescriptionParts = descriptionParts.ToImmutableArrayOrEmpty(); + } + + internal IEnumerable GetAllParts() + { + return + PrefixDisplayParts.Concat( + SeparatorDisplayParts.Concat( + SuffixDisplayParts.Concat( + Parameters.SelectMany(p => p.GetAllParts())).Concat( + DescriptionParts))); + } + + public override string ToString() + { + var prefix = string.Concat(PrefixDisplayParts); + var suffix = string.Concat(SuffixDisplayParts); + var parameters = string.Join(string.Concat(SeparatorDisplayParts), Parameters); + var description = string.Concat(DescriptionParts); + return string.Concat(prefix, parameters, suffix, description); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItems.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItems.cs new file mode 100644 index 0000000000000..3735db23c0d02 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpItems.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Microsoft.CodeAnalysis.Text; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp +{ + internal class FSharpSignatureHelpItems + { + /// + /// The list of items to present to the user. + /// + public IList Items { get; } + + /// + /// The span this session applies to. + /// + /// Navigation outside this span will cause signature help to be dismissed. + /// + public TextSpan ApplicableSpan { get; } + + /// + /// Returns the specified argument index that the provided position is at in the current document. This + /// index may be greater than the number of arguments in the selected . + /// + public int ArgumentIndex { get; } + + /// + /// Returns the total number of arguments that have been typed in the current document. This may be + /// greater than the ArgumentIndex if there are additional arguments after the provided position. + /// + public int ArgumentCount { get; } + + /// + /// Returns the name of specified argument at the current position in the document. + /// This only applies to languages that allow the user to provide named arguments. + /// If no named argument exists at the current position, then null should be returned. + /// + /// This value is used to determine which documentation comment should be provided for the current + /// parameter. Normally this is determined simply by determining the parameter by index. + /// + public string ArgumentName { get; } + + /// + /// The item to select by default. If this is then the controller will + /// pick the first item that has enough arguments to be viable based on what argument + /// position the user is currently inside of. + /// + public int? SelectedItemIndex { get; } + + public FSharpSignatureHelpItems( + IList items, + TextSpan applicableSpan, + int argumentIndex, + int argumentCount, + string argumentName, + int? selectedItem = null) + { + Contract.ThrowIfNull(items); + Contract.ThrowIfTrue(items.IsEmpty()); + Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value >= items.Count); + + if (argumentIndex < 0) + { + throw new ArgumentException($"{nameof(argumentIndex)} < 0. {argumentIndex} < 0", nameof(argumentIndex)); + } + + if (argumentCount < argumentIndex) + { + throw new ArgumentException($"{nameof(argumentCount)} < {nameof(argumentIndex)}. {argumentCount} < {argumentIndex}", nameof(argumentIndex)); + } + + // Adjust the `selectedItem` index if duplicates are able to be removed. + var distinctItems = items.Distinct().ToList(); + if (selectedItem.HasValue && items.Count != distinctItems.Count) + { + // `selectedItem` index has already been determined to be valid, it now needs to be adjusted to point + // to the equivalent item in the reduced list to account for duplicates being removed + // E.g., + // items = {A, A, B, B, C, D} + // selectedItem = 4 (index for item C) + // ergo + // distinctItems = {A, B, C, D} + // actualItem = C + // selectedItem = 2 (index for item C) + var actualItem = items[selectedItem.Value]; + selectedItem = distinctItems.IndexOf(actualItem); + Debug.Assert(selectedItem.Value >= 0, "actual item was not part of the final list"); + } + + this.Items = distinctItems; + this.ApplicableSpan = applicableSpan; + this.ArgumentIndex = argumentIndex; + this.ArgumentCount = argumentCount; + this.SelectedItemIndex = selectedItem; + this.ArgumentName = argumentName; + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpParameter.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpParameter.cs new file mode 100644 index 0000000000000..78965b2d4f956 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpParameter.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp +{ + internal class FSharpSignatureHelpParameter + { + /// + /// The name of this parameter. + /// + public string Name { get; } + + /// + /// Documentation for this parameter. This should normally be presented to the user when + /// this parameter is selected. + /// + public Func> DocumentationFactory { get; } + + /// + /// Display parts to show before the normal display parts for the parameter. + /// + public IList PrefixDisplayParts { get; } + + /// + /// Display parts to show after the normal display parts for the parameter. + /// + public IList SuffixDisplayParts { get; } + + /// + /// Display parts for this parameter. This should normally be presented to the user as part + /// of the entire signature display. + /// + public IList DisplayParts { get; } + + /// + /// True if this parameter is optional or not. Optional parameters may be presented in a + /// different manner to users. + /// + public bool IsOptional { get; } + + /// + /// Display parts for this parameter that should be presented to the user when this + /// parameter is selected. + /// + public IList SelectedDisplayParts { get; } + + private static readonly Func> s_emptyDocumentationFactory = + _ => SpecializedCollections.EmptyEnumerable(); + + public FSharpSignatureHelpParameter( + string name, + bool isOptional, + Func> documentationFactory, + IEnumerable displayParts, + IEnumerable prefixDisplayParts = null, + IEnumerable suffixDisplayParts = null, + IEnumerable selectedDisplayParts = null) + { + this.Name = name ?? string.Empty; + this.IsOptional = isOptional; + this.DocumentationFactory = documentationFactory ?? s_emptyDocumentationFactory; + this.DisplayParts = displayParts.ToImmutableArrayOrEmpty(); + this.PrefixDisplayParts = prefixDisplayParts.ToImmutableArrayOrEmpty(); + this.SuffixDisplayParts = suffixDisplayParts.ToImmutableArrayOrEmpty(); + this.SelectedDisplayParts = selectedDisplayParts.ToImmutableArrayOrEmpty(); + } + + internal IEnumerable GetAllParts() + { + return this.PrefixDisplayParts.Concat(this.DisplayParts) + .Concat(this.SuffixDisplayParts) + .Concat(this.SelectedDisplayParts); + } + + public override string ToString() + { + var prefix = string.Concat(PrefixDisplayParts); + var display = string.Concat(DisplayParts); + var suffix = string.Concat(SuffixDisplayParts); + return string.Concat(prefix, display, suffix); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpProvider.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpProvider.cs new file mode 100644 index 0000000000000..81966279da109 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpProvider.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.SignatureHelp; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp +{ + [Shared] + [ExportSignatureHelpProvider("FSharpSignatureHelpProvider", LanguageNames.FSharp)] + internal class FSharpSignatureHelpProvider : ISignatureHelpProvider + { + private readonly IFSharpSignatureHelpProvider _provider; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpSignatureHelpProvider(IFSharpSignatureHelpProvider provider) + { + _provider = provider; + } + + public async Task GetItemsAsync(Document document, int position, SignatureHelpTriggerInfo triggerInfo, CancellationToken cancellationToken) + { + var mappedTriggerReason = FSharpSignatureHelpTriggerReasonHelpers.ConvertFrom(triggerInfo.TriggerReason); + var mappedTriggerInfo = new FSharpSignatureHelpTriggerInfo(mappedTriggerReason, triggerInfo.TriggerCharacter); + var mappedSignatureHelpItems = await _provider.GetItemsAsync(document, position, mappedTriggerInfo, cancellationToken).ConfigureAwait(false); + + return new SignatureHelpItems( + mappedSignatureHelpItems.Items.Select(x => + new SignatureHelpItem( + x.IsVariadic, + x.DocumentationFactory, + x.PrefixDisplayParts, + x.SeparatorDisplayParts, + x.SuffixDisplayParts, + x.Parameters.Select(y => + new SignatureHelpParameter( + y.Name, + y.IsOptional, + y.DocumentationFactory, + y.DisplayParts, + y.PrefixDisplayParts, + y.SuffixDisplayParts, + y.SelectedDisplayParts)).ToList(), + x.DescriptionParts)).ToList(), + mappedSignatureHelpItems.ApplicableSpan, + mappedSignatureHelpItems.ArgumentIndex, + mappedSignatureHelpItems.ArgumentCount, + mappedSignatureHelpItems.ArgumentName, + mappedSignatureHelpItems.SelectedItemIndex); + } + + public bool IsRetriggerCharacter(char ch) + { + return _provider.IsRetriggerCharacter(ch); + } + + public bool IsTriggerCharacter(char ch) + { + return _provider.IsTriggerCharacter(ch); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs new file mode 100644 index 0000000000000..9e60088578e04 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp +{ + internal readonly struct FSharpSignatureHelpTriggerInfo + { + public FSharpSignatureHelpTriggerReason TriggerReason { get; } + public char? TriggerCharacter { get; } + + internal FSharpSignatureHelpTriggerInfo(FSharpSignatureHelpTriggerReason triggerReason, char? triggerCharacter = null) + : this() + { + Contract.ThrowIfTrue(triggerReason == FSharpSignatureHelpTriggerReason.TypeCharCommand && triggerCharacter == null); + this.TriggerReason = triggerReason; + this.TriggerCharacter = triggerCharacter; + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReason.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReason.cs new file mode 100644 index 0000000000000..f1b78cd2832d1 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReason.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp +{ + internal enum FSharpSignatureHelpTriggerReason + { + /// + /// Signature Help was triggered through the 'Invoke Signature Help' command + /// + InvokeSignatureHelpCommand, + + /// + /// Signature Help was triggered through the 'Type Char' command. + /// + TypeCharCommand, + + /// + /// Signature Help was triggered through typing a closing brace. + /// + RetriggerCommand, + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs new file mode 100644 index 0000000000000..ca79ca9e3eac5 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp; +using Microsoft.CodeAnalysis.SignatureHelp; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp +{ + internal static class FSharpSignatureHelpTriggerReasonHelpers + { + public static FSharpSignatureHelpTriggerReason ConvertFrom(SignatureHelpTriggerReason triggerReason) + { + switch (triggerReason) + { + case SignatureHelpTriggerReason.InvokeSignatureHelpCommand: + { + return FSharpSignatureHelpTriggerReason.InvokeSignatureHelpCommand; + } + + case SignatureHelpTriggerReason.RetriggerCommand: + { + return FSharpSignatureHelpTriggerReason.RetriggerCommand; + } + + case SignatureHelpTriggerReason.TypeCharCommand: + { + return FSharpSignatureHelpTriggerReason.TypeCharCommand; + } + + default: + throw new InvalidOperationException(); + } + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/IFSharpSignatureHelpProvider.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/IFSharpSignatureHelpProvider.cs new file mode 100644 index 0000000000000..f773211bc8e63 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/IFSharpSignatureHelpProvider.cs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp +{ + internal interface IFSharpSignatureHelpProvider + { + /// + /// Returns true if the character might trigger completion, + /// e.g. '(' and ',' for method invocations + /// + bool IsTriggerCharacter(char ch); + + /// + /// Returns true if the character might end a Signature Help session, + /// e.g. ')' for method invocations. + /// + bool IsRetriggerCharacter(char ch); + + /// + /// Returns valid signature help items at the specified position in the document. + /// + Task GetItemsAsync(Document document, int position, FSharpSignatureHelpTriggerInfo triggerInfo, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs b/src/Tools/ExternalAccess/FSharp/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs new file mode 100644 index 0000000000000..96b5da8bb62ae --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.ComponentModel.Composition; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.VisualStudio.Utilities; +using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.VisualStudio.Text; +using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHelp.Presentation; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.VisualStudio.Text.Classification +{ + [Export(typeof(IClassifierProvider))] + [ContentType(FSharpContentTypeNames.FSharpSignatureHelpContentType)] + internal class FSharpSignatureHelpClassifierProvider : IClassifierProvider + { + private readonly ClassificationTypeMap _typeMap; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpSignatureHelpClassifierProvider(ClassificationTypeMap typeMap) + { + _typeMap = typeMap; + } + + public IClassifier GetClassifier(ITextBuffer textBuffer) + { + return new SignatureHelpClassifier(textBuffer, _typeMap); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs new file mode 100644 index 0000000000000..f204f68431ad6 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp; +using Microsoft.CodeAnalysis.SignatureHelp; +using Xunit; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests +{ + public class FSharpSignatureHelpTriggerReasonTests + { + public static IEnumerable enumValues() + { + foreach (var number in Enum.GetValues(typeof(SignatureHelpTriggerReason))) + { + yield return new object[] { number }; + } + } + + internal static FSharpSignatureHelpTriggerReason GetExpectedTriggerReason(SignatureHelpTriggerReason triggerReason) + { + switch (triggerReason) + { + case SignatureHelpTriggerReason.InvokeSignatureHelpCommand: + { + return FSharpSignatureHelpTriggerReason.InvokeSignatureHelpCommand; + } + + case SignatureHelpTriggerReason.RetriggerCommand: + { + return FSharpSignatureHelpTriggerReason.RetriggerCommand; + } + + case SignatureHelpTriggerReason.TypeCharCommand: + { + return FSharpSignatureHelpTriggerReason.TypeCharCommand; + } + + default: + throw new InvalidOperationException(); + } + } + + [Theory] + [MemberData(nameof(enumValues))] + internal void MapsCorrectly(SignatureHelpTriggerReason triggerReason) + { + var actual = FSharpSignatureHelpTriggerReasonHelpers.ConvertFrom(triggerReason); + var expected = GetExpectedTriggerReason(triggerReason); + Assert.Equal(expected, actual); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj b/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj new file mode 100644 index 0000000000000..b5b343aee3579 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj @@ -0,0 +1,39 @@ + + + + + Library + Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests + net472 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj index d3012f6a1d670..7b4f5286b9f25 100644 --- a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj +++ b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj @@ -114,6 +114,7 @@ + diff --git a/src/VisualStudio/Core/Impl/Microsoft.VisualStudio.LanguageServices.Implementation.csproj b/src/VisualStudio/Core/Impl/Microsoft.VisualStudio.LanguageServices.Implementation.csproj index 5917773810001..f7e31089033f3 100644 --- a/src/VisualStudio/Core/Impl/Microsoft.VisualStudio.LanguageServices.Implementation.csproj +++ b/src/VisualStudio/Core/Impl/Microsoft.VisualStudio.LanguageServices.Implementation.csproj @@ -26,6 +26,7 @@ + diff --git a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj index bd6a8ea5aa271..80ee6c9070176 100644 --- a/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj +++ b/src/Workspaces/Core/Portable/Microsoft.CodeAnalysis.Workspaces.csproj @@ -257,7 +257,6 @@ - @@ -302,6 +301,7 @@ + From 59d76218dab026010876e246c0d54b02956f6814 Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 8 May 2019 12:50:29 -0700 Subject: [PATCH 03/22] Moved around internal files. Added shim over InlineRenameService. --- .../IFSharpEditorInlineRenameService.cs | 178 ++++++++++++++++++ .../FSharp/FSharpEditorFeaturesResources.cs | 11 ++ .../FSharpClassificationService.cs | 0 .../FSharpInternalCommonCompletionProvider.cs | 0 .../FSharpDiagnosticAnalyzerService.cs | 0 .../FSharpDocumentDiagnosticAnalyzer.cs | 0 .../FSharpProjectDiagnosticAnalyzer.cs | 0 .../FSharpSimplifyNameDiagnosticAnalyzer.cs | 0 .../FSharpUnusedDeclarationsAnalyzer.cs | 0 .../FSharpUnusedOpensDiagnosticAnalyzer.cs | 0 .../Editor/FSharpBraceMatcher.cs | 0 .../FSharpContentTypeLanguageService.cs | 0 .../Editor/FSharpEditorFormattingService.cs | 0 .../Editor/FSharpEditorInlineRenameService.cs | 172 +++++++++++++++++ .../FSharpSynchronousIndentationService.cs | 0 .../FindUsages/FSharpFindUsagesContext.cs | 0 .../FindUsages/FSharpFindUsagesService.cs | 0 .../FSharpBreakpointResolutionService.cs | 0 .../FSharpLanguageDebugInfoService.cs | 0 .../Internal/FSharpContentTypeDefinitions.cs | 21 +++ .../{ => Internal}/FSharpGlyphHelpers.cs | 0 .../FSharpSignatureHelpProvider.cs | 0 ...FSharpSignatureHelpTriggerReasonHelpers.cs | 4 +- .../FSharpSignatureHelpClassifierProvider.cs | 0 .../FSharpInlineRenameReplacementKindTests.cs | 67 +++++++ .../FSharpSignatureHelpTriggerReasonTests.cs | 4 +- 26 files changed, 455 insertions(+), 2 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/FSharpEditorFeaturesResources.cs rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Classification/FSharpClassificationService.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Completion/FSharpInternalCommonCompletionProvider.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Diagnostics/FSharpDiagnosticAnalyzerService.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/FSharpBraceMatcher.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/FSharpContentTypeLanguageService.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/FSharpEditorFormattingService.cs (100%) create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/FSharpSynchronousIndentationService.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/FindUsages/FSharpFindUsagesContext.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/FindUsages/FSharpFindUsagesService.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/Implementation/Debugging/FSharpBreakpointResolutionService.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/Editor/Implementation/Debugging/FSharpLanguageDebugInfoService.cs (100%) create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs rename src/Tools/ExternalAccess/FSharp/{ => Internal}/FSharpGlyphHelpers.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/SignatureHelp/FSharpSignatureHelpProvider.cs (100%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs (89%) rename src/Tools/ExternalAccess/FSharp/{ => Internal}/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs (100%) create mode 100644 src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs new file mode 100644 index 0000000000000..0ab93471d363f --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor +{ + internal struct FSharpInlineRenameLocation + { + public Document Document { get; } + public TextSpan TextSpan { get; } + + public FSharpInlineRenameLocation(Document document, TextSpan textSpan) : this() + { + this.Document = document; + this.TextSpan = textSpan; + } + } + + internal enum FSharpInlineRenameReplacementKind + { + NoConflict, + ResolvedReferenceConflict, + ResolvedNonReferenceConflict, + UnresolvedConflict, + Complexified, + } + + internal struct FSharpInlineRenameReplacement + { + public FSharpInlineRenameReplacementKind Kind { get; } + public TextSpan OriginalSpan { get; } + public TextSpan NewSpan { get; } + + public FSharpInlineRenameReplacement(FSharpInlineRenameReplacementKind kind, TextSpan originalSpan, TextSpan newSpan) : this() + { + this.Kind = kind; + this.OriginalSpan = originalSpan; + this.NewSpan = newSpan; + } + } + + internal interface IFSharpInlineRenameReplacementInfo + { + /// + /// The solution obtained after resolving all conflicts. + /// + Solution NewSolution { get; } + + /// + /// Whether or not the replacement text entered by the user is valid. + /// + bool ReplacementTextValid { get; } + + /// + /// The documents that need to be updated. + /// + IEnumerable DocumentIds { get; } + + /// + /// Returns all the replacements that need to be performed for the specified document. + /// + IEnumerable GetReplacements(DocumentId documentId); + } + + internal interface IFSharpInlineRenameLocationSet + { + /// + /// The set of locations that need to be updated with the replacement text that the user + /// has entered in the inline rename session. These are the locations are all relative + /// to the solution when the inline rename session began. + /// + IList Locations { get; } + + /// + /// Returns the set of replacements and their possible resolutions if the user enters the + /// provided replacement text and options. Replacements are keyed by their document id + /// and TextSpan in the original solution, and specify their new span and possible conflict + /// resolution. + /// + Task GetReplacementsAsync(string replacementText, OptionSet optionSet, CancellationToken cancellationToken); + } + + internal interface IFSharpInlineRenameInfo + { + /// + /// Whether or not the entity at the selected location can be renamed. + /// + bool CanRename { get; } + + /// + /// Provides the reason that can be displayed to the user if the entity at the selected + /// location cannot be renamed. + /// + string LocalizedErrorMessage { get; } + + /// + /// The span of the entity that is being renamed. + /// + TextSpan TriggerSpan { get; } + + /// + /// Whether or not this entity has overloads that can also be renamed if the user wants. + /// + bool HasOverloads { get; } + + /// + /// Whether the Rename Overloads option should be forced to true. Used if rename is invoked from within a nameof expression. + /// + bool ForceRenameOverloads { get; } + + /// + /// The short name of the symbol being renamed, for use in displaying information to the user. + /// + string DisplayName { get; } + + /// + /// The full name of the symbol being renamed, for use in displaying information to the user. + /// + string FullDisplayName { get; } + + /// + /// The glyph for the symbol being renamed, for use in displaying information to the user. + /// + FSharpGlyph Glyph { get; } + + /// + /// Gets the final name of the symbol if the user has typed the provided replacement text + /// in the editor. Normally, the final name will be same as the replacement text. However, + /// that may not always be the same. For example, when renaming an attribute the replacement + /// text may be "NewName" while the final symbol name might be "NewNameAttribute". + /// + string GetFinalSymbolName(string replacementText); + + /// + /// Returns the actual span that should be edited in the buffer for a given rename reference + /// location. + /// + TextSpan GetReferenceEditSpan(FSharpInlineRenameLocation location, CancellationToken cancellationToken); + + /// + /// Returns the actual span that should be edited in the buffer for a given rename conflict + /// location. + /// + TextSpan? GetConflictEditSpan(FSharpInlineRenameLocation location, string replacementText, CancellationToken cancellationToken); + + /// + /// Determine the set of locations to rename given the provided options. May be called + /// multiple times. For example, this can be called one time for the initial set of + /// locations to rename, as well as any time the rename options are changed by the user. + /// + Task FindRenameLocationsAsync(OptionSet optionSet, CancellationToken cancellationToken); + + /// + /// Called before the rename is applied to the specified documents in the workspace. Return + /// if rename should proceed, or if it should be canceled. + /// + bool TryOnBeforeGlobalSymbolRenamed(Workspace workspace, IEnumerable changedDocumentIDs, string replacementText); + + /// + /// Called after the rename is applied to the specified documents in the workspace. Return + /// if this operation succeeded, or if it failed. + /// + bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable changedDocumentIDs, string replacementText); + } + + /// + /// Language service that allows a language to participate in the editor's inline rename feature. + /// + internal interface IFSharpEditorInlineRenameService + { + Task GetRenameInfoAsync(Document document, int position, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/FSharpEditorFeaturesResources.cs b/src/Tools/ExternalAccess/FSharp/FSharpEditorFeaturesResources.cs new file mode 100644 index 0000000000000..48f3364411f0d --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/FSharpEditorFeaturesResources.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Editor; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp +{ + internal static class FSharpEditorFeaturesResources + { + public static string You_cannot_rename_this_element => EditorFeaturesResources.You_cannot_rename_this_element; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Classification/FSharpClassificationService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Classification/FSharpClassificationService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Classification/FSharpClassificationService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Classification/FSharpClassificationService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Completion/FSharpInternalCommonCompletionProvider.cs b/src/Tools/ExternalAccess/FSharp/Internal/Completion/FSharpInternalCommonCompletionProvider.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Completion/FSharpInternalCommonCompletionProvider.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Completion/FSharpInternalCommonCompletionProvider.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDiagnosticAnalyzerService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDiagnosticAnalyzerService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDiagnosticAnalyzerService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDiagnosticAnalyzerService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpBraceMatcher.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpBraceMatcher.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/FSharpBraceMatcher.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpBraceMatcher.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpContentTypeLanguageService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpContentTypeLanguageService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/FSharpContentTypeLanguageService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpContentTypeLanguageService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpEditorFormattingService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorFormattingService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/FSharpEditorFormattingService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorFormattingService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs new file mode 100644 index 0000000000000..766bb290675ec --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor +{ + internal static class FSharpInlineRenameReplacementKindHelpers + { + public static InlineRenameReplacementKind ConvertTo(FSharpInlineRenameReplacementKind kind) + { + switch (kind) + { + case FSharpInlineRenameReplacementKind.NoConflict: + { + return InlineRenameReplacementKind.NoConflict; + } + + case FSharpInlineRenameReplacementKind.ResolvedReferenceConflict: + { + return InlineRenameReplacementKind.ResolvedReferenceConflict; + } + + case FSharpInlineRenameReplacementKind.ResolvedNonReferenceConflict: + { + return InlineRenameReplacementKind.ResolvedNonReferenceConflict; + } + + case FSharpInlineRenameReplacementKind.UnresolvedConflict: + { + return InlineRenameReplacementKind.UnresolvedConflict; + } + + case FSharpInlineRenameReplacementKind.Complexified: + { + return InlineRenameReplacementKind.Complexified; + } + + default: + { + throw new ArgumentException("Enum case not handled.", nameof(kind)); + } + } + } + } + internal class FSharpInlineRenameReplacementInfo : IInlineRenameReplacementInfo + { + private readonly IFSharpInlineRenameReplacementInfo _info; + + public FSharpInlineRenameReplacementInfo(IFSharpInlineRenameReplacementInfo info) + { + _info = info; + } + + public Solution NewSolution => _info.NewSolution; + + public bool ReplacementTextValid => _info.ReplacementTextValid; + + public IEnumerable DocumentIds => _info.DocumentIds; + + public IEnumerable GetReplacements(DocumentId documentId) + { + return _info.GetReplacements(documentId).Select(x => + new InlineRenameReplacement(FSharpInlineRenameReplacementKindHelpers.ConvertTo(x.Kind), x.OriginalSpan, x.NewSpan)); + } + } + internal class FSharpInlineRenameLocationSet : IInlineRenameLocationSet + { + private readonly IFSharpInlineRenameLocationSet _set; + private readonly IList _locations; + + public FSharpInlineRenameLocationSet(IFSharpInlineRenameLocationSet set) + { + _set = set; + _locations = set.Locations.Select(x => new InlineRenameLocation(x.Document, x.TextSpan)).ToList(); + } + + public IList Locations => _locations; + + public async Task GetReplacementsAsync(string replacementText, OptionSet optionSet, CancellationToken cancellationToken) + { + var info = await _set.GetReplacementsAsync(replacementText, optionSet, cancellationToken).ConfigureAwait(false); + return new FSharpInlineRenameReplacementInfo(info); + } + } + + internal class FSharpInlineRenameInfo : IInlineRenameInfo + { + private readonly IFSharpInlineRenameInfo _info; + + public FSharpInlineRenameInfo(IFSharpInlineRenameInfo info) + { + _info = info; + } + + public bool CanRename => _info.CanRename; + + public string LocalizedErrorMessage => _info.LocalizedErrorMessage; + + public TextSpan TriggerSpan => _info.TriggerSpan; + + public bool HasOverloads => _info.HasOverloads; + + public bool ForceRenameOverloads => _info.ForceRenameOverloads; + + public string DisplayName => _info.DisplayName; + + public string FullDisplayName => _info.FullDisplayName; + + public Glyph Glyph => FSharpGlyphHelpers.ConvertTo(_info.Glyph); + + public async Task FindRenameLocationsAsync(OptionSet optionSet, CancellationToken cancellationToken) + { + var set = await _info.FindRenameLocationsAsync(optionSet, cancellationToken).ConfigureAwait(false); + return new FSharpInlineRenameLocationSet(set); + } + + public TextSpan? GetConflictEditSpan(InlineRenameLocation location, string replacementText, CancellationToken cancellationToken) + { + return _info.GetConflictEditSpan(new FSharpInlineRenameLocation(location.Document, location.TextSpan), replacementText, cancellationToken); + } + + public string GetFinalSymbolName(string replacementText) + { + return _info.GetFinalSymbolName(replacementText); + } + + public TextSpan GetReferenceEditSpan(InlineRenameLocation location, CancellationToken cancellationToken) + { + return _info.GetReferenceEditSpan(new FSharpInlineRenameLocation(location.Document, location.TextSpan), cancellationToken); + } + + public bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable changedDocumentIDs, string replacementText) + { + return _info.TryOnAfterGlobalSymbolRenamed(workspace, changedDocumentIDs, replacementText); + } + + public bool TryOnBeforeGlobalSymbolRenamed(Workspace workspace, IEnumerable changedDocumentIDs, string replacementText) + { + return _info.TryOnBeforeGlobalSymbolRenamed(workspace, changedDocumentIDs, replacementText); + } + } + + [Shared] + [ExportLanguageService(typeof(IEditorInlineRenameService), LanguageNames.FSharp)] + internal class FSharpEditorInlineRenameService : IEditorInlineRenameService + { + private readonly IFSharpEditorInlineRenameService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpEditorInlineRenameService(IFSharpEditorInlineRenameService service) + { + _service = service; + } + + public async Task GetRenameInfoAsync(Document document, int position, CancellationToken cancellationToken) + { + var info = await _service.GetRenameInfoAsync(document, position, cancellationToken).ConfigureAwait(false); + return new FSharpInlineRenameInfo(info); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpSynchronousIndentationService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/FSharpSynchronousIndentationService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpSynchronousIndentationService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FindUsages/FSharpFindUsagesContext.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesContext.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/FindUsages/FSharpFindUsagesContext.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesContext.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FindUsages/FSharpFindUsagesService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/FindUsages/FSharpFindUsagesService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/Implementation/Debugging/FSharpBreakpointResolutionService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/Implementation/Debugging/FSharpBreakpointResolutionService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/Implementation/Debugging/FSharpBreakpointResolutionService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/Implementation/Debugging/FSharpBreakpointResolutionService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/Implementation/Debugging/FSharpLanguageDebugInfoService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/Implementation/Debugging/FSharpLanguageDebugInfoService.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/Editor/Implementation/Debugging/FSharpLanguageDebugInfoService.cs rename to src/Tools/ExternalAccess/FSharp/Internal/Editor/Implementation/Debugging/FSharpLanguageDebugInfoService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs b/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs new file mode 100644 index 0000000000000..817f927bcb6c2 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.ComponentModel.Composition; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.VisualStudio.Utilities; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal +{ + internal static class FSharpContentTypeDefinitions + { + [Export] + [Name(FSharpContentTypeNames.FSharpContentType)] + [BaseDefinition(FSharpContentTypeNames.RoslynContentType)] + public static ContentTypeDefinition FSharpContentTypeDefinition => new ContentTypeDefinition(); + + [Export] + [Name(FSharpContentTypeNames.FSharpSignatureHelpContentType)] + [BaseDefinition("sighelp")] + public static ContentTypeDefinition FSharpSignatureHelpContentTypeDefinition => new ContentTypeDefinition(); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/FSharpGlyphHelpers.cs rename to src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpProvider.cs b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpProvider.cs rename to src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs similarity index 89% rename from src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs rename to src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs index ca79ca9e3eac5..1a6cea72d1917 100644 --- a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs @@ -28,7 +28,9 @@ public static FSharpSignatureHelpTriggerReason ConvertFrom(SignatureHelpTriggerR } default: - throw new InvalidOperationException(); + { + throw new ArgumentException("Enum case not handled.", nameof(triggerReason)); + } } } } diff --git a/src/Tools/ExternalAccess/FSharp/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs b/src/Tools/ExternalAccess/FSharp/Internal/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs similarity index 100% rename from src/Tools/ExternalAccess/FSharp/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs rename to src/Tools/ExternalAccess/FSharp/Internal/VisualStudio/Text/Classification/FSharpSignatureHelpClassifierProvider.cs diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs new file mode 100644 index 0000000000000..53600e00732da --- /dev/null +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor; +using Xunit; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests +{ + public class FSharpInlineRenameReplacementKindTests + { + public static IEnumerable enumValues() + { + foreach (var number in Enum.GetValues(typeof(FSharpInlineRenameReplacementKind))) + { + yield return new object[] { number }; + } + } + + internal static InlineRenameReplacementKind GetExpectedInlineRenameReplacementKind(FSharpInlineRenameReplacementKind kind) + { + switch (kind) + { + case FSharpInlineRenameReplacementKind.NoConflict: + { + return InlineRenameReplacementKind.NoConflict; + } + + case FSharpInlineRenameReplacementKind.ResolvedReferenceConflict: + { + return InlineRenameReplacementKind.ResolvedReferenceConflict; + } + + case FSharpInlineRenameReplacementKind.ResolvedNonReferenceConflict: + { + return InlineRenameReplacementKind.ResolvedNonReferenceConflict; + } + + case FSharpInlineRenameReplacementKind.UnresolvedConflict: + { + return InlineRenameReplacementKind.UnresolvedConflict; + } + + case FSharpInlineRenameReplacementKind.Complexified: + { + return InlineRenameReplacementKind.Complexified; + } + + default: + { + throw new ArgumentException("Enum case not handled.", nameof(kind)); + } + } + } + + [Theory] + [MemberData(nameof(enumValues))] + internal void MapsCorrectly(FSharpInlineRenameReplacementKind kind) + { + var actual = FSharpInlineRenameReplacementKindHelpers.ConvertTo(kind); + var expected = GetExpectedInlineRenameReplacementKind(kind); + Assert.Equal(expected, actual); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs index f204f68431ad6..331b80b669c72 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs @@ -39,7 +39,9 @@ internal static FSharpSignatureHelpTriggerReason GetExpectedTriggerReason(Signat } default: - throw new InvalidOperationException(); + { + throw new ArgumentException("Enum case not handled.", nameof(triggerReason)); + } } } From 181fe000b4f8b2db78f8f3914b0091562ee598fc Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 8 May 2019 13:36:06 -0700 Subject: [PATCH 04/22] Starting shim over document highlights service. Added a better way to handle diagnostics --- .../Diagnostics/FSharpDiagnosticCustomTags.cs | 2 - .../IFSharpDocumentDiagnosticAnalyzer.cs | 3 +- .../IFSharpProjectDiagnosticAnalyzer.cs | 3 +- .../IFSharpSimplifyNameDiagnosticAnalyzer.cs | 3 +- ...arpUnusedDeclarationsDiagnosticAnalyzer.cs | 3 +- .../IFSharpUnusedOpensDiagnosticAnalyzer.cs | 3 +- .../IFSharpDocumentHighlightsService.cs | 51 +++++++++++++++++++ .../FSharpDocumentDiagnosticAnalyzer.cs | 31 ++++++++++- .../FSharpProjectDiagnosticAnalyzer.cs | 25 ++++++++- .../FSharpSimplifyNameDiagnosticAnalyzer.cs | 25 ++++++++- .../FSharpUnusedDeclarationsAnalyzer.cs | 25 ++++++++- .../FSharpUnusedOpensDiagnosticAnalyzer.cs | 25 ++++++++- .../FSharpDocumentHighlightsService.cs | 21 ++++++++ 13 files changed, 202 insertions(+), 18 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/DocumentHighlighting/IFSharpDocumentHighlightsService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDiagnosticCustomTags.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDiagnosticCustomTags.cs index a418bece32c58..a371e89f32ed1 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDiagnosticCustomTags.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpDiagnosticCustomTags.cs @@ -1,7 +1,5 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft; - namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics { internal static class FSharpDiagnosticCustomTags diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpDocumentDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpDocumentDiagnosticAnalyzer.cs index 9eba5d8b1b134..2864674618850 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpDocumentDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpDocumentDiagnosticAnalyzer.cs @@ -3,11 +3,10 @@ using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics { - internal interface IFSharpDocumentDiagnosticAnalyzer : ILanguageService + internal interface IFSharpDocumentDiagnosticAnalyzer { Task> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken); diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpProjectDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpProjectDiagnosticAnalyzer.cs index 17a292b670470..9a0e0c93fc5f5 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpProjectDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpProjectDiagnosticAnalyzer.cs @@ -3,11 +3,10 @@ using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics { - internal interface IFSharpProjectDiagnosticAnalyzer : ILanguageService + internal interface IFSharpProjectDiagnosticAnalyzer { Task> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken); } diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpSimplifyNameDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpSimplifyNameDiagnosticAnalyzer.cs index db40932be6687..7a0eeb93161db 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpSimplifyNameDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpSimplifyNameDiagnosticAnalyzer.cs @@ -3,11 +3,10 @@ using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics { - internal interface IFSharpSimplifyNameDiagnosticAnalyzer : ILanguageService + internal interface IFSharpSimplifyNameDiagnosticAnalyzer { Task> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken); } diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedDeclarationsDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedDeclarationsDiagnosticAnalyzer.cs index 776d7b89765f1..98e9cb7de6ce4 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedDeclarationsDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedDeclarationsDiagnosticAnalyzer.cs @@ -3,11 +3,10 @@ using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics { - internal interface IFSharpUnusedDeclarationsDiagnosticAnalyzer : ILanguageService + internal interface IFSharpUnusedDeclarationsDiagnosticAnalyzer { Task> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken); } diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedOpensDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedOpensDiagnosticAnalyzer.cs index 9a3a128f87c74..1cde722257ee8 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedOpensDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/IFSharpUnusedOpensDiagnosticAnalyzer.cs @@ -3,11 +3,10 @@ using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics { - internal interface IFSharpUnusedOpensDiagnosticAnalyzer : ILanguageService + internal interface IFSharpUnusedOpensDiagnosticAnalyzer { Task> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken); } diff --git a/src/Tools/ExternalAccess/FSharp/DocumentHighlighting/IFSharpDocumentHighlightsService.cs b/src/Tools/ExternalAccess/FSharp/DocumentHighlighting/IFSharpDocumentHighlightsService.cs new file mode 100644 index 0000000000000..c5592878e5fee --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/DocumentHighlighting/IFSharpDocumentHighlightsService.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.DocumentHighlighting +{ + internal enum FSharpHighlightSpanKind + { + None, + Definition, + Reference, + WrittenReference, + } + + internal readonly struct FSharpHighlightSpan + { + public TextSpan TextSpan { get; } + public FSharpHighlightSpanKind Kind { get; } + + public FSharpHighlightSpan(TextSpan textSpan, FSharpHighlightSpanKind kind) : this() + { + this.TextSpan = textSpan; + this.Kind = kind; + } + } + + internal readonly struct FSharpDocumentHighlights + { + public Document Document { get; } + public ImmutableArray HighlightSpans { get; } + + public FSharpDocumentHighlights(Document document, ImmutableArray highlightSpans) + { + this.Document = document; + this.HighlightSpans = highlightSpans; + } + } + + /// + /// Note: This is the new version of the language service and superceded the same named type + /// in the EditorFeatures layer. + /// + internal interface IFSharpDocumentHighlightsService + { + Task> GetDocumentHighlightsAsync( + Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs index 94874f05a0ea7..770de8c2eb583 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpDocumentDiagnosticAnalyzer.cs @@ -2,13 +2,40 @@ using System; using System.Collections.Immutable; +using System.Composition; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Diagnostics { + [Shared] + [ExportLanguageService(typeof(FSharpDocumentDiagnosticAnalyzerService), LanguageNames.FSharp)] + internal class FSharpDocumentDiagnosticAnalyzerService : ILanguageService + { + private readonly IFSharpDocumentDiagnosticAnalyzer _analyzer; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpDocumentDiagnosticAnalyzerService(IFSharpDocumentDiagnosticAnalyzer analyzer) + { + _analyzer = analyzer; + } + + public Task> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) + { + return _analyzer.AnalyzeSemanticsAsync(document, cancellationToken); + } + + public Task> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) + { + return _analyzer.AnalyzeSyntaxAsync(document, cancellationToken); + } + } + [DiagnosticAnalyzer(LanguageNames.FSharp)] internal class FSharpDocumentDiagnosticAnalyzer : DocumentDiagnosticAnalyzer, IBuiltInAnalyzer { @@ -36,7 +63,7 @@ static public ImmutableArray CreateSupportedDiagnostics() public override Task> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) { - var analyzer = document.Project.LanguageServices.GetService(); + var analyzer = document.Project.LanguageServices.GetService(); if (analyzer == null) { return Task.FromResult(ImmutableArray.Empty); @@ -47,7 +74,7 @@ public override Task> AnalyzeSemanticsAsync(Document public override Task> AnalyzeSyntaxAsync(Document document, CancellationToken cancellationToken) { - var analyzer = document.Project.LanguageServices.GetService(); + var analyzer = document.Project.LanguageServices.GetService(); if (analyzer == null) { return Task.FromResult(ImmutableArray.Empty); diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs index 63d81b6df3eeb..0bca28565e3ed 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpProjectDiagnosticAnalyzer.cs @@ -1,13 +1,36 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Immutable; +using System.Composition; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Diagnostics { + [Shared] + [ExportLanguageService(typeof(FSharpProjectDiagnosticAnalyzerService), LanguageNames.FSharp)] + internal class FSharpProjectDiagnosticAnalyzerService : ILanguageService + { + private readonly IFSharpProjectDiagnosticAnalyzer _analyzer; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpProjectDiagnosticAnalyzerService(IFSharpProjectDiagnosticAnalyzer analyzer) + { + _analyzer = analyzer; + } + + public Task> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken) + { + return _analyzer.AnalyzeProjectAsync(project, cancellationToken); + } + } + [DiagnosticAnalyzer(LanguageNames.FSharp)] internal class FSharpProjectDiagnosticAnalyzer : ProjectDiagnosticAnalyzer { @@ -22,7 +45,7 @@ public FSharpProjectDiagnosticAnalyzer() public override Task> AnalyzeProjectAsync(Project project, CancellationToken cancellationToken) { - var analyzer = project.LanguageServices.GetService(); + var analyzer = project.LanguageServices.GetService(); if (analyzer == null) { return Task.FromResult(ImmutableArray.Empty); diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs index baed418ee4d32..a30dd07008346 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpSimplifyNameDiagnosticAnalyzer.cs @@ -1,13 +1,36 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Immutable; +using System.Composition; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Diagnostics { + [Shared] + [ExportLanguageService(typeof(FSharpSimplifyNameDiagnosticAnalyzerService), LanguageNames.FSharp)] + internal class FSharpSimplifyNameDiagnosticAnalyzerService : ILanguageService + { + private readonly IFSharpSimplifyNameDiagnosticAnalyzer _analyzer; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpSimplifyNameDiagnosticAnalyzerService(IFSharpSimplifyNameDiagnosticAnalyzer analyzer) + { + _analyzer = analyzer; + } + + public Task> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken) + { + return _analyzer.AnalyzeSemanticsAsync(descriptor, document, cancellationToken); + } + } + [DiagnosticAnalyzer(LanguageNames.FSharp)] internal class FSharpSimplifyNameDiagnosticAnalyzer : DocumentDiagnosticAnalyzer, IBuiltInAnalyzer { @@ -24,7 +47,7 @@ internal class FSharpSimplifyNameDiagnosticAnalyzer : DocumentDiagnosticAnalyzer public override Task> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) { - var analyzer = document.Project.LanguageServices.GetService(); + var analyzer = document.Project.LanguageServices.GetService(); if (analyzer == null) { return Task.FromResult(ImmutableArray.Empty); diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs index 051e22ef38cbb..a0c6ab0ae9378 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedDeclarationsAnalyzer.cs @@ -1,13 +1,36 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Immutable; +using System.Composition; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Diagnostics { + [Shared] + [ExportLanguageService(typeof(FSharpUnusedDeclarationsDiagnosticAnalyzerService), LanguageNames.FSharp)] + internal class FSharpUnusedDeclarationsDiagnosticAnalyzerService : ILanguageService + { + private readonly IFSharpUnusedDeclarationsDiagnosticAnalyzer _analyzer; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpUnusedDeclarationsDiagnosticAnalyzerService(IFSharpUnusedDeclarationsDiagnosticAnalyzer analyzer) + { + _analyzer = analyzer; + } + + public Task> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken) + { + return _analyzer.AnalyzeSemanticsAsync(descriptor, document, cancellationToken); + } + } + [DiagnosticAnalyzer(LanguageNames.FSharp)] internal class FSharpUnusedDeclarationsDiagnosticAnalyzer : DocumentDiagnosticAnalyzer, IBuiltInAnalyzer { @@ -26,7 +49,7 @@ internal class FSharpUnusedDeclarationsDiagnosticAnalyzer : DocumentDiagnosticAn public override Task> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) { - var analyzer = document.Project.LanguageServices.GetService(); + var analyzer = document.Project.LanguageServices.GetService(); if (analyzer == null) { return Task.FromResult(ImmutableArray.Empty); diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs index c664d659c2802..fa425cdf10d09 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Diagnostics/FSharpUnusedOpensDiagnosticAnalyzer.cs @@ -1,13 +1,36 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Collections.Immutable; +using System.Composition; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics; +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Host.Mef; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Diagnostics { + [Shared] + [ExportLanguageService(typeof(FSharpUnusedOpensDiagnosticAnalyzerService), LanguageNames.FSharp)] + internal class FSharpUnusedOpensDiagnosticAnalyzerService : ILanguageService + { + private readonly IFSharpUnusedOpensDiagnosticAnalyzer _analyzer; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpUnusedOpensDiagnosticAnalyzerService(IFSharpUnusedOpensDiagnosticAnalyzer analyzer) + { + _analyzer = analyzer; + } + + public Task> AnalyzeSemanticsAsync(DiagnosticDescriptor descriptor, Document document, CancellationToken cancellationToken) + { + return _analyzer.AnalyzeSemanticsAsync(descriptor, document, cancellationToken); + } + } + [DiagnosticAnalyzer(LanguageNames.FSharp)] internal class FSharpUnusedOpensDeclarationsDiagnosticAnalyzer : DocumentDiagnosticAnalyzer { @@ -24,7 +47,7 @@ internal class FSharpUnusedOpensDeclarationsDiagnosticAnalyzer : DocumentDiagnos public override Task> AnalyzeSemanticsAsync(Document document, CancellationToken cancellationToken) { - var analyzer = document.Project.LanguageServices.GetService(); + var analyzer = document.Project.LanguageServices.GetService(); if (analyzer == null) { return Task.FromResult(ImmutableArray.Empty); diff --git a/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs b/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs new file mode 100644 index 0000000000000..2baf7a0a9122e --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Composition; +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.DocumentHighlighting; +using Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.DocumentHighlighting +{ + [Shared] + [ExportLanguageService(typeof(IDocumentHighlightsService), LanguageNames.FSharp)] + internal class FSharpDocumentHighlightsService : IDocumentHighlightsService + { + public Task> GetDocumentHighlightsAsync(Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken) + { + throw new System.NotImplementedException(); + } + } +} From bfcfbf01d0ab26c38a80b4aca67cdb2ef10b2d52 Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 8 May 2019 13:58:55 -0700 Subject: [PATCH 05/22] Added shim for document highlights service --- .../FSharpDocumentHighlightsService.cs | 56 ++++++++++++++++- .../FSharpHighlightSpanKindTests.cs | 62 +++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs diff --git a/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs b/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs index 2baf7a0a9122e..db262ef0727b8 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs @@ -1,21 +1,73 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Linq; using System.Composition; using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.DocumentHighlighting; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.DocumentHighlighting { + internal static class FSharpHighlightSpanKindHelpers + { + public static HighlightSpanKind ConvertTo(FSharpHighlightSpanKind kind) + { + switch (kind) + { + case FSharpHighlightSpanKind.None: + { + return HighlightSpanKind.None; + } + + case FSharpHighlightSpanKind.Definition: + { + return HighlightSpanKind.Definition; + } + + case FSharpHighlightSpanKind.Reference: + { + return HighlightSpanKind.Reference; + } + + case FSharpHighlightSpanKind.WrittenReference: + { + return HighlightSpanKind.WrittenReference; + } + + default: + { + throw new ArgumentException("Enum case not handled.", nameof(kind)); + } + } + } + } + [Shared] [ExportLanguageService(typeof(IDocumentHighlightsService), LanguageNames.FSharp)] internal class FSharpDocumentHighlightsService : IDocumentHighlightsService { - public Task> GetDocumentHighlightsAsync(Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken) + private readonly IFSharpDocumentHighlightsService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpDocumentHighlightsService(IFSharpDocumentHighlightsService service) + { + _service = service; + } + + private static ImmutableArray MapHighlightSpans(ImmutableArray highlightSpans) + { + return highlightSpans.Select(x => new HighlightSpan(x.TextSpan, FSharpHighlightSpanKindHelpers.ConvertTo(x.Kind))).AsImmutable(); + } + + public async Task> GetDocumentHighlightsAsync(Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken) { - throw new System.NotImplementedException(); + var highlights = await _service.GetDocumentHighlightsAsync(document, position, documentsToSearch, cancellationToken).ConfigureAwait(false); + return highlights.Select(x => new DocumentHighlights(x.Document, MapHighlightSpans(x.HighlightSpans))).AsImmutable(); } } } diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs new file mode 100644 index 0000000000000..3cb2ac2f08045 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.DocumentHighlighting; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.DocumentHighlighting; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.DocumentHighlighting; +using Xunit; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests +{ + public class FSharpHighlightSpanKindTests + { + public static IEnumerable enumValues() + { + foreach (var number in Enum.GetValues(typeof(FSharpHighlightSpanKind))) + { + yield return new object[] { number }; + } + } + + internal static HighlightSpanKind GetExpectedHighlightSpanKind(FSharpHighlightSpanKind kind) + { + switch (kind) + { + case FSharpHighlightSpanKind.None: + { + return HighlightSpanKind.None; + } + + case FSharpHighlightSpanKind.Definition: + { + return HighlightSpanKind.Definition; + } + + case FSharpHighlightSpanKind.Reference: + { + return HighlightSpanKind.Reference; + } + + case FSharpHighlightSpanKind.WrittenReference: + { + return HighlightSpanKind.WrittenReference; + } + + default: + { + throw new ArgumentException("Enum case not handled.", nameof(kind)); + } + } + } + + [Theory] + [MemberData(nameof(enumValues))] + internal void MapsCorrectly(FSharpHighlightSpanKind kind) + { + var actual = FSharpHighlightSpanKindHelpers.ConvertTo(kind); + var expected = GetExpectedHighlightSpanKind(kind); + Assert.Equal(expected, actual); + } + } +} From 5d61f32039350de8d98df10759a9b28d6894d9ca Mon Sep 17 00:00:00 2001 From: TIHan Date: Sat, 25 May 2019 22:43:35 -0700 Subject: [PATCH 06/22] Added IFSharpDocumentNavigationService --- .../Navigation/InternalFSharpNavigableItem.cs | 32 +++++++++ .../FSharpDocumentNavigationService.cs | 68 +++++++++++++++++++ .../FSharp/Navigation/FSharpNavigableItem.cs | 19 ++++++ .../Navigation/FSharpNavigationOptions.cs | 12 ++++ .../IFSharpDocumentNavigationService.cs | 41 +++++++++++ 5 files changed, 172 insertions(+) create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigationOptions.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Navigation/IFSharpDocumentNavigationService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs new file mode 100644 index 0000000000000..ef39ef8527c7b --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; +using Microsoft.CodeAnalysis.Navigation; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation +{ + internal class InternalFSharpNavigableItem : INavigableItem + { + public InternalFSharpNavigableItem(FSharpNavigableItem item) + { + Document = item.Document; + SourceSpan = item.SourceSpan; + } + + public Glyph Glyph => Glyph.BasicFile; + + public ImmutableArray DisplayTaggedParts => ImmutableArray.Empty; + + public bool DisplayFileLocation => true; + + public bool IsImplicitlyDeclared => false; + + public Document Document { get; private set; } + + public TextSpan SourceSpan { get; private set; } + + public ImmutableArray ChildItems => ImmutableArray.Empty; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs new file mode 100644 index 0000000000000..f743761716c35 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Composition; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Navigation; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation +{ + [ExportWorkspaceService(typeof(IFSharpDocumentNavigationService)), Shared] + internal sealed class FSharpDocumentNavigationService : IFSharpDocumentNavigationService + { + /// + /// Determines whether it is possible to navigate to the given position in the specified document. + /// + public bool CanNavigateToSpan(Workspace workspace, DocumentId documentId, TextSpan textSpan) + { + var service = workspace.Services.GetService(); + return service.CanNavigateToSpan(workspace, documentId, textSpan); + } + + /// + /// Determines whether it is possible to navigate to the given line/offset in the specified document. + /// + public bool CanNavigateToLineAndOffset(Workspace workspace, DocumentId documentId, int lineNumber, int offset) + { + var service = workspace.Services.GetService(); + return service.CanNavigateToLineAndOffset(workspace, documentId, lineNumber, offset); + } + + /// + /// Determines whether it is possible to navigate to the given virtual position in the specified document. + /// + public bool CanNavigateToPosition(Workspace workspace, DocumentId documentId, int position, int virtualSpace = 0) + { + var service = workspace.Services.GetService(); + return service.CanNavigateToPosition(workspace, documentId, position, virtualSpace); + } + + /// + /// Navigates to the given position in the specified document, opening it if necessary. + /// + public bool TryNavigateToSpan(Workspace workspace, DocumentId documentId, TextSpan textSpan, OptionSet options = null) + { + var service = workspace.Services.GetService(); + return service.TryNavigateToSpan(workspace, documentId, textSpan, options); + } + + /// + /// Navigates to the given line/offset in the specified document, opening it if necessary. + /// + public bool TryNavigateToLineAndOffset(Workspace workspace, DocumentId documentId, int lineNumber, int offset, OptionSet options = null) + { + var service = workspace.Services.GetService(); + return service.TryNavigateToLineAndOffset(workspace, documentId, lineNumber, offset, options); + } + + /// + /// Navigates to the given virtual position in the specified document, opening it if necessary. + /// + public bool TryNavigateToPosition(Workspace workspace, DocumentId documentId, int position, int virtualSpace = 0, OptionSet options = null) + { + var service = workspace.Services.GetService(); + return service.TryNavigateToPosition(workspace, documentId, position, virtualSpace, options); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs new file mode 100644 index 0000000000000..4f80e7feaab69 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation +{ + internal class FSharpNavigableItem + { + public FSharpNavigableItem(Document document, TextSpan sourceSpan) + { + Document = document; + SourceSpan = sourceSpan; + } + + public Document Document { get; private set; } + + public TextSpan SourceSpan { get; private set; } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigationOptions.cs b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigationOptions.cs new file mode 100644 index 0000000000000..b8913fcc98f58 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigationOptions.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Navigation; +using Microsoft.CodeAnalysis.Options; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation +{ + internal static class FSharpNavigationOptions + { + public static Option PreferProvisionalTab => NavigationOptions.PreferProvisionalTab; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/IFSharpDocumentNavigationService.cs b/src/Tools/ExternalAccess/FSharp/Navigation/IFSharpDocumentNavigationService.cs new file mode 100644 index 0000000000000..0f7d696cae118 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Navigation/IFSharpDocumentNavigationService.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Host; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation +{ + internal interface IFSharpDocumentNavigationService : IWorkspaceService + { + /// + /// Determines whether it is possible to navigate to the given position in the specified document. + /// + bool CanNavigateToSpan(Workspace workspace, DocumentId documentId, TextSpan textSpan); + + /// + /// Determines whether it is possible to navigate to the given line/offset in the specified document. + /// + bool CanNavigateToLineAndOffset(Workspace workspace, DocumentId documentId, int lineNumber, int offset); + + /// + /// Determines whether it is possible to navigate to the given virtual position in the specified document. + /// + bool CanNavigateToPosition(Workspace workspace, DocumentId documentId, int position, int virtualSpace = 0); + + /// + /// Navigates to the given position in the specified document, opening it if necessary. + /// + bool TryNavigateToSpan(Workspace workspace, DocumentId documentId, TextSpan textSpan, OptionSet options = null); + + /// + /// Navigates to the given line/offset in the specified document, opening it if necessary. + /// + bool TryNavigateToLineAndOffset(Workspace workspace, DocumentId documentId, int lineNumber, int offset, OptionSet options = null); + + /// + /// Navigates to the given virtual position in the specified document, opening it if necessary. + /// + bool TryNavigateToPosition(Workspace workspace, DocumentId documentId, int position, int virtualSpace = 0, OptionSet options = null); + } +} From a5b66724a90a0216f3a38faf426af685e7cbcf7a Mon Sep 17 00:00:00 2001 From: TIHan Date: Sat, 25 May 2019 23:02:05 -0700 Subject: [PATCH 07/22] Added IFSharpGoToDefinitionService --- .../Editor/IFSharpGoToDefinitionService.cs | 24 +++++++++++ .../Editor/FSharpGoToDefinitionService.cs | 41 +++++++++++++++++++ .../FSharpDocumentNavigationService.cs | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Editor/IFSharpGoToDefinitionService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/IFSharpGoToDefinitionService.cs b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpGoToDefinitionService.cs new file mode 100644 index 0000000000000..774d625687967 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpGoToDefinitionService.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor +{ + internal interface IFSharpGoToDefinitionService + { + /// + /// Finds the definitions for the symbol at the specific position in the document. + /// + Task> FindDefinitionsAsync(Document document, int position, CancellationToken cancellationToken); + + /// + /// Finds the definitions for the symbol at the specific position in the document and then + /// navigates to them. + /// + /// True if navigating to the definition of the symbol at the provided position succeeds. False, otherwise. + bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs new file mode 100644 index 0000000000000..9fed05156ad2e --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Composition; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.Navigation; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor +{ + [Shared] + [ExportLanguageService(typeof(IGoToDefinitionService), LanguageNames.FSharp)] + internal class FSharpGoToDefinitionService : IGoToDefinitionService + { + private readonly IFSharpGoToDefinitionService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpGoToDefinitionService(IFSharpGoToDefinitionService service) + { + _service = service; + } + + public async Task> FindDefinitionsAsync(Document document, int position, CancellationToken cancellationToken) + { + var items = await _service.FindDefinitionsAsync(document, position, cancellationToken).ConfigureAwait(false); + return items.Select(x => new InternalFSharpNavigableItem(x)); + } + + public bool TryGoToDefinition(Document document, int position, CancellationToken cancellationToken) + { + return _service.TryGoToDefinition(document, position, cancellationToken); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs index f743761716c35..eaf9c8d1deaaa 100644 --- a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs +++ b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpDocumentNavigationService.cs @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation { [ExportWorkspaceService(typeof(IFSharpDocumentNavigationService)), Shared] - internal sealed class FSharpDocumentNavigationService : IFSharpDocumentNavigationService + internal class FSharpDocumentNavigationService : IFSharpDocumentNavigationService { /// /// Determines whether it is possible to navigate to the given position in the specified document. From 39f8214193d93bf0ed03759c5f2c586d69808d6d Mon Sep 17 00:00:00 2001 From: TIHan Date: Sat, 25 May 2019 23:56:44 -0700 Subject: [PATCH 08/22] Added IFSharpNavigationBarItemService --- .../FSharp/Editor/FSharpNavigationBarItem.cs | 40 ++++++++ .../Editor/IFSharpNavigationBarItemService.cs | 13 +++ .../Editor/FSharpGoToDefinitionService.cs | 27 +++++- .../Editor/FSharpNavigationBarItemService.cs | 91 +++++++++++++++++++ .../Navigation/InternalFSharpNavigableItem.cs | 32 ------- 5 files changed, 170 insertions(+), 33 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Editor/FSharpNavigationBarItem.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Editor/IFSharpNavigationBarItemService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpNavigationBarItemService.cs delete mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs diff --git a/src/Tools/ExternalAccess/FSharp/Editor/FSharpNavigationBarItem.cs b/src/Tools/ExternalAccess/FSharp/Editor/FSharpNavigationBarItem.cs new file mode 100644 index 0000000000000..69790cd336b96 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Editor/FSharpNavigationBarItem.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.Text; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor +{ + internal class FSharpNavigationBarItem + { + public string Text { get; } + public FSharpGlyph Glyph { get; } + public bool Bolded { get; } + public bool Grayed { get; } + public int Indent { get; } + public IList ChildItems { get; } + + public IList Spans { get; internal set; } + internal IList TrackingSpans { get; set; } + + public FSharpNavigationBarItem( + string text, + FSharpGlyph glyph, + IList spans, + IList childItems = null, + int indent = 0, + bool bolded = false, + bool grayed = false) + { + this.Text = text; + this.Glyph = glyph; + this.Spans = spans; + this.ChildItems = childItems ?? SpecializedCollections.EmptyList(); + this.Indent = indent; + this.Bolded = bolded; + this.Grayed = grayed; + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Editor/IFSharpNavigationBarItemService.cs b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpNavigationBarItemService.cs new file mode 100644 index 0000000000000..f7faf0ea5687b --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpNavigationBarItemService.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor +{ + internal interface IFSharpNavigationBarItemService + { + Task> GetItemsAsync(Document document, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs index 9fed05156ad2e..5e887d0ea4585 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs @@ -10,7 +10,9 @@ using Microsoft.CodeAnalysis.Navigation; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; -using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor { @@ -37,5 +39,28 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken { return _service.TryGoToDefinition(document, position, cancellationToken); } + + private class InternalFSharpNavigableItem : INavigableItem + { + public InternalFSharpNavigableItem(FSharpNavigableItem item) + { + Document = item.Document; + SourceSpan = item.SourceSpan; + } + + public Glyph Glyph => Glyph.BasicFile; + + public ImmutableArray DisplayTaggedParts => ImmutableArray.Empty; + + public bool DisplayFileLocation => true; + + public bool IsImplicitlyDeclared => false; + + public Document Document { get; private set; } + + public TextSpan SourceSpan { get; private set; } + + public ImmutableArray ChildItems => ImmutableArray.Empty; + } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpNavigationBarItemService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpNavigationBarItemService.cs new file mode 100644 index 0000000000000..54a4673aca17a --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpNavigationBarItemService.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Composition; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; +using Microsoft.VisualStudio.Text.Editor; +using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; +using Microsoft.CodeAnalysis.Notification; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor +{ + [Shared] + [ExportLanguageService(typeof(INavigationBarItemService), LanguageNames.FSharp)] + internal class FSharpNavigationBarItemService : INavigationBarItemService + { + private readonly IFSharpNavigationBarItemService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpNavigationBarItemService(IFSharpNavigationBarItemService service) + { + _service = service; + } + + public async Task> GetItemsAsync(Document document, CancellationToken cancellationToken) + { + var items = await _service.GetItemsAsync(document, cancellationToken).ConfigureAwait(false); + return items.Select(x => ConvertToNavigationBarItem(x)).ToList(); + } + + public void NavigateToItem(Document document, NavigationBarItem item, ITextView view, CancellationToken cancellationToken) + { + // The logic here was ported from FSharp's implementation. The main reason was to avoid shimming INotificationService. + if (item.Spans.Count > 0) + { + var span = item.Spans.First(); + var workspace = document.Project.Solution.Workspace; + var navigationService = workspace.Services.GetService(); + + if (navigationService.CanNavigateToPosition(workspace, document.Id, span.Start)) + { + navigationService.TryNavigateToPosition(workspace, document.Id, span.Start); + } + else + { + var notificationService = workspace.Services.GetService(); + notificationService.SendNotification(EditorFeaturesResources.The_definition_of_the_object_is_hidden, severity: NotificationSeverity.Error); + } + } + } + + public bool ShowItemGrayedIfNear(NavigationBarItem item) + { + return false; + } + + private static NavigationBarItem ConvertToNavigationBarItem(FSharpNavigationBarItem item) + { + return + new InternalNavigationBarItem( + item.Text, + FSharpGlyphHelpers.ConvertTo(item.Glyph), + item.Spans, + item.ChildItems.Select(x => ConvertToNavigationBarItem(x)).ToList(), + item.Indent, + item.Bolded, + item.Grayed); + } + + private class InternalNavigationBarItem : NavigationBarItem + { + public InternalNavigationBarItem( + string text, + Glyph glyph, + IList spans, + IList childItems, + int indent, + bool bolded, + bool grayed) : base(text, glyph, spans, childItems, indent, bolded, grayed) + { + } + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs deleted file mode 100644 index ef39ef8527c7b..0000000000000 --- a/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Immutable; -using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; -using Microsoft.CodeAnalysis.Navigation; -using Microsoft.CodeAnalysis.Text; - -namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation -{ - internal class InternalFSharpNavigableItem : INavigableItem - { - public InternalFSharpNavigableItem(FSharpNavigableItem item) - { - Document = item.Document; - SourceSpan = item.SourceSpan; - } - - public Glyph Glyph => Glyph.BasicFile; - - public ImmutableArray DisplayTaggedParts => ImmutableArray.Empty; - - public bool DisplayFileLocation => true; - - public bool IsImplicitlyDeclared => false; - - public Document Document { get; private set; } - - public TextSpan SourceSpan { get; private set; } - - public ImmutableArray ChildItems => ImmutableArray.Empty; - } -} From 7e269584e9f1f506e98f2dedca7c5cc297c58f09 Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 01:26:18 -0700 Subject: [PATCH 09/22] Added IFSharpNavigateToSearchService --- ...crosoft.CodeAnalysis.EditorFeatures.csproj | 4 +- .../Roslyn.Hosting.Diagnostics.csproj | 4 +- .../FSharpContentTypeLanguageService.cs | 4 +- .../Editor/FSharpGoToDefinitionService.cs | 27 +- .../FSharp/Internal/FSharpGlyphHelpers.cs | 10 +- .../FSharpNavigateToMatchKindHelpers.cs | 66 ++ .../FSharpNavigateToSearchService.cs | 43 ++ .../InternalFSharpNavigateToSearchResult.cs | 41 ++ .../Navigation/InternalFSharpNavigableItem.cs | 34 + ....CodeAnalysis.ExternalAccess.FSharp.csproj | 4 + .../NavigateTo/FSharpNavigateToItemKind.cs | 25 + .../NavigateTo/FSharpNavigateToMatchKind.cs | 19 + .../FSharpNavigateToSearchResult.cs | 32 + .../IFSharpNavigateToSearchService.cs | 24 + .../FSharp/Navigation/FSharpNavigableItem.cs | 9 +- .../FSharpTest/FSharpGlyphTests.cs | 668 ++++++++++++++++++ .../FSharpNavigateToMatchKindTests.cs | 86 +++ ...osoft.VisualStudio.LanguageServices.csproj | 5 +- ...slyn.VisualStudio.DiagnosticsWindow.csproj | 1 - 19 files changed, 1064 insertions(+), 42 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToSearchService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs create mode 100644 src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs create mode 100644 src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToMatchKind.cs create mode 100644 src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs create mode 100644 src/Tools/ExternalAccess/FSharp/NavigateTo/IFSharpNavigateToSearchService.cs create mode 100644 src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs create mode 100644 src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs diff --git a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj index fe60697fb37c9..f0b25974542fc 100644 --- a/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj +++ b/src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj @@ -110,9 +110,7 @@ True True - - Code - + diff --git a/src/Test/Diagnostics/Roslyn.Hosting.Diagnostics.csproj b/src/Test/Diagnostics/Roslyn.Hosting.Diagnostics.csproj index 8a3a1419a24ec..7b407355f3dde 100644 --- a/src/Test/Diagnostics/Roslyn.Hosting.Diagnostics.csproj +++ b/src/Test/Diagnostics/Roslyn.Hosting.Diagnostics.csproj @@ -30,9 +30,7 @@ StatusIndicator.xaml - - Code - + diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpContentTypeLanguageService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpContentTypeLanguageService.cs index a521d5607c28b..688dac9979c61 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpContentTypeLanguageService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpContentTypeLanguageService.cs @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor { - [ExportContentTypeLanguageService(FSharp.Editor.FSharpContentTypeNames.FSharpContentType, LanguageNames.FSharp), Shared] + [ExportContentTypeLanguageService(FSharpContentTypeNames.FSharpContentType, LanguageNames.FSharp), Shared] internal class FSharpContentTypeLanguageService : IContentTypeLanguageService { private readonly IContentTypeRegistryService _contentTypeRegistry; @@ -23,7 +23,7 @@ public FSharpContentTypeLanguageService(IContentTypeRegistryService contentTypeR public IContentType GetDefaultContentType() { - return _contentTypeRegistry.GetContentType(FSharp.Editor.FSharpContentTypeNames.FSharpContentType); + return _contentTypeRegistry.GetContentType(FSharpContentTypeNames.FSharpContentType); } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs index 5e887d0ea4585..9fed05156ad2e 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpGoToDefinitionService.cs @@ -10,9 +10,7 @@ using Microsoft.CodeAnalysis.Navigation; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; -using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; -using System.Collections.Immutable; -using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor { @@ -39,28 +37,5 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken { return _service.TryGoToDefinition(document, position, cancellationToken); } - - private class InternalFSharpNavigableItem : INavigableItem - { - public InternalFSharpNavigableItem(FSharpNavigableItem item) - { - Document = item.Document; - SourceSpan = item.SourceSpan; - } - - public Glyph Glyph => Glyph.BasicFile; - - public ImmutableArray DisplayTaggedParts => ImmutableArray.Empty; - - public bool DisplayFileLocation => true; - - public bool IsImplicitlyDeclared => false; - - public Document Document { get; private set; } - - public TextSpan SourceSpan { get; private set; } - - public ImmutableArray ChildItems => ImmutableArray.Empty; - } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs index 2577bfc438799..64b817f343c81 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs @@ -1,4 +1,8 @@ -namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal { internal static class FSharpGlyphHelpers { @@ -308,7 +312,7 @@ public static FSharpGlyph ConvertFrom(Microsoft.CodeAnalysis.Glyph glyph) } default: { - return FSharpGlyph.None; + throw new ArgumentException("Enum case not handled.", nameof(glyph)); } } } @@ -619,7 +623,7 @@ public static Microsoft.CodeAnalysis.Glyph ConvertTo(FSharpGlyph glyph) } default: { - return Microsoft.CodeAnalysis.Glyph.None; + throw new ArgumentException("Enum case not handled.", nameof(glyph)); } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs new file mode 100644 index 0000000000000..5024a4a4cb552 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo; +using Microsoft.CodeAnalysis.NavigateTo; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.NavigateTo +{ + internal static class FSharpNavigateToMatchKindHelpers + { + public static NavigateToMatchKind ConvertTo(FSharpNavigateToMatchKind kind) + { + switch (kind) + { + case FSharpNavigateToMatchKind.Exact: + { + return NavigateToMatchKind.Exact; + } + case FSharpNavigateToMatchKind.Prefix: + { + return NavigateToMatchKind.Prefix; + } + case FSharpNavigateToMatchKind.Substring: + { + return NavigateToMatchKind.Substring; + } + case FSharpNavigateToMatchKind.Regular: + { + return NavigateToMatchKind.Regular; + } + case FSharpNavigateToMatchKind.None: + { + return NavigateToMatchKind.None; + } + case FSharpNavigateToMatchKind.CamelCaseExact: + { + return NavigateToMatchKind.CamelCaseExact; + } + case FSharpNavigateToMatchKind.CamelCasePrefix: + { + return NavigateToMatchKind.CamelCasePrefix; + } + case FSharpNavigateToMatchKind.CamelCaseNonContiguousPrefix: + { + return NavigateToMatchKind.CamelCaseNonContiguousPrefix; + } + case FSharpNavigateToMatchKind.CamelCaseSubstring: + { + return NavigateToMatchKind.CamelCaseSubstring; + } + case FSharpNavigateToMatchKind.CamelCaseNonContiguousSubstring: + { + return NavigateToMatchKind.CamelCaseNonContiguousSubstring; + } + case FSharpNavigateToMatchKind.Fuzzy: + { + return NavigateToMatchKind.Fuzzy; + } + default: + { + throw new ArgumentException("Enum case not handled.", nameof(kind)); + } + } + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToSearchService.cs b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToSearchService.cs new file mode 100644 index 0000000000000..db82d6497b8df --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToSearchService.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Immutable; +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.NavigateTo; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.NavigateTo +{ + [Shared] + [ExportLanguageService(typeof(INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate), LanguageNames.FSharp)] + internal class FSharpNavigateToSearchService : INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate + { + private readonly IFSharpNavigateToSearchService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpNavigateToSearchService(IFSharpNavigateToSearchService service) + { + _service = service; + } + + public IImmutableSet KindsProvided => _service.KindsProvided; + + public bool CanFilter => _service.CanFilter; + + public async Task> SearchDocumentAsync(Document document, string searchPattern, IImmutableSet kinds, CancellationToken cancellationToken) + { + var results = await _service.SearchDocumentAsync(document, searchPattern, kinds, cancellationToken).ConfigureAwait(false); + return results.SelectAsArray(x => (INavigateToSearchResult)new InternalFSharpNavigateToSearchResult(x)); + } + + public async Task> SearchProjectAsync(Project project, ImmutableArray priorityDocuments, string searchPattern, IImmutableSet kinds, CancellationToken cancellationToken) + { + var results = await _service.SearchProjectAsync(project, priorityDocuments, searchPattern, kinds, cancellationToken).ConfigureAwait(false); + return results.SelectAsArray(x => (INavigateToSearchResult)new InternalFSharpNavigateToSearchResult(x)); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs new file mode 100644 index 0000000000000..aa54132c63200 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo; +using Microsoft.CodeAnalysis.NavigateTo; +using Microsoft.CodeAnalysis.Navigation; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.NavigateTo +{ + internal class InternalFSharpNavigateToSearchResult : INavigateToSearchResult + { + public InternalFSharpNavigateToSearchResult(FSharpNavigateToSearchResult result) + { + AdditionalInformation = result.AdditionalInformation; + Kind = result.Kind; + MatchKind = FSharpNavigateToMatchKindHelpers.ConvertTo(result.MatchKind); + Name = result.Name; + NavigableItem = new InternalFSharpNavigableItem(result.NavigableItem); + } + + public string AdditionalInformation { get; private set; } + + public string Kind { get; private set; } + + public NavigateToMatchKind MatchKind { get; private set; } + + public bool IsCaseSensitive => false; + + public string Name { get; private set; } + + public ImmutableArray NameMatchSpans => ImmutableArray.Empty; + + public string SecondarySort => null; + + public string Summary => null; + + public INavigableItem NavigableItem { get; private set; } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs new file mode 100644 index 0000000000000..055a409e273a0 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; +using Microsoft.CodeAnalysis.Navigation; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Navigation +{ + internal class InternalFSharpNavigableItem : INavigableItem + { + public InternalFSharpNavigableItem(FSharpNavigableItem item) + { + Glyph = FSharpGlyphHelpers.ConvertTo(item.Glyph); + DisplayTaggedParts = item.DisplayTaggedParts; + Document = item.Document; + SourceSpan = item.SourceSpan; + } + + public Glyph Glyph { get; private set; } + + public ImmutableArray DisplayTaggedParts { get; private set; } + + public bool DisplayFileLocation => true; + + public bool IsImplicitlyDeclared => false; + + public Document Document { get; private set; } + + public TextSpan SourceSpan { get; private set; } + + public ImmutableArray ChildItems => ImmutableArray.Empty; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj index ddd66fe4c293a..99a7c2552516a 100644 --- a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj +++ b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj @@ -96,4 +96,8 @@ + + + + \ No newline at end of file diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs new file mode 100644 index 0000000000000..c2ac4b589037f --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.NavigateTo; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo +{ + internal static class FSharpNavigateToItemKind + { + public static string Line => NavigateToItemKind.Line; + public static string File = NavigateToItemKind.File; + public static string Class => NavigateToItemKind.Class; + public static string Structure => NavigateToItemKind.Structure; + public static string Interface => NavigateToItemKind.Interface; + public static string Delegate => NavigateToItemKind.Delegate; + public static string Enum => NavigateToItemKind.Enum; + public static string Module => NavigateToItemKind.Module; + public static string Constant => NavigateToItemKind.Constant; + public static string EnumItem => NavigateToItemKind.EnumItem; + public static string Field => NavigateToItemKind.Field; + public static string Method => NavigateToItemKind.Method; + public static string Property => NavigateToItemKind.Property; + public static string Event => NavigateToItemKind.Event; + public static string OtherSymbol => NavigateToItemKind.OtherSymbol; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToMatchKind.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToMatchKind.cs new file mode 100644 index 0000000000000..c3a8e4ce20b06 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToMatchKind.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo +{ + internal enum FSharpNavigateToMatchKind + { + Exact = 0, + Prefix = 1, + Substring = 2, + Regular = 3, + None = 4, + CamelCaseExact = 5, + CamelCasePrefix = 6, + CamelCaseNonContiguousPrefix = 7, + CamelCaseSubstring = 8, + CamelCaseNonContiguousSubstring = 9, + Fuzzy = 10 + } +} diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs new file mode 100644 index 0000000000000..90a3e4f41ea05 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo +{ + internal class FSharpNavigateToSearchResult + { + public FSharpNavigateToSearchResult( + string additionalInformation, + string kind, + FSharpNavigateToMatchKind matchKind, + string name, + FSharpNavigableItem navigateItem) + { + AdditionalInformation = additionalInformation; + Kind = kind; + MatchKind = matchKind; + NavigableItem = navigateItem; + } + + public string AdditionalInformation { get; private set; } + + public string Kind { get; private set; } + + public FSharpNavigateToMatchKind MatchKind { get; private set; } + + public string Name { get; private set; } + + public FSharpNavigableItem NavigableItem { get; private set; } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/IFSharpNavigateToSearchService.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/IFSharpNavigateToSearchService.cs new file mode 100644 index 0000000000000..fd6060027553f --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/IFSharpNavigateToSearchService.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo +{ + internal interface IFSharpNavigateToSearchService + { + IImmutableSet KindsProvided + { + get; + } + + bool CanFilter + { + get; + } + + Task> SearchProjectAsync(Project project, ImmutableArray priorityDocuments, string searchPattern, IImmutableSet kinds, CancellationToken cancellationToken); + Task> SearchDocumentAsync(Document document, string searchPattern, IImmutableSet kinds, CancellationToken cancellationToken); + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs index 4f80e7feaab69..cd4a65c1b63cf 100644 --- a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs +++ b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs @@ -1,17 +1,24 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Immutable; using Microsoft.CodeAnalysis.Text; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation { internal class FSharpNavigableItem { - public FSharpNavigableItem(Document document, TextSpan sourceSpan) + public FSharpNavigableItem(FSharpGlyph glyph, ImmutableArray displayTaggedParts, Document document, TextSpan sourceSpan) { + Glyph = glyph; + DisplayTaggedParts = displayTaggedParts; Document = document; SourceSpan = sourceSpan; } + public FSharpGlyph Glyph { get; private set; } + + public ImmutableArray DisplayTaggedParts { get; private set; } + public Document Document { get; private set; } public TextSpan SourceSpan { get; private set; } diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs new file mode 100644 index 0000000000000..7169396216eb3 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs @@ -0,0 +1,668 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal; +using Xunit; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests +{ + public class FSharpGlyphTests + { + public static IEnumerable enumValues() + { + foreach (var number in Enum.GetValues(typeof(FSharpGlyph))) + { + yield return new object[] { number }; + } + } + + public static IEnumerable enumValuesOpposite() + { + foreach (var number in Enum.GetValues(typeof(Glyph))) + { + yield return new object[] { number }; + } + } + + internal static FSharpGlyph GetExpectedFSharpGlyph(Microsoft.CodeAnalysis.Glyph glyph) + { + switch (glyph) + { + case Microsoft.CodeAnalysis.Glyph.None: + { + return FSharpGlyph.None; + } + case Microsoft.CodeAnalysis.Glyph.Assembly: + { + return FSharpGlyph.Assembly; + } + case Microsoft.CodeAnalysis.Glyph.BasicFile: + { + return FSharpGlyph.BasicFile; + } + case Microsoft.CodeAnalysis.Glyph.BasicProject: + { + return FSharpGlyph.BasicProject; + } + case Microsoft.CodeAnalysis.Glyph.ClassPublic: + { + return FSharpGlyph.ClassPublic; + } + case Microsoft.CodeAnalysis.Glyph.ClassProtected: + { + return FSharpGlyph.ClassProtected; + } + case Microsoft.CodeAnalysis.Glyph.ClassPrivate: + { + return FSharpGlyph.ClassPrivate; + } + case Microsoft.CodeAnalysis.Glyph.ClassInternal: + { + return FSharpGlyph.ClassInternal; + } + case Microsoft.CodeAnalysis.Glyph.CSharpFile: + { + return FSharpGlyph.CSharpFile; + } + case Microsoft.CodeAnalysis.Glyph.CSharpProject: + { + return FSharpGlyph.CSharpProject; + } + case Microsoft.CodeAnalysis.Glyph.ConstantPublic: + { + return FSharpGlyph.ConstantPublic; + } + case Microsoft.CodeAnalysis.Glyph.ConstantProtected: + { + return FSharpGlyph.ConstantProtected; + } + case Microsoft.CodeAnalysis.Glyph.ConstantPrivate: + { + return FSharpGlyph.ConstantPrivate; + } + case Microsoft.CodeAnalysis.Glyph.ConstantInternal: + { + return FSharpGlyph.ConstantInternal; + } + case Microsoft.CodeAnalysis.Glyph.DelegatePublic: + { + return FSharpGlyph.DelegatePublic; + } + case Microsoft.CodeAnalysis.Glyph.DelegateProtected: + { + return FSharpGlyph.DelegateProtected; + } + case Microsoft.CodeAnalysis.Glyph.DelegatePrivate: + { + return FSharpGlyph.DelegatePrivate; + } + case Microsoft.CodeAnalysis.Glyph.DelegateInternal: + { + return FSharpGlyph.DelegateInternal; + } + case Microsoft.CodeAnalysis.Glyph.EnumPublic: + { + return FSharpGlyph.EnumPublic; + } + case Microsoft.CodeAnalysis.Glyph.EnumProtected: + { + return FSharpGlyph.EnumProtected; + } + case Microsoft.CodeAnalysis.Glyph.EnumPrivate: + { + return FSharpGlyph.EnumPrivate; + } + case Microsoft.CodeAnalysis.Glyph.EnumInternal: + { + return FSharpGlyph.EnumInternal; + } + case Microsoft.CodeAnalysis.Glyph.EnumMemberPublic: + { + return FSharpGlyph.EnumMemberPublic; + } + case Microsoft.CodeAnalysis.Glyph.EnumMemberProtected: + { + return FSharpGlyph.EnumMemberProtected; + } + case Microsoft.CodeAnalysis.Glyph.EnumMemberPrivate: + { + return FSharpGlyph.EnumMemberPrivate; + } + case Microsoft.CodeAnalysis.Glyph.EnumMemberInternal: + { + return FSharpGlyph.EnumMemberInternal; + } + case Microsoft.CodeAnalysis.Glyph.Error: + { + return FSharpGlyph.Error; + } + case Microsoft.CodeAnalysis.Glyph.StatusInformation: + { + return FSharpGlyph.StatusInformation; + } + case Microsoft.CodeAnalysis.Glyph.EventPublic: + { + return FSharpGlyph.EventPublic; + } + case Microsoft.CodeAnalysis.Glyph.EventProtected: + { + return FSharpGlyph.EventProtected; + } + case Microsoft.CodeAnalysis.Glyph.EventPrivate: + { + return FSharpGlyph.EventPrivate; + } + case Microsoft.CodeAnalysis.Glyph.EventInternal: + { + return FSharpGlyph.EventInternal; + } + case Microsoft.CodeAnalysis.Glyph.ExtensionMethodPublic: + { + return FSharpGlyph.ExtensionMethodPublic; + } + case Microsoft.CodeAnalysis.Glyph.ExtensionMethodProtected: + { + return FSharpGlyph.ExtensionMethodProtected; + } + case Microsoft.CodeAnalysis.Glyph.ExtensionMethodPrivate: + { + return FSharpGlyph.ExtensionMethodPrivate; + } + case Microsoft.CodeAnalysis.Glyph.ExtensionMethodInternal: + { + return FSharpGlyph.ExtensionMethodInternal; + } + case Microsoft.CodeAnalysis.Glyph.FieldPublic: + { + return FSharpGlyph.FieldPublic; + } + case Microsoft.CodeAnalysis.Glyph.FieldProtected: + { + return FSharpGlyph.FieldProtected; + } + case Microsoft.CodeAnalysis.Glyph.FieldPrivate: + { + return FSharpGlyph.FieldPrivate; + } + case Microsoft.CodeAnalysis.Glyph.FieldInternal: + { + return FSharpGlyph.FieldInternal; + } + case Microsoft.CodeAnalysis.Glyph.InterfacePublic: + { + return FSharpGlyph.InterfacePublic; + } + case Microsoft.CodeAnalysis.Glyph.InterfaceProtected: + { + return FSharpGlyph.InterfaceProtected; + } + case Microsoft.CodeAnalysis.Glyph.InterfacePrivate: + { + return FSharpGlyph.InterfacePrivate; + } + case Microsoft.CodeAnalysis.Glyph.InterfaceInternal: + { + return FSharpGlyph.InterfaceInternal; + } + case Microsoft.CodeAnalysis.Glyph.Intrinsic: + { + return FSharpGlyph.Intrinsic; + } + case Microsoft.CodeAnalysis.Glyph.Keyword: + { + return FSharpGlyph.Keyword; + } + case Microsoft.CodeAnalysis.Glyph.Label: + { + return FSharpGlyph.Label; + } + case Microsoft.CodeAnalysis.Glyph.Local: + { + return FSharpGlyph.Local; + } + case Microsoft.CodeAnalysis.Glyph.Namespace: + { + return FSharpGlyph.Namespace; + } + case Microsoft.CodeAnalysis.Glyph.MethodPublic: + { + return FSharpGlyph.MethodPublic; + } + case Microsoft.CodeAnalysis.Glyph.MethodProtected: + { + return FSharpGlyph.MethodProtected; + } + case Microsoft.CodeAnalysis.Glyph.MethodPrivate: + { + return FSharpGlyph.MethodPrivate; + } + case Microsoft.CodeAnalysis.Glyph.MethodInternal: + { + return FSharpGlyph.MethodInternal; + } + case Microsoft.CodeAnalysis.Glyph.ModulePublic: + { + return FSharpGlyph.ModulePublic; + } + case Microsoft.CodeAnalysis.Glyph.ModuleProtected: + { + return FSharpGlyph.ModuleProtected; + } + case Microsoft.CodeAnalysis.Glyph.ModulePrivate: + { + return FSharpGlyph.ModulePrivate; + } + case Microsoft.CodeAnalysis.Glyph.ModuleInternal: + { + return FSharpGlyph.ModuleInternal; + } + case Microsoft.CodeAnalysis.Glyph.OpenFolder: + { + return FSharpGlyph.OpenFolder; + } + case Microsoft.CodeAnalysis.Glyph.Operator: + { + return FSharpGlyph.Operator; + } + case Microsoft.CodeAnalysis.Glyph.Parameter: + { + return FSharpGlyph.Parameter; + } + case Microsoft.CodeAnalysis.Glyph.PropertyPublic: + { + return FSharpGlyph.PropertyPublic; + } + case Microsoft.CodeAnalysis.Glyph.PropertyProtected: + { + return FSharpGlyph.PropertyProtected; + } + case Microsoft.CodeAnalysis.Glyph.PropertyPrivate: + { + return FSharpGlyph.PropertyPrivate; + } + case Microsoft.CodeAnalysis.Glyph.PropertyInternal: + { + return FSharpGlyph.PropertyInternal; + } + case Microsoft.CodeAnalysis.Glyph.RangeVariable: + { + return FSharpGlyph.RangeVariable; + } + case Microsoft.CodeAnalysis.Glyph.Reference: + { + return FSharpGlyph.Reference; + } + case Microsoft.CodeAnalysis.Glyph.StructurePublic: + { + return FSharpGlyph.StructurePublic; + } + case Microsoft.CodeAnalysis.Glyph.StructureProtected: + { + return FSharpGlyph.StructureProtected; + } + case Microsoft.CodeAnalysis.Glyph.StructurePrivate: + { + return FSharpGlyph.StructurePrivate; + } + case Microsoft.CodeAnalysis.Glyph.StructureInternal: + { + return FSharpGlyph.StructureInternal; + } + case Microsoft.CodeAnalysis.Glyph.TypeParameter: + { + return FSharpGlyph.TypeParameter; + } + case Microsoft.CodeAnalysis.Glyph.Snippet: + { + return FSharpGlyph.Snippet; + } + case Microsoft.CodeAnalysis.Glyph.CompletionWarning: + { + return FSharpGlyph.CompletionWarning; + } + case Microsoft.CodeAnalysis.Glyph.AddReference: + { + return FSharpGlyph.AddReference; + } + case Microsoft.CodeAnalysis.Glyph.NuGet: + { + return FSharpGlyph.NuGet; + } + default: + { + throw new ArgumentException("Enum case not handled.", nameof(glyph)); + } + } + } + + internal static Microsoft.CodeAnalysis.Glyph GetExpectedGlyph(FSharpGlyph glyph) + { + switch (glyph) + { + case FSharpGlyph.None: + { + return Microsoft.CodeAnalysis.Glyph.None; + } + case FSharpGlyph.Assembly: + { + return Microsoft.CodeAnalysis.Glyph.Assembly; + } + case FSharpGlyph.BasicFile: + { + return Microsoft.CodeAnalysis.Glyph.BasicFile; + } + case FSharpGlyph.BasicProject: + { + return Microsoft.CodeAnalysis.Glyph.BasicProject; + } + case FSharpGlyph.ClassPublic: + { + return Microsoft.CodeAnalysis.Glyph.ClassPublic; + } + case FSharpGlyph.ClassProtected: + { + return Microsoft.CodeAnalysis.Glyph.ClassProtected; + } + case FSharpGlyph.ClassPrivate: + { + return Microsoft.CodeAnalysis.Glyph.ClassPrivate; + } + case FSharpGlyph.ClassInternal: + { + return Microsoft.CodeAnalysis.Glyph.ClassInternal; + } + case FSharpGlyph.CSharpFile: + { + return Microsoft.CodeAnalysis.Glyph.CSharpFile; + } + case FSharpGlyph.CSharpProject: + { + return Microsoft.CodeAnalysis.Glyph.CSharpProject; + } + case FSharpGlyph.ConstantPublic: + { + return Microsoft.CodeAnalysis.Glyph.ConstantPublic; + } + case FSharpGlyph.ConstantProtected: + { + return Microsoft.CodeAnalysis.Glyph.ConstantProtected; + } + case FSharpGlyph.ConstantPrivate: + { + return Microsoft.CodeAnalysis.Glyph.ConstantPrivate; + } + case FSharpGlyph.ConstantInternal: + { + return Microsoft.CodeAnalysis.Glyph.ConstantInternal; + } + case FSharpGlyph.DelegatePublic: + { + return Microsoft.CodeAnalysis.Glyph.DelegatePublic; + } + case FSharpGlyph.DelegateProtected: + { + return Microsoft.CodeAnalysis.Glyph.DelegateProtected; + } + case FSharpGlyph.DelegatePrivate: + { + return Microsoft.CodeAnalysis.Glyph.DelegatePrivate; + } + case FSharpGlyph.DelegateInternal: + { + return Microsoft.CodeAnalysis.Glyph.DelegateInternal; + } + case FSharpGlyph.EnumPublic: + { + return Microsoft.CodeAnalysis.Glyph.EnumPublic; + } + case FSharpGlyph.EnumProtected: + { + return Microsoft.CodeAnalysis.Glyph.EnumProtected; + } + case FSharpGlyph.EnumPrivate: + { + return Microsoft.CodeAnalysis.Glyph.EnumPrivate; + } + case FSharpGlyph.EnumInternal: + { + return Microsoft.CodeAnalysis.Glyph.EnumInternal; + } + case FSharpGlyph.EnumMemberPublic: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberPublic; + } + case FSharpGlyph.EnumMemberProtected: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberProtected; + } + case FSharpGlyph.EnumMemberPrivate: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberPrivate; + } + case FSharpGlyph.EnumMemberInternal: + { + return Microsoft.CodeAnalysis.Glyph.EnumMemberInternal; + } + case FSharpGlyph.Error: + { + return Microsoft.CodeAnalysis.Glyph.Error; + } + case FSharpGlyph.StatusInformation: + { + return Microsoft.CodeAnalysis.Glyph.StatusInformation; + } + case FSharpGlyph.EventPublic: + { + return Microsoft.CodeAnalysis.Glyph.EventPublic; + } + case FSharpGlyph.EventProtected: + { + return Microsoft.CodeAnalysis.Glyph.EventProtected; + } + case FSharpGlyph.EventPrivate: + { + return Microsoft.CodeAnalysis.Glyph.EventPrivate; + } + case FSharpGlyph.EventInternal: + { + return Microsoft.CodeAnalysis.Glyph.EventInternal; + } + case FSharpGlyph.ExtensionMethodPublic: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodPublic; + } + case FSharpGlyph.ExtensionMethodProtected: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodProtected; + } + case FSharpGlyph.ExtensionMethodPrivate: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodPrivate; + } + case FSharpGlyph.ExtensionMethodInternal: + { + return Microsoft.CodeAnalysis.Glyph.ExtensionMethodInternal; + } + case FSharpGlyph.FieldPublic: + { + return Microsoft.CodeAnalysis.Glyph.FieldPublic; + } + case FSharpGlyph.FieldProtected: + { + return Microsoft.CodeAnalysis.Glyph.FieldProtected; + } + case FSharpGlyph.FieldPrivate: + { + return Microsoft.CodeAnalysis.Glyph.FieldPrivate; + } + case FSharpGlyph.FieldInternal: + { + return Microsoft.CodeAnalysis.Glyph.FieldInternal; + } + case FSharpGlyph.InterfacePublic: + { + return Microsoft.CodeAnalysis.Glyph.InterfacePublic; + } + case FSharpGlyph.InterfaceProtected: + { + return Microsoft.CodeAnalysis.Glyph.InterfaceProtected; + } + case FSharpGlyph.InterfacePrivate: + { + return Microsoft.CodeAnalysis.Glyph.InterfacePrivate; + } + case FSharpGlyph.InterfaceInternal: + { + return Microsoft.CodeAnalysis.Glyph.InterfaceInternal; + } + case FSharpGlyph.Intrinsic: + { + return Microsoft.CodeAnalysis.Glyph.Intrinsic; + } + case FSharpGlyph.Keyword: + { + return Microsoft.CodeAnalysis.Glyph.Keyword; + } + case FSharpGlyph.Label: + { + return Microsoft.CodeAnalysis.Glyph.Label; + } + case FSharpGlyph.Local: + { + return Microsoft.CodeAnalysis.Glyph.Local; + } + case FSharpGlyph.Namespace: + { + return Microsoft.CodeAnalysis.Glyph.Namespace; + } + case FSharpGlyph.MethodPublic: + { + return Microsoft.CodeAnalysis.Glyph.MethodPublic; + } + case FSharpGlyph.MethodProtected: + { + return Microsoft.CodeAnalysis.Glyph.MethodProtected; + } + case FSharpGlyph.MethodPrivate: + { + return Microsoft.CodeAnalysis.Glyph.MethodPrivate; + } + case FSharpGlyph.MethodInternal: + { + return Microsoft.CodeAnalysis.Glyph.MethodInternal; + } + case FSharpGlyph.ModulePublic: + { + return Microsoft.CodeAnalysis.Glyph.ModulePublic; + } + case FSharpGlyph.ModuleProtected: + { + return Microsoft.CodeAnalysis.Glyph.ModuleProtected; + } + case FSharpGlyph.ModulePrivate: + { + return Microsoft.CodeAnalysis.Glyph.ModulePrivate; + } + case FSharpGlyph.ModuleInternal: + { + return Microsoft.CodeAnalysis.Glyph.ModuleInternal; + } + case FSharpGlyph.OpenFolder: + { + return Microsoft.CodeAnalysis.Glyph.OpenFolder; + } + case FSharpGlyph.Operator: + { + return Microsoft.CodeAnalysis.Glyph.Operator; + } + case FSharpGlyph.Parameter: + { + return Microsoft.CodeAnalysis.Glyph.Parameter; + } + case FSharpGlyph.PropertyPublic: + { + return Microsoft.CodeAnalysis.Glyph.PropertyPublic; + } + case FSharpGlyph.PropertyProtected: + { + return Microsoft.CodeAnalysis.Glyph.PropertyProtected; + } + case FSharpGlyph.PropertyPrivate: + { + return Microsoft.CodeAnalysis.Glyph.PropertyPrivate; + } + case FSharpGlyph.PropertyInternal: + { + return Microsoft.CodeAnalysis.Glyph.PropertyInternal; + } + case FSharpGlyph.RangeVariable: + { + return Microsoft.CodeAnalysis.Glyph.RangeVariable; + } + case FSharpGlyph.Reference: + { + return Microsoft.CodeAnalysis.Glyph.Reference; + } + case FSharpGlyph.StructurePublic: + { + return Microsoft.CodeAnalysis.Glyph.StructurePublic; + } + case FSharpGlyph.StructureProtected: + { + return Microsoft.CodeAnalysis.Glyph.StructureProtected; + } + case FSharpGlyph.StructurePrivate: + { + return Microsoft.CodeAnalysis.Glyph.StructurePrivate; + } + case FSharpGlyph.StructureInternal: + { + return Microsoft.CodeAnalysis.Glyph.StructureInternal; + } + case FSharpGlyph.TypeParameter: + { + return Microsoft.CodeAnalysis.Glyph.TypeParameter; + } + case FSharpGlyph.Snippet: + { + return Microsoft.CodeAnalysis.Glyph.Snippet; + } + case FSharpGlyph.CompletionWarning: + { + return Microsoft.CodeAnalysis.Glyph.CompletionWarning; + } + case FSharpGlyph.AddReference: + { + return Microsoft.CodeAnalysis.Glyph.AddReference; + } + case FSharpGlyph.NuGet: + { + return Microsoft.CodeAnalysis.Glyph.NuGet; + } + default: + { + throw new ArgumentException("Enum case not handled.", nameof(glyph)); + } + } + } + + [Theory] + [MemberData(nameof(enumValues))] + internal void MapsCorrectly(FSharpGlyph glyph) + { + var actual = FSharpGlyphHelpers.ConvertTo(glyph); + var expected = GetExpectedGlyph(glyph); + Assert.Equal(expected, actual); + } + + [Theory] + [MemberData(nameof(enumValuesOpposite))] + internal void MapsCorrectlyOpposite(Glyph glyph) + { + var actual = FSharpGlyphHelpers.ConvertFrom(glyph); + var expected = GetExpectedFSharpGlyph(glyph); + Assert.Equal(expected, actual); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs new file mode 100644 index 0000000000000..107aa0dbed9c2 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.NavigateTo; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo; +using Microsoft.CodeAnalysis.NavigateTo; +using Xunit; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests +{ + public class FSharpNavigateToMatchKindTests + { + public static IEnumerable enumValues() + { + foreach (var number in Enum.GetValues(typeof(FSharpNavigateToMatchKind))) + { + yield return new object[] { number }; + } + } + + internal static NavigateToMatchKind GetExpectedNavigateToMatchKind(FSharpNavigateToMatchKind kind) + { + switch (kind) + { + case FSharpNavigateToMatchKind.Exact: + { + return NavigateToMatchKind.Exact; + } + case FSharpNavigateToMatchKind.Prefix: + { + return NavigateToMatchKind.Prefix; + } + case FSharpNavigateToMatchKind.Substring: + { + return NavigateToMatchKind.Substring; + } + case FSharpNavigateToMatchKind.Regular: + { + return NavigateToMatchKind.Regular; + } + case FSharpNavigateToMatchKind.None: + { + return NavigateToMatchKind.None; + } + case FSharpNavigateToMatchKind.CamelCaseExact: + { + return NavigateToMatchKind.CamelCaseExact; + } + case FSharpNavigateToMatchKind.CamelCasePrefix: + { + return NavigateToMatchKind.CamelCasePrefix; + } + case FSharpNavigateToMatchKind.CamelCaseNonContiguousPrefix: + { + return NavigateToMatchKind.CamelCaseNonContiguousPrefix; + } + case FSharpNavigateToMatchKind.CamelCaseSubstring: + { + return NavigateToMatchKind.CamelCaseSubstring; + } + case FSharpNavigateToMatchKind.CamelCaseNonContiguousSubstring: + { + return NavigateToMatchKind.CamelCaseNonContiguousSubstring; + } + case FSharpNavigateToMatchKind.Fuzzy: + { + return NavigateToMatchKind.Fuzzy; + } + default: + { + throw new ArgumentException("Enum case not handled.", nameof(kind)); + } + } + } + + [Theory] + [MemberData(nameof(enumValues))] + internal void MapsCorrectly(FSharpNavigateToMatchKind kind) + { + var actual = FSharpNavigateToMatchKindHelpers.ConvertTo(kind); + var expected = GetExpectedNavigateToMatchKind(kind); + Assert.Equal(expected, actual); + } + } +} diff --git a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj index 7b4f5286b9f25..384503425ec91 100644 --- a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj +++ b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj @@ -52,7 +52,6 @@ MoveToNamespaceDialog.xaml - Code PickMembersDialog.xaml @@ -78,7 +77,7 @@ - + @@ -192,7 +191,7 @@ - + diff --git a/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Roslyn.VisualStudio.DiagnosticsWindow.csproj b/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Roslyn.VisualStudio.DiagnosticsWindow.csproj index 2ebc9a64d8d95..3d8deb9469ab6 100644 --- a/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Roslyn.VisualStudio.DiagnosticsWindow.csproj +++ b/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Roslyn.VisualStudio.DiagnosticsWindow.csproj @@ -74,7 +74,6 @@ TelemetryPanel.xaml - Code ProjectionBufferMargin.xaml From 37e0a5b9d10974a9b84d8579234cd54ffc733579 Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 01:55:26 -0700 Subject: [PATCH 10/22] Added extra glyph case --- src/Tools/ExternalAccess/FSharp/FSharpGlyph.cs | 3 ++- .../ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs | 8 ++++++++ src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Tools/ExternalAccess/FSharp/FSharpGlyph.cs b/src/Tools/ExternalAccess/FSharp/FSharpGlyph.cs index 135429c4b8d9d..072aa115012b0 100644 --- a/src/Tools/ExternalAccess/FSharp/FSharpGlyph.cs +++ b/src/Tools/ExternalAccess/FSharp/FSharpGlyph.cs @@ -109,6 +109,7 @@ internal enum FSharpGlyph CompletionWarning, AddReference, - NuGet + NuGet, + TargetTypeMatch } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs index 64b817f343c81..4f7984e836a6a 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs @@ -310,6 +310,10 @@ public static FSharpGlyph ConvertFrom(Microsoft.CodeAnalysis.Glyph glyph) { return FSharpGlyph.NuGet; } + case Microsoft.CodeAnalysis.Glyph.TargetTypeMatch: + { + return FSharpGlyph.TargetTypeMatch; + } default: { throw new ArgumentException("Enum case not handled.", nameof(glyph)); @@ -621,6 +625,10 @@ public static Microsoft.CodeAnalysis.Glyph ConvertTo(FSharpGlyph glyph) { return Microsoft.CodeAnalysis.Glyph.NuGet; } + case FSharpGlyph.TargetTypeMatch: + { + return Microsoft.CodeAnalysis.Glyph.TargetTypeMatch; + } default: { throw new ArgumentException("Enum case not handled.", nameof(glyph)); diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs index 7169396216eb3..c3a60cbe066f5 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs @@ -329,6 +329,10 @@ internal static FSharpGlyph GetExpectedFSharpGlyph(Microsoft.CodeAnalysis.Glyph { return FSharpGlyph.NuGet; } + case Microsoft.CodeAnalysis.Glyph.TargetTypeMatch: + { + return FSharpGlyph.TargetTypeMatch; + } default: { throw new ArgumentException("Enum case not handled.", nameof(glyph)); @@ -640,6 +644,10 @@ internal static Microsoft.CodeAnalysis.Glyph GetExpectedGlyph(FSharpGlyph glyph) { return Microsoft.CodeAnalysis.Glyph.NuGet; } + case FSharpGlyph.TargetTypeMatch: + { + return Microsoft.CodeAnalysis.Glyph.TargetTypeMatch; + } default: { throw new ArgumentException("Enum case not handled.", nameof(glyph)); From c72a35328887355180e56fc57a4faa21b1ccdc6c Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 02:07:11 -0700 Subject: [PATCH 11/22] Added FSharpGlyphTags --- .../ExternalAccess/FSharp/FSharpGlyphTags.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/Tools/ExternalAccess/FSharp/FSharpGlyphTags.cs diff --git a/src/Tools/ExternalAccess/FSharp/FSharpGlyphTags.cs b/src/Tools/ExternalAccess/FSharp/FSharpGlyphTags.cs new file mode 100644 index 0000000000000..abb58a5354d61 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/FSharpGlyphTags.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp +{ + internal static class FSharpGlyphTags + { + public static ImmutableArray GetTags(FSharpGlyph glyph) + { + return GlyphTags.GetTags(FSharpGlyphHelpers.ConvertTo(glyph)); + } + } +} From 7489b82385654813dc9b0244a0417c2e63da2514 Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 02:16:07 -0700 Subject: [PATCH 12/22] Added FSharpCommentSelectionService --- .../FSharpCommentSelectionService.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs b/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs new file mode 100644 index 0000000000000..85945d329f3cd --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CommentSelection; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.CommentSelection +{ + [Shared] + [ExportLanguageService(typeof(ICommentSelectionService, LanguageNames.FSharp)] + internal class FSharpCommentSelectionService : ICommentSelectionService + { + public Task FormatAsync(Document document, ImmutableArray changes, CancellationToken cancellationToken) + { + return Task.FromResult(document); + } + + public Task GetInfoAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken) + { + return Task.FromResult(new CommentSelectionInfo( + supportsSingleLineComment: true, + supportsBlockComment: true, + singleLineCommentString: "//", + blockCommentStartString: "(*", + blockCommentEndString: "*)")); + } + } +} From 98ff359ea8528ca6fc16ed47b25b7ba160165520 Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 03:06:25 -0700 Subject: [PATCH 13/22] Some cleanup. Added FSharpBlockStructureService --- .../FSharpCommentSelectionService.cs | 2 +- .../InternalFSharpNavigateToSearchResult.cs | 10 +-- .../Navigation/InternalFSharpNavigableItem.cs | 8 +-- .../Structure/FSharpBlockStructureService.cs | 34 ++++++++++ .../FSharpNavigateToSearchResult.cs | 10 +-- .../FSharp/Navigation/FSharpNavigableItem.cs | 8 +-- .../FSharp/Structure/FSharpBlockSpan.cs | 68 +++++++++++++++++++ .../FSharp/Structure/FSharpBlockStructure.cs | 16 +++++ .../FSharp/Structure/FSharpBlockTypes.cs | 29 ++++++++ .../Structure/IFSharpBlockStructureService.cs | 12 ++++ 10 files changed, 178 insertions(+), 19 deletions(-) create mode 100644 src/Tools/ExternalAccess/FSharp/Internal/Structure/FSharpBlockStructureService.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockSpan.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockStructure.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockTypes.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Structure/IFSharpBlockStructureService.cs diff --git a/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs b/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs index 85945d329f3cd..a68e6b54afff2 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/CommentSelection/FSharpCommentSelectionService.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.CommentSelection { [Shared] - [ExportLanguageService(typeof(ICommentSelectionService, LanguageNames.FSharp)] + [ExportLanguageService(typeof(ICommentSelectionService), LanguageNames.FSharp)] internal class FSharpCommentSelectionService : ICommentSelectionService { public Task FormatAsync(Document document, ImmutableArray changes, CancellationToken cancellationToken) diff --git a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs index aa54132c63200..05f3594abd4f9 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/InternalFSharpNavigateToSearchResult.cs @@ -20,15 +20,15 @@ public InternalFSharpNavigateToSearchResult(FSharpNavigateToSearchResult result) NavigableItem = new InternalFSharpNavigableItem(result.NavigableItem); } - public string AdditionalInformation { get; private set; } + public string AdditionalInformation { get; } - public string Kind { get; private set; } + public string Kind { get; } - public NavigateToMatchKind MatchKind { get; private set; } + public NavigateToMatchKind MatchKind { get; } public bool IsCaseSensitive => false; - public string Name { get; private set; } + public string Name { get; } public ImmutableArray NameMatchSpans => ImmutableArray.Empty; @@ -36,6 +36,6 @@ public InternalFSharpNavigateToSearchResult(FSharpNavigateToSearchResult result) public string Summary => null; - public INavigableItem NavigableItem { get; private set; } + public INavigableItem NavigableItem { get; } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs index 055a409e273a0..8cb8aced23088 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Navigation/InternalFSharpNavigableItem.cs @@ -17,17 +17,17 @@ public InternalFSharpNavigableItem(FSharpNavigableItem item) SourceSpan = item.SourceSpan; } - public Glyph Glyph { get; private set; } + public Glyph Glyph { get; } - public ImmutableArray DisplayTaggedParts { get; private set; } + public ImmutableArray DisplayTaggedParts { get; } public bool DisplayFileLocation => true; public bool IsImplicitlyDeclared => false; - public Document Document { get; private set; } + public Document Document { get; } - public TextSpan SourceSpan { get; private set; } + public TextSpan SourceSpan { get; } public ImmutableArray ChildItems => ImmutableArray.Empty; } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Structure/FSharpBlockStructureService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Structure/FSharpBlockStructureService.cs new file mode 100644 index 0000000000000..96705b4fa2a7d --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Internal/Structure/FSharpBlockStructureService.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Composition; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Structure; +using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Structure; +using Microsoft.CodeAnalysis.Host.Mef; +using System; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Structure +{ + [Shared] + [ExportLanguageService(typeof(BlockStructureService), LanguageNames.FSharp)] + internal class FSharpBlockStructureService : BlockStructureService + { + private readonly IFSharpBlockStructureService _service; + + [ImportingConstructor] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + public FSharpBlockStructureService(IFSharpBlockStructureService service) + { + _service = service; + } + + public override string Language => LanguageNames.FSharp; + + public override async Task GetBlockStructureAsync(Document document, CancellationToken cancellationToken) + { + var blockStructure = await _service.GetBlockStructureAsync(document, cancellationToken).ConfigureAwait(false); + return new BlockStructure(blockStructure.Spans.SelectAsArray(x => new BlockSpan(x.Type, x.IsCollapsible, x.TextSpan, x.HintSpan, x.BannerText, x.AutoCollapse, x.IsDefaultCollapsed))); + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs index 90a3e4f41ea05..3bc6b7c664c81 100644 --- a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs @@ -19,14 +19,14 @@ public FSharpNavigateToSearchResult( NavigableItem = navigateItem; } - public string AdditionalInformation { get; private set; } + public string AdditionalInformation { get; } - public string Kind { get; private set; } + public string Kind { get; } - public FSharpNavigateToMatchKind MatchKind { get; private set; } + public FSharpNavigateToMatchKind MatchKind { get; } - public string Name { get; private set; } + public string Name { get; } - public FSharpNavigableItem NavigableItem { get; private set; } + public FSharpNavigableItem NavigableItem { get; } } } diff --git a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs index cd4a65c1b63cf..8f615c82e1e91 100644 --- a/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs +++ b/src/Tools/ExternalAccess/FSharp/Navigation/FSharpNavigableItem.cs @@ -15,12 +15,12 @@ public FSharpNavigableItem(FSharpGlyph glyph, ImmutableArray display SourceSpan = sourceSpan; } - public FSharpGlyph Glyph { get; private set; } + public FSharpGlyph Glyph { get; } - public ImmutableArray DisplayTaggedParts { get; private set; } + public ImmutableArray DisplayTaggedParts { get; } - public Document Document { get; private set; } + public Document Document { get; } - public TextSpan SourceSpan { get; private set; } + public TextSpan SourceSpan { get; } } } diff --git a/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockSpan.cs b/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockSpan.cs new file mode 100644 index 0000000000000..d15f3341d2ad4 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockSpan.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Text; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Structure +{ + internal readonly struct FSharpBlockSpan + { + private const string Ellipses = "..."; + + /// + /// Whether or not this span can be collapsed. + /// + public bool IsCollapsible { get; } + + /// + /// The span of text to collapse. + /// + public TextSpan TextSpan { get; } + + /// + /// The span of text to display in the hint on mouse hover. + /// + public TextSpan HintSpan { get; } + + /// + /// The text to display inside the collapsed region. + /// + public string BannerText { get; } + + /// + /// Whether or not this region should be automatically collapsed when the 'Collapse to Definitions' command is invoked. + /// + public bool AutoCollapse { get; } + + /// + /// Whether this region should be collapsed by default when a file is opened the first time. + /// + public bool IsDefaultCollapsed { get; } + + public string Type { get; } + + public FSharpBlockSpan( + string type, bool isCollapsible, TextSpan textSpan, string bannerText = Ellipses, bool autoCollapse = false, bool isDefaultCollapsed = false) + : this(type, isCollapsible, textSpan, textSpan, bannerText, autoCollapse, isDefaultCollapsed) + { + } + + public FSharpBlockSpan( + string type, bool isCollapsible, TextSpan textSpan, TextSpan hintSpan, string bannerText = Ellipses, bool autoCollapse = false, bool isDefaultCollapsed = false) + { + TextSpan = textSpan; + BannerText = bannerText; + HintSpan = hintSpan; + AutoCollapse = autoCollapse; + IsDefaultCollapsed = isDefaultCollapsed; + IsCollapsible = isCollapsible; + Type = type; + } + + public override string ToString() + { + return this.TextSpan != this.HintSpan + ? $"{{Span={TextSpan}, HintSpan={HintSpan}, BannerText=\"{BannerText}\", AutoCollapse={AutoCollapse}, IsDefaultCollapsed={IsDefaultCollapsed}}}" + : $"{{Span={TextSpan}, BannerText=\"{BannerText}\", AutoCollapse={AutoCollapse}, IsDefaultCollapsed={IsDefaultCollapsed}}}"; + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockStructure.cs b/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockStructure.cs new file mode 100644 index 0000000000000..647d1b5d5d784 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockStructure.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Immutable; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Structure +{ + internal class FSharpBlockStructure + { + public ImmutableArray Spans { get; } + + public FSharpBlockStructure(ImmutableArray spans) + { + Spans = spans; + } + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockTypes.cs b/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockTypes.cs new file mode 100644 index 0000000000000..8f2902dc2d889 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Structure/FSharpBlockTypes.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Structure; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Structure +{ + internal static class FSharpBlockTypes + { + // Basic types. + public static string Nonstructural => BlockTypes.Nonstructural; + + // Trivstatic + public static string Comment => BlockTypes.Comment; + public static string PreprocessorRegion => BlockTypes.PreprocessorRegion; + + // Top static declarations. + public static string Imports => BlockTypes.Imports; + public static string Namespace => BlockTypes.Namespace; + public static string Type => BlockTypes.Type; + public static string Member => BlockTypes.Member; + + // Statstatic and expressions. + public static string Statement => BlockTypes.Statement; + public static string Conditional => BlockTypes.Conditional; + public static string Loop => BlockTypes.Loop; + + public static string Expression => BlockTypes.Expression; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Structure/IFSharpBlockStructureService.cs b/src/Tools/ExternalAccess/FSharp/Structure/IFSharpBlockStructureService.cs new file mode 100644 index 0000000000000..7a3a9fefadd0f --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Structure/IFSharpBlockStructureService.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Structure +{ + internal interface IFSharpBlockStructureService + { + Task GetBlockStructureAsync(Document document, CancellationToken cancellationToken); + } +} From f8d89b2e127bf407f4a483fa685f0191909039a3 Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 03:16:43 -0700 Subject: [PATCH 14/22] Added some simple statics --- .../FSharpPredefinedCodeFixProviderNames.cs | 12 ++++++++++++ .../FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs diff --git a/src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs b/src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs new file mode 100644 index 0000000000000..1ebabac59c82a --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.CodeFixes; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.CodeFixes +{ + internal static class FSharpPredefinedCodeFixProviderNames + { + // Normally this would be a property, but this is used inside an attribute. + public const string SimplifyNames = PredefinedCodeFixProviderNames.SimplifyNames; + } +} diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs new file mode 100644 index 0000000000000..d6e7342328e39 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.CodeAnalysis.Diagnostics; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics +{ + internal static class FSharpIDEDiagnosticIds + { + public static string SimplifyNamesDiagnosticId => IDEDiagnosticIds.SimplifyNamesDiagnosticId; + } +} From c3a33ea3e4f5285d9fcf01c0210b25a173b2a350 Mon Sep 17 00:00:00 2001 From: TIHan Date: Sun, 26 May 2019 04:54:13 -0700 Subject: [PATCH 15/22] Finishing the last of shims --- .../FSharpPredefinedCodeFixProviderNames.cs | 12 ---------- .../Diagnostics/FSharpIDEDiagnosticIds.cs | 1 + .../FSharpDependencyObjectExtensions.cs | 22 +++++++++++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) delete mode 100644 src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs create mode 100644 src/Tools/ExternalAccess/FSharp/Editor/Shared/Extensions/FSharpDependencyObjectExtensions.cs diff --git a/src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs b/src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs deleted file mode 100644 index 1ebabac59c82a..0000000000000 --- a/src/Tools/ExternalAccess/FSharp/CodeFixes/FSharpPredefinedCodeFixProviderNames.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.CodeAnalysis.CodeFixes; - -namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.CodeFixes -{ - internal static class FSharpPredefinedCodeFixProviderNames - { - // Normally this would be a property, but this is used inside an attribute. - public const string SimplifyNames = PredefinedCodeFixProviderNames.SimplifyNames; - } -} diff --git a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs b/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs index d6e7342328e39..fdc1b7bb01b3e 100644 --- a/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs +++ b/src/Tools/ExternalAccess/FSharp/Diagnostics/FSharpIDEDiagnosticIds.cs @@ -7,5 +7,6 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics internal static class FSharpIDEDiagnosticIds { public static string SimplifyNamesDiagnosticId => IDEDiagnosticIds.SimplifyNamesDiagnosticId; + public static string RemoveUnnecessaryImportsDiagnosticId => IDEDiagnosticIds.RemoveUnnecessaryImportsDiagnosticId; } } diff --git a/src/Tools/ExternalAccess/FSharp/Editor/Shared/Extensions/FSharpDependencyObjectExtensions.cs b/src/Tools/ExternalAccess/FSharp/Editor/Shared/Extensions/FSharpDependencyObjectExtensions.cs new file mode 100644 index 0000000000000..5392ce7016c42 --- /dev/null +++ b/src/Tools/ExternalAccess/FSharp/Editor/Shared/Extensions/FSharpDependencyObjectExtensions.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Windows; +using Microsoft.CodeAnalysis.Editor.Shared.Extensions; +using Microsoft.VisualStudio.Text.Classification; +using Microsoft.VisualStudio.Text.Formatting; + +namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Shared.Extensions +{ + internal static class FSharpDependencyObjectExtensions + { + public static void SetTextProperties(this DependencyObject dependencyObject, TextFormattingRunProperties textProperties) + { + DependencyObjectExtensions.SetTextProperties(dependencyObject, textProperties); + } + + public static void SetDefaultTextProperties(this DependencyObject dependencyObject, IClassificationFormatMap formatMap) + { + DependencyObjectExtensions.SetDefaultTextProperties(dependencyObject, formatMap); + } + } +} From ab56e246e9670fbca0072b3b76395ebca75701dc Mon Sep 17 00:00:00 2001 From: TIHan Date: Tue, 28 May 2019 14:09:52 -0700 Subject: [PATCH 16/22] Getting analyzers to work --- src/VisualStudio/Setup/source.extension.vsixmanifest | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VisualStudio/Setup/source.extension.vsixmanifest b/src/VisualStudio/Setup/source.extension.vsixmanifest index e61b589e7b099..391210ff97bfe 100644 --- a/src/VisualStudio/Setup/source.extension.vsixmanifest +++ b/src/VisualStudio/Setup/source.extension.vsixmanifest @@ -67,6 +67,7 @@ + From 10bd52e5d25b653af70a6b01122ba9b28bd13ddf Mon Sep 17 00:00:00 2001 From: TIHan Date: Tue, 28 May 2019 16:35:29 -0700 Subject: [PATCH 17/22] Remove folder --- .../Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj index 65bf8b2b55807..c8974fe6c76bf 100644 --- a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj +++ b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj @@ -97,8 +97,4 @@ - - - - \ No newline at end of file From b6e1398e1d2c5fae43e84e92befc116c61f8e8e6 Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 6 Jun 2019 13:40:41 -0700 Subject: [PATCH 18/22] Changes due to feedback --- .../FSharp/Editor/IFSharpEditorInlineRenameService.cs | 8 ++++---- .../FSharpDocumentHighlightsService.cs | 7 ++++--- .../Internal/Editor/FSharpEditorInlineRenameService.cs | 3 ++- .../FSharp/Internal/FSharpContentTypeDefinitions.cs | 4 ++-- .../ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs | 5 +++-- .../NavigateTo/FSharpNavigateToMatchKindHelpers.cs | 3 ++- .../Internal/SignatureHelp/FSharpSignatureHelpProvider.cs | 2 +- .../FSharpSignatureHelpTriggerReasonHelpers.cs | 3 ++- .../FSharp/NavigateTo/FSharpNavigateToSearchResult.cs | 1 + .../SignatureHelp/FSharpSignatureHelpTriggerInfo.cs | 1 - src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs | 5 +++-- .../FSharpTest/FSharpHighlightSpanKindTests.cs | 3 ++- .../FSharpTest/FSharpInlineRenameReplacementKindTests.cs | 3 ++- .../FSharpTest/FSharpNavigateToMatchKindTests.cs | 3 ++- .../FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs | 3 ++- 15 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs index 0ab93471d363f..a37e48fbe1c69 100644 --- a/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs +++ b/src/Tools/ExternalAccess/FSharp/Editor/IFSharpEditorInlineRenameService.cs @@ -9,12 +9,12 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor { - internal struct FSharpInlineRenameLocation + internal readonly struct FSharpInlineRenameLocation { public Document Document { get; } public TextSpan TextSpan { get; } - public FSharpInlineRenameLocation(Document document, TextSpan textSpan) : this() + public FSharpInlineRenameLocation(Document document, TextSpan textSpan) { this.Document = document; this.TextSpan = textSpan; @@ -30,13 +30,13 @@ internal enum FSharpInlineRenameReplacementKind Complexified, } - internal struct FSharpInlineRenameReplacement + internal readonly struct FSharpInlineRenameReplacement { public FSharpInlineRenameReplacementKind Kind { get; } public TextSpan OriginalSpan { get; } public TextSpan NewSpan { get; } - public FSharpInlineRenameReplacement(FSharpInlineRenameReplacementKind kind, TextSpan originalSpan, TextSpan newSpan) : this() + public FSharpInlineRenameReplacement(FSharpInlineRenameReplacementKind kind, TextSpan originalSpan, TextSpan newSpan) { this.Kind = kind; this.OriginalSpan = originalSpan; diff --git a/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs b/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs index db262ef0727b8..4e6d0ce8f3aac 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/DocumentHighlighting/FSharpDocumentHighlightsService.cs @@ -9,6 +9,7 @@ using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.DocumentHighlighting; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.DocumentHighlighting { @@ -40,7 +41,7 @@ public static HighlightSpanKind ConvertTo(FSharpHighlightSpanKind kind) default: { - throw new ArgumentException("Enum case not handled.", nameof(kind)); + throw ExceptionUtilities.UnexpectedValue(kind); } } } @@ -61,13 +62,13 @@ public FSharpDocumentHighlightsService(IFSharpDocumentHighlightsService service) private static ImmutableArray MapHighlightSpans(ImmutableArray highlightSpans) { - return highlightSpans.Select(x => new HighlightSpan(x.TextSpan, FSharpHighlightSpanKindHelpers.ConvertTo(x.Kind))).AsImmutable(); + return highlightSpans.SelectAsArray(x => new HighlightSpan(x.TextSpan, FSharpHighlightSpanKindHelpers.ConvertTo(x.Kind))); } public async Task> GetDocumentHighlightsAsync(Document document, int position, IImmutableSet documentsToSearch, CancellationToken cancellationToken) { var highlights = await _service.GetDocumentHighlightsAsync(document, position, documentsToSearch, cancellationToken).ConfigureAwait(false); - return highlights.Select(x => new DocumentHighlights(x.Document, MapHighlightSpans(x.HighlightSpans))).AsImmutable(); + return highlights.SelectAsArray(x => new DocumentHighlights(x.Document, MapHighlightSpans(x.HighlightSpans))); } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs index 766bb290675ec..5533fb29bb058 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/Editor/FSharpEditorInlineRenameService.cs @@ -11,6 +11,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor { @@ -47,7 +48,7 @@ public static InlineRenameReplacementKind ConvertTo(FSharpInlineRenameReplacemen default: { - throw new ArgumentException("Enum case not handled.", nameof(kind)); + throw ExceptionUtilities.UnexpectedValue(kind); } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs b/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs index 817f927bcb6c2..f818d1ad4ffc7 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/FSharpContentTypeDefinitions.cs @@ -11,11 +11,11 @@ internal static class FSharpContentTypeDefinitions [Export] [Name(FSharpContentTypeNames.FSharpContentType)] [BaseDefinition(FSharpContentTypeNames.RoslynContentType)] - public static ContentTypeDefinition FSharpContentTypeDefinition => new ContentTypeDefinition(); + public static readonly ContentTypeDefinition FSharpContentTypeDefinition; [Export] [Name(FSharpContentTypeNames.FSharpSignatureHelpContentType)] [BaseDefinition("sighelp")] - public static ContentTypeDefinition FSharpSignatureHelpContentTypeDefinition => new ContentTypeDefinition(); + public static readonly ContentTypeDefinition FSharpSignatureHelpContentTypeDefinition; } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs index 4f7984e836a6a..f2a160e53eaaa 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/FSharpGlyphHelpers.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal { @@ -316,7 +317,7 @@ public static FSharpGlyph ConvertFrom(Microsoft.CodeAnalysis.Glyph glyph) } default: { - throw new ArgumentException("Enum case not handled.", nameof(glyph)); + throw ExceptionUtilities.UnexpectedValue(glyph); } } } @@ -631,7 +632,7 @@ public static Microsoft.CodeAnalysis.Glyph ConvertTo(FSharpGlyph glyph) } default: { - throw new ArgumentException("Enum case not handled.", nameof(glyph)); + throw ExceptionUtilities.UnexpectedValue(glyph); } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs index 5024a4a4cb552..2deda2c764019 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/NavigateTo/FSharpNavigateToMatchKindHelpers.cs @@ -3,6 +3,7 @@ using System; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo; using Microsoft.CodeAnalysis.NavigateTo; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.NavigateTo { @@ -58,7 +59,7 @@ public static NavigateToMatchKind ConvertTo(FSharpNavigateToMatchKind kind) } default: { - throw new ArgumentException("Enum case not handled.", nameof(kind)); + throw ExceptionUtilities.UnexpectedValue(kind); } } } diff --git a/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs index 81966279da109..a94a34835c57c 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp { [Shared] - [ExportSignatureHelpProvider("FSharpSignatureHelpProvider", LanguageNames.FSharp)] + [ExportSignatureHelpProvider(nameof(FSharpSignatureHelpProvider), LanguageNames.FSharp)] internal class FSharpSignatureHelpProvider : ISignatureHelpProvider { private readonly IFSharpSignatureHelpProvider _provider; diff --git a/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs index 1a6cea72d1917..bde026f627da6 100644 --- a/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs +++ b/src/Tools/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpTriggerReasonHelpers.cs @@ -3,6 +3,7 @@ using System; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp; using Microsoft.CodeAnalysis.SignatureHelp; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp { @@ -29,7 +30,7 @@ public static FSharpSignatureHelpTriggerReason ConvertFrom(SignatureHelpTriggerR default: { - throw new ArgumentException("Enum case not handled.", nameof(triggerReason)); + throw ExceptionUtilities.UnexpectedValue(triggerReason); } } } diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs index 3bc6b7c664c81..3bcd0e14d48a9 100644 --- a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToSearchResult.cs @@ -15,6 +15,7 @@ public FSharpNavigateToSearchResult( { AdditionalInformation = additionalInformation; Kind = kind; + Name = name; MatchKind = matchKind; NavigableItem = navigateItem; } diff --git a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs index 9e60088578e04..c07dd984c3485 100644 --- a/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs +++ b/src/Tools/ExternalAccess/FSharp/SignatureHelp/FSharpSignatureHelpTriggerInfo.cs @@ -10,7 +10,6 @@ internal readonly struct FSharpSignatureHelpTriggerInfo public char? TriggerCharacter { get; } internal FSharpSignatureHelpTriggerInfo(FSharpSignatureHelpTriggerReason triggerReason, char? triggerCharacter = null) - : this() { Contract.ThrowIfTrue(triggerReason == FSharpSignatureHelpTriggerReason.TypeCharCommand && triggerCharacter == null); this.TriggerReason = triggerReason; diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs index c3a60cbe066f5..ab30e91cd2262 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpGlyphTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal; +using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests @@ -335,7 +336,7 @@ internal static FSharpGlyph GetExpectedFSharpGlyph(Microsoft.CodeAnalysis.Glyph } default: { - throw new ArgumentException("Enum case not handled.", nameof(glyph)); + throw ExceptionUtilities.UnexpectedValue(glyph); } } } @@ -650,7 +651,7 @@ internal static Microsoft.CodeAnalysis.Glyph GetExpectedGlyph(FSharpGlyph glyph) } default: { - throw new ArgumentException("Enum case not handled.", nameof(glyph)); + throw ExceptionUtilities.UnexpectedValue(glyph); } } } diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs index 3cb2ac2f08045..3d0a1f7c11986 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpHighlightSpanKindTests.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.DocumentHighlighting; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.DocumentHighlighting; +using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests @@ -45,7 +46,7 @@ internal static HighlightSpanKind GetExpectedHighlightSpanKind(FSharpHighlightSp default: { - throw new ArgumentException("Enum case not handled.", nameof(kind)); + throw ExceptionUtilities.UnexpectedValue(kind); } } } diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs index 53600e00732da..59596e5db5b98 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpInlineRenameReplacementKindTests.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.Editor; +using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests @@ -50,7 +51,7 @@ internal static InlineRenameReplacementKind GetExpectedInlineRenameReplacementKi default: { - throw new ArgumentException("Enum case not handled.", nameof(kind)); + throw ExceptionUtilities.UnexpectedValue(kind); } } } diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs index 107aa0dbed9c2..3b18aa55e2ca7 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpNavigateToMatchKindTests.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.NavigateTo; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo; using Microsoft.CodeAnalysis.NavigateTo; +using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests @@ -69,7 +70,7 @@ internal static NavigateToMatchKind GetExpectedNavigateToMatchKind(FSharpNavigat } default: { - throw new ArgumentException("Enum case not handled.", nameof(kind)); + throw ExceptionUtilities.UnexpectedValue(kind); } } } diff --git a/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs b/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs index 331b80b669c72..237fe89a884ca 100644 --- a/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs +++ b/src/Tools/ExternalAccess/FSharpTest/FSharpSignatureHelpTriggerReasonTests.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp; using Microsoft.CodeAnalysis.SignatureHelp; +using Roslyn.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests @@ -40,7 +41,7 @@ internal static FSharpSignatureHelpTriggerReason GetExpectedTriggerReason(Signat default: { - throw new ArgumentException("Enum case not handled.", nameof(triggerReason)); + throw ExceptionUtilities.UnexpectedValue(triggerReason); } } } From b0e1cbfb076386b38cda014f641538250b00b598 Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 7 Jun 2019 14:11:39 -0700 Subject: [PATCH 19/22] Fixing build --- .../FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj index c8974fe6c76bf..93370878ecce8 100644 --- a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj +++ b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj @@ -77,9 +77,7 @@ - - From 76e06343266effc9bcd3f50ce472536edacf47aa Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 7 Jun 2019 16:27:04 -0700 Subject: [PATCH 20/22] Still trying to fix build --- .../FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj | 1 + ...Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj index 93370878ecce8..da1601b8115d8 100644 --- a/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj +++ b/src/Tools/ExternalAccess/FSharp/Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj @@ -78,6 +78,7 @@ + diff --git a/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj b/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj index b5b343aee3579..dadc1d28465f3 100644 --- a/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj +++ b/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj @@ -35,5 +35,6 @@ + \ No newline at end of file From 2cf6c1130555a344eb4f131e97bdc3608af1c790 Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 7 Jun 2019 18:51:43 -0700 Subject: [PATCH 21/22] Fixed guid --- Roslyn.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roslyn.sln b/Roslyn.sln index 143443c37f7ba..d8933bfa2a311 100644 --- a/Roslyn.sln +++ b/Roslyn.sln @@ -404,7 +404,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Exte EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.VisualStudio.Setup.ServiceHub", "src\Setup\DevDivVsix\ServiceHubConfig\Roslyn.VisualStudio.Setup.ServiceHub.csproj", "{3D33BBFD-EC63-4E8C-A714-0A48A3809A87}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests", "src\Tools\ExternalAccess\FSharpTest\Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj", "{BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests", "src\Tools\ExternalAccess\FSharpTest\Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj", "{BFFB5CAE-33B5-447E-9218-BDEBFDA96CB5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Apex", "src\Tools\ExternalAccess\Apex\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj", "{FC32EF16-31B1-47B3-B625-A80933CB3F29}" EndProject From f0e004ea07bf13fdca510bb2940a6120804a3f3a Mon Sep 17 00:00:00 2001 From: TIHan Date: Mon, 10 Jun 2019 16:09:38 -0700 Subject: [PATCH 22/22] Fixing build again --- ...nalysis.ExternalAccess.FSharp.UnitTests.csproj | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj b/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj index dadc1d28465f3..e166d9241e0fb 100644 --- a/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj +++ b/src/Tools/ExternalAccess/FSharpTest/Microsoft.CodeAnalysis.ExternalAccess.FSharp.UnitTests.csproj @@ -7,7 +7,22 @@ net472 + + + + + + + + + + + + + + +