void Answer(string will, StringLiteralManager manager, IParseTree tree) { var statement = tree.CloseSt <JsParser.StatementContext>(); var message = factoryMessage .CreateMessage($"Заменить {manager.Value}? \r\n{statement.GetText()}") .AddAction( External.Models.AnswerType.Ok, () => { manager.Value = will; }) .GetMessage(); valueProvider.GetOutputMessages().Add(message); }
public override object VisitLiteral([NotNull] JsParser.LiteralContext context) { if (context.StringLiteral() == null) { return(null); } var manager = new StringLiteralManager(context); string id = manager.Value; if (id.Length <= 1) { return(null); } if (idsMap.ContainsKey(id)) { Answer(idsMap[id], manager, context); return(null); } var id2 = id.Substring(1); if (idsMap.ContainsKey(id2)) { string will = id[0] + idsMap[id2]; if (!id.StartsWith("#")) { Answer(will, manager, context); } else { manager.Value = will; } return(null); } var ids = idsMap.Keys; foreach (var item in ids) { if (id.IndexOf('#' + item) >= 0) { manager.Value = id.Replace(item, idsMap[item]); } } return(null); }
public override object VisitLiteral([NotNull] JsParser.LiteralContext context) { if (context.StringLiteral() == null) { return(null); } var manager = new StringLiteralManager(context); string name = manager.Value; if (name.Length <= 1) { return(null); } if (map.ContainsKey(name)) { Answer(map[name], manager, context); return(null); } var id2 = name.Substring(1); if (map.ContainsKey(id2)) { string will = "." + map[id2]; if (!name.StartsWith(".")) { Answer(will, manager, context); } else { manager.Value = will; } return(null); } var keys = map.Keys; foreach (var item in keys) { if (name.IndexOf('.' + item) >= 0) { manager.Value = name.Replace(item, map[item]); } } return(base.VisitLiteral(context)); }