use `isCallableWithArg` in paren completion
For consistency and to allow future changes to type matching (e.g. implicit type conversion)
This commit is contained in:
parent
4fd12cf485
commit
2457f70b8e
|
@ -107,16 +107,18 @@ DSymbol*[] getSymbolsForUFCS(Scope* completionScope, const(DSymbol)* beforeDotSy
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Params:
|
* Params:
|
||||||
symbol = the symbol to check
|
* incomingSymbol = the function symbol to check if it is valid for UFCS with `beforeDotType`.
|
||||||
incomingSymbol = symbols we check on
|
* beforeDotType = the type of the expression that's used before the dot.
|
||||||
Returns:
|
* isGlobalScope = the symbol to check
|
||||||
true if incomingSymbols first parameter matches beforeDotSymbol
|
* Returns:
|
||||||
false otherwise
|
* `true` if `incomingSymbols`' first parameter matches `beforeDotType`
|
||||||
*/
|
* `false` otherwise
|
||||||
bool isCallableWithArg(const(DSymbol)* incomingSymbol, const(DSymbol)* beforeDotSymbol, bool isGlobalScope = false)
|
*/
|
||||||
|
bool isCallableWithArg(const(DSymbol)* incomingSymbol, const(DSymbol)* beforeDotType, bool isGlobalScope = false)
|
||||||
{
|
{
|
||||||
if (isGlobalScope && incomingSymbol.protection == tok!"private")
|
if (!incomingSymbol || !beforeDotType
|
||||||
|
|| (isGlobalScope && incomingSymbol.protection == tok!"private"))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +126,7 @@ bool isCallableWithArg(const(DSymbol)* incomingSymbol, const(DSymbol)* beforeDot
|
||||||
if (incomingSymbol.kind == CompletionKind.functionName && !incomingSymbol
|
if (incomingSymbol.kind == CompletionKind.functionName && !incomingSymbol
|
||||||
.functionParameters.empty)
|
.functionParameters.empty)
|
||||||
{
|
{
|
||||||
return incomingSymbol.functionParameters.front.type is beforeDotSymbol;
|
return incomingSymbol.functionParameters.front.type is beforeDotType;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -181,7 +183,7 @@ void getUFCSParenCompletion(ref DSymbol*[] symbols, Scope* completionScope, istr
|
||||||
foreach(nextSymbol; possibleUFCSSymbol){
|
foreach(nextSymbol; possibleUFCSSymbol){
|
||||||
if (nextSymbol && nextSymbol.functionParameters)
|
if (nextSymbol && nextSymbol.functionParameters)
|
||||||
{
|
{
|
||||||
if (firstSymbol.type is nextSymbol.functionParameters.front.type)
|
if (nextSymbol.isCallableWithArg(firstSymbol.type))
|
||||||
{
|
{
|
||||||
nextSymbol.kind = CompletionKind.ufcsName;
|
nextSymbol.kind = CompletionKind.ufcsName;
|
||||||
symbols ~= nextSymbol;
|
symbols ~= nextSymbol;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
void showSomething(int x, string message, bool ok){}
|
void showSomething(int x, string message, bool ok){}
|
||||||
void showSomething(int x, string message, bool ok, float percentage){}
|
void showSomething(int x, string message, bool ok, float percentage){}
|
||||||
|
void showSomething(string x, string message, bool ok){}
|
||||||
|
void showSomething(){}
|
||||||
|
int showSomething;
|
||||||
|
struct showSomething { int x; }
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
int x;
|
int x;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
../../bin/dcd-client $1 -c163 file.d > actual.txt
|
../../bin/dcd-client $1 -c293 file.d > actual.txt
|
||||||
diff actual.txt expected.txt
|
diff actual.txt expected.txt
|
||||||
|
|
Loading…
Reference in New Issue