This commit is contained in:
Hackerpilot 2015-01-30 00:50:38 -08:00
parent 2129f0625b
commit 15aeda1530
5 changed files with 39 additions and 17 deletions

2
.gitignore vendored
View File

@ -17,4 +17,4 @@ callgrind.*
githash.txt githash.txt
# Test results # Test results
tests/tc*/actual.txt tests/tc*/actual*.txt

View File

@ -78,6 +78,21 @@ public:
private: private:
bool shouldFollowtype(const ACSymbol* t, const SemanticSymbol* currentSymbol)
{
if (t is null)
return false;
if (currentSymbol.acSymbol.kind == CompletionKind.withSymbol
&& (t.kind == CompletionKind.variableName
|| t.kind == CompletionKind.aliasName))
{
return true;
}
if (t.kind == CompletionKind.aliasName)
return true;
return false;
}
void thirdPass(SemanticSymbol* currentSymbol) void thirdPass(SemanticSymbol* currentSymbol)
{ {
// Log.trace("third pass on ", currentSymbol.acSymbol.name); // Log.trace("third pass on ", currentSymbol.acSymbol.name);
@ -94,12 +109,8 @@ private:
case aliasName: case aliasName:
ACSymbol* t = resolveType(currentSymbol.initializer, ACSymbol* t = resolveType(currentSymbol.initializer,
currentSymbol.type, currentSymbol.acSymbol.location); currentSymbol.type, currentSymbol.acSymbol.location);
while (t !is null && (t.kind == CompletionKind.aliasName while (shouldFollowtype(t, currentSymbol))
|| (currentSymbol.acSymbol.kind == CompletionKind.withSymbol
&& t.kind == CompletionKind.variableName)))
{
t = t.type; t = t.type;
}
currentSymbol.acSymbol.type = t; currentSymbol.acSymbol.type = t;
break; break;
case structName: case structName:
@ -141,12 +152,12 @@ private:
void resolveInheritance(SemanticSymbol* currentSymbol) void resolveInheritance(SemanticSymbol* currentSymbol)
{ {
// Log.trace("Resolving inheritance for ", currentSymbol.acSymbol.name);
outer: foreach (string[] base; currentSymbol.baseClasses) outer: foreach (string[] base; currentSymbol.baseClasses)
{ {
ACSymbol* baseClass; ACSymbol* baseClass;
if (base.length == 0) if (base.length == 0)
continue; continue;
auto symbolScope = moduleScope.getScopeByCursor(currentSymbol.acSymbol.location);
auto symbols = moduleScope.getSymbolsByNameAndCursor( auto symbols = moduleScope.getSymbolsByNameAndCursor(
base[0], currentSymbol.acSymbol.location); base[0], currentSymbol.acSymbol.location);
if (symbols.length == 0) if (symbols.length == 0)
@ -160,6 +171,7 @@ private:
baseClass = symbols[0]; baseClass = symbols[0];
} }
currentSymbol.acSymbol.parts.insert(baseClass.parts[]); currentSymbol.acSymbol.parts.insert(baseClass.parts[]);
symbolScope.symbols.insert(baseClass.parts[]);
} }
} }
@ -224,7 +236,7 @@ private:
slice.popFront(); slice.popFront();
auto s = symbols[0]; auto s = symbols[0];
while (s !is null && s.type !is null && !slice.empty) while (s !is null && s.type !is null && s !is s.type && !slice.empty)
{ {
s = s.type; s = s.type;
if (slice.front == "foreach") if (slice.front == "foreach")
@ -243,12 +255,14 @@ private:
else if (slice.front == "[]") else if (slice.front == "[]")
s = s.type; s = s.type;
else else
{ break;
auto parts = s.getPartsByName(internString(slice.front)); }
if (parts.length == 0) while (s !is null && !slice.empty)
return null; {
s = parts[0]; auto parts = s.getPartsByName(internString(slice.front));
} if (parts.length == 0)
return null;
s = parts[0];
slice.popFront(); slice.popFront();
} }
return s; return s;
@ -258,7 +272,8 @@ private:
{ {
if (t is null) if (t is null)
return resolveInitializerType(initializer, location); return resolveInitializerType(initializer, location);
if (t.type2 is null) return null; if (t.type2 is null)
return null;
ACSymbol* s; ACSymbol* s;
if (t.type2.builtinType != tok!"") if (t.type2.builtinType != tok!"")
s = convertBuiltinType(t.type2); s = convertBuiltinType(t.type2);

View File

@ -0,0 +1,2 @@
identifiers
uvalue v

View File

@ -0,0 +1,2 @@
calltips
void setGrandChild(alias X, alias Y)()

View File

@ -1,5 +1,8 @@
set -e set -e
set -u set -u
dcd-client file.d -c863 > actual.txt dcd-client file.d -c839 > actual1.txt
diff actual.txt expected.txt diff actual1.txt expected1.txt
dcd-client file.d -c862 > actual2.txt
diff actual2.txt expected2.txt