コード例 #1
0
            void ReportErrorInJSNode(SourceInfo sourceInfo, AstNode node, int code, string message)
            {
                if (sourceInfo.Diagnostics == null)
                {
                    sourceInfo.Diagnostics = new List <Diagnostic>();
                }
                var d = new Diagnostic
                {
                    Code      = code,
                    Text      = message,
                    IsError   = true,
                    StartLine = node.Start.Line,
                    StartCol  = node.Start.Column,
                    EndLine   = node.End.Line,
                    EndCol    = node.End.Column
                };

                sourceInfo.Diagnostics.Add(d);
            }
コード例 #2
0
    static void ProcessReplacements(SourceReplacer sourceReplacer, Njsast.Bobril.SourceInfo sourceInfo)
    {
        if (sourceInfo.VdomTranslations == null)
        {
            return;
        }
        foreach (var vdomTranslation in sourceInfo.VdomTranslations)
        {
            if (vdomTranslation.Message == null)
            {
                continue;
            }
            if (vdomTranslation.Replacements == null)
            {
                continue;
            }
            foreach (var rep in vdomTranslation.Replacements)
            {
                if (rep.Type == Njsast.Bobril.SourceInfo.ReplacementType.MoveToPlace)
                {
                    sourceReplacer.Move(rep.StartLine, rep.StartCol, rep.EndLine, rep.EndCol, rep.PlaceLine,
                                        rep.PlaceCol);
                }
                else
                {
                    var t = rep.Text;
                    if (rep.Type == Njsast.Bobril.SourceInfo.ReplacementType.MessageId)
                    {
                        t = JsonSerializer.Serialize(vdomTranslation.Message);
                    }

                    sourceReplacer.Replace(rep.StartLine, rep.StartCol, rep.EndLine, rep.EndCol,
                                           t ?? "");
                }
            }
        }
    }
コード例 #3
0
 public GatherTreeWalker(IConstEvalCtx evalCtx)
 {
     _evalCtxWithPath = evalCtx;
     _evalCtx         = evalCtx.StripPathResolver();
     SourceInfo       = new SourceInfo();
 }