Updated according to PR changes
This commit is contained in:
parent
15881dca19
commit
430238bdd4
|
|
@ -127,7 +127,7 @@ private TokenCursorResult getCursorToken(const(Token)[] tokens, size_t cursorPos
|
||||||
return tokenCursorResult;
|
return tokenCursorResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getUFCSSymbols(T, Y)(ref T localAppender, ref Y globalAppender, Scope* completionScope, size_t cursorPosition)
|
private void getUFCSSymbols(T, Y)(scope ref T localAppender, scope ref Y globalAppender, Scope* completionScope, size_t cursorPosition)
|
||||||
{
|
{
|
||||||
|
|
||||||
Scope* currentScope = completionScope.getScopeByCursor(cursorPosition);
|
Scope* currentScope = completionScope.getScopeByCursor(cursorPosition);
|
||||||
|
|
@ -177,7 +177,7 @@ private void getUFCSSymbols(T, Y)(ref T localAppender, ref Y globalAppender, Sco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DSymbol*[] getUFCSSymbolsForCursor(Scope* completionScope, ref const(Token)[] tokens, size_t cursorPosition)
|
DSymbol*[] getUFCSSymbolsForCursor(Scope* completionScope, scope ref const(Token)[] tokens, size_t cursorPosition)
|
||||||
{
|
{
|
||||||
TokenCursorResult tokenCursorResult = getCursorToken(tokens, cursorPosition);
|
TokenCursorResult tokenCursorResult = getCursorToken(tokens, cursorPosition);
|
||||||
|
|
||||||
|
|
@ -257,7 +257,7 @@ private DSymbol*[] getUFCSSymbolsForParenCompletion(const(DSymbol)* symbolType,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool willImplicitBeUpcasted(ref const(DSymbol) incomingSymbolType, ref const(DSymbol) significantSymbolType)
|
private bool willImplicitBeUpcasted(scope ref const(DSymbol) incomingSymbolType, scope ref const(DSymbol) significantSymbolType)
|
||||||
{
|
{
|
||||||
string fromTypeName = significantSymbolType.name.data;
|
string fromTypeName = significantSymbolType.name.data;
|
||||||
string toTypeName = incomingSymbolType.name.data;
|
string toTypeName = incomingSymbolType.name.data;
|
||||||
|
|
@ -273,19 +273,19 @@ private bool typeWillBeUpcastedTo(string from, string to)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNonConstrainedTemplate(ref const(DSymbol) symbolType)
|
bool isNonConstrainedTemplate(scope ref const(DSymbol) symbolType)
|
||||||
{
|
{
|
||||||
return symbolType.kind is CompletionKind.typeTmpParam;
|
return symbolType.kind is CompletionKind.typeTmpParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool matchesWithTypeOfPointer(ref const(DSymbol) incomingSymbolType, ref const(DSymbol) significantSymbolType)
|
private bool matchesWithTypeOfPointer(scope ref const(DSymbol) incomingSymbolType, scope ref const(DSymbol) significantSymbolType)
|
||||||
{
|
{
|
||||||
return incomingSymbolType.qualifier == SymbolQualifier.pointer
|
return incomingSymbolType.qualifier == SymbolQualifier.pointer
|
||||||
&& significantSymbolType.qualifier == SymbolQualifier.pointer
|
&& significantSymbolType.qualifier == SymbolQualifier.pointer
|
||||||
&& incomingSymbolType.type is significantSymbolType.type;
|
&& incomingSymbolType.type is significantSymbolType.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool matchesWithTypeOfArray(ref const(DSymbol) incomingSymbolType, ref const(DSymbol) cursorSymbolType)
|
private bool matchesWithTypeOfArray(scope ref const(DSymbol) incomingSymbolType, scope ref const(DSymbol) cursorSymbolType)
|
||||||
{
|
{
|
||||||
return incomingSymbolType.qualifier == SymbolQualifier.array
|
return incomingSymbolType.qualifier == SymbolQualifier.array
|
||||||
&& cursorSymbolType.qualifier == SymbolQualifier.array
|
&& cursorSymbolType.qualifier == SymbolQualifier.array
|
||||||
|
|
@ -293,7 +293,7 @@ private bool matchesWithTypeOfArray(ref const(DSymbol) incomingSymbolType, ref c
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool typeMatchesWith(ref const(DSymbol) incomingSymbolType, ref const(DSymbol) significantSymbolType) {
|
private bool typeMatchesWith(scope ref const(DSymbol) incomingSymbolType, scope ref const(DSymbol) significantSymbolType) {
|
||||||
return incomingSymbolType is significantSymbolType
|
return incomingSymbolType is significantSymbolType
|
||||||
|| isNonConstrainedTemplate(incomingSymbolType)
|
|| isNonConstrainedTemplate(incomingSymbolType)
|
||||||
|| matchesWithTypeOfArray(incomingSymbolType, significantSymbolType)
|
|| matchesWithTypeOfArray(incomingSymbolType, significantSymbolType)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
struct S { S* s; S get() { return *s; } alias get this; }
|
||||||
|
|
||||||
|
void ufcsMatching(S value) {}
|
||||||
|
void ufcsNonMatching(int value) {}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
S s;
|
||||||
|
s.ufcs
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
identifiers
|
||||||
|
ufcsMatching F
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
identifiers
|
||||||
|
ufcsA F
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
identifiers
|
||||||
|
ufcsA F
|
||||||
|
ufcsB F
|
||||||
|
ufcsC F
|
||||||
|
ufcsD F
|
||||||
|
ufcsE F
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
struct A { int x; }
|
||||||
|
struct B { A a; alias a this; }
|
||||||
|
struct C { B b; alias b this; }
|
||||||
|
struct D { C c; alias c this; }
|
||||||
|
struct E { D d; alias d this; }
|
||||||
|
struct F { E e; alias e this; }
|
||||||
|
|
||||||
|
void ufcsA(A a) {}
|
||||||
|
void ufcsB(B b) {}
|
||||||
|
void ufcsC(C c) {}
|
||||||
|
void ufcsD(D d) {}
|
||||||
|
void ufcsE(E e) {}
|
||||||
|
|
||||||
|
void testA()
|
||||||
|
{
|
||||||
|
A a;
|
||||||
|
a.ufcs // should only give ufcsA
|
||||||
|
}
|
||||||
|
|
||||||
|
void testE()
|
||||||
|
{
|
||||||
|
E e;
|
||||||
|
e.ufcs // should give all the ufcs methods
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
#TEST CASE 0
|
||||||
|
SOURCE_FILE_0=alias_this_on_function.d
|
||||||
|
ACTUAL_FILE_NAME_0="actual_alias_this_on_function_test.txt"
|
||||||
|
EXPECTED_FILE_NAME_0="expected_alias_this_on_function_test.txt"
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 -c152 $SOURCE_FILE_0 > $ACTUAL_FILE_NAME_0
|
||||||
|
diff $ACTUAL_FILE_NAME_0 $EXPECTED_FILE_NAME_0 --strip-trailing-cr
|
||||||
|
|
||||||
|
#TEST CASE 1
|
||||||
|
SOURCE_FILE_1=plenty_alias_this_defined.d
|
||||||
|
ACTUAL_FILE_NAME_1="actual_plenty_alias_this_defined_test.txt"
|
||||||
|
EXPECTED_FILE_NAME_1="expected_plenty_alias_this_defined_test.txt"
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 -c305 $SOURCE_FILE_1 > $ACTUAL_FILE_NAME_1
|
||||||
|
diff $ACTUAL_FILE_NAME_1 $EXPECTED_FILE_NAME_1 --strip-trailing-cr
|
||||||
|
|
||||||
|
#TEST CASE 2
|
||||||
|
ACTUAL_FILE_NAME_2="actual_plenty_alias_this_defined_test2.txt"
|
||||||
|
EXPECTED_FILE_NAME_2="expected_plenty_alias_this_defined_test2.txt"
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 -c363 $SOURCE_FILE_1 > $ACTUAL_FILE_NAME_2
|
||||||
|
diff $ACTUAL_FILE_NAME_2 $EXPECTED_FILE_NAME_2 --strip-trailing-cr
|
||||||
Loading…
Reference in New Issue