Fixed #34. Also fixed an issue where modules would be corrupted when performing a selective import.

This commit is contained in:
Hackerpilot 2013-09-11 01:26:57 +00:00
parent b1b4444cdb
commit 5ee2192c6f
5 changed files with 10 additions and 9 deletions

View File

@ -246,19 +246,18 @@ public:
|| a.kind == CompletionKind.enumMember || a.kind == CompletionKind.aliasName) || a.kind == CompletionKind.enumMember || a.kind == CompletionKind.aliasName)
&& a.resolvedType is null)()) && a.resolvedType is null)())
{ {
// writeln("Resolving type of symbol ", s.name); //writeln("Resolving type of symbol ", s.name);
Type type = s.type; Type type = s.type;
if (type is null) if (type is null)
{ {
//writeln("Could not find it due to null type"); //writeln("Could not find it due to null type");
continue; continue;
} }
if (type.type2.builtinType != TokenType.invalid) if (type.type2.builtinType != TokenType.invalid)
{ {
//writeln("It was a built-in type");
// This part is easy. Autocomplete properties of built-in types // This part is easy. Autocomplete properties of built-in types
s.resolvedType = findSymbolsInScope(getTokenValue(type.type2.builtinType))[0]; auto foundSymbols = findSymbolsInScope(getTokenValue(type.type2.builtinType));
s.resolvedType = foundSymbols[0];
} }
else if (type.type2.symbol !is null) else if (type.type2.symbol !is null)
{ {

View File

@ -457,7 +457,8 @@ class AutocompleteVisitor : ASTVisitor
if (b.right == TokenType.invalid) if (b.right == TokenType.invalid)
{ {
// Selecive import // Selecive import
importedSymbols.filter!(a => a.name == b.left).copy(scope_.symbols); foreach (ACSymbol symbol; importedSymbols.filter!(a => a.name == b.left))
scope_.symbols ~= symbol;
} }
else else
{ {

View File

@ -496,9 +496,11 @@ T getExpression(T)(T beforeTokens)
void setImportCompletions(T)(T tokens, ref AutocompleteResponse response) void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
{ {
writeln("Setting import collections");
response.completionType = CompletionType.identifiers; response.completionType = CompletionType.identifiers;
string path = buildPath(tokens.filter!(a => a.type == TokenType.identifier).map!("a.value").array()); auto moduleParts = tokens.filter!(a => a.type == TokenType.identifier).map!("a.value").array();
if (moduleParts.length == 0)
return;
string path = buildPath(moduleParts);
foreach (importDirectory; ModuleCache.getImportPaths()) foreach (importDirectory; ModuleCache.getImportPaths())
{ {
string p = format("%s%s%s", importDirectory, dirSeparator, path); string p = format("%s%s%s", importDirectory, dirSeparator, path);

View File

@ -123,7 +123,6 @@ function M.autocomplete(ch)
p:close() p:close()
local tmpFile = io.open(fileName, "r") local tmpFile = io.open(fileName, "r")
local r = tmpFile:read("*a") local r = tmpFile:read("*a")
print(r)
if r ~= "\n" then if r ~= "\n" then
if r:match("^identifiers.*") then if r:match("^identifiers.*") then
showCompletionList(r) showCompletionList(r)

View File

@ -51,7 +51,7 @@ struct ModuleCache
*/ */
static void clear() static void clear()
{ {
cache.clear(); cache = cache.init;
} }
/** /**