예제 #1
0
        public static string Format(AphidExpression statement, string name)
        {
            if (statement == null ||
                string.IsNullOrWhiteSpace(statement.Code) ||
                statement.Index < 0)
            {
                return(null);
            }

            var code = TokenHelper.GetCodeExcerpt(
                statement.Code
                .Insert(statement.Index + statement.Length, End)
                .Insert(statement.Index, Start),
                statement.Index + Start.Length,
                AphidConfig.Current.FrameExcerptLines / 2);

            var highlighted = SyntaxHighlightingFormatter.Format(code);

            return(!string.IsNullOrWhiteSpace(highlighted) ? highlighted : null);
        }
예제 #2
0
 public static IEnumerable <Lazy <string> > Format(
     AphidInterpreter interpreter,
     AphidPair[] locals,
     List <AphidObject> scopes,
     int index = 0) =>
 locals
 .Select(x => new Lazy <string>(() =>
                                LineNumberFormatter.PrefixIndex(index++,
                                                                SyntaxHighlightingFormatter.Format(
                                                                    string.Format(
                                                                        "{0} {1} = {2}",
                                                                        AphidCli.GetAphidObjectTypeName(x.Value),
                                                                        x.Key,
                                                                        SerializingFormatter.Format(
                                                                            interpreter,
                                                                            x.Value,
                                                                            ignoreNull: false,
                                                                            ignoreClrObj: false,
                                                                            scopes: scopes)
                                                                        .Indent(new string(' ', 5))
                                                                        .TrimStart())))));