/// <summary> /// If the dmd bin directory contains a 'dmd' or 'dmd2', /// check if phobos and/or core paths are existing, /// and add them to the ASTCache /// OR empirically update the directory paths /// </summary> public void TryAddImportPaths(bool UpdateOldPaths = true) { var defaultDmdDirname = Version == DVersion.D2? "dmd2":"dmd"; int k = BaseDirectory.IndexOf(defaultDmdDirname + '\\'); if (k > 0) { var dmdPath = BaseDirectory.Substring(0, k + defaultDmdDirname.Length); var dirs = new[] { @"src\phobos", @"src\druntime\import" }; bool DirAdded = false; // Check for phobos on both D1 and D2 foreach (var subPath in dirs) { var dir = Path.Combine(dmdPath, subPath); var wasUpdated = false; if (UpdateOldPaths && ASTCache.ParsedDirectories != null) { foreach (var pdir in ASTCache.ParsedDirectories.ToArray()) { if (wasUpdated = pdir.Contains(Path.Combine(defaultDmdDirname, subPath))) { ASTCache.ParsedDirectories.Remove(pdir); ASTCache.ParsedDirectories.Add(dir); } } } if (!wasUpdated && !ASTCache.ParsedDirectories.Contains(dir) && Directory.Exists(dir)) { DirAdded = true; ASTCache.ParsedDirectories.Add(dir); } } if (DirAdded) { ASTCache.BeginParse(); } } }
/// <summary> /// If the dmd bin directory contains a 'dmd' or 'dmd2', /// check if phobos and/or core paths are existing, /// and add them to the ASTCache /// OR empirically update the directory paths /// </summary> public void TryAddImportPaths() { var defaultDmdDirname = Version == DVersion.D2? "dmd2":"dmd"; int k = BaseDirectory.IndexOf(defaultDmdDirname + '\\'); if (k > 0) { var dmdPath = BaseDirectory.Substring(0, k + defaultDmdDirname.Length); var dirs = new[] { @"src\phobos", @"src\druntime\import" }; // Check for phobos on both D1 and D2 var newImports = new List <string>(); foreach (var subPath in dirs) { var dir = Path.Combine(dmdPath, subPath); if (ImportDirectories.Count != 0) { foreach (var pdir in ImportDirectories) { if (!pdir.Contains(Path.Combine(defaultDmdDirname, subPath))) { newImports.Add(dir); } } } } ImportDirectories.AddRange(newImports); if (newImports.Count != 0) { ReparseImportDirectories(); } } }