diff --git a/dsymbol b/dsymbol index 211a3cf..913e1f1 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit 211a3cf8c8a22f4329aabacbde4251cedbccdf8c +Subproject commit 913e1f1207f2488400e383d9e74219eb706fdb05 diff --git a/dub.json b/dub.json index 2b70bdd..13fd5c3 100644 --- a/dub.json +++ b/dub.json @@ -7,7 +7,7 @@ ], "license": "GPL-3.0", "dependencies": { - "dsymbol": "~>0.5.5", + "dsymbol": "~>0.5.6", "libdparse": "~>0.10.10", "msgpack-d": "~>1.0.0-beta.7", "stdx-allocator": "~>2.77.5" diff --git a/src/dcd/server/autocomplete/doc.d b/src/dcd/server/autocomplete/doc.d index 2b40e8d..081062c 100644 --- a/src/dcd/server/autocomplete/doc.d +++ b/src/dcd/server/autocomplete/doc.d @@ -53,17 +53,16 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request, warning("Could not find symbol"); else { - bool isDitto(string s) + // 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)) { - import std.uni : icmp; - if (s.length > 5) - return false; - else - return s.icmp("ditto") == 0; - } + if (!firstSymbol && symbol.doc.ditto) + continue; + firstSymbol = false; - foreach(ref symbol; stuff.symbols.filter!(a => !a.doc.empty && !isDitto(a.doc))) - { AutocompleteResponse.Completion c; c.documentation = symbol.doc; response.completions ~= c; diff --git a/tests/tc_ditto_scopes/expected1.txt b/tests/tc_ditto_scopes/expected1.txt new file mode 100644 index 0000000..4442d6e --- /dev/null +++ b/tests/tc_ditto_scopes/expected1.txt @@ -0,0 +1 @@ +documentation for a; b has no documentation diff --git a/tests/tc_ditto_scopes/expected2.txt b/tests/tc_ditto_scopes/expected2.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/tc_ditto_scopes/expected3.txt b/tests/tc_ditto_scopes/expected3.txt new file mode 100644 index 0000000..0bfb404 --- /dev/null +++ b/tests/tc_ditto_scopes/expected3.txt @@ -0,0 +1 @@ +documentation for c and d\nmore documentation for c and d diff --git a/tests/tc_ditto_scopes/expected4.txt b/tests/tc_ditto_scopes/expected4.txt new file mode 100644 index 0000000..0bfb404 --- /dev/null +++ b/tests/tc_ditto_scopes/expected4.txt @@ -0,0 +1 @@ +documentation for c and d\nmore documentation for c and d diff --git a/tests/tc_ditto_scopes/expected5.txt b/tests/tc_ditto_scopes/expected5.txt new file mode 100644 index 0000000..7d84de2 --- /dev/null +++ b/tests/tc_ditto_scopes/expected5.txt @@ -0,0 +1 @@ +documentation for e and f diff --git a/tests/tc_ditto_scopes/expected6.txt b/tests/tc_ditto_scopes/expected6.txt new file mode 100644 index 0000000..7d84de2 --- /dev/null +++ b/tests/tc_ditto_scopes/expected6.txt @@ -0,0 +1 @@ +documentation for e and f diff --git a/tests/tc_ditto_scopes/expected7.txt b/tests/tc_ditto_scopes/expected7.txt new file mode 100644 index 0000000..d6401cb --- /dev/null +++ b/tests/tc_ditto_scopes/expected7.txt @@ -0,0 +1 @@ +documentation for g\nmore documentation for g diff --git a/tests/tc_ditto_scopes/expected8.1.txt b/tests/tc_ditto_scopes/expected8.1.txt new file mode 100644 index 0000000..0abcef7 --- /dev/null +++ b/tests/tc_ditto_scopes/expected8.1.txt @@ -0,0 +1 @@ +documentation for C.x diff --git a/tests/tc_ditto_scopes/expected8.2.txt b/tests/tc_ditto_scopes/expected8.2.txt new file mode 100644 index 0000000..5b56b11 --- /dev/null +++ b/tests/tc_ditto_scopes/expected8.2.txt @@ -0,0 +1 @@ +documentation for C.y and C.z diff --git a/tests/tc_ditto_scopes/expected8.3.txt b/tests/tc_ditto_scopes/expected8.3.txt new file mode 100644 index 0000000..5b56b11 --- /dev/null +++ b/tests/tc_ditto_scopes/expected8.3.txt @@ -0,0 +1 @@ +documentation for C.y and C.z diff --git a/tests/tc_ditto_scopes/expected8.txt b/tests/tc_ditto_scopes/expected8.txt new file mode 100644 index 0000000..668a6a3 --- /dev/null +++ b/tests/tc_ditto_scopes/expected8.txt @@ -0,0 +1 @@ +documentation for C and D diff --git a/tests/tc_ditto_scopes/expected9.txt b/tests/tc_ditto_scopes/expected9.txt new file mode 100644 index 0000000..668a6a3 --- /dev/null +++ b/tests/tc_ditto_scopes/expected9.txt @@ -0,0 +1 @@ +documentation for C and D diff --git a/tests/tc_ditto_scopes/file.d b/tests/tc_ditto_scopes/file.d new file mode 100644 index 0000000..79f55ef --- /dev/null +++ b/tests/tc_ditto_scopes/file.d @@ -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 { } \ No newline at end of file diff --git a/tests/tc_ditto_scopes/run.sh b/tests/tc_ditto_scopes/run.sh new file mode 100755 index 0000000..58d0858 --- /dev/null +++ b/tests/tc_ditto_scopes/run.sh @@ -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 + diff --git a/tests/tc_extended_ditto/expected1.txt b/tests/tc_extended_ditto/expected1.txt new file mode 100644 index 0000000..8574d4a --- /dev/null +++ b/tests/tc_extended_ditto/expected1.txt @@ -0,0 +1,3 @@ +identifiers +foo f void foo() stdin 26 my documentation +foo f void foo(int i) stdin 49 my documentation diff --git a/tests/tc_extended_ditto/file.d b/tests/tc_extended_ditto/file.d new file mode 100644 index 0000000..6c20263 --- /dev/null +++ b/tests/tc_extended_ditto/file.d @@ -0,0 +1,9 @@ +/// my documentation +void foo(){} +/// ditto +void foo(int i){} + +void test() +{ + fo +} diff --git a/tests/tc_extended_ditto/run.sh b/tests/tc_extended_ditto/run.sh new file mode 100755 index 0000000..03f8b1e --- /dev/null +++ b/tests/tc_extended_ditto/run.sh @@ -0,0 +1,5 @@ +set -e +set -u + +../../bin/dcd-client $1 file.d -x -c80 > actual1.txt +diff actual1.txt expected1.txt