Switch visitor class over to formatter instead of toString. Fixed #28
This commit is contained in:
parent
3c20163456
commit
afb51f24e9
27
acvisitor.d
27
acvisitor.d
|
@ -330,8 +330,8 @@ class AutocompleteVisitor : ASTVisitor
|
||||||
else if (dec.hasRef)
|
else if (dec.hasRef)
|
||||||
returnType = "ref";
|
returnType = "ref";
|
||||||
}
|
}
|
||||||
symbol.calltip = format("%s %s%s", returnType,
|
symbol.calltip = format("%s %s%s", formatNode(dec.returnType),
|
||||||
dec.name.value, dec.parameters.toString());
|
dec.name.value, formatNode(dec.parameters));
|
||||||
}
|
}
|
||||||
auto p = parentSymbol;
|
auto p = parentSymbol;
|
||||||
parentSymbol = symbol;
|
parentSymbol = symbol;
|
||||||
|
@ -376,9 +376,9 @@ class AutocompleteVisitor : ASTVisitor
|
||||||
{
|
{
|
||||||
TypeSuffix suffix = dec.type.typeSuffixes[$ - 1];
|
TypeSuffix suffix = dec.type.typeSuffixes[$ - 1];
|
||||||
dec.type.typeSuffixes = dec.type.typeSuffixes[0 .. $ - 1];
|
dec.type.typeSuffixes = dec.type.typeSuffixes[0 .. $ - 1];
|
||||||
symbol.calltip = "%s %s%s".format(dec.type,
|
symbol.calltip = "%s %s%s".format(formatNode(dec.type),
|
||||||
suffix.delegateOrFunction.value,
|
suffix.delegateOrFunction.value,
|
||||||
suffix.parameters.toString());
|
formatNode(suffix.parameters));
|
||||||
}
|
}
|
||||||
symbol.kind = CompletionKind.variableName;
|
symbol.kind = CompletionKind.variableName;
|
||||||
|
|
||||||
|
@ -407,9 +407,9 @@ class AutocompleteVisitor : ASTVisitor
|
||||||
{
|
{
|
||||||
TypeSuffix suffix = aliasPart.type.typeSuffixes[$ - 1];
|
TypeSuffix suffix = aliasPart.type.typeSuffixes[$ - 1];
|
||||||
aliasPart.type.typeSuffixes = aliasPart.type.typeSuffixes[0 .. $ - 1];
|
aliasPart.type.typeSuffixes = aliasPart.type.typeSuffixes[0 .. $ - 1];
|
||||||
aliasSymbol.calltip = "%s %s%s".format(dec.type,
|
aliasSymbol.calltip = "%s %s%s".format(formatNode(dec.type),
|
||||||
suffix.delegateOrFunction.value,
|
suffix.delegateOrFunction.value,
|
||||||
suffix.parameters.toString());
|
formatNode(suffix.parameters));
|
||||||
}
|
}
|
||||||
if (parentSymbol is null)
|
if (parentSymbol is null)
|
||||||
symbols ~= aliasSymbol;
|
symbols ~= aliasSymbol;
|
||||||
|
@ -429,9 +429,9 @@ class AutocompleteVisitor : ASTVisitor
|
||||||
{
|
{
|
||||||
TypeSuffix suffix = dec.type.typeSuffixes[$ - 1];
|
TypeSuffix suffix = dec.type.typeSuffixes[$ - 1];
|
||||||
dec.type.typeSuffixes = dec.type.typeSuffixes[0 .. $ - 1];
|
dec.type.typeSuffixes = dec.type.typeSuffixes[0 .. $ - 1];
|
||||||
aliasSymbol.calltip = "%s %s%s".format(dec.type,
|
aliasSymbol.calltip = "%s %s%s".format(formatNode(dec.type),
|
||||||
suffix.delegateOrFunction.value,
|
suffix.delegateOrFunction.value,
|
||||||
suffix.parameters.toString());
|
formatNode(suffix.parameters));
|
||||||
}
|
}
|
||||||
aliasSymbol.location = dec.name.startIndex;
|
aliasSymbol.location = dec.name.startIndex;
|
||||||
if (parentSymbol is null)
|
if (parentSymbol is null)
|
||||||
|
@ -509,6 +509,17 @@ class AutocompleteVisitor : ASTVisitor
|
||||||
bool currentFile = false;
|
bool currentFile = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
string formatNode(T)(T node) const
|
||||||
|
{
|
||||||
|
if (node is null) return "";
|
||||||
|
import formatter;
|
||||||
|
auto app = appender!(char[])();
|
||||||
|
auto f = new Formatter!(typeof(app))(app);
|
||||||
|
f.format(node);
|
||||||
|
return to!string(app.data);
|
||||||
|
}
|
||||||
|
|
||||||
static enum string visitAndAdd = q{
|
static enum string visitAndAdd = q{
|
||||||
auto p = parentSymbol;
|
auto p = parentSymbol;
|
||||||
parentSymbol = symbol;
|
parentSymbol = symbol;
|
||||||
|
|
|
@ -52,10 +52,13 @@ AutocompleteResponse complete(AutocompleteRequest request, string[] importPaths)
|
||||||
|
|
||||||
auto beforeTokens = sortedTokens.lowerBound(cast(size_t) request.cursorPosition);
|
auto beforeTokens = sortedTokens.lowerBound(cast(size_t) request.cursorPosition);
|
||||||
|
|
||||||
|
TokenType tokenType;
|
||||||
|
|
||||||
if (beforeTokens.length >= 1 && beforeTokens[$ - 1] == TokenType.identifier)
|
if (beforeTokens.length >= 1 && beforeTokens[$ - 1] == TokenType.identifier)
|
||||||
{
|
{
|
||||||
//writeln("partial completion");
|
//writeln("partial completion");
|
||||||
partial = beforeTokens[$ - 1].value;
|
partial = beforeTokens[$ - 1].value;
|
||||||
|
tokenType = beforeTokens[$ - 1].type;
|
||||||
beforeTokens = beforeTokens[0 .. $ - 1];
|
beforeTokens = beforeTokens[0 .. $ - 1];
|
||||||
goto dotCompletion;
|
goto dotCompletion;
|
||||||
}
|
}
|
||||||
|
@ -100,9 +103,9 @@ AutocompleteResponse complete(AutocompleteRequest request, string[] importPaths)
|
||||||
}
|
}
|
||||||
else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == TokenType.dot)
|
else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == TokenType.dot)
|
||||||
{
|
{
|
||||||
beforeTokens = beforeTokens[0 .. $ - 1];
|
tokenType = beforeTokens[$ - 2].type;
|
||||||
dotCompletion:
|
dotCompletion:
|
||||||
switch (beforeTokens[$ - 1].type)
|
switch (tokenType)
|
||||||
{
|
{
|
||||||
case TokenType.stringLiteral:
|
case TokenType.stringLiteral:
|
||||||
case TokenType.wstringLiteral:
|
case TokenType.wstringLiteral:
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -1,2 +1,2 @@
|
||||||
dmd -wi client.d messages.d msgpack-d/src/msgpack.d -Imsgpack-d/src -ofdcd-client
|
dmd -wi client.d messages.d msgpack-d/src/msgpack.d -Imsgpack-d/src -ofdcd-client
|
||||||
dmd -wi -g server.d modulecache.d actypes.d messages.d constants.d acvisitor.d autocomplete.d dscanner/stdx/d/ast.d dscanner/stdx/d/parser.d dscanner/stdx/d/lexer.d dscanner/stdx/d/entities.d msgpack-d/src/msgpack.d -Imsgpack-d/src -Idscanner/ -ofdcd-server
|
dmd -wi -g server.d modulecache.d actypes.d messages.d constants.d acvisitor.d autocomplete.d dscanner/stdx/d/ast.d dscanner/stdx/d/parser.d dscanner/stdx/d/lexer.d dscanner/stdx/d/entities.d msgpack-d/src/msgpack.d dscanner/formatter.d -Imsgpack-d/src -Idscanner/ -ofdcd-server
|
||||||
|
|
2
dscanner
2
dscanner
|
@ -1 +1 @@
|
||||||
Subproject commit 2088089e368e5621673bf83472e441b28c43c81a
|
Subproject commit 80c2462445a937eaf339890edf4282c4e6878d08
|
Loading…
Reference in New Issue