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

View File

@ -642,18 +642,20 @@ void setCompletions(T)(ref AutocompleteResponse response,
if (symbols.length == 0) if (symbols.length == 0)
return; return;
} }
TTree!(ACSymbol*, true, "a < b", false) parts; foreach (sym; symbols[0].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)))
{ {
// Log.trace("Adding ", s.name, " to the completion list"); if (sym.kind == CompletionKind.importSymbol) foreach (s; sym.type.parts[])
response.completionKinds ~= s.kind; {
response.completions ~= s.name.dup; 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; response.completionType = CompletionType.identifiers;
} }
@ -865,10 +867,14 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
} }
else if (isDir(name)) else if (isDir(name))
{ {
response.completions ~= name.baseName(); string n = name.baseName();
response.completionKinds ~= if (n[0] != '.')
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di")) {
? CompletionKind.moduleName : CompletionKind.packageName; 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); auto parts = currentSymbol.acSymbol.getPartsByName(aliasThis);
if (parts.length == 0 || parts[0].type is null) if (parts.length == 0 || parts[0].type is null)
continue; 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);
} }
} }