Merge pull request #328 from WebFreak001/master
Added support for single files as import paths (fix #278)
This commit is contained in:
commit
923535ef94
|
@ -643,35 +643,53 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response,
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
foreach (importDirectory; cache.getImportPaths())
|
foreach (importPath; cache.getImportPaths())
|
||||||
{
|
{
|
||||||
string p = buildPath(importDirectory, path);
|
if (importPath.isFile)
|
||||||
if (!exists(p))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
found = true;
|
|
||||||
|
|
||||||
foreach (string name; dirEntries(p, SpanMode.shallow))
|
|
||||||
{
|
{
|
||||||
import std.path: baseName;
|
if (!exists(importPath))
|
||||||
if (name.baseName.startsWith(".#"))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto n = name.baseName(".d").baseName(".di");
|
found = true;
|
||||||
if (isFile(name) && (name.endsWith(".d") || name.endsWith(".di"))
|
|
||||||
&& (partial is null || n.startsWith(partial)))
|
auto n = importPath.baseName(".d").baseName(".di");
|
||||||
|
if (isFile(importPath) && (importPath.endsWith(".d") || importPath.endsWith(".di"))
|
||||||
|
&& (partial is null || n.startsWith(partial)))
|
||||||
{
|
{
|
||||||
response.completions ~= n;
|
response.completions ~= n;
|
||||||
response.completionKinds ~= CompletionKind.moduleName;
|
response.completionKinds ~= CompletionKind.moduleName;
|
||||||
}
|
}
|
||||||
else if (isDir(name))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string p = buildPath(importPath, path);
|
||||||
|
if (!exists(p))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
foreach (string name; dirEntries(p, SpanMode.shallow))
|
||||||
{
|
{
|
||||||
if (n[0] != '.' && (partial is null || n.startsWith(partial)))
|
import std.path: baseName;
|
||||||
|
if (name.baseName.startsWith(".#"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto n = name.baseName(".d").baseName(".di");
|
||||||
|
if (isFile(name) && (name.endsWith(".d") || name.endsWith(".di"))
|
||||||
|
&& (partial is null || n.startsWith(partial)))
|
||||||
{
|
{
|
||||||
response.completions ~= n;
|
response.completions ~= n;
|
||||||
response.completionKinds ~=
|
response.completionKinds ~= CompletionKind.moduleName;
|
||||||
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di"))
|
}
|
||||||
? CompletionKind.moduleName : CompletionKind.packageName;
|
else if (isDir(name))
|
||||||
|
{
|
||||||
|
if (n[0] != '.' && (partial is null || n.startsWith(partial)))
|
||||||
|
{
|
||||||
|
response.completions ~= n;
|
||||||
|
response.completionKinds ~=
|
||||||
|
exists(buildPath(name, "package.d")) || exists(buildPath(name, "package.di"))
|
||||||
|
? CompletionKind.moduleName : CompletionKind.packageName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module tc036.bar;
|
||||||
|
|
||||||
|
void fooBarFunc() { }
|
|
@ -0,0 +1,2 @@
|
||||||
|
identifiers
|
||||||
|
bar M
|
|
@ -0,0 +1,2 @@
|
||||||
|
identifiers
|
||||||
|
fooBarFunc f
|
|
@ -0,0 +1,3 @@
|
||||||
|
import tc036.bar;
|
||||||
|
|
||||||
|
void main() { fooBarF }
|
|
@ -0,0 +1,10 @@
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 -I bar.d
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 file.d -c 15 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt
|
||||||
|
diff actual1.txt expected1.txt
|
||||||
|
|
||||||
|
../../bin/dcd-client $1 file.d -c 40 | sed s\""$(dirname "$(pwd)")"\"\" > actual2.txt
|
||||||
|
diff actual2.txt expected2.txt
|
Loading…
Reference in New Issue