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.resolvedType is null)())
{
// writeln("Resolving type of symbol ", s.name);
//writeln("Resolving type of symbol ", s.name);
Type type = s.type;
if (type is null)
{
//writeln("Could not find it due to null type");
continue;
}
if (type.type2.builtinType != TokenType.invalid)
{
//writeln("It was a built-in type");
// 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)
{

View File

@ -457,7 +457,8 @@ class AutocompleteVisitor : ASTVisitor
if (b.right == TokenType.invalid)
{
// 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
{

View File

@ -496,9 +496,11 @@ T getExpression(T)(T beforeTokens)
void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
{
writeln("Setting import collections");
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())
{
string p = format("%s%s%s", importDirectory, dirSeparator, path);

View File

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

View File

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