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:
WebFreak001 2017-08-24 21:56:22 +02:00
parent 843a7783c3
commit 3d5ec1fe60
24 changed files with 155 additions and 155 deletions

View File

@ -41,81 +41,81 @@ import common.messages;
* the autocompletion response. * the autocompletion response.
*/ */
public AutocompleteResponse findLocalUse(AutocompleteRequest request, public AutocompleteResponse findLocalUse(AutocompleteRequest request,
ref ModuleCache moduleCache) ref ModuleCache moduleCache)
{ {
AutocompleteResponse response; AutocompleteResponse response;
RollbackAllocator rba; RollbackAllocator rba;
auto allocator = scoped!(ASTAllocator)(); auto allocator = scoped!(ASTAllocator)();
auto cache = StringCache(StringCache.defaultBucketCount); auto cache = StringCache(StringCache.defaultBucketCount);
// patchs the original request for the subsequent requests // patchs the original request for the subsequent requests
request.kind = RequestKind.symbolLocation; request.kind = RequestKind.symbolLocation;
// getSymbolsForCompletion() copy to avoid repetitive parsing // getSymbolsForCompletion() copy to avoid repetitive parsing
LexerConfig config; LexerConfig config;
config.fileName = ""; config.fileName = "";
const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode, const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode,
config, &cache); config, &cache);
SymbolStuff getSymbolsAtCursor(size_t cursorPosition) SymbolStuff getSymbolsAtCursor(size_t cursorPosition)
{ {
auto sortedTokens = assumeSorted(tokenArray); auto sortedTokens = assumeSorted(tokenArray);
auto beforeTokens = sortedTokens.lowerBound(cursorPosition); auto beforeTokens = sortedTokens.lowerBound(cursorPosition);
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator, ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
&rba, request.cursorPosition, moduleCache); &rba, request.cursorPosition, moduleCache);
auto expression = getExpression(beforeTokens); auto expression = getExpression(beforeTokens);
return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression, return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression,
cursorPosition, CompletionType.location), pair.symbol, pair.scope_); cursorPosition, CompletionType.location), pair.symbol, pair.scope_);
} }
// gets the symbol matching to cursor pos // gets the symbol matching to cursor pos
SymbolStuff stuff = getSymbolsAtCursor(cast(size_t)request.cursorPosition); SymbolStuff stuff = getSymbolsAtCursor(cast(size_t)request.cursorPosition);
scope(exit) stuff.destroy(); scope(exit) stuff.destroy();
// starts searching only if no ambiguity with the symbol // starts searching only if no ambiguity with the symbol
if (stuff.symbols.length == 1) if (stuff.symbols.length == 1)
{ {
const(DSymbol*) sourceSymbol = stuff.symbols[0]; const(DSymbol*) sourceSymbol = stuff.symbols[0];
response.symbolLocation = sourceSymbol.location; response.symbolLocation = sourceSymbol.location;
response.symbolFilePath = sourceSymbol.symbolFile.idup; response.symbolFilePath = sourceSymbol.symbolFile.idup;
// gets the source token to avoid too much getSymbolsAtCursor() // gets the source token to avoid too much getSymbolsAtCursor()
const(Token)* sourceToken; const(Token)* sourceToken;
foreach(i, t; tokenArray) foreach(i, t; tokenArray)
{ {
if (t.type != tok!"identifier") if (t.type != tok!"identifier")
continue; continue;
if (request.cursorPosition >= t.index && if (request.cursorPosition >= t.index &&
request.cursorPosition < t.index + t.text.length) request.cursorPosition < t.index + t.text.length)
{ {
sourceToken = tokenArray.ptr + i; sourceToken = tokenArray.ptr + i;
break; break;
} }
} }
// finds the tokens that match to the source symbol // finds the tokens that match to the source symbol
if (sourceToken != null) foreach (t; tokenArray) if (sourceToken != null) foreach (t; tokenArray)
{ {
if (t.type == tok!"identifier" && t.text == sourceToken.text) if (t.type == tok!"identifier" && t.text == sourceToken.text)
{ {
size_t pos = cast(size_t) t.index + 1; // place cursor inside the token size_t pos = cast(size_t) t.index + 1; // place cursor inside the token
SymbolStuff candidate = getSymbolsAtCursor(pos); SymbolStuff candidate = getSymbolsAtCursor(pos);
scope(exit) candidate.destroy(); scope(exit) candidate.destroy();
if (candidate.symbols.length == 1 && if (candidate.symbols.length == 1 &&
candidate.symbols[0].location == sourceSymbol.location && candidate.symbols[0].location == sourceSymbol.location &&
candidate.symbols[0].symbolFile == sourceSymbol.symbolFile) candidate.symbols[0].symbolFile == sourceSymbol.symbolFile)
{ {
response.locations ~= t.index; response.locations ~= t.index;
} }
} }
} }
else else
{ {
warning("The source token is not an identifier"); warning("The source token is not an identifier");
} }
} }
else else
{ {
warning("No or ambiguous symbol for the identifier at cursor"); warning("No or ambiguous symbol for the identifier at cursor");
} }
return response; return response;
} }

View File

@ -2,5 +2,5 @@ module b;
string BAR; string BAR;
struct S { struct S {
int x; int x;
} }

View File

@ -1,39 +1,39 @@
abstract class InheritMe(T) abstract class InheritMe(T)
{ {
final abstract class GrandChild(U, V) final abstract class GrandChild(U, V)
{ {
/// I am uvalue /// I am uvalue
static U uvalue; static U uvalue;
/// I am vvalue /// I am vvalue
static V vvalue; static V vvalue;
/// I am setGrandChild /// I am setGrandChild
static void setGrandChild(alias X, alias Y)() static void setGrandChild(alias X, alias Y)()
{ {
X = Y; X = Y;
} }
} }
} }
final abstract class Parent(T) final abstract class Parent(T)
{ {
/// I am stringChild /// I am stringChild
final abstract class StringChild : InheritMe!(string) final abstract class StringChild : InheritMe!(string)
{ {
/// I am a string GrandChild /// I am a string GrandChild
alias s = GrandChild!(T, string); alias s = GrandChild!(T, string);
/// I am an int GrandChild /// I am an int GrandChild
alias i = GrandChild!(T, int); alias i = GrandChild!(T, int);
} }
/// I am a parentF /// I am a parentF
static void parentF() static void parentF()
{ {
} }
} }
/// I am stringParent /// I am stringParent
@ -41,11 +41,11 @@ alias stringParent = Parent!string;
void main(string[] args) void main(string[] args)
{ {
with(stringParent.StringChild.s) with(stringParent.StringChild.s)
{ {
setGrandChild setGrandChild
!( !(
uvalue, "test", uvalue, "test",
)(); )();
} }
} }

View File

@ -1,8 +1,8 @@
set -e set -e
set -u 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 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 diff actual2.txt expected2.txt

View File

@ -2,14 +2,14 @@ import std.stdio;
final abstract class ABC final abstract class ABC
{ {
static @property bool mybool() static @property bool mybool()
{ {
return true; return true;
} }
} }
void main(string[] s) void main(string[] s)
{ {
while(!ABC.mybool) {} while(!ABC.mybool) {}
} }
// Regression test for issue 182 // Regression test for issue 182

View File

@ -1,5 +1,5 @@
set -e set -e
set -u 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 diff actual.txt expected.txt

View File

@ -1,14 +1,14 @@
struct Bob struct Bob
{ {
version (all) version (all)
{ {
} }
else else
{ {
@disable this(); @disable this();
} }
int abcde; int abcde;
} }
unittest unittest

View File

@ -1,6 +1,6 @@
unittest unittest
{ {
int car; int car;
alias complicatedLess = (a, b) => a.c.d < b.c.d; alias complicatedLess = (a, b) => a.c.d < b.c.d;
c c
} }

View File

@ -1,5 +1,5 @@
set -e set -e
set -u 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 diff actual1.txt expected1.txt

View File

@ -1,15 +1,15 @@
/// A /// A
enum A enum A
{ {
none, /// A.none none, /// A.none
one, /// A.one one, /// A.one
} }
/// B /// B
enum B enum B
{ {
none, /// B.none none, /// B.none
one, /// B.one one, /// B.one
} }
void main() void main()

View File

@ -1,15 +1,15 @@
set -e set -e
set -u 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 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 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 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 diff actual4.txt expected4.txt

View File

@ -1,13 +1,13 @@
/// A /// A
enum A enum A
{ {
none, /// A.none none, /// A.none
one, /// A.one one, /// A.one
} }
/// B /// B
enum B enum B
{ {
none, /// B.none none, /// B.none
one, /// B.one one, /// B.one
} }

View File

@ -1,8 +1,8 @@
set -e set -e
set -u 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 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 diff actual2.txt expected2.txt

View File

@ -1,5 +1,5 @@
this() this()
{ {
new class C {}; new class C {};
XX XX
} }

View File

@ -1,5 +1,5 @@
set -e set -e
set -u 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 diff actual.txt expected.txt

View File

@ -1,9 +1,9 @@
struct Foo struct Foo
{ {
/// Sets or gets prop /// Sets or gets prop
void prop(int t); void prop(int t);
/// ditto /// ditto
int prop(); int prop();
} }
void main(string[] args) void main(string[] args)

View File

@ -1,5 +1,5 @@
set -e set -e
set -u 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 diff actual.txt expected.txt

View File

@ -1,9 +1,9 @@
template Foo(T) template Foo(T)
{ {
void bar(); void bar();
} }
void main(string[] args) void main(string[] args)
{ {
(Foo!int). (Foo!int).
} }

View File

@ -1,5 +1,5 @@
set -e set -e
set -u 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 diff actual.txt expected.txt

View File

@ -1 +1 @@
stdin 143 stdin 140

View File

@ -5,13 +5,13 @@ alias bar = T!foo; // doesn't work
final class ABC final class ABC
{ {
static @property bool mybool() static @property bool mybool()
{ {
return true; return true;
} }
} }
void main() void main()
{ {
while(!ABC.mybool) {} while(!ABC.mybool) {}
} }

View File

@ -7,5 +7,5 @@ diff actual1.txt expected1.txt
../../bin/dcd-client $1 file.d -l -c47 > actual2.txt ../../bin/dcd-client $1 file.d -l -c47 > actual2.txt
diff actual2.txt expected2.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 diff actual3.txt expected3.txt

View File

@ -2,5 +2,5 @@ auto a = [[[0]]];
void main(string[] args) void main(string[] args)
{ {
a[0][0][0]. a[0][0][0].
} }

View File

@ -1,5 +1,5 @@
set -e set -e
set -u 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 diff actual.txt expected.txt