Ejemplo n.º 1
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();
        }
Ejemplo n.º 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 (!Path.IsPathRooted(error.FileName))
                    {
                        error.FileName = Project.GetAbsoluteChildPath(error.FileName);
                    }
                    br.Append(error);
                }
            }

            reader.Close();
        }
Ejemplo n.º 3
0
        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);
            }
        }