Merge pull request #249 from Hackerpilot/issue-244

Issue 244
This commit is contained in:
Brian Schott 2015-08-21 03:01:54 -07:00
commit 70c78a2a10
7 changed files with 39 additions and 11 deletions

@ -1 +1 @@
Subproject commit 6aca66ef031cca3687df8f022e8c04a33fa7c263
Subproject commit 4ac656541a719c27cf549fddcb1e85cf702ce804

View File

@ -819,6 +819,22 @@ void setCompletions(T)(ref AutocompleteResponse response,
Scope* completionScope, T tokens, size_t cursorPosition,
CompletionType completionType, bool isBracket = false, string partial = null)
{
static void addSymToResponse(DSymbol* s, ref AutocompleteResponse r, string p)
{
foreach (sym; s.opSlice())
{
if (sym.name !is null && sym.name.length > 0 && sym.kind != CompletionKind.importSymbol
&& (p is null ? true : sym.name.toUpper().startsWith(p.toUpper()))
&& !r.completions.canFind(sym.name))
{
r.completionKinds ~= sym.kind;
r.completions ~= sym.name.dup;
}
if (sym.kind == CompletionKind.importSymbol && !sym.skipOver && sym.type !is null)
addSymToResponse(sym.type, r, p);
}
}
// Handle the simple case where we get all symbols in scope and filter it
// based on the currently entered text.
if (partial !is null && tokens.length == 0)
@ -854,16 +870,7 @@ void setCompletions(T)(ref AutocompleteResponse response,
if (symbols.length == 0)
return;
}
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))
{
response.completionKinds ~= sym.kind;
response.completions ~= sym.name.dup;
}
}
addSymToResponse(symbols[0], response, partial);
response.completionType = CompletionType.identifiers;
}
else if (completionType == CompletionType.calltips)

3
tests/imports/a.d Normal file
View File

@ -0,0 +1,3 @@
module a;
public import b;
string FOO;

6
tests/imports/b.d Normal file
View File

@ -0,0 +1,6 @@
module b;
string BAR;
struct S {
int x;
}

4
tests/tc017/expected.txt Normal file
View File

@ -0,0 +1,4 @@
identifiers
BAR v
FOO v
S s

3
tests/tc017/file.d Normal file
View File

@ -0,0 +1,3 @@
module main;
import mod = a;
mod.

5
tests/tc017/run.sh Executable file
View File

@ -0,0 +1,5 @@
set -e
set -u
../../bin/dcd-client file.d -c33 > actual.txt
diff actual.txt expected.txt