Fix autocomplete on foreach expressions
This commit is contained in:
parent
81e652c4c8
commit
5964940d41
|
@ -453,11 +453,7 @@ final class FirstPass : ASTVisitor
|
||||||
feType.identifier.text, CompletionKind.variableName,
|
feType.identifier.text, CompletionKind.variableName,
|
||||||
symbolFile, feType.identifier.index, feType.type);
|
symbolFile, feType.identifier.index, feType.type);
|
||||||
if (symbol.type is null && feExpression !is null)
|
if (symbol.type is null && feExpression !is null)
|
||||||
{
|
|
||||||
// Log.trace("Populating initializer");
|
|
||||||
populateInitializer(symbol, feExpression, true);
|
populateInitializer(symbol, feExpression, true);
|
||||||
// Log.trace(symbol.initializer[]);
|
|
||||||
}
|
|
||||||
symbol.parent = currentSymbol;
|
symbol.parent = currentSymbol;
|
||||||
currentSymbol.addChild(symbol);
|
currentSymbol.addChild(symbol);
|
||||||
}
|
}
|
||||||
|
@ -888,6 +884,15 @@ class InitializerVisitor : ASTVisitor
|
||||||
on = false;
|
on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override void visit(const ExpressionNode expression)
|
||||||
|
{
|
||||||
|
on = true;
|
||||||
|
expression.accept(this);
|
||||||
|
if (appendForeach)
|
||||||
|
semanticSymbol.initializer.insert(internString("foreach"));
|
||||||
|
on = false;
|
||||||
|
}
|
||||||
|
|
||||||
SemanticSymbol* semanticSymbol;
|
SemanticSymbol* semanticSymbol;
|
||||||
bool on = false;
|
bool on = false;
|
||||||
const bool appendForeach;
|
const bool appendForeach;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import actypes;
|
||||||
import messages;
|
import messages;
|
||||||
import std.allocator;
|
import std.allocator;
|
||||||
import string_interning;
|
import string_interning;
|
||||||
|
import stupidlog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Third pass handles the following:
|
* Third pass handles the following:
|
||||||
|
@ -95,7 +96,6 @@ private:
|
||||||
|
|
||||||
void thirdPass(SemanticSymbol* currentSymbol)
|
void thirdPass(SemanticSymbol* currentSymbol)
|
||||||
{
|
{
|
||||||
// Log.trace("third pass on ", currentSymbol.acSymbol.name);
|
|
||||||
with (CompletionKind) final switch (currentSymbol.acSymbol.kind)
|
with (CompletionKind) final switch (currentSymbol.acSymbol.kind)
|
||||||
{
|
{
|
||||||
case className:
|
case className:
|
||||||
|
@ -242,6 +242,7 @@ private:
|
||||||
s = s.type;
|
s = s.type;
|
||||||
if (slice.front == "foreach")
|
if (slice.front == "foreach")
|
||||||
{
|
{
|
||||||
|
// Log.trace("foreach");
|
||||||
if (s.qualifier == SymbolQualifier.array)
|
if (s.qualifier == SymbolQualifier.array)
|
||||||
s = s.type;
|
s = s.type;
|
||||||
else
|
else
|
||||||
|
@ -252,6 +253,7 @@ private:
|
||||||
else
|
else
|
||||||
s = null;
|
s = null;
|
||||||
}
|
}
|
||||||
|
slice.popFront();
|
||||||
}
|
}
|
||||||
else if (slice.front == "[]")
|
else if (slice.front == "[]")
|
||||||
s = s.type;
|
s = s.type;
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
identifiers
|
||||||
|
alignof k
|
||||||
|
dup k
|
||||||
|
idup k
|
||||||
|
init k
|
||||||
|
length k
|
||||||
|
mangleof k
|
||||||
|
ptr k
|
||||||
|
reverse k
|
||||||
|
sizeof k
|
||||||
|
sort k
|
||||||
|
stringof k
|
|
@ -0,0 +1,8 @@
|
||||||
|
identifiers
|
||||||
|
alignof k
|
||||||
|
init k
|
||||||
|
mangleof k
|
||||||
|
max k
|
||||||
|
min k
|
||||||
|
sizeof k
|
||||||
|
stringof k
|
|
@ -0,0 +1,17 @@
|
||||||
|
struct R { int front() { return 1; } }
|
||||||
|
|
||||||
|
void main(string[] args)
|
||||||
|
{
|
||||||
|
foreach (arg; args)
|
||||||
|
{
|
||||||
|
arg.
|
||||||
|
}
|
||||||
|
R r;
|
||||||
|
foreach (i; r)
|
||||||
|
{
|
||||||
|
i.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
dcd-client file.d -c97 > actual1.txt
|
||||||
|
diff actual1.txt expected1.txt
|
||||||
|
|
||||||
|
dcd-client file.d -c130 > actual2.txt
|
||||||
|
diff actual2.txt expected2.txt
|
Loading…
Reference in New Issue