Added paren completion for UFCS
This commit is contained in:
parent
15ae4e5f00
commit
6c3a4d3797
|
@ -558,6 +558,12 @@ void setCompletions(T)(ref AutocompleteResponse response,
|
||||||
DSymbol*[] symbols = getSymbolsByTokenChain(completionScope, tokens,
|
DSymbol*[] symbols = getSymbolsByTokenChain(completionScope, tokens,
|
||||||
cursorPosition, completionType);
|
cursorPosition, completionType);
|
||||||
|
|
||||||
|
if (tokens.length > 2 && tokens[1] == tok!".")
|
||||||
|
{
|
||||||
|
symbols.getUFCSParenCompletion(completionScope, stringToken(tokens[0]), stringToken(
|
||||||
|
tokens[2]), cursorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
if (symbols.length == 0)
|
if (symbols.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -169,3 +169,19 @@ bool doUFCSSearch(string beforeToken, string lastToken)
|
||||||
// we do the search if they are different from eachother
|
// we do the search if they are different from eachother
|
||||||
return beforeToken != lastToken;
|
return beforeToken != lastToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getUFCSParenCompletion(ref DSymbol*[] symbols, Scope* completionScope, istring firstToken, istring nextToken, size_t cursorPosition)
|
||||||
|
{
|
||||||
|
DSymbol* firstSymbol = completionScope.getFirstSymbolByNameAndCursor(firstToken, cursorPosition);
|
||||||
|
DSymbol*[] possibleUFCSSymbol = completionScope.getSymbolsByNameAndCursor(nextToken, cursorPosition);
|
||||||
|
foreach(nextSymbol; possibleUFCSSymbol){
|
||||||
|
if (nextSymbol && nextSymbol.functionParameters)
|
||||||
|
{
|
||||||
|
if (firstSymbol.type is nextSymbol.functionParameters.front.type)
|
||||||
|
{
|
||||||
|
nextSymbol.kind = CompletionKind.ufcsName;
|
||||||
|
symbols ~= nextSymbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
calltips
|
||||||
|
void showSomething(int x, string message, bool ok)
|
||||||
|
void showSomething(int x, string message, bool ok, float percentage)
|
|
@ -0,0 +1,7 @@
|
||||||
|
void showSomething(int x, string message, bool ok){}
|
||||||
|
void showSomething(int x, string message, bool ok, float percentage){}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
int x;
|
||||||
|
x.showSomething(
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 -c163 file.d > actual.txt
|
||||||
|
diff actual.txt expected.txt
|
Loading…
Reference in New Issue