Merge pull request #328 from WebFreak001/master

Added support for single files as import paths (fix #278)
This commit is contained in:
Brian Schott 2016-06-30 18:04:38 -07:00 committed by GitHub
commit 923535ef94
6 changed files with 56 additions and 18 deletions

View File

@ -643,9 +643,26 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response,
bool found = false;
foreach (importDirectory; cache.getImportPaths())
foreach (importPath; cache.getImportPaths())
{
string p = buildPath(importDirectory, path);
if (importPath.isFile)
{
if (!exists(importPath))
continue;
found = true;
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.completionKinds ~= CompletionKind.moduleName;
}
}
else
{
string p = buildPath(importPath, path);
if (!exists(p))
continue;
@ -676,6 +693,7 @@ void setImportCompletions(T)(T tokens, ref AutocompleteResponse response,
}
}
}
}
if (!found)
warning("Could not find ", moduleParts);
}

3
tests/tc036/bar.d Normal file
View File

@ -0,0 +1,3 @@
module tc036.bar;
void fooBarFunc() { }

View File

@ -0,0 +1,2 @@
identifiers
bar M

View File

@ -0,0 +1,2 @@
identifiers
fooBarFunc f

3
tests/tc036/file.d Normal file
View File

@ -0,0 +1,3 @@
import tc036.bar;
void main() { fooBarF }

10
tests/tc036/run.sh Executable file
View File

@ -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