From fc419405ea6062d5e321d72f50ef3c901582ba09 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Thu, 26 Feb 2015 17:52:41 +0300 Subject: [PATCH] add dependency projects to import paths when running DCD --- dlangide.visualdproj | 2 +- src/dlangide/ui/dsourceedit.d | 2 +- src/dlangide/workspace/project.d | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dlangide.visualdproj b/dlangide.visualdproj index 734db22..51867a8 100644 --- a/dlangide.visualdproj +++ b/dlangide.visualdproj @@ -72,7 +72,7 @@ 0 DebugInfo DCD 0 - Unicode USE_FREETYPE USE_LIBDPARSE USE_MAGO + Unicode USE_FREETYPE 0 3 0 diff --git a/src/dlangide/ui/dsourceedit.d b/src/dlangide/ui/dsourceedit.d index 9655fc1..2f5e824 100644 --- a/src/dlangide/ui/dsourceedit.d +++ b/src/dlangide/ui/dsourceedit.d @@ -83,7 +83,7 @@ class DSourceEdit : SourceEdit { /// returns project import paths - if file from project is opened in current editor string[] importPaths() { if (_projectSourceFile) - return _projectSourceFile.project.sourcePaths ~ _projectSourceFile.project.builderSourcePaths; + return _projectSourceFile.project.importPaths; return null; } diff --git a/src/dlangide/workspace/project.d b/src/dlangide/workspace/project.d index 7d741fa..3d1f9df 100644 --- a/src/dlangide/workspace/project.d +++ b/src/dlangide/workspace/project.d @@ -259,6 +259,29 @@ class Project : WorkspaceItem { return _builderSourcePaths; } + private static void addUnique(ref string[] dst, string[] items) { + foreach(item; items) { + bool found = false; + foreach(existing; dst) { + if (item.equal(existing)) { + found = true; + break; + } + } + if (!found) + dst ~= item; + } + } + @property string[] importPaths() { + string[] res; + addUnique(res, sourcePaths); + addUnique(res, builderSourcePaths); + foreach(dep; _dependencies) { + addUnique(res, dep.sourcePaths); + } + return res; + } + string relativeToAbsolutePath(string path) { if (isAbsolute(path)) return path;