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

Commitd867864

Browse files
Revert "make QuickInfo description and signature help synchronous"
This reverts commit2f0ad0f.
1 parent2f0ad0f commitd867864

File tree

2 files changed

+153
-170
lines changed

2 files changed

+153
-170
lines changed

‎src/fsharp/vs/service.fs‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,14 +1998,9 @@ type FSharpCheckFileResults(errors: FSharpErrorInfo[], scopeOptX: TypeCheckInfo
19981998

19991999
// Resolve the names at the given location to a set of methods
20002000
memberinfo.GetMethodsAlternate(line,colAtEndOfNames,lineStr,names)=
2001-
async{
2002-
letdflt= FSharpMethodGroup("",[||])
2003-
return
2004-
threadSafeOp
2005-
(fun()-> dflt)
2006-
(fun(scope,_,_)->
2007-
scope.GetMethods(line, lineStr, colAtEndOfNames, names))
2008-
}
2001+
letdflt= FSharpMethodGroup("",[||])
2002+
reactorOp"GetMethods" dflt(fun scope->
2003+
scope.GetMethods(line, lineStr, colAtEndOfNames, names))
20092004

20102005
memberinfo.GetDeclarationLocationAlternate(line,colAtEndOfNames,lineStr,names,?preferFlag)=
20112006
letdflt= FSharpFindDeclResult.DeclNotFound FSharpFindDeclFailureReason.Unknown

‎vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs‎

Lines changed: 150 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -46,168 +46,156 @@ type internal FSharpSignatureHelpProvider
4646

4747
// Unit-testable core rutine
4848
static memberinternalProvideMethodsAsyncAux(checker:FSharpChecker,documentationBuilder:IDocumentationBuilder,sourceText:SourceText,caretPosition:int,options:FSharpProjectOptions,triggerIsTypedChar:char option,filePath:string,textVersionHash:int)=async{
49-
let!results=
50-
async{
51-
match checker.TryGetRecentCheckResultsForFile(filePath, options)with
52-
| Some(parseResults, checkFileResults,_)->
53-
return Some(parseResults, checkFileResults)
54-
| None->
55-
let!parseResults,checkFileAnswer= checker.ParseAndCheckFileInProject(filePath, textVersionHash, sourceText.ToString(), options)
56-
match checkFileAnswerwith
57-
| FSharpCheckFileAnswer.Aborted->
58-
return None
59-
| FSharpCheckFileAnswer.Succeeded(checkFileResults)->
60-
return Some(parseResults, checkFileResults)
61-
}
62-
63-
match resultswith
64-
| None->return None
65-
| Some(parseResults, checkFileResults)->
66-
lettextLines= sourceText.Lines
67-
letcaretLinePos= textLines.GetLinePosition(caretPosition)
68-
letcaretLineColumn= caretLinePos.Character
69-
70-
// Get the parameter locations
71-
letparamLocations= parseResults.FindNoteworthyParamInfoLocations(Pos.fromZ caretLinePos.Line caretLineColumn)
72-
73-
match paramLocationswith
74-
| None->return None// no locations = no help
75-
| Some nwpl->
76-
letnames= nwpl.LongId
77-
letlidEnd= nwpl.LongIdEndLocation
78-
79-
// Get the methods
80-
let!methodGroup= checkFileResults.GetMethodsAlternate(lidEnd.Line, lidEnd.Column,"", Some names)
81-
82-
letmethods= methodGroup.Methods
83-
84-
if(methods.Length=0|| methodGroup.MethodName.EndsWith("> )"))thenreturn Noneelse
85-
86-
letisStaticArgTip=
87-
letparenLine,parenCol= Pos.toZ nwpl.OpenParenLocation
88-
assert(parenLine< textLines.Count)
89-
letparenLineText= textLines.[parenLine].ToString()
90-
parenCol< parenLineText.Length&& parenLineText.[parenCol]='<'
91-
92-
letfilteredMethods=
93-
[|for min methodsdo
94-
if(isStaticArgTip&& m.StaticParameters.Length>0)||
95-
(not isStaticArgTip&& m.HasParameters)then// need to distinguish TP<...>(...) angle brackets tip from parens tip
96-
yield m|]
97-
98-
if filteredMethods.Length=0thenreturn Noneelse
99-
100-
letposToLinePosition pos=
101-
let(l,c)= Pos.toZ pos
102-
// FSROSLYNTODO: FCS gives back line counts that are too large. Really, this shouldn't happen
103-
letresult=LinePosition(l,c)
104-
letlastPosInDocument= textLines.GetLinePosition(textLines.[textLines.Count-1].End)
105-
if lastPosInDocument.CompareTo(result)>0then resultelse lastPosInDocument
106-
107-
// Compute the start position
108-
letstartPos= nwpl.LongIdStartLocation|> posToLinePosition
109-
110-
// Compute the end position
111-
letendPos=
112-
letlast= nwpl.TupleEndLocations.[nwpl.TupleEndLocations.Length-1]|> posToLinePosition
113-
(if nwpl.IsThereACloseParenthen oneColBefore lastelse last)
114-
115-
assert(startPos.CompareTo(endPos)<=0)
116-
117-
// Compute the applicable span between the parentheses
118-
letapplicableSpan=
119-
textLines.GetTextSpan(LinePositionSpan(startPos, endPos))
120-
121-
letstartOfArgs= nwpl.OpenParenLocation|> posToLinePosition|> oneColAfter
122-
123-
lettupleEnds=
124-
[|yield startOfArgs
125-
for iin0..nwpl.TupleEndLocations.Length-2do
126-
yield nwpl.TupleEndLocations.[i]|> posToLinePosition
127-
yield endPos|]
128-
129-
// If we are pressing "(" or "<" or ",", then only pop up the info if this is one of the actual, real detected positions in the detected promptable call
130-
//
131-
// For example the last "(" in
132-
// List.map (fun a -> (
133-
// should not result in a prompt.
134-
//
135-
// Likewise the last "," in
136-
// Console.WriteLine( [(1,
137-
// should not result in a prompt, whereas this one will:
138-
// Console.WriteLine( [(1,2)],
139-
140-
match triggerIsTypedCharwith
141-
| Some('<'|'('|',')whennot(tupleEnds|> Array.exists(fun lp-> lp.Character= caretLineColumn))->
142-
return None// comma or paren at wrong location = remove help display
143-
|_->
144-
145-
// Compute the argument index by working out where the caret is between the various commas.
146-
letargumentIndex=
147-
letcomputedTextSpans=
148-
tupleEnds
149-
|> Array.pairwise
150-
|> Array.map(fun(lp1,lp2)-> textLines.GetTextSpan(LinePositionSpan(lp1, lp2)))
151-
152-
match(computedTextSpans|> Array.tryFindIndex(fun t-> t.Contains(caretPosition)))with
153-
| None->
154-
// Because 'TextSpan.Contains' only succeeeds if 'TextSpan.Start <= caretPosition < TextSpan.End' is true,
155-
// we need to check if the caret is at the very last position in the TextSpan.
156-
//
157-
// We default to 0, which is the first argument, if the caret position was nowhere to be found.
158-
if computedTextSpans.[computedTextSpans.Length-1].End= caretPositionthen
159-
computedTextSpans.Length-1
160-
else0
161-
| Some n-> n
162-
163-
// Compute the overall argument count
164-
letargumentCount=
165-
match nwpl.TupleEndLocations.Lengthwith
166-
|1when caretLinePos.Character= startOfArgs.Character->0// count "WriteLine(" as zero arguments
167-
| n-> n
168-
169-
// Compute the current argument name, if any
170-
letargumentName=
171-
if argumentIndex< nwpl.NamedParamNames.Lengththen
172-
nwpl.NamedParamNames.[argumentIndex]
173-
else
174-
None// not a named argument
175-
176-
// Prepare the results
177-
letresults= List<_>()
178-
179-
for methodin methodsdo
180-
// Create the documentation. Note, do this on the background thread, since doing it in the documentationBuild fails to build the XML index
181-
letmainDescription= List()
182-
letdocumentation= List()
183-
XmlDocumentation.BuildMethodOverloadTipText(documentationBuilder, CommonRoslynHelpers.CollectTaggedText mainDescription, CommonRoslynHelpers.CollectTaggedText documentation, method.StructuredDescription,false)
184-
185-
letparameters=
186-
letparameters=if isStaticArgTipthen method.StaticParameterselse method.Parameters
187-
[|for pin parametersdo
188-
letdoc= List()
189-
// FSROSLYNTODO: compute the proper help text for parameters, c.f. AppendParameter in XmlDocumentation.fs
190-
XmlDocumentation.BuildMethodParamText(documentationBuilder, CommonRoslynHelpers.CollectTaggedText doc, method.XmlDoc, p.ParameterName)
191-
letparts= List()
192-
renderL(taggedTextListR(CommonRoslynHelpers.CollectTaggedText parts)) p.StructuredDisplay|> ignore
193-
yield(p.ParameterName, p.IsOptional, doc, parts)
194-
|]
195-
196-
letprefixParts=
197-
[| TaggedText(TextTags.Method, methodGroup.MethodName);
198-
TaggedText(TextTags.Punctuation,(if isStaticArgTipthen"<"else"("))|]
199-
letseparatorParts=[| TaggedText(TextTags.Punctuation,","); TaggedText(TextTags.Space,"")|]
200-
letsuffixParts=[| TaggedText(TextTags.Punctuation,(if isStaticArgTipthen">"else")"))|]
201-
202-
letcompletionItem=(method.HasParamArrayArg, documentation, prefixParts, separatorParts, suffixParts, parameters, mainDescription)
203-
// FSROSLYNTODO: Do we need a cache like for completion?
204-
//declarationItemsCache.Remove(completionItem.DisplayText) |> ignore // clear out stale entries if they exist
205-
//declarationItemsCache.Add(completionItem.DisplayText, declarationItem)
206-
results.Add(completionItem)
207-
208-
209-
letitems=(results.ToArray(),applicableSpan,argumentIndex,argumentCount,argumentName)
210-
return Some items
49+
let!parseResults,checkFileAnswer= checker.ParseAndCheckFileInProject(filePath, textVersionHash, sourceText.ToString(), options)
50+
match checkFileAnswerwith
51+
| FSharpCheckFileAnswer.Aborted->return None
52+
| FSharpCheckFileAnswer.Succeeded(checkFileResults)->
53+
54+
lettextLines= sourceText.Lines
55+
letcaretLinePos= textLines.GetLinePosition(caretPosition)
56+
letcaretLineColumn= caretLinePos.Character
57+
58+
// Get the parameter locations
59+
letparamLocations= parseResults.FindNoteworthyParamInfoLocations(Pos.fromZ caretLinePos.Line caretLineColumn)
60+
61+
match paramLocationswith
62+
| None->return None// no locations = no help
63+
| Some nwpl->
64+
letnames= nwpl.LongId
65+
letlidEnd= nwpl.LongIdEndLocation
66+
67+
// Get the methods
68+
let!methodGroup= checkFileResults.GetMethodsAlternate(lidEnd.Line, lidEnd.Column,"", Some names)
69+
70+
letmethods= methodGroup.Methods
71+
72+
if(methods.Length=0|| methodGroup.MethodName.EndsWith("> )"))thenreturn Noneelse
73+
74+
letisStaticArgTip=
75+
letparenLine,parenCol= Pos.toZ nwpl.OpenParenLocation
76+
assert(parenLine< textLines.Count)
77+
letparenLineText= textLines.[parenLine].ToString()
78+
parenCol< parenLineText.Length&& parenLineText.[parenCol]='<'
79+
80+
letfilteredMethods=
81+
[|for min methodsdo
82+
if(isStaticArgTip&& m.StaticParameters.Length>0)||
83+
(not isStaticArgTip&& m.HasParameters)then// need to distinguish TP<...>(...) angle brackets tip from parens tip
84+
yield m|]
85+
86+
if filteredMethods.Length=0thenreturn Noneelse
87+
88+
letposToLinePosition pos=
89+
let(l,c)= Pos.toZ pos
90+
// FSROSLYNTODO: FCS gives back line counts that are too large. Really, this shouldn't happen
91+
letresult=LinePosition(l,c)
92+
letlastPosInDocument= textLines.GetLinePosition(textLines.[textLines.Count-1].End)
93+
if lastPosInDocument.CompareTo(result)>0then resultelse lastPosInDocument
94+
95+
// Compute the start position
96+
letstartPos= nwpl.LongIdStartLocation|> posToLinePosition
97+
98+
// Compute the end position
99+
letendPos=
100+
letlast= nwpl.TupleEndLocations.[nwpl.TupleEndLocations.Length-1]|> posToLinePosition
101+
(if nwpl.IsThereACloseParenthen oneColBefore lastelse last)
102+
103+
assert(startPos.CompareTo(endPos)<=0)
104+
105+
// Compute the applicable span between the parentheses
106+
letapplicableSpan=
107+
textLines.GetTextSpan(LinePositionSpan(startPos, endPos))
108+
109+
letstartOfArgs= nwpl.OpenParenLocation|> posToLinePosition|> oneColAfter
110+
111+
lettupleEnds=
112+
[|yield startOfArgs
113+
for iin0..nwpl.TupleEndLocations.Length-2do
114+
yield nwpl.TupleEndLocations.[i]|> posToLinePosition
115+
yield endPos|]
116+
117+
// If we are pressing "(" or "<" or ",", then only pop up the info if this is one of the actual, real detected positions in the detected promptable call
118+
//
119+
// For example the last "(" in
120+
// List.map (fun a -> (
121+
// should not result in a prompt.
122+
//
123+
// Likewise the last "," in
124+
// Console.WriteLine( [(1,
125+
// should not result in a prompt, whereas this one will:
126+
// Console.WriteLine( [(1,2)],
127+
128+
match triggerIsTypedCharwith
129+
| Some('<'|'('|',')whennot(tupleEnds|> Array.exists(fun lp-> lp.Character= caretLineColumn))->
130+
return None// comma or paren at wrong location = remove help display
131+
|_->
132+
133+
// Compute the argument index by working out where the caret is between the various commas.
134+
letargumentIndex=
135+
letcomputedTextSpans=
136+
tupleEnds
137+
|> Array.pairwise
138+
|> Array.map(fun(lp1,lp2)-> textLines.GetTextSpan(LinePositionSpan(lp1, lp2)))
139+
140+
match(computedTextSpans|> Array.tryFindIndex(fun t-> t.Contains(caretPosition)))with
141+
| None->
142+
// Because 'TextSpan.Contains' only succeeeds if 'TextSpan.Start <= caretPosition < TextSpan.End' is true,
143+
// we need to check if the caret is at the very last position in the TextSpan.
144+
//
145+
// We default to 0, which is the first argument, if the caret position was nowhere to be found.
146+
if computedTextSpans.[computedTextSpans.Length-1].End= caretPositionthen
147+
computedTextSpans.Length-1
148+
else0
149+
| Some n-> n
150+
151+
// Compute the overall argument count
152+
letargumentCount=
153+
match nwpl.TupleEndLocations.Lengthwith
154+
|1when caretLinePos.Character= startOfArgs.Character->0// count "WriteLine(" as zero arguments
155+
| n-> n
156+
157+
// Compute the current argument name, if any
158+
letargumentName=
159+
if argumentIndex< nwpl.NamedParamNames.Lengththen
160+
nwpl.NamedParamNames.[argumentIndex]
161+
else
162+
None// not a named argument
163+
164+
// Prepare the results
165+
letresults= List<_>()
166+
167+
for methodin methodsdo
168+
// Create the documentation. Note, do this on the background thread, since doing it in the documentationBuild fails to build the XML index
169+
letmainDescription= List()
170+
letdocumentation= List()
171+
XmlDocumentation.BuildMethodOverloadTipText(documentationBuilder, CommonRoslynHelpers.CollectTaggedText mainDescription, CommonRoslynHelpers.CollectTaggedText documentation, method.StructuredDescription,false)
172+
173+
letparameters=
174+
letparameters=if isStaticArgTipthen method.StaticParameterselse method.Parameters
175+
[|for pin parametersdo
176+
letdoc= List()
177+
// FSROSLYNTODO: compute the proper help text for parameters, c.f. AppendParameter in XmlDocumentation.fs
178+
XmlDocumentation.BuildMethodParamText(documentationBuilder, CommonRoslynHelpers.CollectTaggedText doc, method.XmlDoc, p.ParameterName)
179+
letparts= List()
180+
renderL(taggedTextListR(CommonRoslynHelpers.CollectTaggedText parts)) p.StructuredDisplay|> ignore
181+
yield(p.ParameterName, p.IsOptional, doc, parts)
182+
|]
183+
184+
letprefixParts=
185+
[| TaggedText(TextTags.Method, methodGroup.MethodName);
186+
TaggedText(TextTags.Punctuation,(if isStaticArgTipthen"<"else"("))|]
187+
letseparatorParts=[| TaggedText(TextTags.Punctuation,","); TaggedText(TextTags.Space,"")|]
188+
letsuffixParts=[| TaggedText(TextTags.Punctuation,(if isStaticArgTipthen">"else")"))|]
189+
190+
letcompletionItem=(method.HasParamArrayArg, documentation, prefixParts, separatorParts, suffixParts, parameters, mainDescription)
191+
// FSROSLYNTODO: Do we need a cache like for completion?
192+
//declarationItemsCache.Remove(completionItem.DisplayText) |> ignore // clear out stale entries if they exist
193+
//declarationItemsCache.Add(completionItem.DisplayText, declarationItem)
194+
results.Add(completionItem)
195+
196+
197+
letitems=(results.ToArray(),applicableSpan,argumentIndex,argumentCount,argumentName)
198+
return Some items
211199
}
212200

213201
interface ISignatureHelpProviderwith

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp