Beispiel #1
0
 public static ParseCacheView CreateCacheList(AbstractDProject Project = null)
 {
     if (Project != null)
         return Project.ParseCache;
     else
         return DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView();
 }
Beispiel #2
0
		/// <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();
		}
Beispiel #3
0
		public DustMiteArgDlg (AbstractDProject prj)
		{
			this.Project = prj;
			this.Build ();
			ResetDustmiteCmd ();
			ResetBuildCommand ();
		}
Beispiel #4
0
		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;
		}
        /// <summary>
        /// Returns all libs that are included by default both by the compiler and this specific build config
        /// </summary>
        public IEnumerable <string> GetReferencedLibraries(ConfigurationSelector configSelector)
        {
            foreach (var i in Project.Compiler.DefaultLibraries)
            {
                yield return(i);
            }
            foreach (var i in ExtraLibraries)
            {
                yield return(i);
            }

            bool takeDefSelector = configSelector == null;

            foreach (var dep_ in AbstractDProject.GetSortedProjectDependencies(Project, configSelector))
            {
                var dep = dep_ as DProject;
                if (dep == null || dep == Project)
                {
                    continue;
                }

                if (takeDefSelector)
                {
                    configSelector = dep.DefaultConfiguration.Selector;
                }

                var activeConfig = dep.GetConfiguration(configSelector) as DProjectConfiguration;

                if (activeConfig != null)
                {
                    if (activeConfig.CompileTarget == DCompileTarget.StaticLibrary)
                    {
                        yield return(dep.GetOutputFileName(configSelector));
                    }
                    // Assume there is an import lib inside the dll's output directory and add it to the linked-in libs
                    // https://github.com/aBothe/Mono-D/issues/180
                    else if (OS.IsWindows &&
                             activeConfig.CompileTarget == DCompileTarget.SharedLibrary)
                    {
                        var lib = Path.ChangeExtension(dep.GetOutputFileName(configSelector), DCompilerService.StaticLibraryExtension);
                        if (File.Exists(lib))
                        {
                            yield return(lib);
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public static ParseCacheList CreateCacheList(AbstractDProject Project = null)
        {
            if (Project != null)
            {
                var pcl = ParseCacheList.Create(Project.LocalFileCache, Project.LocalIncludeCache, Project.Compiler.ParseCache);

                // Automatically include dep projects' caches
                foreach (var dep in Project.GetReferencedItems(IdeApp.Workspace.ActiveConfiguration))
                    if (dep is AbstractDProject)
                        pcl.Add((dep as AbstractDProject).LocalFileCache);

                return pcl;
            }
            else
                return ParseCacheList.Create(DCompilerService.Instance.GetDefaultCompiler().ParseCache);
        }
		public DProjectReference (AbstractDProject Owner, ReferenceType refType, string reference)
		{
			OwnerProject = Owner;
			ReferenceType = refType;
			this.reference = reference;
		}
 protected DProjectReferenceCollection(AbstractDProject owner)
 {
     this.owner = new WeakReference(owner);
     includeMacros = new LocalIncludesMacroProvider (this.owner);
 }
Beispiel #9
0
		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 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);
		}
Beispiel #11
0
		protected override void Update (CommandInfo info)
		{
			prj = Ide.IdeApp.ProjectOperations.CurrentSelectedItem as AbstractDProject;
			info.Bypass = prj != null;
			base.Update (info);
		}
Beispiel #12
0
		public static void HandleOptLinkOutput(AbstractDProject Project,BuildResult br, string linkerOutput)
		{
			var ctxt = ResolutionContext.Create(DResolverWrapper.CreateParseCacheView(Project), null, null);

			ctxt.ContextIndependentOptions =
				ResolutionOptions.IgnoreAllProtectionAttributes |
				ResolutionOptions.DontResolveBaseTypes |
				ResolutionOptions.DontResolveBaseClasses |
				ResolutionOptions.DontResolveAliases;

			foreach (Match match in optlinkRegex.Matches(linkerOutput))
			{
				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 = 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);
			}
		}
Beispiel #13
0
 public void AnalyseTraceFile(AbstractDProject project)
 {
     TraceParser.Clear();
     if(ProfilerModeHandler.IsProfilerMode)
         TraceParser.Parse(project);
 }
 protected DProjectReferenceCollection(AbstractDProject owner)
 {
     this.owner    = new WeakReference(owner);
     includeMacros = new LocalIncludesMacroProvider(this.owner);
 }
Beispiel #15
0
		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);
			}
		}
Beispiel #16
0
        public void Parse(AbstractDProject project)
        {
            var file = TraceLogFile(project);
            if(file == null)
            {
                profilerPadWidget.AddTracedFunction(0,0,0,0,new DVariable{Name = "trace.log not found.."});
                return;
            }

            lastProfiledProject = project;
            profilerPadWidget.ClearTracedFunctions();

            var ctxt = ResolutionContext.Create(project.ParseCache, null, null);

            StreamReader reader = File.OpenText(file);
            string line;
            while ((line = reader.ReadLine()) != null) {
                var m = traceFuncRegex.Match(line);

                if (m.Success)
                {
                    var symName = m.Groups[5].Value;

                    if(symName.StartsWith("="))
                        continue;

                    bool mightBeLegalUnresolvableSymbol;
                    var dn = ExamTraceSymbol(symName, ctxt, out mightBeLegalUnresolvableSymbol);

                    if(dn != null || mightBeLegalUnresolvableSymbol)
                        profilerPadWidget.AddTracedFunction(long.Parse(m.Groups[1].Value), long.Parse(m.Groups[2].Value),
                                                            long.Parse(m.Groups[3].Value), long.Parse(m.Groups[4].Value), dn ?? new DVariable{Name = symName});
                }
            }
        }
Beispiel #17
0
        public static string TraceLogFile(AbstractDProject project)
        {
            if(project == null)
                return null;

            string file = project.GetOutputFileName(Ide.IdeApp.Workspace.ActiveConfiguration).ParentDirectory.Combine("trace.log");
            return File.Exists (file) ? file : null;
        }
 public static DModule GetFileSyntaxTree(string file, out AbstractDProject OwnerProject)
 {
     OwnerProject = IdeApp.Workbench.ActiveDocument.Project as AbstractDProject;
     return GlobalParseCache.GetModule(file);
 }
Beispiel #19
0
        /// <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();
        }