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

Commit a17c17d

Browse files
authored
Merge pull request dotnet#3810 from Microsoft/master
Merge F# code generation into vs2017-rtm
2 parents af12d31 + ceb73ec commit a17c17d

File tree

8 files changed

+35
-19
lines changed

8 files changed

+35
-19
lines changed

Commands/HelpContextService.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ open Microsoft.CodeAnalysis.Classification
1010
open Microsoft.VisualStudio.FSharp.LanguageService
1111
open Microsoft.VisualStudio.LanguageServices.Implementation.F1Help
1212
open Microsoft.CodeAnalysis.Host.Mef
13+
open Microsoft.FSharp.Compiler
1314
open Microsoft.FSharp.Compiler.Range
1415
open Microsoft.FSharp.Compiler.SourceCodeServices
1516

Common/AssemblyInfo.fs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ namespace Microsoft.VisualStudio.FSharp.Editor
44

55
open Microsoft.VisualStudio.Shell
66

7-
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("FSharp.ProjectSystem.FSharp, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]
8-
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Unittests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]
9-
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Salsa, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]
10-
117
[<assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\FSharp.Editor.dll")>]
128
[<assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\FSharp.UIResources.dll")>]
139
[<assembly: ProvideCodeBase(CodeBase = @"$PackageFolder$\Newtonsoft.Json.dll")>]

Completion/CompletionProvider.fs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,23 @@ type internal FSharpCompletionProvider
5555

5656
let xmlMemberIndexService = serviceProvider.GetService(typeof<IVsXMLMemberIndexService>) :?> IVsXMLMemberIndexService
5757
let documentationBuilder = XmlDocumentation.CreateDocumentationBuilder(xmlMemberIndexService, serviceProvider.DTE)
58-
58+
5959
static let noCommitOnSpaceRules =
60-
CompletionItemRules.Default.WithCommitCharacterRule(CharacterSetModificationRule.Create(CharacterSetModificationKind.Remove, ' ', '=', ',', '.', '<', '>', '(', ')', '!', ':'))
60+
// These are important. They make sure we don't _commit_ autocompletion when people don't expect them to. Some examples:
61+
//
62+
// * type Foo() =
63+
// member val a = 12 with get, <<---- Don't commit autocomplete!
64+
//
65+
// * type MyRecord = { name: <<---- Don't commit autocomplete!
66+
//
67+
// * type My< <<---- Don't commit autocomplete!
68+
//
69+
// * let myClassInstance = MyClass(Date= <<---- Don't commit autocomplete!
70+
//
71+
// * let xs = [1..10] <<---- Don't commit autocomplete! (same for arrays)
72+
let noCommitChars = [|' '; '='; ','; '.'; '<'; '>'; '('; ')'; '!'; ':'; '['; ']'; '|'|].ToImmutableArray()
73+
74+
CompletionItemRules.Default.WithCommitCharacterRule(CharacterSetModificationRule.Create(CharacterSetModificationKind.Remove, noCommitChars))
6175

6276
static let getRules() = if Settings.IntelliSense.ShowAfterCharIsTyped then noCommitOnSpaceRules else CompletionItemRules.Default
6377

@@ -100,14 +114,14 @@ type internal FSharpCompletionProvider
100114
let caretLine = textLines.GetLineFromPosition(caretPosition)
101115
let fcsCaretLineNumber = Line.fromZ caretLinePos.Line // Roslyn line numbers are zero-based, FSharp.Compiler.Service line numbers are 1-based
102116
let caretLineColumn = caretLinePos.Character
103-
let qualifyingNames, partialName = QuickParse.GetPartialLongNameEx(caretLine.ToString(), caretLineColumn - 1)
117+
let partialName = QuickParse.GetPartialLongNameEx(caretLine.ToString(), caretLineColumn - 1)
104118

105119
let getAllSymbols() =
106-
getAllSymbols() |> List.filter (fun entity -> entity.FullName.Contains "." && not (PrettyNaming.IsOperatorName entity.Symbol.DisplayName))
120+
getAllSymbols()
121+
|> List.filter (fun entity -> entity.FullName.Contains "." && not (PrettyNaming.IsOperatorName entity.Symbol.DisplayName))
107122

108-
let! declarations =
109-
checkFileResults.GetDeclarationListInfo(Some(parseResults), fcsCaretLineNumber, caretLineColumn, caretLine.ToString(), qualifyingNames, partialName, getAllSymbols, userOpName=userOpName) |> liftAsync
110-
123+
let! declarations = checkFileResults.GetDeclarationListInfo(Some(parseResults), fcsCaretLineNumber, caretLine.ToString(),
124+
partialName, getAllSymbols, userOpName=userOpName) |> liftAsync
111125
let results = List<Completion.CompletionItem>()
112126

113127
let getKindPriority = function
@@ -186,7 +200,7 @@ type internal FSharpCompletionProvider
186200
declarationItemsCache.Add(completionItem.DisplayText, declItem)
187201
results.Add(completionItem))
188202

189-
if results.Count > 0 && not declarations.IsForType && not declarations.IsError && List.isEmpty qualifyingNames then
203+
if results.Count > 0 && not declarations.IsForType && not declarations.IsError && List.isEmpty partialName.QualifyingIdents then
190204
let lineStr = textLines.[caretLinePos.Line].ToString()
191205
match UntypedParseImpl.TryGetCompletionContext(Pos.fromZ caretLinePos.Line caretLinePos.Character, Some parseResults, lineStr) with
192206
| None -> results.AddRange(keywordCompletionItems)

Debugging/LanguageDebugInfoService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ open Microsoft.CodeAnalysis.Editor.Implementation.Debugging
1414
open Microsoft.CodeAnalysis.Host.Mef
1515
open Microsoft.CodeAnalysis.Text
1616

17-
open Microsoft.VisualStudio.FSharp.LanguageService
17+
open Microsoft.FSharp.Compiler
1818

1919
[<Shared>]
2020
[<ExportLanguageService(typeof<ILanguageDebugInfoService>, FSharpConstants.FSharpLanguageName)>]

Diagnostics/SimplifyNameDiagnosticAnalyzer.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ type internal SimplifyNameDiagnosticAnalyzer() =
6969
|> Array.Parallel.map (fun symbolUse ->
7070
let lineStr = sourceText.Lines.[Line.toZ symbolUse.RangeAlternate.StartLine].ToString()
7171
// for `System.DateTime.Now` it returns ([|"System"; "DateTime"|], "Now")
72-
let plid, name = QuickParse.GetPartialLongNameEx(lineStr, symbolUse.RangeAlternate.EndColumn - 1)
72+
let partialName = QuickParse.GetPartialLongNameEx(lineStr, symbolUse.RangeAlternate.EndColumn - 1)
7373
// `symbolUse.RangeAlternate.Start` does not point to the start of plid, it points to start of `name`,
7474
// so we have to calculate plid's start ourselves.
75-
let plidStartCol = symbolUse.RangeAlternate.EndColumn - name.Length - (getPlidLength plid)
76-
symbolUse, plid, plidStartCol, name)
75+
let plidStartCol = symbolUse.RangeAlternate.EndColumn - partialName.PartialIdent.Length - (getPlidLength partialName.QualifyingIdents)
76+
symbolUse, partialName.QualifyingIdents, plidStartCol, partialName.PartialIdent)
7777
|> Array.filter (fun (_, plid, _, name) -> name <> "" && not (List.isEmpty plid))
7878
|> Array.groupBy (fun (symbolUse, _, plidStartCol, _) -> symbolUse.RangeAlternate.StartLine, plidStartCol)
7979
|> Array.map (fun (_, xs) -> xs |> Array.maxBy (fun (symbolUse, _, _, _) -> symbolUse.RangeAlternate.EndColumn))

FSharp.Editor.fsproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<GeneratePkgDefFile>true</GeneratePkgDefFile>
2929
<IncludePkgdefInVSIXContainer>true</IncludePkgdefInVSIXContainer>
3030
</PropertyGroup>
31+
<ItemGroup>
32+
<InternalsVisibleTo Include="FSharp.ProjectSystem.FSharp" />
33+
<InternalsVisibleTo Include="VisualFSharp.Unittests" />
34+
<InternalsVisibleTo Include="VisualFSharp.Salsa" />
35+
</ItemGroup>
3136
<ItemGroup>
3237
<EmbeddedResource Include="FSharp.Editor.resx">
3338
<GenerateSource>true</GenerateSource>

LanguageService/Tokenizer.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ module internal Tokenizer =
532532
| _ -> false)
533533
|> Option.orElseWith (fun _ -> tokensUnderCursor |> List.tryFind (fun { DraftToken.Kind = k } -> k = LexerSymbolKind.Operator))
534534
|> Option.map (fun token ->
535-
let plid, _ = QuickParse.GetPartialLongNameEx(lineStr, token.RightColumn)
535+
let partialName = QuickParse.GetPartialLongNameEx(lineStr, token.RightColumn)
536536
let identStr = lineStr.Substring(token.Token.LeftColumn, token.Token.FullMatchedLength)
537537
{ Kind = token.Kind
538538
Ident =
@@ -541,7 +541,7 @@ module internal Tokenizer =
541541
fileName
542542
(Range.mkPos (linePos.Line + 1) token.Token.LeftColumn)
543543
(Range.mkPos (linePos.Line + 1) (token.RightColumn + 1)))
544-
FullIsland = plid @ [identStr] })
544+
FullIsland = partialName.QualifyingIdents @ [identStr] })
545545

546546
let private getCachedSourceLineData(documentKey: DocumentId, sourceText: SourceText, position: int, fileName: string, defines: string list) =
547547
let textLine = sourceText.Lines.GetLineFromPosition(position)

Options/EditorOptions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module DefaultTuning =
1313
let UnusedDeclarationsAnalyzerInitialDelay = 0 (* 1000 *) (* milliseconds *)
1414
let UnusedOpensAnalyzerInitialDelay = 0 (* 2000 *) (* milliseconds *)
1515
let SimplifyNameInitialDelay = 2000 (* milliseconds *)
16-
let SimplifyNameEachItemDelay = 5 (* milliseconds *)
16+
let SimplifyNameEachItemDelay = 0 (* milliseconds *)
1717

1818
// CLIMutable to make the record work also as a view model
1919
[<CLIMutable>]

0 commit comments

Comments
 (0)