Skip to content

Commit 6a3cf3c

Browse files
committed
Decrease the size of the ACSymbol struct
1 parent 02063b8 commit 6a3cf3c

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

src/actypes.d

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,8 @@ public:
123123
auto app = appender!(ACSymbol*[])();
124124
foreach (part; parts.equalRange(&s))
125125
app.put(part);
126-
foreach (extra; aliasThisParts.equalRange(&s))
127-
app.put(extra.getPartsByName(name));
128126
foreach (im; parts.equalRange(&p))
129-
foreach (part; im.type.parts.equalRange(&s))
130-
app.put(part);
127+
app.put(im.type.getPartsByName(name));
131128
return app.data();
132129
}
133130

@@ -142,11 +139,6 @@ public:
142139
*/
143140
TTree!(ACSymbol*, true, "a < b", false) parts;
144141

145-
/**
146-
* Symbols included due to an alias this.
147-
*/
148-
TTree!(ACSymbol*, true, "a < b", false) aliasThisParts;
149-
150142
/**
151143
* Calltip to display if this is a function
152144
*/

src/autocomplete.d

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -642,18 +642,20 @@ void setCompletions(T)(ref AutocompleteResponse response,
642642
if (symbols.length == 0)
643643
return;
644644
}
645-
TTree!(ACSymbol*, true, "a < b", false) parts;
646-
parts.insert(symbols[0].parts[]);
647-
foreach (s; symbols[0].aliasThisParts[])
648-
parts.insert(s.parts[]);
649-
foreach (s; parts[].filter!(a => a.name !is null
650-
&& a.name.length > 0 && a.name[0] != '*'
651-
&& (partial is null ? true : a.name.toUpper().startsWith(partial.toUpper()))
652-
&& !response.completions.canFind(a.name)))
645+
foreach (sym; symbols[0].parts[])
653646
{
654-
// Log.trace("Adding ", s.name, " to the completion list");
655-
response.completionKinds ~= s.kind;
656-
response.completions ~= s.name.dup;
647+
if (sym.kind == CompletionKind.importSymbol) foreach (s; sym.type.parts[])
648+
{
649+
response.completionKinds ~= s.kind;
650+
response.completions ~= s.name.dup;
651+
}
652+
else if (sym.name !is null && sym.name.length > 0 && sym.name[0] != '*'
653+
&& (partial is null ? true : sym.name.toUpper().startsWith(partial.toUpper()))
654+
&& !response.completions.canFind(sym.name))
655+
{
656+
response.completionKinds ~= sym.kind;
657+
response.completions ~= sym.name.dup;
658+
}
657659
}
658660
response.completionType = CompletionType.identifiers;
659661
}
@@ -865,10 +867,14 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
865867
}
866868
else if (isDir(name))
867869
{
868-
response.completions ~= name.baseName();
869-
response.completionKinds ~=
870-
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di"))
871-
? CompletionKind.moduleName : CompletionKind.packageName;
870+
string n = name.baseName();
871+
if (n[0] != '.')
872+
{
873+
response.completions ~= n;
874+
response.completionKinds ~=
875+
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di"))
876+
? CompletionKind.moduleName : CompletionKind.packageName;
877+
}
872878
}
873879
}
874880
}

src/conversion/third.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ private:
146146
auto parts = currentSymbol.acSymbol.getPartsByName(aliasThis);
147147
if (parts.length == 0 || parts[0].type is null)
148148
continue;
149-
currentSymbol.acSymbol.aliasThisParts.insert(parts[0].type);
149+
ACSymbol* s = allocate!ACSymbol(symbolAllocator, IMPORT_SYMBOL_NAME,
150+
CompletionKind.importSymbol);
151+
s.type = parts[0].type;
152+
currentSymbol.acSymbol.parts.insert(s);
150153
}
151154
}
152155

0 commit comments

Comments
 (0)