Skip to content

Commit a5510fb

Browse files
TIHanbrettfo
authored andcommitted
Roslyn Shim - First Phase (#6498)
* Trying to use shim * Removed contenttypelangservice, it's in externalaccess now * Added namespace * Added diagnosticanalyzerservice shim * Using Brace matching from external access * Using VSWorkspace extensions * More apis * Using shim for IEditorFormattingService * More apis * More shims * Updating shim * Update VisualFSharp.UnitTests.fsproj * Fixed api call * Fix debugging * Fixed unit test fsproj, find all refs shimmed * Change analyserservice * Fixed build * Updating shim with FSharp prefixes * Fixing glyph helpers * Fixing typemap * Update fsi.fsproj * Update Versions.props * Update RoslynPackageVersion.txt * Update prim-lexing.fs * Update prim-lexing.fs * Update fsi.fsproj * Update fsi.fsproj * Update VisualFSharp.UnitTests.fsproj * Update CompletionProvider.fs * Fixed package
1 parent 69539f2 commit a5510fb

27 files changed

+92
-76
lines changed

RoslynPackageVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-beta4-19170-01
1+
3.1.0-beta3-19222-02

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
https://api.nuget.org/v3/index.json;
5252
https://dotnet.myget.org/F/roslyn/api/v3/index.json;
5353
https://dotnet.myget.org/F/symreader-converter/api/v3/index.json;
54+
https://dotnet.myget.org/F/interactive-window/api/v3/index.json;
5455
https://myget.org/F/vs-devcore/api/v3/index.json;
5556
https://myget.org/F/vs-editor/api/v3/index.json;
5657
https://vside.myget.org/F/vssdk/api/v3/index.json;

vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ open Microsoft.CodeAnalysis.Classification
1313
open Microsoft.CodeAnalysis.Editor
1414
open Microsoft.CodeAnalysis.Host.Mef
1515
open Microsoft.CodeAnalysis.Text
16+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Classification
1617

1718
// IEditorClassificationService is marked as Obsolete, but is still supported. The replacement (IClassificationService)
1819
// is internal to Microsoft.CodeAnalysis.Workspaces which we don't have internals visible to. Rather than add yet another
@@ -21,7 +22,7 @@ open Microsoft.CodeAnalysis.Text
2122

2223
open FSharp.Compiler.SourceCodeServices
2324

24-
[<ExportLanguageService(typeof<IEditorClassificationService>, FSharpConstants.FSharpLanguageName)>]
25+
[<Export(typeof<IFSharpClassificationService>)>]
2526
type internal FSharpClassificationService
2627
[<ImportingConstructor>]
2728
(
@@ -30,7 +31,7 @@ type internal FSharpClassificationService
3031
) =
3132
static let userOpName = "SemanticColorization"
3233

33-
interface IEditorClassificationService with
34+
interface IFSharpClassificationService with
3435
// Do not perform classification if we don't have project options (#defines matter)
3536
member __.AddLexicalClassifications(_: SourceText, _: TextSpan, _: List<ClassifiedSpan>, _: CancellationToken) = ()
3637

vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ open Microsoft.VisualStudio.Text.Classification
1919
open Microsoft.VisualStudio.ComponentModelHost
2020
open System.Threading
2121
open Microsoft.VisualStudio.FSharp.Editor.Logging
22+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Shared.Utilities
2223

2324
[<Export(typeof<IWpfTextViewCreationListener>)>]
2425
[<Export(typeof<IViewTaggerProvider>)>]
@@ -32,7 +33,7 @@ type internal CodeLensProvider
3233
textDocumentFactory: ITextDocumentFactoryService,
3334
checkerProvider: FSharpCheckerProvider,
3435
projectInfoManager: FSharpProjectOptionsManager,
35-
typeMap : ClassificationTypeMap Lazy,
36+
typeMap : FSharpClassificationTypeMap Lazy,
3637
settings: EditorOptions
3738
) =
3839

vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ open Microsoft.CodeAnalysis
1515
open Microsoft.CodeAnalysis.Editor.Shared.Extensions
1616
open Microsoft.CodeAnalysis.Editor.Shared.Utilities
1717
open Microsoft.CodeAnalysis.Classification
18+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Classification
1819

1920
open FSharp.Compiler
2021
open FSharp.Compiler.Ast
@@ -31,6 +32,8 @@ open Microsoft.VisualStudio.Text.Formatting
3132

3233
open Internal.Utilities.StructuredFormat
3334

35+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor.Shared.Utilities
36+
3437
type internal CodeLens(taggedText, computed, fullTypeSignature, uiElement) =
3538
member val TaggedText: Async<(ResizeArray<Layout.TaggedText> * QuickInfoNavigation) option> = taggedText
3639
member val Computed: bool = computed with get, set
@@ -46,7 +49,7 @@ type internal FSharpCodeLensService
4649
checker: FSharpChecker,
4750
projectInfoManager: FSharpProjectOptionsManager,
4851
classificationFormatMapService: IClassificationFormatMapService,
49-
typeMap: Lazy<ClassificationTypeMap>,
52+
typeMap: Lazy<FSharpClassificationTypeMap>,
5053
codeLens : CodeLensDisplayService,
5154
settings: EditorOptions
5255
) as self =
@@ -78,7 +81,7 @@ type internal FSharpCodeLensService
7881
let layoutTagToFormatting (layoutTag: LayoutTag) =
7982
layoutTag
8083
|> RoslynHelpers.roslynTag
81-
|> ClassificationTags.GetClassificationTypeName
84+
|> FSharpClassificationTags.GetClassificationTypeName
8285
|> typeMap.Value.GetClassificationType
8386
|> formatMap.Value.GetTextProperties
8487

vsintegration/src/FSharp.Editor/Common/ContentType.fs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ open System.ComponentModel.Composition
66

77
open Microsoft.CodeAnalysis.Editor
88
open Microsoft.VisualStudio.Utilities
9+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Editor
910

1011
module FSharpStaticTypeDefinitions =
1112
[<Export>]
@@ -17,11 +18,3 @@ module FSharpStaticTypeDefinitions =
1718
[<Name(FSharpConstants.FSharpSignatureHelpContentTypeName)>]
1819
[<BaseDefinition("sighelp")>]
1920
let FSharpSignatureHelpContentTypeDefinition = ContentTypeDefinition()
20-
21-
[<ExportContentTypeLanguageService(FSharpConstants.FSharpContentTypeName, FSharpConstants.FSharpLanguageName)>]
22-
type FSharpContentType [<System.Composition.ImportingConstructor>](contentTypeRegistry : IContentTypeRegistryService) =
23-
member this.contentTypeRegistryService = contentTypeRegistry
24-
25-
interface IContentTypeLanguageService with
26-
member this.GetDefaultContentType() =
27-
this.contentTypeRegistryService.GetContentType(FSharpConstants.FSharpContentTypeName)

vsintegration/src/FSharp.Editor/Common/Extensions.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ open Microsoft.CodeAnalysis.Host
1111
open FSharp.Compiler.Text
1212
open FSharp.Compiler.Ast
1313
open FSharp.Compiler.SourceCodeServices
14+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp
15+
16+
type private FSharpGlyph = FSharp.Compiler.SourceCodeServices.FSharpGlyph
17+
type private Glyph = Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyph
1418

1519

1620
type Path with

vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ open FSharp.Compiler.Layout
1515
open FSharp.Compiler.SourceCodeServices
1616
open FSharp.Compiler.Range
1717
open Microsoft.VisualStudio.FSharp.Editor.Logging
18+
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Diagnostics
1819

1920
[<RequireQualifiedAccess>]
2021
module internal RoslynHelpers =
@@ -149,7 +150,7 @@ module internal RoslynHelpers =
149150
let severity = if error.Severity = FSharpErrorSeverity.Error then DiagnosticSeverity.Error else DiagnosticSeverity.Warning
150151
let customTags =
151152
match error.ErrorNumber with
152-
| 1182 -> DiagnosticCustomTags.Unnecessary
153+
| 1182 -> FSharpDiagnosticCustomTags.Unnecessary
153154
| _ -> null
154155
let descriptor = new DiagnosticDescriptor(id, emptyString, description, error.Subcategory, severity, true, emptyString, String.Empty, customTags)
155156
Diagnostic.Create(descriptor, location)

vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ type internal FSharpCompletionProvider
156156
| _, idents -> Array.last idents
157157

158158
let completionItem =
159-
CommonCompletionItem.Create(name, null, glyph = Nullable glyph, rules = getRules intellisenseOptions.ShowAfterCharIsTyped, filterText = filterText)
159+
CommonCompletionItem.Create(name, null, rules = getRules intellisenseOptions.ShowAfterCharIsTyped, glyph = Nullable (Microsoft.CodeAnalysis.ExternalAccess.FSharp.FSharpGlyphHelpersObsolete.Convert(glyph)), filterText = filterText)
160160
.AddProperty(FullNamePropName, declarationItem.FullName)
161161

162162
let completionItem =
@@ -303,4 +303,4 @@ type internal FSharpCompletionProvider
303303
}
304304
|> Async.map (Option.defaultValue (CompletionChange.Create(TextChange(item.Span, nameInCode))))
305305

306-
} |> RoslynHelpers.StartAsyncAsTask cancellationToken
306+
} |> RoslynHelpers.StartAsyncAsTask cancellationToken

vsintegration/src/FSharp.Editor/Completion/FileSystemCompletion.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ type internal HashDirectiveCompletionProvider(workspace: Workspace, projectInfoM
129129
rules)
130130

131131
let pathThroughLastSlash = getPathThroughLastSlash(text, position, quotedPathGroup)
132-
context.AddItems(helper.GetItems(pathThroughLastSlash, ct))
132+
let! items = helper.GetItemsAsync(pathThroughLastSlash, ct) |> Async.AwaitTask |> liftAsync
133+
context.AddItems(items)
133134
}
134135
|> Async.Ignore
135136
|> RoslynHelpers.StartAsyncUnitAsTask context.CancellationToken

0 commit comments

Comments
 (0)