Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 6f3dadf

Browse files
dsymeDon Syme
andauthored
Further work on FCS API (dotnet#10772)
* trim API surface area * move Range and Pos types to FSharp.Compiler * undo uppercae range/pos * move Range and Pos types to FSHarp.Compiler.SourceCodeServices since they are part of the FCS API * fix baselines * release notes * FIX BUILD * fix test * fix test * fix test * fix test * fix build * fix build * fix build * PrettyNaming moved to SourceCodeServices * ISourceText moved to SourceCodeServices * update docs * update docs * fix build * fix build * move Range, Pos to FSharp.Compiler.Text * fix test * fix build Co-authored-by: Don Syme <donsyme@fastmail.com>
1 parent 0875147 commit 6f3dadf

File tree

64 files changed

+337
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+337
-351
lines changed

AutomaticCompletion/BraceCompletionSessionProvider.fs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ type BraceCompletionSession
7676
let mutable openingPoint : ITrackingPoint = null
7777
let editorOperations = editorOperationsFactoryService.GetEditorOperations(textView)
7878

79-
member __.EndSession() =
79+
member _.EndSession() =
8080
closingPoint <- null
8181
openingPoint <- null
8282

83-
member __.CreateUndoTransaction() =
83+
member _.CreateUndoTransaction() =
8484
undoHistory.CreateTransaction(BraceCompletion)
8585

8686
member this.Start (cancellationToken: CancellationToken) =
@@ -148,7 +148,7 @@ type BraceCompletionSession
148148

149149
undo.Complete()
150150

151-
member __.HasNoForwardTyping(caretPoint: SnapshotPoint, endPoint: SnapshotPoint) =
151+
member _.HasNoForwardTyping(caretPoint: SnapshotPoint, endPoint: SnapshotPoint) =
152152
Debug.Assert(caretPoint.Snapshot = endPoint.Snapshot, "snapshots do not match")
153153

154154
if caretPoint.Snapshot = endPoint.Snapshot then
@@ -173,7 +173,7 @@ type BraceCompletionSession
173173
else
174174
false
175175

176-
member __.MoveCaretToClosingPoint() =
176+
member _.MoveCaretToClosingPoint() =
177177
let closingSnapshotPoint = closingPoint.GetPoint(subjectBuffer.CurrentSnapshot)
178178

179179
// find the position just after the closing brace in the view's text buffer
@@ -217,7 +217,7 @@ type BraceCompletionSession
217217
undo.Complete()
218218
this.EndSession()
219219

220-
member __.PostBackspace() = ()
220+
member _.PostBackspace() = ()
221221

222222
member this.PreOverType handledCommand =
223223
handledCommand <- false
@@ -259,7 +259,7 @@ type BraceCompletionSession
259259
undo.Complete()
260260
| _ -> ()
261261

262-
member __.PostOverType() = ()
262+
member _.PostOverType() = ()
263263

264264
member this.PreTab handledCommand =
265265
handledCommand <- false
@@ -274,7 +274,7 @@ type BraceCompletionSession
274274
editorOperations.AddAfterTextBufferChangePrimitive()
275275
undo.Complete()
276276

277-
member __.PreReturn handledCommand =
277+
member _.PreReturn handledCommand =
278278
handledCommand <- false
279279

280280
member this.PostReturn() =
@@ -286,26 +286,26 @@ type BraceCompletionSession
286286
session.AfterReturn(this, CancellationToken.None)
287287
| _ -> ()
288288

289-
member __.Finish() = ()
289+
member _.Finish() = ()
290290

291-
member __.PostTab() = ()
291+
member _.PostTab() = ()
292292

293-
member __.PreDelete handledCommand =
293+
member _.PreDelete handledCommand =
294294
handledCommand <- false
295295

296-
member __.PostDelete() = ()
296+
member _.PostDelete() = ()
297297

298-
member __.OpeningBrace = openingBrace
298+
member _.OpeningBrace = openingBrace
299299

300-
member __.ClosingBrace = closingBrace
300+
member _.ClosingBrace = closingBrace
301301

302-
member __.OpeningPoint = openingPoint
302+
member _.OpeningPoint = openingPoint
303303

304-
member __.ClosingPoint = closingPoint
304+
member _.ClosingPoint = closingPoint
305305

306-
member __.SubjectBuffer = subjectBuffer
306+
member _.SubjectBuffer = subjectBuffer
307307

308-
member __.TextView = textView
308+
member _.TextView = textView
309309

310310
module Parenthesis =
311311

@@ -372,88 +372,88 @@ type ParenthesisCompletionSession() =
372372

373373
interface IEditorBraceCompletionSession with
374374

375-
member __.AfterReturn(_session, _cancellationToken) =
375+
member _.AfterReturn(_session, _cancellationToken) =
376376
()
377377

378-
member __.AfterStart(_session, _cancellationToken) =
378+
member _.AfterStart(_session, _cancellationToken) =
379379
()
380380

381-
member __.AllowOverType(_session, _cancellationToken) =
381+
member _.AllowOverType(_session, _cancellationToken) =
382382
true
383383

384-
member __.CheckOpeningPoint(_session, _cancellationToken) =
384+
member _.CheckOpeningPoint(_session, _cancellationToken) =
385385
true
386386

387387
type DoubleQuoteCompletionSession() =
388388

389389
interface IEditorBraceCompletionSession with
390390

391-
member __.AfterReturn(_session, _cancellationToken) =
391+
member _.AfterReturn(_session, _cancellationToken) =
392392
()
393393

394-
member __.AfterStart(_session, _cancellationToken) =
394+
member _.AfterStart(_session, _cancellationToken) =
395395
()
396396

397-
member __.AllowOverType(_session, _cancellationToken) =
397+
member _.AllowOverType(_session, _cancellationToken) =
398398
true
399399

400-
member __.CheckOpeningPoint(_session, _cancellationToken) =
400+
member _.CheckOpeningPoint(_session, _cancellationToken) =
401401
true
402402

403403
type VerticalBarCompletionSession() =
404404

405405
interface IEditorBraceCompletionSession with
406406

407-
member __.AfterReturn(_session, _cancellationToken) =
407+
member _.AfterReturn(_session, _cancellationToken) =
408408
()
409409

410-
member __.AfterStart(_session, _cancellationToken) =
410+
member _.AfterStart(_session, _cancellationToken) =
411411
()
412412

413-
member __.AllowOverType(_session, _cancellationToken) =
413+
member _.AllowOverType(_session, _cancellationToken) =
414414
true
415415

416416
(* This is for [| |] and {| |} , since the implementation deals with chars only.
417417
We have to test if there is a { or [ before the cursor position and insert the closing '|'. *)
418-
member __.CheckOpeningPoint(session, _cancellationToken) =
418+
member _.CheckOpeningPoint(session, _cancellationToken) =
419419
tryInsertAdditionalBracePair session CurlyBrackets.OpenCharacter CurlyBrackets.CloseCharacter ||
420420
tryInsertAdditionalBracePair session SquareBrackets.OpenCharacter SquareBrackets.CloseCharacter
421421

422422
type AngleBracketCompletionSession() =
423423

424424
interface IEditorBraceCompletionSession with
425425

426-
member __.AfterReturn(_session, _cancellationToken) =
426+
member _.AfterReturn(_session, _cancellationToken) =
427427
()
428428

429-
member __.AfterStart(_session, _cancellationToken) =
429+
member _.AfterStart(_session, _cancellationToken) =
430430
()
431431

432-
member __.AllowOverType(_session, _cancellationToken) =
432+
member _.AllowOverType(_session, _cancellationToken) =
433433
true
434434

435435
(* This is for attributes [< >] , since the implementation deals with chars only.
436436
We have to test if there is a [ before the cursor position and insert the closing '>'. *)
437-
member __.CheckOpeningPoint(session, _cancellationToken) =
437+
member _.CheckOpeningPoint(session, _cancellationToken) =
438438
tryInsertAdditionalBracePair session SquareBrackets.OpenCharacter SquareBrackets.CloseCharacter
439439

440440
(* For multi-line comments, test if it is between "()" *)
441441
type AsteriskCompletionSession() =
442442

443443
interface IEditorBraceCompletionSession with
444444

445-
member __.AfterReturn(_session, _cancellationToken) =
445+
member _.AfterReturn(_session, _cancellationToken) =
446446
()
447447

448-
member __.AfterStart(_session, _cancellationToken) =
448+
member _.AfterStart(_session, _cancellationToken) =
449449
()
450450

451-
member __.AllowOverType(_session, _cancellationToken) =
451+
member _.AllowOverType(_session, _cancellationToken) =
452452
true
453453

454454
(* This is for attributes [< >] , since the implementation deals with chars only.
455455
We have to test if there is a [ before the cursor position and insert the closing '>'. *)
456-
member __.CheckOpeningPoint(session, _cancellationToken) =
456+
member _.CheckOpeningPoint(session, _cancellationToken) =
457457
tryInsertAdditionalBracePair session Parenthesis.OpenCharacter Parenthesis.CloseCharacter
458458

459459
[<ExportLanguageService(typeof<IEditorBraceCompletionSessionFactory>, FSharpConstants.FSharpLanguageName)>]
@@ -465,14 +465,14 @@ type EditorBraceCompletionSessionFactory() =
465465
| ClassificationTypeNames.StringLiteral -> false
466466
| _ -> true
467467

468-
member __.IsSupportedOpeningBrace openingBrace =
468+
member _.IsSupportedOpeningBrace openingBrace =
469469
match openingBrace with
470470
| Parenthesis.OpenCharacter | CurlyBrackets.OpenCharacter | SquareBrackets.OpenCharacter
471471
| DoubleQuote.OpenCharacter | VerticalBar.OpenCharacter | AngleBrackets.OpenCharacter
472472
| Asterisk.OpenCharacter -> true
473473
| _ -> false
474474

475-
member __.CheckCodeContext(document: Document, position: int, _openingBrace:char, cancellationToken) =
475+
member _.CheckCodeContext(document: Document, position: int, _openingBrace:char, cancellationToken) =
476476
// We need to know if we are inside a F# string or comment. If we are, then don't do automatic completion.
477477
let sourceCodeTask = document.GetTextAsync(cancellationToken)
478478
sourceCodeTask.Wait(cancellationToken)
@@ -504,7 +504,7 @@ type EditorBraceCompletionSessionFactory() =
504504
// classifiedSpan.TextSpan.IntersectsWith position &&
505505
// not (spanIsString classifiedSpan)))))
506506

507-
member __.CreateEditorSession(_document, _openingPosition, openingBrace, _cancellationToken) =
507+
member _.CreateEditorSession(_document, _openingPosition, openingBrace, _cancellationToken) =
508508
match openingBrace with
509509
| Parenthesis.OpenCharacter -> ParenthesisCompletionSession() :> IEditorBraceCompletionSession
510510
| CurlyBrackets.OpenCharacter -> ParenthesisCompletionSession() :> IEditorBraceCompletionSession
@@ -541,7 +541,7 @@ type BraceCompletionSessionProvider
541541

542542
interface IBraceCompletionSessionProvider with
543543

544-
member __.TryCreateSession(textView, openingPoint, openingBrace, closingBrace, session) =
544+
member _.TryCreateSession(textView, openingPoint, openingBrace, closingBrace, session) =
545545
session <-
546546
maybe {
547547
let! document = openingPoint.Snapshot.GetOpenDocumentInCurrentContextWithChanges() |> Option.ofObj

Build/SetGlobalPropertiesForSdkProjects.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ type internal SetGlobalPropertiesForSdkProjects
2222
) =
2323
inherit StaticGlobalPropertiesProviderBase(projectService.Services)
2424

25-
override __.GetGlobalPropertiesAsync(_cancellationToken: CancellationToken): Task<IImmutableDictionary<string, string>> =
25+
override _.GetGlobalPropertiesAsync(_cancellationToken: CancellationToken): Task<IImmutableDictionary<string, string>> =
2626
let properties = Empty.PropertiesMap.Add("FSharpCompilerPath", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
2727
Task.FromResult<IImmutableDictionary<string, string>>(properties)

Classification/ClassificationService.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ open Microsoft.CodeAnalysis.Host.Mef
1717
open Microsoft.CodeAnalysis.Text
1818
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Classification
1919

20+
open Microsoft.CodeAnalysis
21+
open FSharp.Compiler.SourceCodeServices
22+
open FSharp.Compiler.Text
23+
2024
// IEditorClassificationService is marked as Obsolete, but is still supported. The replacement (IClassificationService)
2125
// is internal to Microsoft.CodeAnalysis.Workspaces which we don't have internals visible to. Rather than add yet another
2226
// IVT, we'll maintain the status quo.
2327
#nowarn "44"
2428

2529
#nowarn "57"
2630

27-
open Microsoft.CodeAnalysis
28-
open FSharp.Compiler.Range
29-
open FSharp.Compiler.SourceCodeServices
30-
31-
type SemanticClassificationData = (struct(FSharp.Compiler.Range.range * SemanticClassificationType)[])
31+
type SemanticClassificationData = (struct(Range * SemanticClassificationType)[])
3232
type SemanticClassificationLookup = IReadOnlyDictionary<int, ResizeArray<struct(range * SemanticClassificationType)>>
3333

3434
[<Sealed>]
@@ -118,7 +118,7 @@ type internal FSharpClassificationService
118118
| _ -> ()
119119

120120
static let toSemanticClassificationLookup (data: SemanticClassificationData) =
121-
let lookup = System.Collections.Generic.Dictionary<int, ResizeArray<struct(FSharp.Compiler.Range.range * SemanticClassificationType)>>()
121+
let lookup = System.Collections.Generic.Dictionary<int, ResizeArray<struct(Range * SemanticClassificationType)>>()
122122
for i = 0 to data.Length - 1 do
123123
let (struct(r, _) as dataItem) = data.[i]
124124
let items =
@@ -135,9 +135,9 @@ type internal FSharpClassificationService
135135

136136
interface IFSharpClassificationService with
137137
// Do not perform classification if we don't have project options (#defines matter)
138-
member __.AddLexicalClassifications(_: SourceText, _: TextSpan, _: List<ClassifiedSpan>, _: CancellationToken) = ()
138+
member _.AddLexicalClassifications(_: SourceText, _: TextSpan, _: List<ClassifiedSpan>, _: CancellationToken) = ()
139139

140-
member __.AddSyntacticClassificationsAsync(document: Document, textSpan: TextSpan, result: List<ClassifiedSpan>, cancellationToken: CancellationToken) =
140+
member _.AddSyntacticClassificationsAsync(document: Document, textSpan: TextSpan, result: List<ClassifiedSpan>, cancellationToken: CancellationToken) =
141141
async {
142142
use _logBlock = Logger.LogBlock(LogEditorFunctionId.Classification_Syntactic)
143143

@@ -153,7 +153,7 @@ type internal FSharpClassificationService
153153
result.AddRange(Tokenizer.getClassifiedSpans(document.Id, sourceText, textSpan, Some(document.FilePath), defines, cancellationToken))
154154
} |> RoslynHelpers.StartAsyncUnitAsTask cancellationToken
155155

156-
member __.AddSemanticClassificationsAsync(document: Document, textSpan: TextSpan, result: List<ClassifiedSpan>, cancellationToken: CancellationToken) =
156+
member _.AddSemanticClassificationsAsync(document: Document, textSpan: TextSpan, result: List<ClassifiedSpan>, cancellationToken: CancellationToken) =
157157
asyncMaybe {
158158
use _logBlock = Logger.LogBlock(LogEditorFunctionId.Classification_Semantic)
159159

@@ -181,6 +181,6 @@ type internal FSharpClassificationService
181181
|> Async.Ignore |> RoslynHelpers.StartAsyncUnitAsTask cancellationToken
182182

183183
// Do not perform classification if we don't have project options (#defines matter)
184-
member __.AdjustStaleClassification(_: SourceText, classifiedSpan: ClassifiedSpan) : ClassifiedSpan = classifiedSpan
184+
member _.AdjustStaleClassification(_: SourceText, classifiedSpan: ClassifiedSpan) : ClassifiedSpan = classifiedSpan
185185

186186

CodeFix/AddOpenCodeFixProvider.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ open Microsoft.CodeAnalysis.Text
1212
open Microsoft.CodeAnalysis.CodeFixes
1313
open Microsoft.CodeAnalysis.CodeActions
1414

15-
open FSharp.Compiler
16-
open FSharp.Compiler.Range
1715
open FSharp.Compiler.SourceCodeServices
16+
open FSharp.Compiler.Text
1817

1918
[<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "AddOpen"); Shared>]
2019
type internal FSharpAddOpenCodeFixProvider

CodeFix/ChangeRefCellDerefToNotExpression.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type internal FSharpChangeRefCellDerefToNotExpressionCodeFixProvider
2020
static let userOpName = "FSharpChangeRefCellDerefToNotExpressionCodeFix"
2121
let fixableDiagnosticIds = set ["FS0001"]
2222

23-
override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
23+
override _.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
2424

2525
override this.RegisterCodeFixesAsync context : Task =
2626
asyncMaybe {

CodeFix/ChangeToUpcast.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type internal FSharpChangeToUpcastCodeFixProvider() =
1414

1515
let fixableDiagnosticIds = set ["FS3198"]
1616

17-
override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
17+
override _.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
1818

1919
override this.RegisterCodeFixesAsync context : Task =
2020
asyncMaybe {

CodeFix/ConvertToSingleEqualsEqualityExpression.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type internal FSharpConvertToSingleEqualsEqualityExpressionCodeFixProvider() =
1616

1717
let fixableDiagnosticIds = set ["FS0043"]
1818

19-
override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
19+
override _.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
2020

2121
override this.RegisterCodeFixesAsync context : Task =
2222
asyncMaybe {

CodeFix/ImplementInterfaceCodeFixProvider.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ open Microsoft.CodeAnalysis.Text
1212
open Microsoft.CodeAnalysis.CodeFixes
1313
open Microsoft.CodeAnalysis.CodeActions
1414

15-
open FSharp.Compiler.Range
1615
open FSharp.Compiler.SourceCodeServices
1716
open FSharp.Compiler.SyntaxTree
17+
open FSharp.Compiler.Text
1818

1919
[<NoEquality; NoComparison>]
2020
type internal InterfaceState =
@@ -133,9 +133,9 @@ type internal FSharpImplementInterfaceCodeFixProvider
133133
else
134134
()
135135

136-
override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
136+
override _.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds
137137

138-
override __.RegisterCodeFixesAsync context : Task =
138+
override _.RegisterCodeFixesAsync context : Task =
139139
asyncMaybe {
140140
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(context.Document, context.CancellationToken, userOpName)
141141
let cancellationToken = context.CancellationToken

CodeFix/MakeDeclarationMutable.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ open System.Threading.Tasks
99
open Microsoft.CodeAnalysis.Text
1010
open Microsoft.CodeAnalysis.CodeFixes
1111

12-
open FSharp.Compiler.Range
1312
open FSharp.Compiler.SourceCodeServices
13+
open FSharp.Compiler.Text
1414

1515
[<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "MakeDeclarationMutable"); Shared>]
1616
type internal FSharpMakeDeclarationMutableFixProvider

CodeFix/MissingReferenceCodeFixProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ type internal MissingReferenceCodeFixProvider() =
4646
),
4747
title)
4848

49-
override __.FixableDiagnosticIds = Seq.toImmutableArray [fixableDiagnosticId]
49+
override _.FixableDiagnosticIds = Seq.toImmutableArray [fixableDiagnosticId]
5050

51-
override __.RegisterCodeFixesAsync context : Task =
51+
override _.RegisterCodeFixesAsync context : Task =
5252
async {
5353
let solution = context.Document.Project.Solution
5454

0 commit comments

Comments
 (0)