internal void AddProject(AbstractDProject sub) { var folder = sub.BaseDirectory == BaseDirectory || sub.BaseDirectory.IsChildPathOf (BaseDirectory) ? RootFolder : ExternalDepFolder; if (folder == ExternalDepFolder && sub is DubProject) { var packageName = (sub as DubProject).packageName.Split(':'); for (int i = 0; i < packageName.Length - 1; i++) { bool foundSubFolder = false; foreach (var subFolder in folder.GetAllItems<SolutionFolder>()) { if (String.Equals (subFolder.Name, packageName [i], StringComparison.CurrentCultureIgnoreCase)) { folder = subFolder; foundSubFolder = true; break; } } if (!foundSubFolder) { var newSubFolder = new SolutionFolder{ Name = packageName [i] }; folder.AddItem (newSubFolder); folder = newSubFolder; } } } if (!folder.Items.Contains (sub)) folder.AddItem (sub, false); }
public DustMiteArgDlg(AbstractDProject prj) { this.Project = prj; this.Build(); ResetDustmiteCmd(); ResetBuildCommand(); }
/// <summary> /// Scans errorString line-wise for filename-line-message patterns (e.g. "myModule(1): Something's wrong here") and add these error locations to the CompilerResults cr. /// </summary> public static void HandleCompilerOutput(AbstractDProject Project, BuildResult br, string errorString) { var reader = new StringReader(errorString); string next; while ((next = reader.ReadLine()) != null) { var error = ErrorExtracting.FindError(next, reader); if (error != null) { if (error.ErrorText != null && error.ErrorText.Length > MaxErrorMsgLength) { error.ErrorText = error.ErrorText.Substring(0, MaxErrorMsgLength) + "..."; } // dmd's error filenames may contain mixin location info var m = mixinInlineRegex.Match(error.FileName); if (m.Success) { error.FileName = error.FileName.Substring(0, m.Index); int line; int.TryParse(m.Groups ["line"].Value, out line); error.Line = line; } if (!Path.IsPathRooted(error.FileName)) { error.FileName = Project.GetAbsoluteChildPath(error.FileName); } br.Append(error); } } reader.Close(); }
internal void AddProject(AbstractDProject sub) { var folder = !sub.BaseDirectory.IsChildPathOf (BaseDirectory) ? ExternalDepFolder : RootFolder; if (!folder.Items.Contains (sub)) folder.AddItem (sub, false); }
public static string GetDubFilePath(AbstractDProject @base, string subPath) { var sub = @base as DubSubPackage; if (sub != null) { sub.useOriginalBasePath = true; } var packageDir = @base.GetAbsPath(Building.ProjectBuilder.EnsureCorrectPathSeparators(subPath)); if (sub != null) { sub.useOriginalBasePath = false; } string dubFileToLoad; if (File.Exists(dubFileToLoad = Path.Combine(packageDir, PackageJsonFile)) || File.Exists(dubFileToLoad = Path.Combine(packageDir, DubJsonFile)) || File.Exists(dubFileToLoad = Path.Combine(packageDir, DubSdlFile))) { return(dubFileToLoad); } return(string.Empty); }
internal void AddProject(AbstractDProject sub) { var folder = sub.BaseDirectory == BaseDirectory || sub.BaseDirectory.IsChildPathOf(BaseDirectory) ? RootFolder : ExternalDepFolder; if (folder == ExternalDepFolder && sub is DubProject) { var packageName = (sub as DubProject).packageName.Split(':'); for (int i = 0; i < packageName.Length - 1; i++) { bool foundSubFolder = false; foreach (var subFolder in folder.GetAllItems <SolutionFolder>()) { if (String.Equals(subFolder.Name, packageName [i], StringComparison.CurrentCultureIgnoreCase)) { folder = subFolder; foundSubFolder = true; break; } } if (!foundSubFolder) { var newSubFolder = new SolutionFolder { Name = packageName [i] }; folder.AddItem(newSubFolder); folder = newSubFolder; } } } if (!folder.Items.Contains(sub)) { folder.AddItem(sub, false); } }
public static DModule GetFileSyntaxTree(string file, out AbstractDProject OwnerProject) { var doc = IdeApp.Workbench.ActiveDocument; OwnerProject = doc.Project as AbstractDProject; var dparsedDoc = doc.ParsedDocument as MonoDevelop.D.Parser.ParsedDModule; return(dparsedDoc != null ? dparsedDoc.DDom : GlobalParseCache.GetModule(file)); }
public static ParseCacheView CreateCacheList(AbstractDProject Project = null) { if (Project != null) { return(Project.ParseCache); } else { return(DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView()); } }
public static string GetDubJsonFilePath(AbstractDProject @base,string subPath) { var sub = @base as DubSubPackage; if (sub != null) sub.useOriginalBasePath = true; var packageDir = @base.GetAbsPath(Building.ProjectBuilder.EnsureCorrectPathSeparators(subPath)); if(sub != null) sub.useOriginalBasePath = false; string packageJsonToLoad; if (File.Exists (packageJsonToLoad = Path.Combine (packageDir, PackageJsonFile)) || File.Exists (packageJsonToLoad = Path.Combine (packageDir, DubJsonFile))) return packageJsonToLoad; return null; }
/// <summary> /// Scans errorString line-wise for filename-line-message patterns (e.g. "myModule(1): Something's wrong here") and add these error locations to the CompilerResults cr. /// </summary> public static void HandleCompilerOutput(AbstractDProject Project, BuildResult br, string errorString) { var reader = new StringReader(errorString); string next; while ((next = reader.ReadLine()) != null) { var error = ErrorExtracting.FindError(next, reader); if (error != null) { if (!Path.IsPathRooted(error.FileName)) { error.FileName = Project.GetAbsoluteChildPath(error.FileName); } br.Append(error); } } reader.Close(); }
public static void HandleLdOutput(AbstractDProject prj, BuildResult br, string linkerOutput) { var ctxt = ResolutionContext.Create(DResolverWrapper.CreateParseCacheView(prj), null, null); ctxt.ContextIndependentOptions = ResolutionOptions.IgnoreAllProtectionAttributes | ResolutionOptions.DontResolveBaseTypes | ResolutionOptions.DontResolveBaseClasses | ResolutionOptions.DontResolveAliases; foreach (Match m in ldErrorRegex.Matches(linkerOutput)) { var error = new BuildError(); var firstSymbolOccurring = ldMangleRegex.Match(m.Groups["err"].Value); if (firstSymbolOccurring.Success) { var mangledString = "_D" + firstSymbolOccurring.Groups["mangle"].Value; var associatedSymbol = DResolver.GetResultMember(Demangler.DemangleAndResolve(mangledString, ctxt)); if (associatedSymbol != null) { error.FileName = (associatedSymbol.NodeRoot as DModule).FileName; error.Line = associatedSymbol.Location.Line; error.Column = associatedSymbol.Location.Column; } } error.ErrorText = m.Groups["msg"].Value; if (string.IsNullOrWhiteSpace(error.ErrorText)) { error.ErrorText = m.Groups["err"].Value; } error.ErrorText = DemangleLdOutput(error.ErrorText); br.Append(error); } }
public static string FindTraceLogFileName(AbstractDProject project) { if (project == null) { return(null); } var file = project.GetAbsPath(trace_log); if (File.Exists(file)) { return(file); } file = project.GetOutputFileName(Ide.IdeApp.Workspace.ActiveConfiguration).ParentDirectory.Combine(trace_log); if (File.Exists(file)) { return(file); } return(null); }
static void ExtractVersionDebugConstantsFromProject(AbstractDProject prj, List <string> versions, List <string> debugConstants) { var cfg = prj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); if (cfg is DProjectConfiguration) { var dcfg = cfg as DProjectConfiguration; if (dcfg.CustomDebugIdentifiers != null) { debugConstants.AddRange(dcfg.CustomDebugIdentifiers); } if (dcfg.GlobalVersionIdentifiers != null) { versions.AddRange(dcfg.GlobalVersionIdentifiers); } } else if (cfg is DubProjectConfiguration) { var dcfg = cfg as DubProjectConfiguration; HandleDubSettingsConditionExtraction(versions, (dcfg.ParentItem as DubProject).CommonBuildSettings); HandleDubSettingsConditionExtraction(versions, dcfg.BuildSettings); } }
public DProjectReference(AbstractDProject Owner, ReferenceType refType, string reference) { OwnerProject = Owner; ReferenceType = refType; this.reference = reference; }
static IEnumerable <SearchResult> FindReferences( AbstractDProject project, INode member, ISearchProgressMonitor monitor = null) { var searchResults = new List <SearchResult>(); var parseCache = project != null ? project.ParseCache : DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView(); var modules = new List <DModule>(); if (project != null) { foreach (var p in project.GetSourcePaths(IdeApp.Workspace.ActiveConfiguration)) { modules.AddRange(GlobalParseCache.EnumModulesRecursively(p, null)); } } else { modules.Add((IdeApp.Workbench.ActiveDocument.ParsedDocument as MonoDevelop.D.Parser.ParsedDModule).DDom); } if (monitor != null) { monitor.BeginStepTask("Scan for references", modules.Count, 1); } List <ISyntaxRegion> references = null; var ctxt = ResolutionContext.Create(parseCache, null); foreach (var mod in modules) { if (mod == null) { continue; } try { references = ReferencesFinder.Scan(mod, member, ctxt).ToList(); if (references.Count < 1) { if (monitor != null) { monitor.Step(1); } continue; } // Sort the references by code location references.Sort(new IdLocationComparer()); // Get actual document code var targetDoc = TextFileProvider.Instance.GetTextEditorData(new FilePath(mod.FileName)); foreach (var reference in references) { CodeLocation loc; if (reference is AbstractTypeDeclaration) { loc = ((AbstractTypeDeclaration)reference).NonInnerTypeDependendLocation; } else if (reference is IExpression) { loc = reference.Location; } else { continue; } searchResults.Add(new SearchResult(new FileProvider(mod.FileName, project), targetDoc.LocationToOffset(loc.Line, loc.Column), member.Name.Length)); } } catch (Exception ex) { LoggingService.LogWarning("Error during reference search", ex); } if (monitor != null) { monitor.Step(1); } } if (monitor != null) { monitor.EndTask(); } return(searchResults); }
public static void HandleOptLinkOutput(AbstractDProject Project, BuildResult br, string linkerOutput) { var matches = optlinkRegex.Matches(linkerOutput); var ctxt = ResolutionContext.Create(Project == null ? DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView() : Project.ParseCache, null, null); ctxt.ContextIndependentOptions = ResolutionOptions.IgnoreAllProtectionAttributes | ResolutionOptions.DontResolveBaseTypes | ResolutionOptions.DontResolveBaseClasses | ResolutionOptions.DontResolveAliases; foreach (Match match in matches) { var error = new BuildError(); // Get associated D source file if (match.Groups["obj"].Success) { var obj = Project.GetAbsoluteChildPath(new FilePath(match.Groups["obj"].Value)).ChangeExtension(".d"); foreach (var pf in Project.Files) { if (pf.FilePath == obj) { error.FileName = pf.FilePath; break; } } } var msg = match.Groups["message"].Value; var symUndefMatch = symbolUndefRegex.Match(msg); if (symUndefMatch.Success && symUndefMatch.Groups["mangle"].Success) { var mangledSymbol = symUndefMatch.Groups["mangle"].Value; ITypeDeclaration qualifier; try { var resSym = D_Parser.Misc.Mangling.Demangler.DemangleAndResolve(mangledSymbol, ctxt, out qualifier); if (resSym is DSymbol) { var ds = resSym as DSymbol; var ast = ds.Definition.NodeRoot as DModule; if (ast != null) { error.FileName = ast.FileName; } error.Line = ds.Definition.Location.Line; error.Column = ds.Definition.Location.Column; msg = ds.Definition.ToString(false, true); } else { msg = qualifier.ToString(); } } catch (Exception ex) { msg = "<log analysis error> " + ex.Message; } error.ErrorText = msg + " could not be resolved - library reference missing?"; } else { error.ErrorText = "Linker error " + match.Groups["code"].Value + " - " + msg; } br.Append(error); } }
protected override void Update(CommandInfo info) { prj = Ide.IdeApp.ProjectOperations.CurrentSelectedItem as AbstractDProject; info.Bypass = prj != null; base.Update(info); }
public ObjectValue Resolve(ulong offset, string symbolname, string typename, string val, DEW.DebugScopedSymbol parentsymbol) { DModule module; int codeLine; INode variableNode = null; // Search currently scoped module string file = ""; uint line = 0; Engine.Symbols.GetLineByOffset(Engine.CurrentInstructionOffset, out file, out line); codeLine = (int)line; if (string.IsNullOrWhiteSpace(file)) { return(null); } AbstractDProject dproj = null; module = GetFileSyntaxTree(file, out dproj); // If syntax tree built, search the variable location if (module != null) { var ed = Resolver.DResolverWrapper.CreateEditorData(IdeApp.Workbench.ActiveDocument); var ctxt = ResolutionContext.Create(ed, false); CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () => { var loc = new CodeLocation(0, codeLine); ctxt.Push(DResolver.SearchBlockAt(module, loc), loc); AbstractType[] res; if (parentsymbol != null) { var parentres = ResolveParentSymbol(parentsymbol, ctxt); res = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(symbolname, parentres, ctxt, null); } else { res = TypeDeclarationResolver.ResolveIdentifier(symbolname, ctxt, null); } if (res != null && res.Length > 0 && res[0] is DSymbol) { variableNode = (res[0] as DSymbol).Definition; } }); } // Set type string string _typeString = typename; if (variableNode != null) { var t = variableNode.Type; if (t != null) { _typeString = t.ToString(); } } // Set value string string _valueString = val; ObjectValueFlags flags = ObjectValueFlags.Variable; if (variableNode != null) { ITypeDeclaration curValueType = variableNode.Type; if (curValueType != null) { if (!IsBasicType(curValueType)) { if (_typeString == "string") //TODO: Replace this by searching the alias definition in the cache { curValueType = new ArrayDecl() { InnerDeclaration = new DTokenDeclaration(DTokens.Char) } } ; else if (_typeString == "wstring") { curValueType = new ArrayDecl() { InnerDeclaration = new DTokenDeclaration(DTokens.Wchar) } } ; else if (_typeString == "dstring") { curValueType = new ArrayDecl() { InnerDeclaration = new DTokenDeclaration(DTokens.Dchar) } } ; if (IsArray(curValueType)) { flags = ObjectValueFlags.Array; var clampDecl = curValueType as ArrayDecl; var valueType = clampDecl.InnerDeclaration; if (valueType is DTokenDeclaration) { bool IsString = false; uint elsz = 0; var realType = DetermineArrayType((valueType as DTokenDeclaration).Token, out elsz, out IsString); var arr = Engine.Symbols.ReadArray(offset, realType, elsz); if (arr != null) { _valueString = BuildArrayContentString(arr, IsString); } } } else { flags = ObjectValueFlags.Object; } } } } return(ObjectValue.CreatePrimitive(ObjectValueSource, new ObjectPath(symbolname), _typeString, new EvaluationResult(_valueString), flags)); }