Use tabs everywhere
For a more consistent code style. I also found a segfault case in tc045 which needs to be investigated
This commit is contained in:
parent
843a7783c3
commit
3d5ec1fe60
|
@ -41,81 +41,81 @@ import common.messages;
|
|||
* the autocompletion response.
|
||||
*/
|
||||
public AutocompleteResponse findLocalUse(AutocompleteRequest request,
|
||||
ref ModuleCache moduleCache)
|
||||
ref ModuleCache moduleCache)
|
||||
{
|
||||
AutocompleteResponse response;
|
||||
RollbackAllocator rba;
|
||||
auto allocator = scoped!(ASTAllocator)();
|
||||
auto cache = StringCache(StringCache.defaultBucketCount);
|
||||
AutocompleteResponse response;
|
||||
RollbackAllocator rba;
|
||||
auto allocator = scoped!(ASTAllocator)();
|
||||
auto cache = StringCache(StringCache.defaultBucketCount);
|
||||
|
||||
// patchs the original request for the subsequent requests
|
||||
request.kind = RequestKind.symbolLocation;
|
||||
// patchs the original request for the subsequent requests
|
||||
request.kind = RequestKind.symbolLocation;
|
||||
|
||||
// getSymbolsForCompletion() copy to avoid repetitive parsing
|
||||
LexerConfig config;
|
||||
config.fileName = "";
|
||||
const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode,
|
||||
config, &cache);
|
||||
SymbolStuff getSymbolsAtCursor(size_t cursorPosition)
|
||||
{
|
||||
auto sortedTokens = assumeSorted(tokenArray);
|
||||
auto beforeTokens = sortedTokens.lowerBound(cursorPosition);
|
||||
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
|
||||
&rba, request.cursorPosition, moduleCache);
|
||||
auto expression = getExpression(beforeTokens);
|
||||
return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression,
|
||||
cursorPosition, CompletionType.location), pair.symbol, pair.scope_);
|
||||
}
|
||||
// getSymbolsForCompletion() copy to avoid repetitive parsing
|
||||
LexerConfig config;
|
||||
config.fileName = "";
|
||||
const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode,
|
||||
config, &cache);
|
||||
SymbolStuff getSymbolsAtCursor(size_t cursorPosition)
|
||||
{
|
||||
auto sortedTokens = assumeSorted(tokenArray);
|
||||
auto beforeTokens = sortedTokens.lowerBound(cursorPosition);
|
||||
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
|
||||
&rba, request.cursorPosition, moduleCache);
|
||||
auto expression = getExpression(beforeTokens);
|
||||
return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression,
|
||||
cursorPosition, CompletionType.location), pair.symbol, pair.scope_);
|
||||
}
|
||||
|
||||
// gets the symbol matching to cursor pos
|
||||
SymbolStuff stuff = getSymbolsAtCursor(cast(size_t)request.cursorPosition);
|
||||
scope(exit) stuff.destroy();
|
||||
// gets the symbol matching to cursor pos
|
||||
SymbolStuff stuff = getSymbolsAtCursor(cast(size_t)request.cursorPosition);
|
||||
scope(exit) stuff.destroy();
|
||||
|
||||
// starts searching only if no ambiguity with the symbol
|
||||
if (stuff.symbols.length == 1)
|
||||
{
|
||||
const(DSymbol*) sourceSymbol = stuff.symbols[0];
|
||||
response.symbolLocation = sourceSymbol.location;
|
||||
response.symbolFilePath = sourceSymbol.symbolFile.idup;
|
||||
// starts searching only if no ambiguity with the symbol
|
||||
if (stuff.symbols.length == 1)
|
||||
{
|
||||
const(DSymbol*) sourceSymbol = stuff.symbols[0];
|
||||
response.symbolLocation = sourceSymbol.location;
|
||||
response.symbolFilePath = sourceSymbol.symbolFile.idup;
|
||||
|
||||
// gets the source token to avoid too much getSymbolsAtCursor()
|
||||
const(Token)* sourceToken;
|
||||
foreach(i, t; tokenArray)
|
||||
{
|
||||
if (t.type != tok!"identifier")
|
||||
continue;
|
||||
if (request.cursorPosition >= t.index &&
|
||||
request.cursorPosition < t.index + t.text.length)
|
||||
{
|
||||
sourceToken = tokenArray.ptr + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// gets the source token to avoid too much getSymbolsAtCursor()
|
||||
const(Token)* sourceToken;
|
||||
foreach(i, t; tokenArray)
|
||||
{
|
||||
if (t.type != tok!"identifier")
|
||||
continue;
|
||||
if (request.cursorPosition >= t.index &&
|
||||
request.cursorPosition < t.index + t.text.length)
|
||||
{
|
||||
sourceToken = tokenArray.ptr + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// finds the tokens that match to the source symbol
|
||||
if (sourceToken != null) foreach (t; tokenArray)
|
||||
{
|
||||
if (t.type == tok!"identifier" && t.text == sourceToken.text)
|
||||
{
|
||||
size_t pos = cast(size_t) t.index + 1; // place cursor inside the token
|
||||
SymbolStuff candidate = getSymbolsAtCursor(pos);
|
||||
scope(exit) candidate.destroy();
|
||||
if (candidate.symbols.length == 1 &&
|
||||
candidate.symbols[0].location == sourceSymbol.location &&
|
||||
candidate.symbols[0].symbolFile == sourceSymbol.symbolFile)
|
||||
{
|
||||
response.locations ~= t.index;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warning("The source token is not an identifier");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warning("No or ambiguous symbol for the identifier at cursor");
|
||||
}
|
||||
return response;
|
||||
// finds the tokens that match to the source symbol
|
||||
if (sourceToken != null) foreach (t; tokenArray)
|
||||
{
|
||||
if (t.type == tok!"identifier" && t.text == sourceToken.text)
|
||||
{
|
||||
size_t pos = cast(size_t) t.index + 1; // place cursor inside the token
|
||||
SymbolStuff candidate = getSymbolsAtCursor(pos);
|
||||
scope(exit) candidate.destroy();
|
||||
if (candidate.symbols.length == 1 &&
|
||||
candidate.symbols[0].location == sourceSymbol.location &&
|
||||
candidate.symbols[0].symbolFile == sourceSymbol.symbolFile)
|
||||
{
|
||||
response.locations ~= t.index;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warning("The source token is not an identifier");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
warning("No or ambiguous symbol for the identifier at cursor");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ module b;
|
|||
string BAR;
|
||||
|
||||
struct S {
|
||||
int x;
|
||||
int x;
|
||||
}
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
abstract class InheritMe(T)
|
||||
{
|
||||
final abstract class GrandChild(U, V)
|
||||
{
|
||||
/// I am uvalue
|
||||
static U uvalue;
|
||||
final abstract class GrandChild(U, V)
|
||||
{
|
||||
/// I am uvalue
|
||||
static U uvalue;
|
||||
|
||||
/// I am vvalue
|
||||
static V vvalue;
|
||||
/// I am vvalue
|
||||
static V vvalue;
|
||||
|
||||
/// I am setGrandChild
|
||||
static void setGrandChild(alias X, alias Y)()
|
||||
{
|
||||
X = Y;
|
||||
}
|
||||
}
|
||||
/// I am setGrandChild
|
||||
static void setGrandChild(alias X, alias Y)()
|
||||
{
|
||||
X = Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final abstract class Parent(T)
|
||||
{
|
||||
/// I am stringChild
|
||||
final abstract class StringChild : InheritMe!(string)
|
||||
{
|
||||
/// I am a string GrandChild
|
||||
alias s = GrandChild!(T, string);
|
||||
/// I am stringChild
|
||||
final abstract class StringChild : InheritMe!(string)
|
||||
{
|
||||
/// I am a string GrandChild
|
||||
alias s = GrandChild!(T, string);
|
||||
|
||||
/// I am an int GrandChild
|
||||
alias i = GrandChild!(T, int);
|
||||
}
|
||||
/// I am an int GrandChild
|
||||
alias i = GrandChild!(T, int);
|
||||
}
|
||||
|
||||
/// I am a parentF
|
||||
static void parentF()
|
||||
{
|
||||
/// I am a parentF
|
||||
static void parentF()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// I am stringParent
|
||||
|
@ -41,11 +41,11 @@ alias stringParent = Parent!string;
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
with(stringParent.StringChild.s)
|
||||
{
|
||||
setGrandChild
|
||||
!(
|
||||
uvalue, "test",
|
||||
)();
|
||||
}
|
||||
with(stringParent.StringChild.s)
|
||||
{
|
||||
setGrandChild
|
||||
!(
|
||||
uvalue, "test",
|
||||
)();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c839 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c696 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client $1 file.d -c862 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -c713 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -2,14 +2,14 @@ import std.stdio;
|
|||
|
||||
final abstract class ABC
|
||||
{
|
||||
static @property bool mybool()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static @property bool mybool()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void main(string[] s)
|
||||
{
|
||||
while(!ABC.mybool) {}
|
||||
while(!ABC.mybool) {}
|
||||
}
|
||||
// Regression test for issue 182
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c154 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c136 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
struct Bob
|
||||
{
|
||||
version (all)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
@disable this();
|
||||
}
|
||||
version (all)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
@disable this();
|
||||
}
|
||||
|
||||
int abcde;
|
||||
int abcde;
|
||||
}
|
||||
|
||||
unittest
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
unittest
|
||||
{
|
||||
int car;
|
||||
alias complicatedLess = (a, b) => a.c.d < b.c.d;
|
||||
int car;
|
||||
alias complicatedLess = (a, b) => a.c.d < b.c.d;
|
||||
c
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c79 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -c73 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
/// A
|
||||
enum A
|
||||
{
|
||||
none, /// A.none
|
||||
one, /// A.one
|
||||
none, /// A.none
|
||||
one, /// A.one
|
||||
}
|
||||
|
||||
/// B
|
||||
enum B
|
||||
{
|
||||
none, /// B.none
|
||||
one, /// B.one
|
||||
none, /// B.none
|
||||
one, /// B.one
|
||||
}
|
||||
|
||||
void main()
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c161 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -d -c149 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c170 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -d -c158 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c178 > actual3.txt
|
||||
../../bin/dcd-client $1 file.d -d -c166 > actual3.txt
|
||||
diff actual3.txt expected3.txt
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c187 > actual4.txt
|
||||
../../bin/dcd-client $1 file.d -d -c175 > actual4.txt
|
||||
diff actual4.txt expected4.txt
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/// A
|
||||
enum A
|
||||
{
|
||||
none, /// A.none
|
||||
one, /// A.one
|
||||
none, /// A.none
|
||||
one, /// A.one
|
||||
}
|
||||
|
||||
/// B
|
||||
enum B
|
||||
{
|
||||
none, /// B.none
|
||||
one, /// B.one
|
||||
none, /// B.none
|
||||
one, /// B.one
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c21 > actual1.txt
|
||||
../../bin/dcd-client $1 file.d -d -c18 > actual1.txt
|
||||
diff actual1.txt expected1.txt
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c119 > actual2.txt
|
||||
../../bin/dcd-client $1 file.d -d -c107 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
this()
|
||||
{
|
||||
new class C {};
|
||||
XX
|
||||
new class C {};
|
||||
XX
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c29 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c26 > actual.txt # segfault if -c29 (" XX|"), bug!
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
struct Foo
|
||||
{
|
||||
/// Sets or gets prop
|
||||
void prop(int t);
|
||||
/// ditto
|
||||
int prop();
|
||||
/// Sets or gets prop
|
||||
void prop(int t);
|
||||
/// ditto
|
||||
int prop();
|
||||
}
|
||||
|
||||
void main(string[] args)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -d -c136 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -d -c124 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
template Foo(T)
|
||||
{
|
||||
void bar();
|
||||
void bar();
|
||||
}
|
||||
|
||||
void main(string[] args)
|
||||
{
|
||||
(Foo!int).
|
||||
(Foo!int).
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c78 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c72 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
|
@ -1 +1 @@
|
|||
stdin 143
|
||||
stdin 140
|
||||
|
|
|
@ -5,13 +5,13 @@ alias bar = T!foo; // doesn't work
|
|||
|
||||
final class ABC
|
||||
{
|
||||
static @property bool mybool()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static @property bool mybool()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
while(!ABC.mybool) {}
|
||||
while(!ABC.mybool) {}
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@ diff actual1.txt expected1.txt
|
|||
../../bin/dcd-client $1 file.d -l -c47 > actual2.txt
|
||||
diff actual2.txt expected2.txt
|
||||
|
||||
../../bin/dcd-client $1 file.d -l -c218 > actual3.txt
|
||||
../../bin/dcd-client $1 file.d -l -c200 > actual3.txt
|
||||
diff actual3.txt expected3.txt
|
||||
|
|
|
@ -2,5 +2,5 @@ auto a = [[[0]]];
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
a[0][0][0].
|
||||
a[0][0][0].
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c61 > actual.txt
|
||||
../../bin/dcd-client $1 file.d -c58 > actual.txt
|
||||
diff actual.txt expected.txt
|
||||
|
|
Loading…
Reference in New Issue