diff --git a/dsymbol b/dsymbol index c4f0652..ea0deb0 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit c4f0652bde7164b892dbdb0ce5f7b42eaf288d50 +Subproject commit ea0deb0ce566ffced71a427885e069998fc9220a diff --git a/src/server/autocomplete.d b/src/server/autocomplete.d index f38eb9f..69518cc 100644 --- a/src/server/autocomplete.d +++ b/src/server/autocomplete.d @@ -734,9 +734,14 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope, break loop; break; case tok!"identifier": - // Use function return type instead of the function itself - if (symbols[0].qualifier == SymbolQualifier.func + trace(symbols[0].qualifier, " ", symbols[0].kind); + + // Use type instead of the symbol itself for certain symbol kinds + while (symbols[0].qualifier == SymbolQualifier.func || symbols[0].kind == CompletionKind.functionName + || (symbols[0].kind == CompletionKind.moduleName + && symbols[0].type !is null && symbols[0].type.kind == CompletionKind.importSymbol) + || symbols[0].kind == CompletionKind.importSymbol || symbols[0].kind == CompletionKind.aliasName) { symbols = symbols[0].type is null ? [] :[symbols[0].type]; @@ -744,7 +749,7 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope, break loop; } -// trace("looking for ", tokens[i].text, " in ", symbols[0].name); + trace("looking for ", tokens[i].text, " in ", symbols[0].name); symbols = symbols[0].getPartsByName(internString(tokens[i].text)); if (symbols.length == 0) { @@ -758,7 +763,8 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope, if (symbols.length == 0) break loop; } - if (symbols[0].kind == CompletionKind.aliasName + if ((symbols[0].kind == CompletionKind.aliasName + || symbols[0].kind == CompletionKind.moduleName) && (completionType == CompletionType.identifiers || i + 1 < tokens.length)) { @@ -877,10 +883,18 @@ void setCompletions(T)(ref AutocompleteResponse response, } else if (completionType == CompletionType.calltips) { -// trace("Showing call tips for ", symbols[0].name, " of kind ", symbols[0].kind); + //trace("Showing call tips for ", symbols[0].name, " of kind ", symbols[0].kind); if (symbols[0].kind != CompletionKind.functionName && symbols[0].callTip is null) { + if (symbols[0].kind == CompletionKind.aliasName) + { + trace("Got here"); + if (symbols[0].type is null) + return; + symbols = [symbols[0].type]; + trace("Got there", symbols[0].kind); + } if (symbols[0].kind == CompletionKind.variableName) { auto dumb = symbols[0].type; @@ -907,7 +921,6 @@ void setCompletions(T)(ref AutocompleteResponse response, goto setCallTips; } } - } if (symbols[0].kind == CompletionKind.structName || symbols[0].kind == CompletionKind.className) @@ -1188,9 +1201,8 @@ body bool shouldSwapWithType(CompletionType completionType, CompletionKind kind, size_t current, size_t max) pure nothrow @safe { - // Modules and packages never have types, so always return false - if (kind == CompletionKind.moduleName - || kind == CompletionKind.packageName + // packages never have types, so always return false + if (kind == CompletionKind.packageName || kind == CompletionKind.className || kind == CompletionKind.structName || kind == CompletionKind.interfaceName diff --git a/tests/imports/std/stdio.d b/tests/imports/std/stdio.d index e69de29..d968bfe 100644 --- a/tests/imports/std/stdio.d +++ b/tests/imports/std/stdio.d @@ -0,0 +1 @@ +void writeln(string); diff --git a/tests/tc012/expected2.txt b/tests/tc012/expected2.txt new file mode 100644 index 0000000..5f017bf --- /dev/null +++ b/tests/tc012/expected2.txt @@ -0,0 +1,2 @@ +identifiers +writeln f diff --git a/tests/tc012/run.sh b/tests/tc012/run.sh index 1351484..ff803fc 100755 --- a/tests/tc012/run.sh +++ b/tests/tc012/run.sh @@ -1,5 +1,8 @@ set -e set -u -dcd-client file.d -c48 > actual1.txt +dcd-client file.d -c35 > actual1.txt diff actual1.txt expected1.txt + +dcd-client file.d -c61 > actual2.txt +diff actual2.txt expected2.txt diff --git a/tests/tc013/run.sh b/tests/tc013/run.sh new file mode 100755 index 0000000..e58d9a1 --- /dev/null +++ b/tests/tc013/run.sh @@ -0,0 +1,5 @@ +set -e +set -u + +dcd-client file.d -c162 > actual1.txt +diff actual1.txt expected1.txt