fix first ditto & added ditto scope test

This commit is contained in:
WebFreak001 2018-12-29 19:27:06 +01:00
parent d2123f9e48
commit 16a362d97c
15 changed files with 86 additions and 1 deletions

View File

@ -53,8 +53,16 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request,
warning("Could not find symbol");
else
{
foreach(ref symbol; stuff.symbols.filter!(a => !a.doc.empty && !a.doc.ditto))
// first symbol allows ditto if it's the first documentation,
// because then it takes documentation from a symbol with different name
// which isn't inside the stuff.symbols range.
bool firstSymbol = true;
foreach(ref symbol; stuff.symbols.filter!(a => !a.doc.empty))
{
if (!firstSymbol && symbol.doc.ditto)
continue;
firstSymbol = false;
AutocompleteResponse.Completion c;
c.documentation = symbol.doc;
response.completions ~= c;

View File

@ -0,0 +1 @@
documentation for a; b has no documentation

View File

View File

@ -0,0 +1 @@
documentation for c and d\nmore documentation for c and d

View File

@ -0,0 +1 @@
documentation for c and d\nmore documentation for c and d

View File

@ -0,0 +1 @@
documentation for e and f

View File

@ -0,0 +1 @@
documentation for e and f

View File

@ -0,0 +1 @@
documentation for g\nmore documentation for g

View File

@ -0,0 +1 @@
documentation for C.x

View File

@ -0,0 +1 @@
documentation for C.y and C.z

View File

@ -0,0 +1 @@
documentation for C.y and C.z

View File

@ -0,0 +1 @@
documentation for C and D

View File

@ -0,0 +1 @@
documentation for C and D

View File

@ -0,0 +1,27 @@
int a; /// documentation for a; b has no documentation
int b;
/** documentation for c and d */
/** more documentation for c and d */
int c;
/** ditto */
int d;
/** documentation for e and f */ int e;
int f; /// ditto
/** documentation for g */
int g; /// more documentation for g
/// documentation for C and D
class C
{
int x; /// documentation for C.x
/** documentation for C.y and C.z */
int y;
int z; /// ditto
}
/// ditto
class D { }

39
tests/tc_ditto_scopes/run.sh Executable file
View File

@ -0,0 +1,39 @@
set -e
set -u
../../bin/dcd-client $1 file.d -d -c5 > actual1.txt
diff actual1.txt expected1.txt
../../bin/dcd-client $1 file.d -d -c61 > actual2.txt
diff actual2.txt expected2.txt
../../bin/dcd-client $1 file.d -d -c140 > actual3.txt
diff actual3.txt expected3.txt
../../bin/dcd-client $1 file.d -d -c160 > actual4.txt
diff actual4.txt expected4.txt
../../bin/dcd-client $1 file.d -d -c201 > actual5.txt
diff actual5.txt expected5.txt
../../bin/dcd-client $1 file.d -d -c208 > actual6.txt
diff actual6.txt expected6.txt
../../bin/dcd-client $1 file.d -d -c254 > actual7.txt
diff actual7.txt expected7.txt
../../bin/dcd-client $1 file.d -d -c323 > actual8.txt
diff actual8.txt expected8.txt
../../bin/dcd-client $1 file.d -d -c335 > actual8.1.txt
diff actual8.1.txt expected8.1.txt
../../bin/dcd-client $1 file.d -d -c414 > actual8.2.txt
diff actual8.2.txt expected8.2.txt
../../bin/dcd-client $1 file.d -d -c425 > actual8.3.txt
diff actual8.3.txt expected8.3.txt
../../bin/dcd-client $1 file.d -d -c457 > actual9.txt
diff actual9.txt expected9.txt