Adding non contrainted templates into ufcs completion
This commit is contained in:
parent
e6b94622f0
commit
2fd33fc27f
|
@ -658,7 +658,6 @@ ScopeSymbolPair generateAutocompleteTreesProd(string source, string filename, si
|
||||||
|
|
||||||
version (linux)
|
version (linux)
|
||||||
{
|
{
|
||||||
import std.string;
|
|
||||||
enum string ufcsExampleCode =
|
enum string ufcsExampleCode =
|
||||||
q{class Incrementer
|
q{class Incrementer
|
||||||
{
|
{
|
||||||
|
@ -690,4 +689,30 @@ void doIncrement()
|
||||||
assert(pair.ufcsSymbols[0].name == "increment");
|
assert(pair.ufcsSymbols[0].name == "increment");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum string ufcsTemplateExampleCode =
|
||||||
|
q{int increment(T)(T x)
|
||||||
|
{
|
||||||
|
return x++;
|
||||||
|
}
|
||||||
|
void doIncrement()
|
||||||
|
{
|
||||||
|
int life = 42;
|
||||||
|
life.
|
||||||
|
}};
|
||||||
|
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
import dsymbol.ufcs;
|
||||||
|
|
||||||
|
writeln("Getting Templated UFCS Symbols For life");
|
||||||
|
ModuleCache cache;
|
||||||
|
// position of variable life
|
||||||
|
size_t cursorPos = 82;
|
||||||
|
auto pair = generateAutocompleteTreesProd(ufcsTemplateExampleCode, randomDFilename, cursorPos, cache);
|
||||||
|
assert(pair.ufcsSymbols.length > 0);
|
||||||
|
assert(pair.ufcsSymbols[0].name == "increment");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ private DSymbol* deduceSymbolType(DSymbol* symbol)
|
||||||
private bool isInvalidForUFCSCompletion(const(DSymbol)* beforeDotSymbol)
|
private bool isInvalidForUFCSCompletion(const(DSymbol)* beforeDotSymbol)
|
||||||
{
|
{
|
||||||
return beforeDotSymbol is null
|
return beforeDotSymbol is null
|
||||||
|| beforeDotSymbol.kind == CompletionKind.templateName
|
|
||||||
|| beforeDotSymbol.name is getBuiltinTypeName(tok!"void")
|
|| beforeDotSymbol.name is getBuiltinTypeName(tok!"void")
|
||||||
|| (beforeDotSymbol.type !is null && beforeDotSymbol.type.name is getBuiltinTypeName(
|
|| (beforeDotSymbol.type !is null && beforeDotSymbol.type.name is getBuiltinTypeName(
|
||||||
tok!"void"));
|
tok!"void"));
|
||||||
|
@ -307,11 +306,11 @@ bool isCallableWithArg(DSymbol* incomingSymbol, const(DSymbol)* beforeDotType, b
|
||||||
.functionParameters.empty)
|
.functionParameters.empty)
|
||||||
{
|
{
|
||||||
if (beforeDotType is incomingSymbol.functionParameters.front.type
|
if (beforeDotType is incomingSymbol.functionParameters.front.type
|
||||||
|
|| incomingSymbol.functionParameters.front.type.kind is CompletionKind.typeTmpParam // non constrained template
|
||||||
|| willImplicitBeUpcasted(beforeDotType.name, incomingSymbol
|
|| willImplicitBeUpcasted(beforeDotType.name, incomingSymbol
|
||||||
.functionParameters.front.type.name)
|
.functionParameters.front.type.name)
|
||||||
|| matchAliasThis(beforeDotType, incomingSymbol, recursionDepth))
|
|| matchAliasThis(beforeDotType, incomingSymbol, recursionDepth))
|
||||||
{
|
{
|
||||||
// incomingSymbol.kind = CompletionKind.ufcsName;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue