minor adjustments
This commit is contained in:
parent
78740cc1b1
commit
642a0e0a14
|
@ -1,40 +0,0 @@
|
|||
module dcd.server.autocomplete.calltip_utils;
|
||||
import std.string;
|
||||
import std.regex;
|
||||
import std.range : empty;
|
||||
import std.experimental.logger;
|
||||
import std.algorithm : canFind;
|
||||
|
||||
string removeFirstArgumentOfFunction(string callTip)
|
||||
{
|
||||
auto parentheseSplit = callTip.split('(');
|
||||
// has only one argument
|
||||
if (!callTip.canFind(','))
|
||||
{
|
||||
return parentheseSplit[0] ~ "()";
|
||||
}
|
||||
auto commaSplit = parentheseSplit[1].split(',');
|
||||
string newCallTip = callTip.replace((commaSplit[0] ~ ", "), "");
|
||||
return newCallTip;
|
||||
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
auto result = removeFirstArgumentOfFunction("void fooFunction(const(immutable(Foo)) foo)");
|
||||
assert(result, "void fooFunction()");
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
auto result = removeFirstArgumentOfFunction(
|
||||
"void fooFunction(const(immutable(Foo)) foo), string message");
|
||||
assert(result, "void fooFunction(string message)");
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
auto result = removeFirstArgumentOfFunction(
|
||||
"void fooFunction(const(immutable(Foo)) foo), string message, ref int age");
|
||||
assert(result, "void fooFunction(string message, ref int age)");
|
||||
}
|
|
@ -202,7 +202,7 @@ AutocompleteResponse dotCompletion(T)(T beforeTokens, const(Token)[] tokenArray,
|
|||
}
|
||||
else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == tok!".")
|
||||
significantTokenType = beforeTokens[$ - 2].type;
|
||||
else
|
||||
else
|
||||
return response;
|
||||
|
||||
switch (significantTokenType)
|
||||
|
|
|
@ -12,10 +12,7 @@ import dsymbol.builtin.names;
|
|||
import std.string;
|
||||
import dparse.lexer : tok;
|
||||
import std.regex;
|
||||
import dcd.server.autocomplete.calltip_utils;
|
||||
import containers.hashset : HashSet;
|
||||
import std.experimental.logger;
|
||||
import std.algorithm.iteration : map;
|
||||
|
||||
void lookupUFCS(Scope* completionScope, DSymbol* beforeDotSymbol, size_t cursorPosition, ref AutocompleteResponse response)
|
||||
{
|
||||
|
@ -26,8 +23,7 @@ void lookupUFCS(Scope* completionScope, DSymbol* beforeDotSymbol, size_t cursorP
|
|||
|
||||
AutocompleteResponse.Completion createCompletionForUFCS(const DSymbol* symbol)
|
||||
{
|
||||
return AutocompleteResponse.Completion(symbol.name, symbol.kind, "(UFCS) " ~ removeFirstArgumentOfFunction(
|
||||
symbol.callTip), symbol
|
||||
return AutocompleteResponse.Completion(symbol.name, symbol.kind, "(UFCS) " ~ symbol.callTip, symbol
|
||||
.symbolFile, symbol
|
||||
.location, symbol
|
||||
.doc);
|
||||
|
@ -59,7 +55,8 @@ bool isInvalidForUFCSCompletion(const(DSymbol)* beforeDotSymbol)
|
|||
*/
|
||||
DSymbol*[] getSymbolsForUFCS(Scope* completionScope, const(DSymbol)* beforeDotSymbol, size_t cursorPosition)
|
||||
{
|
||||
if (beforeDotSymbol.isInvalidForUFCSCompletion) {
|
||||
if (beforeDotSymbol.isInvalidForUFCSCompletion)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,11 +146,10 @@ SymbolStuff getSymbolsForCompletion(const AutocompleteRequest request,
|
|||
auto expression = getExpression(beforeTokens);
|
||||
auto symbols = getSymbolsByTokenChain(pair.scope_, expression,
|
||||
request.cursorPosition, type);
|
||||
if (symbols.length == 0 && doUFCSSearch(stringToken(beforeTokens.front), stringToken(beforeTokens.back))) {
|
||||
// Let search for UFCS, since we got no hit
|
||||
symbols ~= getSymbolsByTokenChain(pair.scope_, getExpression([beforeTokens.back]),
|
||||
request.cursorPosition, type);
|
||||
}
|
||||
if (symbols.length == 0 && doUFCSSearch(stringToken(beforeTokens.front), stringToken(beforeTokens.back))) {
|
||||
// Let search for UFCS, since we got no hit
|
||||
symbols ~= getSymbolsByTokenChain(pair.scope_, getExpression([beforeTokens.back]), request.cursorPosition, type);
|
||||
}
|
||||
return SymbolStuff(symbols, pair.symbol, pair.scope_);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,17 @@
|
|||
module fooutils;
|
||||
|
||||
struct Foo {
|
||||
void fooHey(){ }
|
||||
void fooHey(){}
|
||||
}
|
||||
|
||||
void u(Foo foo) {
|
||||
}
|
||||
|
||||
void ufcsHello(ref Foo foo)
|
||||
{
|
||||
}
|
||||
|
||||
void ufcsBar(Foo foo, string mama)
|
||||
{
|
||||
}
|
||||
|
||||
void ufcsBarRef(ref Foo foo, string mama)
|
||||
{
|
||||
}
|
||||
|
||||
void ufcsBarRefConst(ref const Foo foo, string mama)
|
||||
{
|
||||
}
|
||||
void u(Foo foo) {}
|
||||
void ufcsHello(ref Foo foo) {}
|
||||
void ufcsBar(Foo foo, string mama) {}
|
||||
void ufcsBarRef(ref Foo foo, string mama) {}
|
||||
void ufcsBarRefConst(ref const Foo foo, string mama) {}
|
||||
void ufcsBarRefConstWrapped(ref const(Foo) foo, string mama) {}
|
||||
void ufcsBarRefImmuttableWrapped(ref immutable(Foo) foo, string mama) {}
|
||||
void ufcsBarScope(ref scope Foo foo, string mama) {}
|
||||
void ufcsBarReturnScope(return scope Foo foo, string mama) {}
|
||||
private void privateUfcsBar(Foo foo, string message) {}
|
||||
void notUfcsBar(string message) {}
|
||||
private void ufcsBarPrivate(Foo foo, string message) {}
|
||||
void helloBar(string message) {}
|
Loading…
Reference in New Issue