Autocomplete function parameters

This commit is contained in:
Hackerpilot 2013-08-11 00:37:14 +00:00
parent 3c0606ced5
commit fecad2bd10
1 changed files with 48 additions and 1 deletions

View File

@ -98,12 +98,59 @@ class AutocompleteVisitor : ASTVisitor
symbol.location = dec.name.startIndex;
symbol.kind = CompletionKind.functionName;
symbol.type = dec.returnType;
ACSymbol[] parameterSymbols;
if (dec.parameters !is null)
{
foreach (parameter; dec.parameters.parameters)
{
writeln("Adding parameter ", parameter.name.value);
ACSymbol paramSymbol = new ACSymbol;
paramSymbol.name = parameter.name.value;
paramSymbol.type = parameter.type;
paramSymbol.kind = CompletionKind.variableName;
paramSymbol.location = parameter.name.startIndex;
parameterSymbols ~= paramSymbol;
}
}
writeln("Parameter symbols added");
if (dec.returnType !is null)
{
symbol.calltip = format("%s %s%s", dec.returnType.toString(),
dec.name.value, dec.parameters.toString());
}
mixin (visitAndAdd);
auto p = parentSymbol;
parentSymbol = symbol;
BlockStatement functionBody = dec.functionBody is null ? null
: (dec.functionBody.bodyStatement !is null
? dec.functionBody.bodyStatement.blockStatement : dec.functionBody.blockStatement);
if (functionBody !is null)
{
writeln("Processing function body");
auto s = scope_;
scope_ = new Scope(functionBody.startLocation,
functionBody.endLocation);
scope_.parent = s;
foreach (parameterSymbol; parameterSymbols)
{
parameterSymbol.location = functionBody.startLocation;
scope_.symbols ~= parameterSymbol;
}
if (functionBody.declarationsAndStatements !is null)
functionBody.declarationsAndStatements.accept(this);
s.children ~= scope_;
scope_ = s;
}
parentSymbol = p;
if (parentSymbol is null)
symbols ~= symbol;
else
parentSymbol.parts ~= symbol;
scope_.symbols ~= symbol;
}
override void visit(EnumMember member)