Now starts up in 800ms and uses 105MB memory on druntime+phobos
This commit is contained in:
parent
ae91019ab4
commit
cf57888140
10
actypes.d
10
actypes.d
|
@ -110,17 +110,17 @@ public:
|
||||||
return array(parts.equalRange(&s));
|
return array(parts.equalRange(&s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Symbol's name
|
||||||
|
*/
|
||||||
|
string name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symbols that compose this symbol, such as enum members, class variables,
|
* Symbols that compose this symbol, such as enum members, class variables,
|
||||||
* methods, etc.
|
* methods, etc.
|
||||||
*/
|
*/
|
||||||
TTree!(ACSymbol*, true, "a < b", false) parts;
|
TTree!(ACSymbol*, true, "a < b", false) parts;
|
||||||
|
|
||||||
/**
|
|
||||||
* Symbol's name
|
|
||||||
*/
|
|
||||||
string name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calltip to display if this is a function
|
* Calltip to display if this is a function
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -53,7 +53,9 @@ AutocompleteResponse getDoc(const AutocompleteRequest request)
|
||||||
Log.trace("Getting doc comments");
|
Log.trace("Getting doc comments");
|
||||||
AutocompleteResponse response;
|
AutocompleteResponse response;
|
||||||
auto allocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 16)))();
|
auto allocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 16)))();
|
||||||
ACSymbol*[] symbols = getSymbolsForCompletion(request, CompletionType.ddoc, allocator);
|
auto cache = StringCache(StringCache.defaultBucketCount);
|
||||||
|
ACSymbol*[] symbols = getSymbolsForCompletion(request, CompletionType.ddoc,
|
||||||
|
allocator, &cache);
|
||||||
if (symbols.length == 0)
|
if (symbols.length == 0)
|
||||||
Log.error("Could not find symbol");
|
Log.error("Could not find symbol");
|
||||||
else foreach (symbol; symbols)
|
else foreach (symbol; symbols)
|
||||||
|
@ -81,11 +83,13 @@ AutocompleteResponse findDeclaration(const AutocompleteRequest request)
|
||||||
Log.trace("Finding declaration");
|
Log.trace("Finding declaration");
|
||||||
AutocompleteResponse response;
|
AutocompleteResponse response;
|
||||||
auto allocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 16)))();
|
auto allocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024 * 16)))();
|
||||||
ACSymbol*[] symbols = getSymbolsForCompletion(request, CompletionType.location, allocator);
|
auto cache = StringCache(StringCache.defaultBucketCount);
|
||||||
|
ACSymbol*[] symbols = getSymbolsForCompletion(request,
|
||||||
|
CompletionType.location, allocator, &cache);
|
||||||
if (symbols.length > 0)
|
if (symbols.length > 0)
|
||||||
{
|
{
|
||||||
response.symbolLocation = symbols[0].location;
|
response.symbolLocation = symbols[0].location;
|
||||||
response.symbolFilePath = symbols[0].symbolFile;
|
response.symbolFilePath = symbols[0].symbolFile.idup;
|
||||||
Log.info(symbols[0].name, " declared in ",
|
Log.info(symbols[0].name, " declared in ",
|
||||||
response.symbolFilePath, " at ", response.symbolLocation);
|
response.symbolFilePath, " at ", response.symbolLocation);
|
||||||
}
|
}
|
||||||
|
@ -106,8 +110,9 @@ AutocompleteResponse complete(const AutocompleteRequest request)
|
||||||
Log.info("Got a completion request");
|
Log.info("Got a completion request");
|
||||||
|
|
||||||
const(Token)[] tokenArray;
|
const(Token)[] tokenArray;
|
||||||
|
auto cache = StringCache(StringCache.defaultBucketCount);
|
||||||
auto beforeTokens = getTokensBeforeCursor(request.sourceCode,
|
auto beforeTokens = getTokensBeforeCursor(request.sourceCode,
|
||||||
request.cursorPosition, tokenArray);
|
request.cursorPosition, &cache, tokenArray);
|
||||||
string partial;
|
string partial;
|
||||||
IdType tokenType;
|
IdType tokenType;
|
||||||
|
|
||||||
|
@ -134,7 +139,7 @@ AutocompleteResponse complete(const AutocompleteRequest request)
|
||||||
foreach (symbol; (cast() arraySymbols)[])
|
foreach (symbol; (cast() arraySymbols)[])
|
||||||
{
|
{
|
||||||
response.completionKinds ~= symbol.kind;
|
response.completionKinds ~= symbol.kind;
|
||||||
response.completions ~= symbol.name;
|
response.completions ~= symbol.name.dup;
|
||||||
}
|
}
|
||||||
response.completionType = CompletionType.identifiers;
|
response.completionType = CompletionType.identifiers;
|
||||||
break;
|
break;
|
||||||
|
@ -193,11 +198,10 @@ AutocompleteResponse complete(const AutocompleteRequest request)
|
||||||
* a sorted range of tokens before the cursor position
|
* a sorted range of tokens before the cursor position
|
||||||
*/
|
*/
|
||||||
auto getTokensBeforeCursor(const(ubyte[]) sourceCode, size_t cursorPosition,
|
auto getTokensBeforeCursor(const(ubyte[]) sourceCode, size_t cursorPosition,
|
||||||
out const(Token)[] tokenArray)
|
StringCache* cache, out const(Token)[] tokenArray)
|
||||||
{
|
{
|
||||||
LexerConfig config;
|
LexerConfig config;
|
||||||
config.fileName = "stdin";
|
config.fileName = "stdin";
|
||||||
StringCache* cache = new StringCache(StringCache.defaultBucketCount);
|
|
||||||
auto tokens = byToken(cast(ubyte[]) sourceCode, config, cache);
|
auto tokens = byToken(cast(ubyte[]) sourceCode, config, cache);
|
||||||
tokenArray = tokens.array();
|
tokenArray = tokens.array();
|
||||||
auto sortedTokens = assumeSorted(tokenArray);
|
auto sortedTokens = assumeSorted(tokenArray);
|
||||||
|
@ -213,11 +217,11 @@ auto getTokensBeforeCursor(const(ubyte[]) sourceCode, size_t cursorPosition,
|
||||||
* the request's source code, cursor position, and completion type.
|
* the request's source code, cursor position, and completion type.
|
||||||
*/
|
*/
|
||||||
ACSymbol*[] getSymbolsForCompletion(const AutocompleteRequest request,
|
ACSymbol*[] getSymbolsForCompletion(const AutocompleteRequest request,
|
||||||
const CompletionType type, CAllocator allocator)
|
const CompletionType type, CAllocator allocator, StringCache* cache)
|
||||||
{
|
{
|
||||||
const(Token)[] tokenArray;
|
const(Token)[] tokenArray;
|
||||||
auto beforeTokens = getTokensBeforeCursor(request.sourceCode,
|
auto beforeTokens = getTokensBeforeCursor(request.sourceCode,
|
||||||
request.cursorPosition, tokenArray);
|
request.cursorPosition, cache, tokenArray);
|
||||||
auto semanticAllocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024*16)));
|
auto semanticAllocator = scoped!(CAllocatorImpl!(BlockAllocator!(1024*16)));
|
||||||
Scope* completionScope = generateAutocompleteTrees(tokenArray,
|
Scope* completionScope = generateAutocompleteTrees(tokenArray,
|
||||||
"stdin", allocator, semanticAllocator);
|
"stdin", allocator, semanticAllocator);
|
||||||
|
@ -470,7 +474,7 @@ void setCompletions(T)(ref AutocompleteResponse response,
|
||||||
.filter!(a => a.name.toUpper().startsWith(partial.toUpper())))
|
.filter!(a => a.name.toUpper().startsWith(partial.toUpper())))
|
||||||
{
|
{
|
||||||
response.completionKinds ~= s.kind;
|
response.completionKinds ~= s.kind;
|
||||||
response.completions ~= s.name;
|
response.completions ~= s.name.dup;
|
||||||
}
|
}
|
||||||
response.completionType = CompletionType.identifiers;
|
response.completionType = CompletionType.identifiers;
|
||||||
return;
|
return;
|
||||||
|
@ -502,7 +506,7 @@ void setCompletions(T)(ref AutocompleteResponse response,
|
||||||
{
|
{
|
||||||
// Log.trace("Adding ", s.name, " to the completion list");
|
// Log.trace("Adding ", s.name, " to the completion list");
|
||||||
response.completionKinds ~= s.kind;
|
response.completionKinds ~= s.kind;
|
||||||
response.completions ~= s.name;
|
response.completions ~= s.name.dup;
|
||||||
}
|
}
|
||||||
response.completionType = CompletionType.identifiers;
|
response.completionType = CompletionType.identifiers;
|
||||||
}
|
}
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -42,7 +42,7 @@ dmd\
|
||||||
-Icontainers/src\
|
-Icontainers/src\
|
||||||
-Imsgpack-d/src\
|
-Imsgpack-d/src\
|
||||||
-Idscanner\
|
-Idscanner\
|
||||||
-wi -O -release\
|
-wi -O -release -inline\
|
||||||
-ofdcd-server
|
-ofdcd-server
|
||||||
|
|
||||||
#gdc client.d\
|
#gdc client.d\
|
||||||
|
|
2
dscanner
2
dscanner
|
@ -1 +1 @@
|
||||||
Subproject commit 19dc7c707f857b104144e909d77543b2db1521b8
|
Subproject commit 25f0d93b90cf039577ed2fb7091efd18770dc06c
|
Loading…
Reference in New Issue