From 872d0c5e59275ff4e3aee8c3eeafcf7a5729717b Mon Sep 17 00:00:00 2001 From: davu Date: Sun, 19 Mar 2023 17:48:42 +0100 Subject: [PATCH] Included array matching --- dsymbol/src/dsymbol/ufcs.d | 8 ++++++++ .../expected_array_test.txt | 12 ++++++++++++ tests/tc_ufcs_array_type_completion/file.d | 5 +++++ tests/tc_ufcs_array_type_completion/run.sh | 5 +++++ 4 files changed, 30 insertions(+) create mode 100644 tests/tc_ufcs_array_type_completion/expected_array_test.txt create mode 100644 tests/tc_ufcs_array_type_completion/file.d create mode 100755 tests/tc_ufcs_array_type_completion/run.sh diff --git a/dsymbol/src/dsymbol/ufcs.d b/dsymbol/src/dsymbol/ufcs.d index 2349e02..ad9c732 100644 --- a/dsymbol/src/dsymbol/ufcs.d +++ b/dsymbol/src/dsymbol/ufcs.d @@ -290,6 +290,13 @@ private bool matchesWithTypeOfPointer(const(DSymbol)* incomingSymbol, const(DSym } +private bool matchesWithTypeOfArray(const(DSymbol)* incomingSymbol, const(DSymbol)* cursorSymbolType) { + return incomingSymbol.functionParameters.front.type.qualifier == SymbolQualifier.array + && cursorSymbolType.qualifier == SymbolQualifier.array + && incomingSymbol.functionParameters.front.type.type is cursorSymbolType.type; + +} + /** * Params: * incomingSymbol = the function symbol to check if it is valid for UFCS with `beforeDotType`. @@ -313,6 +320,7 @@ bool isCallableWithArg(const(DSymbol)* incomingSymbol, const(DSymbol)* beforeDot { return beforeDotType is incomingSymbol.functionParameters.front.type || isNonConstrainedTemplate(incomingSymbol) + || matchesWithTypeOfArray(incomingSymbol, beforeDotType) || matchesWithTypeOfPointer(incomingSymbol, beforeDotType) || willImplicitBeUpcasted(beforeDotType, incomingSymbol) || matchAliasThis(beforeDotType, incomingSymbol, recursionDepth); diff --git a/tests/tc_ufcs_array_type_completion/expected_array_test.txt b/tests/tc_ufcs_array_type_completion/expected_array_test.txt new file mode 100644 index 0000000..af8a65d --- /dev/null +++ b/tests/tc_ufcs_array_type_completion/expected_array_test.txt @@ -0,0 +1,12 @@ +identifiers +alignof k +arrayStuff F +doArray F +dup k +idup k +init k +length k +mangleof k +ptr k +sizeof k +stringof k diff --git a/tests/tc_ufcs_array_type_completion/file.d b/tests/tc_ufcs_array_type_completion/file.d new file mode 100644 index 0000000..1d8c6c6 --- /dev/null +++ b/tests/tc_ufcs_array_type_completion/file.d @@ -0,0 +1,5 @@ +void arrayStuff(int[] x) { } +void doArray(int[] x, int[] y) +{ + y. +} \ No newline at end of file diff --git a/tests/tc_ufcs_array_type_completion/run.sh b/tests/tc_ufcs_array_type_completion/run.sh new file mode 100755 index 0000000..d8c6781 --- /dev/null +++ b/tests/tc_ufcs_array_type_completion/run.sh @@ -0,0 +1,5 @@ +set -e +set -u + +../../bin/dcd-client $1 -c65 file.d > actual_array_test.txt +diff actual_array_test.txt expected_array_test.txt \ No newline at end of file