This commit is contained in:
Hackerpilot 2013-09-07 18:49:40 +00:00
parent d4af3e994a
commit 156908deb9
3 changed files with 40 additions and 14 deletions

View File

@ -330,8 +330,7 @@ class AutocompleteVisitor : ASTVisitor
else if (dec.hasRef) else if (dec.hasRef)
returnType = "ref"; returnType = "ref";
} }
symbol.calltip = format("%s %s%s", formatNode(dec.returnType), symbol.calltip = formatCalltip(dec.returnType, dec.name.value, dec.parameters);
dec.name.value, formatNode(dec.parameters));
} }
auto p = parentSymbol; auto p = parentSymbol;
parentSymbol = symbol; parentSymbol = symbol;
@ -376,9 +375,8 @@ class AutocompleteVisitor : ASTVisitor
{ {
TypeSuffix suffix = dec.type.typeSuffixes[$ - 1]; TypeSuffix suffix = dec.type.typeSuffixes[$ - 1];
dec.type.typeSuffixes = dec.type.typeSuffixes[0 .. $ - 1]; dec.type.typeSuffixes = dec.type.typeSuffixes[0 .. $ - 1];
symbol.calltip = "%s %s%s".format(formatNode(dec.type), symbol.calltip = formatCalltip(dec.type,
suffix.delegateOrFunction.value, suffix.delegateOrFunction.value, suffix.parameters);
formatNode(suffix.parameters));
} }
symbol.kind = CompletionKind.variableName; symbol.kind = CompletionKind.variableName;
@ -407,9 +405,7 @@ class AutocompleteVisitor : ASTVisitor
{ {
TypeSuffix suffix = aliasPart.type.typeSuffixes[$ - 1]; TypeSuffix suffix = aliasPart.type.typeSuffixes[$ - 1];
aliasPart.type.typeSuffixes = aliasPart.type.typeSuffixes[0 .. $ - 1]; aliasPart.type.typeSuffixes = aliasPart.type.typeSuffixes[0 .. $ - 1];
aliasSymbol.calltip = "%s %s%s".format(formatNode(dec.type), aliasSymbol.calltip = formatCalltip(dec.type, suffix.delegateOrFunction.value, suffix.parameters);
suffix.delegateOrFunction.value,
formatNode(suffix.parameters));
} }
if (parentSymbol is null) if (parentSymbol is null)
symbols ~= aliasSymbol; symbols ~= aliasSymbol;
@ -456,9 +452,33 @@ class AutocompleteVisitor : ASTVisitor
if (dec.importBindings !is null if (dec.importBindings !is null
&& dec.importBindings.singleImport.identifierChain !is null) && dec.importBindings.singleImport.identifierChain !is null)
{ {
scope_.symbols ~= ModuleCache.getSymbolsInModule( ACSymbol[] importedSymbols = ModuleCache.getSymbolsInModule(
convertChainToImportPath( convertChainToImportPath(dec.importBindings.singleImport.identifierChain));
dec.importBindings.singleImport.identifierChain)); foreach (ImportBind b; dec.importBindings.importBinds)
{
if (b.right == TokenType.invalid)
{
// Selecive import
importedSymbols.filter!(a => a.name == b.left).copy(scope_.symbols);
}
else
{
// renamed selective import
foreach (ACSymbol symbol; importedSymbols.filter!(a => a.name == b.right))
{
ACSymbol s = new ACSymbol;
s.kind = symbol.kind;
s.location = symbol.location;
s.name = b.left.value;
s.parts = symbol.parts;
s.qualifier = symbol.qualifier;
s.resolvedType = symbol.resolvedType;
s.superClasses = symbol.superClasses;
s.type = symbol.type;
scope_.symbols ~= s;
}
}
}
} }
} }
@ -510,7 +530,13 @@ class AutocompleteVisitor : ASTVisitor
private: private:
string formatNode(T)(T node) const static string formatCalltip(Type returnType, string name, Parameters parameters,
string doc = null)
{
return "%s %s%s".format(formatNode(returnType), name, formatNode(parameters));
}
static string formatNode(T)(T node)
{ {
if (node is null) return ""; if (node is null) return "";
import formatter; import formatter;

View File

@ -308,7 +308,7 @@ void setCompletions(T)(ref AutocompleteResponse response,
p.setTokens(tokens[h .. i].array()); p.setTokens(tokens[h .. i].array());
if (!p.isSliceExpression()) if (!p.isSliceExpression())
{ {
symbols = symbols[0].resolvedType is null ? [] :[symbols[0].resolvedType]; symbols = symbols[0].resolvedType is null ? [] : [symbols[0].resolvedType];
} }
} }
else if (symbols[0].qualifier == SymbolQualifier.assocArray) else if (symbols[0].qualifier == SymbolQualifier.assocArray)

View File

@ -71,7 +71,7 @@ end
local function showCurrentCallTip() local function showCurrentCallTip()
local tip = calltips[currentCalltip] local tip = calltips[currentCalltip]
buffer:call_tip_show(buffer:word_start_position(buffer.current_pos), buffer:call_tip_show(buffer:word_start_position(buffer.current_pos),
string.format("overload %d of %d\1\2\n%s", currentCalltip, #calltips, string.format("%d of %d\1\2\n%s", currentCalltip, #calltips,
calltips[currentCalltip])) calltips[currentCalltip]))
end end