Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf78fee3

Browse files
smoothdeveloperKevinRansom
authored andcommitted
Add non-regression test for backtick member completion (#2660)
as I had to chase down where `and CompletionItem = string * string * (unit -> string) * DeclarationType` was originating from, I had to make it a single case DU to find places which would break and eventually find the source (Salsa.Privates.SimpleOpenFile.AutoCompleteAtCursorImpl); I think having it as a DU is better, and we should avoid type alias over mere tuples as finding their source is difficult.I had to surface "nameInCode" into CompletionItem to add my test.I added AssertCtrlSpaceCompletion taking higher order function to enable arbitrary checks on the completion lists.
1 parentbe7a935 commitf78fee3

File tree

8 files changed

+134
-83
lines changed

8 files changed

+134
-83
lines changed

‎vsintegration/src/FSharp.LanguageService.Base/LanguageService.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,8 @@ internal abstract class Declarations
13951395

13961396
internalabstractStringGetName(stringfilterText,intindex);
13971397

1398+
internalabstractstringGetNameInCode(stringfilterText,intindex);
1399+
13981400
internalabstractStringGetDescription(stringfilterText,intindex);
13991401

14001402
internalabstractintGetGlyph(stringfilterText,intindex);

‎vsintegration/src/FSharp.LanguageService/Intellisense.fs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ type internal FSharpDeclarations(documentationBuilder, declarations: FSharpDecla
163163
else
164164
item.Name
165165
else String.Empty
166+
167+
overridedecl.GetNameInCode(filterText,index)=
168+
letdecls= trimmedDeclarations filterText
169+
if(index>=0&& index< decls.Length)then
170+
letitem= decls.[index]
171+
if(item.Glyph= FSharpGlyph.Error)then
172+
""
173+
else
174+
item.NameInCode
175+
else String.Empty
166176

167177
overridedecl.GetDescription(filterText,index)=
168178
letdecls= trimmedDeclarations filterText

‎vsintegration/tests/Salsa/SalsaUtils.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,21 @@ module internal VsOpsUtils =
206206
/// Verify the completion list is empty, typically for negative tests
207207
letAssertCompListIsEmpty(completions:CompletionItem[])=
208208
ifnot(Array.isEmpty completions)then
209-
printfn"Expected empty completion list but got:%A"(completions|> Array.map(fun(nm,_,_,_)-> nm))
209+
printfn"Expected empty completion list but got:%A"(completions|> Array.map(fun(CompletionItem(nm,_,_,_,_))-> nm))
210210
Assert.IsTrue(Array.isEmpty completions,"Expected empty completion list but got some items")
211211

212212
/// Verify that the given completion list contains a member with the given name
213213
letAssertCompListContains(completions:CompletionItem[],membername)=
214-
letfound= completions|> Array.filter(fun(name,_,_,_)-> name= membername)|> Array.length
214+
letfound= completions|> Array.filter(fun(CompletionItem(name,_,_,_,_))-> name= membername)|> Array.length
215215
if found=0then
216216
printfn"Failed to find expected value%s in" membername
217217
letMAX=25
218218
printfn"Completion list =%s"(if completions.Length> MAXthen sprintf"%A ... and more" completions.[0..MAX]else sprintf"%A" completions)
219-
Assert.Fail(sprintf"Couldn't find '%s' in completion list:%+A" membername(completions|> Array.map(fun(name,_,_,_)-> name)))
219+
Assert.Fail(sprintf"Couldn't find '%s' in completion list:%+A" membername(completions|> Array.map(fun(CompletionItem(name,_,_,_,_))-> name)))
220220

221221
/// Verify the completion list does not contain a member with the given name
222222
letAssertCompListDoesNotContain(completions:CompletionItem[],membername)=
223-
letfound= completions|> Array.filter(fun(name,_,_,_)-> name= membername)|> Array.length
223+
letfound= completions|> Array.filter(fun(CompletionItem(name,_,_,_,_))-> name= membername)|> Array.length
224224
if found<>0then
225225
printfn"Value%s should have been absent from" membername
226226
printfn"Completion list =%A" completions

‎vsintegration/tests/Salsa/salsa.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ module internal Salsa =
457457

458458

459459
// Result of querying the completion list
460-
andCompletionItem= string* string*(unit-> string)* DeclarationType
460+
andCompletionItem=CompletionItemofname:string*displayText:string*nameInCode:string*(unit->string)*DeclarationType
461461

462462
/// Representes the information that is displayed in the navigation bar
463463
andNavigationBarResult=
@@ -1327,7 +1327,7 @@ module internal Salsa =
13271327
letresult= Array.zeroCreate count
13281328
for iin0..count-1do
13291329
letglyph=enum<DeclarationType>(declarations.GetGlyph(filterText,i))
1330-
result.[i]<-(declarations.GetDisplayText(filterText,i), declarations.GetName(filterText,i),(fun()-> declarations.GetDescription(filterText,i)), glyph)
1330+
result.[i]<-CompletionItem(declarations.GetDisplayText(filterText,i), declarations.GetName(filterText,i), declarations.GetNameInCode(filterText,i),(fun()-> declarations.GetDescription(filterText,i)), glyph)
13311331
result
13321332

13331333
memberfile.AutoCompleteAtCursor(?filterText)= file.AutoCompleteAtCursorImpl(BackgroundRequestReason.MemberSelect, ?filterText=filterText)

‎vsintegration/tests/unittests/TestLib.LanguageService.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ type internal Helper =
7575
TakeCoffeeBreak(file.VS)(* why needed?*)
7676
MoveCursorToEndOfMarker(file,marker)
7777
letcompletions= AutoCompleteAtCursor file
78-
match completions|> Array.tryFind(fun(name,_,_,_)-> name= completionName)with
79-
| Some(_,_, descrFunc,_)->
78+
match completions|> Array.tryFind(fun(CompletionItem(name,_,_,_,_))-> name= completionName)with
79+
| Some(CompletionItem(_,_,_,descrFunc,_))->
8080
letdescr= descrFunc()
8181
AssertContainsInOrder(descr,rhsContainsOrder)
8282
| None->

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp