Decrease the size of the ACSymbol struct

This commit is contained in:
Hackerpilot 2014-09-03 17:29:12 -07:00
parent 02063b87a3
commit 6a3cf3c572
3 changed files with 26 additions and 25 deletions

View File

@ -123,11 +123,8 @@ public:
auto app = appender!(ACSymbol*[])();
foreach (part; parts.equalRange(&s))
app.put(part);
foreach (extra; aliasThisParts.equalRange(&s))
app.put(extra.getPartsByName(name));
foreach (im; parts.equalRange(&p))
foreach (part; im.type.parts.equalRange(&s))
app.put(part);
app.put(im.type.getPartsByName(name));
return app.data();
}
@ -142,11 +139,6 @@ public:
*/
TTree!(ACSymbol*, true, "a < b", false) parts;
/**
* Symbols included due to an alias this.
*/
TTree!(ACSymbol*, true, "a < b", false) aliasThisParts;
/**
* Calltip to display if this is a function
*/

View File

@ -642,19 +642,21 @@ void setCompletions(T)(ref AutocompleteResponse response,
if (symbols.length == 0)
return;
}
TTree!(ACSymbol*, true, "a < b", false) parts;
parts.insert(symbols[0].parts[]);
foreach (s; symbols[0].aliasThisParts[])
parts.insert(s.parts[]);
foreach (s; parts[].filter!(a => a.name !is null
&& a.name.length > 0 && a.name[0] != '*'
&& (partial is null ? true : a.name.toUpper().startsWith(partial.toUpper()))
&& !response.completions.canFind(a.name)))
foreach (sym; symbols[0].parts[])
{
if (sym.kind == CompletionKind.importSymbol) foreach (s; sym.type.parts[])
{
// Log.trace("Adding ", s.name, " to the completion list");
response.completionKinds ~= s.kind;
response.completions ~= s.name.dup;
}
else 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.completionType = CompletionType.identifiers;
}
else if (completionType == CompletionType.calltips)
@ -865,13 +867,17 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
}
else if (isDir(name))
{
response.completions ~= name.baseName();
string n = name.baseName();
if (n[0] != '.')
{
response.completions ~= n;
response.completionKinds ~=
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di"))
? CompletionKind.moduleName : CompletionKind.packageName;
}
}
}
}
}
/**

View File

@ -146,7 +146,10 @@ private:
auto parts = currentSymbol.acSymbol.getPartsByName(aliasThis);
if (parts.length == 0 || parts[0].type is null)
continue;
currentSymbol.acSymbol.aliasThisParts.insert(parts[0].type);
ACSymbol* s = allocate!ACSymbol(symbolAllocator, IMPORT_SYMBOL_NAME,
CompletionKind.importSymbol);
s.type = parts[0].type;
currentSymbol.acSymbol.parts.insert(s);
}
}