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); }
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 ?? ""); } } } }
public GatherTreeWalker(IConstEvalCtx evalCtx) { _evalCtxWithPath = evalCtx; _evalCtx = evalCtx.StripPathResolver(); SourceInfo = new SourceInfo(); }