Esempio n. 1
0
 public ConfigBuilder(ImportLog log, EscapingOptions escaping)
 {
     this.log      = log;
     this.escaping = escaping;
 }
Esempio n. 2
0
        private static void ValidateFirstHeaderRegex(List <SyntaxAnalysis.NodeRegex> regexps, ImportLog log)
        {
            var first = regexps.First();

            if ((first.Flags & SyntaxAnalysis.NodeRegexFlags.IsNotSpecific) != 0)
            {
                log.AddMessage(ImportLog.MessageType.FirstRegexIsNotSpecific, ImportLog.MessageSeverity.Error)
                .AddText("LogJoint can not match layouts that start from")
                .AddCustom(first.AddLinkToSelf)
                .AddText(". Start your layout with a specific renderer like ${longdate}.");
                log.FailIfThereIsError();
            }
        }
Esempio n. 3
0
 private static void ReportUnknownRenderers(List <SyntaxAnalysis.NodeRegex> regexps, ImportLog log)
 {
     foreach (var unknown in regexps.Where(re => (re.Flags & SyntaxAnalysis.NodeRegexFlags.IsUnknownRenderer) != 0))
     {
         log.AddMessage(ImportLog.MessageType.UnknownRenderer, ImportLog.MessageSeverity.Warn)
         .AddText("Unknown renderer")
         .AddCustom(unknown.AddLinkToSelf)
         .AddText("ignored");
     }
 }
Esempio n. 4
0
        private static void ReportMatchabilityProblems(List <SyntaxAnalysis.NodeRegex> regexps, ImportLog log)
        {
            Func <int, bool> isSpecificByIdx = i =>
                                               i >= 0 && i < regexps.Count && (regexps[i].Flags & SyntaxAnalysis.NodeRegexFlags.IsNotSpecific) == 0;

            Action <int> markAsMakingPreviousCapturable = i =>
            {
                if (i >= 0 && i < regexps.Count)
                {
                    var tmp = regexps[i];
                    tmp.Flags |= SyntaxAnalysis.NodeRegexFlags.MakesPreviousCapturable;
                    regexps[i] = tmp;
                }
            };

            for (int i = 0; i < regexps.Count; ++i)
            {
                var re = regexps[i];
                if ((re.Flags & SyntaxAnalysis.NodeRegexFlags.RepresentationMask) != 0 &&
                    (re.Flags & SyntaxAnalysis.NodeRegexFlags.IsNotSpecific) != 0)
                {
                    bool isPreceededBySpecific               = isSpecificByIdx(i - 1);
                    bool isFollowedBySpecific                = isSpecificByIdx(i + 1);
                    bool isSurroundedBySpecificNodes         = isPreceededBySpecific && isFollowedBySpecific;
                    bool isNotSurroundedBySpecificNodes      = !isSurroundedBySpecificNodes;
                    bool representsFieldThatCanBeNotSpecific =
                        (re.Flags & SyntaxAnalysis.NodeRegexFlags.RepresentationMask) == SyntaxAnalysis.NodeRegexFlags.RepresentsThread;
                    bool representsFieldThatMustBeSpecific = !representsFieldThatCanBeNotSpecific;
                    if (isNotSurroundedBySpecificNodes || representsFieldThatMustBeSpecific)
                    {
                        var warn = log.AddMessage(ImportLog.MessageType.RendererIgnored, ImportLog.MessageSeverity.Warn);
                        warn
                        .AddText("Renderer")
                        .AddCustom(re.AddLinkToSelf)
                        .AddText("can not be matched and as such ignored.");
                        if (re.WrapperThatMakesRegexNotSpecific != null)
                        {
                            var wrap = re.WrapperThatMakesRegexNotSpecific.Value;
                            warn
                            .AddText("Renderer is not matchable because of")
                            .AddCustom(wrap.AddLinkToSelf);
                        }

                        re.Flags   = re.Flags & ~SyntaxAnalysis.NodeRegexFlags.RepresentationMask;
                        regexps[i] = re;
                    }
                    if (representsFieldThatCanBeNotSpecific && isSurroundedBySpecificNodes)
                    {
                        markAsMakingPreviousCapturable(i + 1);
                    }
                }
            }
        }