Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle FunctionCallExpression #761

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions dsymbol/src/dsymbol/conversion/first.d
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,53 @@ final class FirstPass : ASTVisitor
visitDestructor(des.location, des.functionBody, des.comment);
}

override void visit(const FunctionCallExpression fce)
{
assert(fce);

auto fnToken = fce.tokens[0];

pushSymbol(fnToken.text, CompletionKind.functionName, symbolFile, fnToken.index);
scope (exit) popSymbol();

if (fce.arguments && fce.arguments.namedArgumentList)
{
auto argsList = fce.arguments.namedArgumentList;

pushScope(argsList.startLocation, argsList.endLocation);
scope (exit) popScope();

currentSymbol.acSymbol.functionParameters.reserve(argsList.items.length);
foreach(arg; argsList.items)
{
auto argToken = arg.tokens[0];

// TODO: suport token chain: myfunc(SomeType.variable);
// perhaps it should be handled later during completion time
// but we need to store the tokens?

// strip named arguments syntax
bool named = arg.tokens.length >= 3 && arg.tokens[1] == tok!(":");
auto firstTokenIndex = named ? 2 : 0;
auto tokens = arg.tokens[firstTokenIndex .. $];
auto firstToken = tokens[0];

// writeln(" arg: ", firstToken.text, " pos: ", firstToken.index, " named: ", named, " l: ", arg.tokens.length);

SemanticSymbol* parameter = allocateSemanticSymbol(
firstToken.text, CompletionKind.variableName, symbolFile,
firstToken.index);

parameter.parent = currentSymbol;

currentSymbol.acSymbol.functionParameters ~= parameter.acSymbol;

currentSymbol.addChild(parameter, true);
currentScope.addSymbol(parameter.acSymbol, false);
}
}
}

override void visit(const FunctionDeclaration dec)
{
assert(dec);
Expand Down
Loading