Updated for PR
This commit is contained in:
parent
de001983c2
commit
434a838d20
|
@ -146,7 +146,8 @@ do
|
||||||
{
|
{
|
||||||
if (moduleSymbol is null)
|
if (moduleSymbol is null)
|
||||||
{
|
{
|
||||||
DeferredSymbol* deferred = DeferredSymbolsAllocator.instance.make!DeferredSymbol(acSymbol);
|
DeferredSymbol* deferred = DeferredSymbolsAllocator.instance.make!DeferredSymbol(
|
||||||
|
acSymbol);
|
||||||
cache.deferredSymbols.insert(deferred);
|
cache.deferredSymbols.insert(deferred);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -188,8 +189,8 @@ do
|
||||||
}
|
}
|
||||||
if (!isArr && !isAssoc && !isFunction)
|
if (!isArr && !isAssoc && !isFunction)
|
||||||
break;
|
break;
|
||||||
immutable qualifier = isAssoc ? SymbolQualifier.assocArray :
|
immutable qualifier = isAssoc ? SymbolQualifier.assocArray
|
||||||
(isFunction ? SymbolQualifier.func : SymbolQualifier.array);
|
: (isFunction ? SymbolQualifier.func : SymbolQualifier.array);
|
||||||
lastSuffix = GCAllocator.instance.make!DSymbol(back, CompletionKind.dummy, lastSuffix);
|
lastSuffix = GCAllocator.instance.make!DSymbol(back, CompletionKind.dummy, lastSuffix);
|
||||||
lastSuffix.qualifier = qualifier;
|
lastSuffix.qualifier = qualifier;
|
||||||
lastSuffix.ownType = true;
|
lastSuffix.ownType = true;
|
||||||
|
@ -355,6 +356,7 @@ void resolveAliasThis(DSymbol* symbol,
|
||||||
ref TypeLookups typeLookups, Scope* moduleScope, ref ModuleCache cache)
|
ref TypeLookups typeLookups, Scope* moduleScope, ref ModuleCache cache)
|
||||||
{
|
{
|
||||||
import std.algorithm : filter;
|
import std.algorithm : filter;
|
||||||
|
import std.array : array;
|
||||||
|
|
||||||
foreach (aliasThis; typeLookups[].filter!(a => a.kind == TypeLookupKind.aliasThis))
|
foreach (aliasThis; typeLookups[].filter!(a => a.kind == TypeLookupKind.aliasThis))
|
||||||
{
|
{
|
||||||
|
@ -363,7 +365,7 @@ void resolveAliasThis(DSymbol* symbol,
|
||||||
if (parts.length == 0 || parts[0].type is null)
|
if (parts.length == 0 || parts[0].type is null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
symbol.aliasThisSymbol = parts[0];
|
symbol.aliasThisSymbols ~= parts;
|
||||||
|
|
||||||
DSymbol* s = GCAllocator.instance.make!DSymbol(IMPORT_SYMBOL_NAME,
|
DSymbol* s = GCAllocator.instance.make!DSymbol(IMPORT_SYMBOL_NAME,
|
||||||
CompletionKind.importSymbol, parts[0].type);
|
CompletionKind.importSymbol, parts[0].type);
|
||||||
|
@ -430,7 +432,6 @@ void resolveType(DSymbol* symbol, ref TypeLookups typeLookups,
|
||||||
assert(false, "How did this happen?");
|
assert(false, "How did this happen?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void resolveTypeFromInitializer(DSymbol* symbol, TypeLookup* lookup,
|
void resolveTypeFromInitializer(DSymbol* symbol, TypeLookup* lookup,
|
||||||
Scope* moduleScope, ref ModuleCache cache)
|
Scope* moduleScope, ref ModuleCache cache)
|
||||||
{
|
{
|
||||||
|
@ -450,8 +451,7 @@ void resolveTypeFromInitializer(DSymbol* symbol, TypeLookup* lookup,
|
||||||
if (currentSymbol is null)
|
if (currentSymbol is null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else if (crumb == ARRAY_LITERAL_SYMBOL_NAME)
|
||||||
if (crumb == ARRAY_LITERAL_SYMBOL_NAME)
|
|
||||||
{
|
{
|
||||||
auto arr = GCAllocator.instance.make!(DSymbol)(ARRAY_LITERAL_SYMBOL_NAME, CompletionKind.dummy, currentSymbol);
|
auto arr = GCAllocator.instance.make!(DSymbol)(ARRAY_LITERAL_SYMBOL_NAME, CompletionKind.dummy, currentSymbol);
|
||||||
arr.qualifier = SymbolQualifier.array;
|
arr.qualifier = SymbolQualifier.array;
|
||||||
|
|
|
@ -375,8 +375,8 @@ struct DSymbol
|
||||||
// TODO: assert that the type is not a function
|
// TODO: assert that the type is not a function
|
||||||
DSymbol* type;
|
DSymbol* type;
|
||||||
|
|
||||||
// Is using alias this
|
// Is alias this symbols
|
||||||
DSymbol* aliasThisSymbol;
|
DSymbol*[] aliasThisSymbols;
|
||||||
/**
|
/**
|
||||||
* Names of function arguments
|
* Names of function arguments
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -129,13 +129,18 @@ bool willImplicitBeUpcasted(string from, string to)
|
||||||
return INTEGER_PROMOTIONS[from] == to;
|
return INTEGER_PROMOTIONS[from] == to;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matchAliasThis(const(DSymbol)* aliasThisSymbol, const(DSymbol)* incomingSymbol)
|
bool matchAliasThis(const(DSymbol)* beforeDotType, const(DSymbol)* incomingSymbol)
|
||||||
|
{
|
||||||
|
// For now we are only resolving the first alias this symbol
|
||||||
|
// when multiple alias this are supported, we can rethink another solution
|
||||||
|
if (!beforeDotType.aliasThisSymbols
|
||||||
|
|| !beforeDotType.aliasThisSymbols.front
|
||||||
|
|| beforeDotType.aliasThisSymbols.front == beforeDotType)
|
||||||
{
|
{
|
||||||
if(aliasThisSymbol) {
|
|
||||||
return isCallableWithArg(incomingSymbol, aliasThisSymbol.type);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return isCallableWithArg(incomingSymbol, beforeDotType.aliasThisSymbols.front.type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Params:
|
* Params:
|
||||||
|
@ -158,8 +163,9 @@ bool isCallableWithArg(const(DSymbol)* incomingSymbol, const(DSymbol)* beforeDot
|
||||||
.functionParameters.empty)
|
.functionParameters.empty)
|
||||||
{
|
{
|
||||||
return beforeDotType is incomingSymbol.functionParameters.front.type
|
return beforeDotType is incomingSymbol.functionParameters.front.type
|
||||||
|| willImplicitBeUpcasted(beforeDotType.name, incomingSymbol.functionParameters.front.type.name)
|
|| willImplicitBeUpcasted(beforeDotType.name, incomingSymbol
|
||||||
|| matchAliasThis(beforeDotType.aliasThisSymbol, incomingSymbol);
|
.functionParameters.front.type.name)
|
||||||
|
|| matchAliasThis(beforeDotType, incomingSymbol);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,12 +214,14 @@ bool doUFCSSearch(string beforeToken, string lastToken)
|
||||||
|
|
||||||
void getUFCSParenCompletion(ref DSymbol*[] symbols, Scope* completionScope, istring firstToken, istring nextToken, size_t cursorPosition)
|
void getUFCSParenCompletion(ref DSymbol*[] symbols, Scope* completionScope, istring firstToken, istring nextToken, size_t cursorPosition)
|
||||||
{
|
{
|
||||||
DSymbol* firstSymbol = completionScope.getFirstSymbolByNameAndCursor(firstToken, cursorPosition);
|
DSymbol* firstSymbol = completionScope.getFirstSymbolByNameAndCursor(
|
||||||
|
firstToken, cursorPosition);
|
||||||
|
|
||||||
if (firstSymbol is null)
|
if (firstSymbol is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DSymbol*[] possibleUFCSSymbol = completionScope.getSymbolsByNameAndCursor(nextToken, cursorPosition);
|
DSymbol*[] possibleUFCSSymbol = completionScope.getSymbolsByNameAndCursor(
|
||||||
|
nextToken, cursorPosition);
|
||||||
foreach (nextSymbol; possibleUFCSSymbol)
|
foreach (nextSymbol; possibleUFCSSymbol)
|
||||||
{
|
{
|
||||||
if (nextSymbol && nextSymbol.functionParameters)
|
if (nextSymbol && nextSymbol.functionParameters)
|
||||||
|
|
|
@ -7,6 +7,7 @@ min k
|
||||||
sizeof k
|
sizeof k
|
||||||
stringof k
|
stringof k
|
||||||
tupleof k
|
tupleof k
|
||||||
|
ufcsExactAliasedType F
|
||||||
ufcsSomeInt F
|
ufcsSomeInt F
|
||||||
ufcsSomeShort F
|
ufcsSomeShort F
|
||||||
x v
|
x v
|
||||||
|
|
|
@ -20,4 +20,5 @@ void ufcsBarScope(ref scope Foo foo, string mama) {}
|
||||||
void ufcsBarReturnScope(return scope Foo foo, string mama) {}
|
void ufcsBarReturnScope(return scope Foo foo, string mama) {}
|
||||||
void ufcsSomeInt(int x) {}
|
void ufcsSomeInt(int x) {}
|
||||||
void ufcsSomeShort(short x) {}
|
void ufcsSomeShort(short x) {}
|
||||||
|
void ufcsExactAliasedType(IntAliased x) {}
|
||||||
private void ufcsBarPrivate(Foo foo, string message) {}
|
private void ufcsBarPrivate(Foo foo, string message) {}
|
Loading…
Reference in New Issue