Fix #67 and update DScanner
This commit is contained in:
parent
ed7a667ae4
commit
52b919bd3a
|
|
@ -428,16 +428,6 @@ private:
|
||||||
return "%s %s%s".format(formatNode(returnType), name, parameterString);
|
return "%s %s%s".format(formatNode(returnType), name, parameterString);
|
||||||
}
|
}
|
||||||
|
|
||||||
static string formatNode(T)(T node)
|
|
||||||
{
|
|
||||||
if (node is null) return "";
|
|
||||||
import formatter;
|
|
||||||
auto app = appender!(char[])();
|
|
||||||
auto f = new Formatter!(typeof(app))(app);
|
|
||||||
f.format(node);
|
|
||||||
return to!string(app.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Current protection type
|
/// Current protection type
|
||||||
TokenType protection;
|
TokenType protection;
|
||||||
|
|
||||||
|
|
@ -499,13 +489,13 @@ private:
|
||||||
{
|
{
|
||||||
foreach (importInfo; currentScope.importInformation)
|
foreach (importInfo; currentScope.importInformation)
|
||||||
{
|
{
|
||||||
auto symbols = ModuleCache.getSymbolsInModule(importInfo.modulePath);
|
auto symbols = ModuleCache.getSymbolsInModule(
|
||||||
|
ModuleCache.resolveImportLoctation(importInfo.modulePath));
|
||||||
if (importInfo.importedSymbols.length == 0)
|
if (importInfo.importedSymbols.length == 0)
|
||||||
{
|
{
|
||||||
currentScope.symbols ~= symbols;
|
currentScope.symbols ~= symbols;
|
||||||
if (importInfo.isPublic && currentScope.parent is null)
|
if (importInfo.isPublic && currentScope.parent is null)
|
||||||
{
|
{
|
||||||
Log.trace("Public import");
|
|
||||||
rootSymbol.acSymbol.parts ~= symbols;
|
rootSymbol.acSymbol.parts ~= symbols;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -708,8 +698,11 @@ private:
|
||||||
}
|
}
|
||||||
if (suffix.parameters)
|
if (suffix.parameters)
|
||||||
{
|
{
|
||||||
Log.error("TODO: Function type suffix");
|
ACSymbol* s = new ACSymbol;
|
||||||
return null;
|
s.type = symbol;
|
||||||
|
s.qualifier = SymbolQualifier.func;
|
||||||
|
s.callTip = suffix.delegateOrFunction.value ~ formatNode(suffix.parameters);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -836,7 +829,7 @@ string[] iotcToStringArray(const IdentifierOrTemplateChain iotc)
|
||||||
|
|
||||||
private static string convertChainToImportPath(IdentifierChain chain)
|
private static string convertChainToImportPath(IdentifierChain chain)
|
||||||
{
|
{
|
||||||
return to!string(chain.identifiers.map!(a => a.value).join(dirSeparator).array) ~ ".d";
|
return to!string(chain.identifiers.map!(a => a.value).join(dirSeparator).array);
|
||||||
}
|
}
|
||||||
|
|
||||||
version(unittest) Module parseTestCode(string code)
|
version(unittest) Module parseTestCode(string code)
|
||||||
|
|
@ -852,4 +845,14 @@ version(unittest) Module parseTestCode(string code)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string formatNode(T)(T node)
|
||||||
|
{
|
||||||
|
if (node is null) return "";
|
||||||
|
import formatter;
|
||||||
|
auto app = appender!(char[])();
|
||||||
|
auto f = new Formatter!(typeof(app))(app);
|
||||||
|
f.format(node);
|
||||||
|
return to!string(app.data);
|
||||||
|
}
|
||||||
|
|
||||||
private void doesNothing(string a, int b, int c, string d) {}
|
private void doesNothing(string a, int b, int c, string d) {}
|
||||||
|
|
|
||||||
|
|
@ -570,7 +570,9 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response)
|
||||||
else if (isDir(name))
|
else if (isDir(name))
|
||||||
{
|
{
|
||||||
response.completions ~= name.baseName();
|
response.completions ~= name.baseName();
|
||||||
response.completionKinds ~= CompletionKind.packageName;
|
response.completionKinds ~=
|
||||||
|
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di"))
|
||||||
|
? CompletionKind.packageName : CompletionKind.moduleName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
dscanner
2
dscanner
|
|
@ -1 +1 @@
|
||||||
Subproject commit e3819643bbec121e16abda6f980cc096d2e7f4f1
|
Subproject commit c522170983576c533b8a378040648612aeee7953
|
||||||
|
|
@ -97,14 +97,12 @@ struct ModuleCache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Params:
|
* Params:
|
||||||
* moduleName = the name of the module in "a/b.d" form
|
* moduleName = the name of the module in "a/b/c" form
|
||||||
* Returns:
|
* Returns:
|
||||||
* The symbols defined in the given module
|
* The symbols defined in the given module
|
||||||
*/
|
*/
|
||||||
static const(ACSymbol)*[] getSymbolsInModule(string moduleName)
|
static const(ACSymbol)*[] getSymbolsInModule(string location)
|
||||||
{
|
{
|
||||||
|
|
||||||
string location = resolveImportLoctation(moduleName);
|
|
||||||
if (location is null)
|
if (location is null)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
|
|
@ -115,7 +113,7 @@ struct ModuleCache
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info("Getting symbols for module ", moduleName);
|
Log.info("Getting symbols for ", location);
|
||||||
|
|
||||||
recursionGuard[location] = true;
|
recursionGuard[location] = true;
|
||||||
|
|
||||||
|
|
@ -154,28 +152,37 @@ struct ModuleCache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Params:
|
* Params:
|
||||||
* moduleName the name of the module being imported, in "a/b/c.d" style
|
* moduleName the name of the module being imported, in "a/b/c" style
|
||||||
* Returns:
|
* Returns:
|
||||||
* The absolute path to the file that contains the module, or null if
|
* The absolute path to the file that contains the module, or null if
|
||||||
* not found.
|
* not found.
|
||||||
*/
|
*/
|
||||||
static string resolveImportLoctation(string moduleName)
|
static string resolveImportLoctation(string moduleName)
|
||||||
{
|
{
|
||||||
// Log.trace("Resolving location of ", moduleName);
|
|
||||||
if (isRooted(moduleName))
|
if (isRooted(moduleName))
|
||||||
return moduleName;
|
return moduleName;
|
||||||
|
string[] alternatives;
|
||||||
foreach (path; importPaths)
|
foreach (path; importPaths)
|
||||||
{
|
{
|
||||||
string filePath = path ~ "/" ~ moduleName;
|
string filePath = buildPath(path, moduleName);
|
||||||
if (filePath.exists())
|
if (exists(filePath ~ ".d") && isFile(filePath ~ ".d"))
|
||||||
return filePath;
|
alternatives = (filePath ~ ".d") ~ alternatives;
|
||||||
filePath ~= "i"; // check for x.di if x.d isn't found
|
else if (exists(filePath ~ ".di") && isFile(filePath ~ ".di"))
|
||||||
if (filePath.exists())
|
alternatives = (filePath ~ ".di") ~ alternatives;
|
||||||
return filePath;
|
else if (exists(filePath) && isDir(filePath))
|
||||||
|
{
|
||||||
|
string packagePath = buildPath(filePath, "package.d");
|
||||||
|
if (exists(packagePath) && isFile(packagePath))
|
||||||
|
{
|
||||||
|
alternatives ~= packagePath;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
packagePath ~= "i";
|
||||||
|
if (exists(packagePath) && isFile(packagePath))
|
||||||
|
alternatives ~= packagePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.error("Could not find ", moduleName);
|
return alternatives.length > 0 ? alternatives[0] : null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const(string[]) getImportPaths()
|
static const(string[]) getImportPaths()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue