Merge pull request #372 from BBasile/fixup-uda
fixup #369, completion after UDA, not only calltips broken
This commit is contained in:
commit
4fe57ff3e3
|
@ -175,8 +175,12 @@ public AutocompleteResponse complete(const AutocompleteRequest request,
|
|||
{
|
||||
ImportKind kind = determineImportKind(beforeTokens);
|
||||
if (kind == ImportKind.neither)
|
||||
{
|
||||
if (beforeTokens.isUdaExpression)
|
||||
beforeTokens = beforeTokens[$-1 .. $];
|
||||
return dotCompletion(beforeTokens, tokenArray, request.cursorPosition,
|
||||
moduleCache);
|
||||
}
|
||||
else
|
||||
return importCompletion(beforeTokens, kind, moduleCache);
|
||||
}
|
||||
|
@ -1195,6 +1199,29 @@ private enum TYPE_IDENT_AND_LITERAL_CASES = q{
|
|||
case tok!"dstringLiteral":
|
||||
};
|
||||
|
||||
bool isUdaExpression(T)(ref T tokens)
|
||||
{
|
||||
bool result;
|
||||
ptrdiff_t skip;
|
||||
ptrdiff_t i = tokens.length - 2;
|
||||
|
||||
while (i >= 2)
|
||||
{
|
||||
if (skip == 0 && tokens[i].type == tok!"identifier" && tokens[i-1].type == tok!"@")
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
skip += tokens[i].type == tok!")";
|
||||
skip -= tokens[i].type == tok!"(";
|
||||
|
||||
--i;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1222,13 +1249,6 @@ T getExpression(T)(T beforeTokens)
|
|||
|
||||
expressionLoop: while (true)
|
||||
{
|
||||
|
||||
if (i > 0 && beforeTokens[i].type == tok!"identifier" &&
|
||||
beforeTokens[i-1].type == tok!"@" )
|
||||
{
|
||||
return beforeTokens[0 .. 0];
|
||||
}
|
||||
|
||||
switch (beforeTokens[i].type)
|
||||
{
|
||||
case tok!"import":
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
calltips
|
||||
this(int a)
|
|
@ -0,0 +1 @@
|
|||
struct UDA{int a;} @UDA(
|
|
@ -3,3 +3,6 @@ set -u
|
|||
|
||||
../../bin/dcd-client $1 file.d -c29 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
||||
../../bin/dcd-client $1 file1.d -c25 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
|
Loading…
Reference in New Issue