From c1d75abbfd587f55c7328d6963c3eda777d55791 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Wed, 5 Aug 2015 16:08:46 -0700 Subject: [PATCH] Fix #228 --- .gitignore | 2 ++ dsymbol | 2 +- makefile | 10 ++-------- src/server/autocomplete.d | 26 ++++++++++++++------------ tests/run_tests.sh | 2 +- tests/tc011/expected1.txt | 1 + tests/tc011/file.d | 6 ------ tests/tc011/run.sh | 3 --- 8 files changed, 21 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 6cdef8b..37f8b93 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ githash.txt # Test results tests/tc*/actual*.txt +stderr.txt +stdout.txt diff --git a/dsymbol b/dsymbol index d6d4cc0..c4f0652 160000 --- a/dsymbol +++ b/dsymbol @@ -1 +1 @@ -Subproject commit d6d4cc070f7a18912568048657ee513b30038725 +Subproject commit c4f0652bde7164b892dbdb0ce5f7b42eaf288d50 diff --git a/makefile b/makefile index 5cd1f5f..8de6c29 100644 --- a/makefile +++ b/makefile @@ -61,15 +61,9 @@ SERVER_SRC := \ libdparse/src/std/d/entities.d\ libdparse/src/std/d/lexer.d\ libdparse/src/std/d/parser.d\ - libdparse/src/std/lexer.d\ libdparse/src/std/d/formatter.d\ - containers/src/std/experimental/allocator/mallocator.d\ - containers/src/std/experimental/allocator/package.d\ - containers/src/std/experimental/allocator/common.d\ - containers/src/std/experimental/allocator/gc_allocator.d\ - containers/src/std/experimental/allocator/building_blocks/allocator_list.d\ - containers/src/std/experimental/allocator/building_blocks/stats_collector.d\ - containers/src/std/experimental/allocator/typed.d\ + libdparse/src/std/lexer.d\ + $(shell find containers/src/std/experimental/allocator/ -name "*.d")\ containers/src/memory/allocators.d\ containers/src/memory/appender.d\ containers/src/containers/dynamicarray.d\ diff --git a/src/server/autocomplete.d b/src/server/autocomplete.d index d663470..f38eb9f 100644 --- a/src/server/autocomplete.d +++ b/src/server/autocomplete.d @@ -736,7 +736,8 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope, case tok!"identifier": // Use function return type instead of the function itself if (symbols[0].qualifier == SymbolQualifier.func - || symbols[0].kind == CompletionKind.functionName) + || symbols[0].kind == CompletionKind.functionName + || symbols[0].kind == CompletionKind.aliasName) { symbols = symbols[0].type is null ? [] :[symbols[0].type]; if (symbols.length == 0) @@ -853,24 +854,23 @@ void setCompletions(T)(ref AutocompleteResponse response, if (completionType == CompletionType.identifiers) { - if (symbols[0].qualifier == SymbolQualifier.func - || symbols[0].kind == CompletionKind.functionName) + while (symbols[0].qualifier == SymbolQualifier.func + || symbols[0].kind == CompletionKind.functionName + || symbols[0].kind == CompletionKind.importSymbol + || symbols[0].kind == CompletionKind.aliasName) { symbols = symbols[0].type is null ? [] : [symbols[0].type]; if (symbols.length == 0) return; } - if (symbols[0].kind != CompletionKind.importSymbol) + foreach (sym; symbols[0].opSlice()) { - foreach (sym; symbols[0].opSlice()) + if (sym.name !is null && sym.name.length > 0 && sym.kind != CompletionKind.importSymbol + && (partial is null ? true : sym.name.toUpper().startsWith(partial.toUpper())) + && !response.completions.canFind(sym.name)) { - if (sym.name !is null && sym.name.length > 0 && sym.name[0] != '*' - && (partial is null ? true : sym.name.toUpper().startsWith(partial.toUpper())) - && !response.completions.canFind(sym.name)) - { - response.completionKinds ~= sym.kind; - response.completions ~= sym.name.dup; - } + response.completionKinds ~= sym.kind; + response.completions ~= sym.name.dup; } } response.completionType = CompletionType.identifiers; @@ -1206,6 +1206,8 @@ bool shouldSwapWithType(CompletionType completionType, CompletionKind kind, immutable bool isInteresting = kind == CompletionKind.variableName || kind == CompletionKind.memberVariableName + || kind == CompletionKind.importSymbol + || kind == CompletionKind.aliasName || kind == CompletionKind.enumMember || kind == CompletionKind.functionName; return isInteresting && (completionType == CompletionType.identifiers diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 573ef96..07ec2ed 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -14,7 +14,7 @@ sleep 1s; # Start up the server echo "Starting server..." -../bin/dcd-server --ignoreConfig -I $IMPORTS 2>/dev/null > /dev/null & +../bin/dcd-server --ignoreConfig -I $IMPORTS 2>stderr.txt > stdout.txt & sleep 1s; # Run tests diff --git a/tests/tc011/expected1.txt b/tests/tc011/expected1.txt index 267d0a5..7d65484 100644 --- a/tests/tc011/expected1.txt +++ b/tests/tc011/expected1.txt @@ -1 +1,2 @@ +identifiers Point s diff --git a/tests/tc011/file.d b/tests/tc011/file.d index d17a65a..4ab4ccc 100644 --- a/tests/tc011/file.d +++ b/tests/tc011/file.d @@ -6,9 +6,3 @@ unittest { p. } - -unittest -{ - p.Point p1; - p1. -} diff --git a/tests/tc011/run.sh b/tests/tc011/run.sh index aebbb09..1351484 100755 --- a/tests/tc011/run.sh +++ b/tests/tc011/run.sh @@ -3,6 +3,3 @@ set -u dcd-client file.d -c48 > actual1.txt diff actual1.txt expected1.txt - -dcd-client file.d -c80 > actual2.txt -diff actual2.txt expected2.txt