diff --git a/src/dcd/server/autocomplete/complete.d b/src/dcd/server/autocomplete/complete.d index 79bfa08..b2ce3cc 100644 --- a/src/dcd/server/autocomplete/complete.d +++ b/src/dcd/server/autocomplete/complete.d @@ -558,6 +558,12 @@ void setCompletions(T)(ref AutocompleteResponse response, DSymbol*[] symbols = getSymbolsByTokenChain(completionScope, tokens, cursorPosition, completionType); + if (tokens.length > 2 && tokens[1] == tok!".") + { + symbols.getUFCSParenCompletion(completionScope, stringToken(tokens[0]), stringToken( + tokens[2]), cursorPosition); + } + if (symbols.length == 0) return; diff --git a/src/dcd/server/autocomplete/ufcs.d b/src/dcd/server/autocomplete/ufcs.d index 8a38911..9c575ee 100644 --- a/src/dcd/server/autocomplete/ufcs.d +++ b/src/dcd/server/autocomplete/ufcs.d @@ -169,3 +169,19 @@ bool doUFCSSearch(string beforeToken, string lastToken) // we do the search if they are different from eachother 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; + } + } + } +} \ No newline at end of file diff --git a/tests/tc_ufcs_calltip_in_func/expected.txt b/tests/tc_ufcs_calltip_in_func/expected.txt new file mode 100644 index 0000000..3a200bb --- /dev/null +++ b/tests/tc_ufcs_calltip_in_func/expected.txt @@ -0,0 +1,3 @@ +calltips +void showSomething(int x, string message, bool ok) +void showSomething(int x, string message, bool ok, float percentage) diff --git a/tests/tc_ufcs_calltip_in_func/file.d b/tests/tc_ufcs_calltip_in_func/file.d new file mode 100644 index 0000000..cbdb8d1 --- /dev/null +++ b/tests/tc_ufcs_calltip_in_func/file.d @@ -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( +} diff --git a/tests/tc_ufcs_calltip_in_func/run.sh b/tests/tc_ufcs_calltip_in_func/run.sh new file mode 100755 index 0000000..16cb3c4 --- /dev/null +++ b/tests/tc_ufcs_calltip_in_func/run.sh @@ -0,0 +1,5 @@ +set -e +set -u + +../../bin/dcd-client $1 -c163 file.d > actual.txt +diff actual.txt expected.txt