prepare for libdparse changes 1/2
This commit is contained in:
parent
fbd79b258f
commit
c10d453747
|
|
@ -723,20 +723,20 @@ final class FirstPass : ASTVisitor
|
||||||
|
|
||||||
override void visit(const IfStatement ifs)
|
override void visit(const IfStatement ifs)
|
||||||
{
|
{
|
||||||
if (ifs.identifier != tok!"" && ifs.thenStatement)
|
if (ifs.condition && ifs.condition.identifier != tok!"" && ifs.thenStatement)
|
||||||
{
|
{
|
||||||
pushScope(ifs.thenStatement.startLocation, ifs.thenStatement.endLocation);
|
pushScope(ifs.thenStatement.startLocation, ifs.thenStatement.endLocation);
|
||||||
scope(exit) popScope();
|
scope(exit) popScope();
|
||||||
|
|
||||||
SemanticSymbol* symbol = allocateSemanticSymbol(ifs.identifier.text,
|
SemanticSymbol* symbol = allocateSemanticSymbol(ifs.condition.identifier.text,
|
||||||
CompletionKind.variableName, symbolFile, ifs.identifier.index);
|
CompletionKind.variableName, symbolFile, ifs.condition.identifier.index);
|
||||||
if (ifs.type !is null)
|
if (ifs.condition !is null && ifs.condition.type !is null)
|
||||||
addTypeToLookups(symbol.typeLookups, ifs.type);
|
addTypeToLookups(symbol.typeLookups, ifs.condition.type);
|
||||||
symbol.parent = currentSymbol;
|
symbol.parent = currentSymbol;
|
||||||
currentSymbol.addChild(symbol, true);
|
currentSymbol.addChild(symbol, true);
|
||||||
currentScope.addSymbol(symbol.acSymbol, true);
|
currentScope.addSymbol(symbol.acSymbol, true);
|
||||||
if (symbol.typeLookups.empty && ifs.expression !is null)
|
if (symbol.typeLookups.empty && ifs.condition !is null && ifs.condition.expression !is null)
|
||||||
populateInitializer(symbol, ifs.expression, false);
|
populateInitializer(symbol, ifs.condition.expression, false);
|
||||||
}
|
}
|
||||||
ifs.accept(this);
|
ifs.accept(this);
|
||||||
}
|
}
|
||||||
|
|
@ -1091,7 +1091,10 @@ private:
|
||||||
auto lookup = TypeLookupsAllocator.instance.make!TypeLookup(TypeLookupKind.initializer);
|
auto lookup = TypeLookupsAllocator.instance.make!TypeLookup(TypeLookupKind.initializer);
|
||||||
scope visitor = new InitializerVisitor(lookup, appendForeach, this);
|
scope visitor = new InitializerVisitor(lookup, appendForeach, this);
|
||||||
symbol.typeLookups.insert(lookup);
|
symbol.typeLookups.insert(lookup);
|
||||||
visitor.visit(initializer);
|
static if (is(T == typeof(feExpression)))
|
||||||
|
visitor.dynamicDispatch(initializer);
|
||||||
|
else
|
||||||
|
visitor.visit(initializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SemanticSymbol* allocateSemanticSymbol(string name, CompletionKind kind,
|
SemanticSymbol* allocateSemanticSymbol(string name, CompletionKind kind,
|
||||||
|
|
@ -1361,6 +1364,7 @@ class InitializerVisitor : ASTVisitor
|
||||||
}
|
}
|
||||||
|
|
||||||
alias visit = ASTVisitor.visit;
|
alias visit = ASTVisitor.visit;
|
||||||
|
alias dynamicDispatch = ASTVisitor.dynamicDispatch;
|
||||||
|
|
||||||
override void visit(const FunctionLiteralExpression exp)
|
override void visit(const FunctionLiteralExpression exp)
|
||||||
{
|
{
|
||||||
|
|
@ -1442,7 +1446,7 @@ class InitializerVisitor : ASTVisitor
|
||||||
|
|
||||||
override void visit(const IndexExpression expr)
|
override void visit(const IndexExpression expr)
|
||||||
{
|
{
|
||||||
expr.unaryExpression.accept(this);
|
dynamicDispatch(expr.unaryExpression);
|
||||||
foreach (index; expr.indexes)
|
foreach (index; expr.indexes)
|
||||||
if (index.high is null)
|
if (index.high is null)
|
||||||
lookup.breadcrumbs.insert(ARRAY_SYMBOL_NAME);
|
lookup.breadcrumbs.insert(ARRAY_SYMBOL_NAME);
|
||||||
|
|
@ -1534,10 +1538,10 @@ class InitializerVisitor : ASTVisitor
|
||||||
on = false;
|
on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const ExpressionNode expression)
|
override void dynamicDispatch(const ExpressionNode expression)
|
||||||
{
|
{
|
||||||
on = true;
|
on = true;
|
||||||
expression.accept(this);
|
super.dynamicDispatch(expression);
|
||||||
if (appendForeach)
|
if (appendForeach)
|
||||||
lookup.breadcrumbs.insert(internString("foreach"));
|
lookup.breadcrumbs.insert(internString("foreach"));
|
||||||
on = false;
|
on = false;
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,8 @@ unittest
|
||||||
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
||||||
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
||||||
assert(S);
|
assert(S);
|
||||||
|
assert(b);
|
||||||
|
assert(b.type);
|
||||||
assert(b.type is S);
|
assert(b.type is S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -343,6 +345,8 @@ unittest
|
||||||
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
||||||
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
||||||
assert(S);
|
assert(S);
|
||||||
|
assert(b);
|
||||||
|
assert(b.type);
|
||||||
assert(b.type is S);
|
assert(b.type is S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -351,6 +355,8 @@ unittest
|
||||||
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
||||||
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
||||||
assert(S);
|
assert(S);
|
||||||
|
assert(b);
|
||||||
|
assert(b.type);
|
||||||
assert(b.type.type is S);
|
assert(b.type.type is S);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -359,6 +365,8 @@ unittest
|
||||||
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
||||||
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
||||||
assert(S);
|
assert(S);
|
||||||
|
assert(b);
|
||||||
|
assert(b.type);
|
||||||
assert(b.type.name == ARRAY_SYMBOL_NAME);
|
assert(b.type.name == ARRAY_SYMBOL_NAME);
|
||||||
assert(b.type.type is S);
|
assert(b.type.type is S);
|
||||||
}
|
}
|
||||||
|
|
@ -368,6 +376,7 @@ unittest
|
||||||
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
DSymbol* S = pair.symbol.getFirstPartNamed(internString("S"));
|
||||||
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
DSymbol* b = pair.symbol.getFirstPartNamed(internString("b"));
|
||||||
assert(S);
|
assert(S);
|
||||||
|
assert(b);
|
||||||
assert(b.type is S);
|
assert(b.type is S);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue