Autocomplete function parameters
This commit is contained in:
parent
3c0606ced5
commit
fecad2bd10
49
acvisitor.d
49
acvisitor.d
|
@ -98,12 +98,59 @@ class AutocompleteVisitor : ASTVisitor
|
||||||
symbol.location = dec.name.startIndex;
|
symbol.location = dec.name.startIndex;
|
||||||
symbol.kind = CompletionKind.functionName;
|
symbol.kind = CompletionKind.functionName;
|
||||||
symbol.type = dec.returnType;
|
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)
|
if (dec.returnType !is null)
|
||||||
{
|
{
|
||||||
symbol.calltip = format("%s %s%s", dec.returnType.toString(),
|
symbol.calltip = format("%s %s%s", dec.returnType.toString(),
|
||||||
dec.name.value, dec.parameters.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)
|
override void visit(EnumMember member)
|
||||||
|
|
Loading…
Reference in New Issue