예제 #1
0
        private void FillMacros(string prefix, LiveTemplateMatcher.MatchResult matchResult)
        {
            _template.Fields.Clear();
            var appliedRules     = matchResult.ReMatchLeafs(prefix);
            var appliedSubsNames = new List <string>();

            foreach (var subst in appliedRules.Where(ar => ar.This is LeafRule.Substitution))
            {
                var rule = (LeafRule.Substitution)subst.This;
                if (!appliedSubsNames.Contains(rule.Name))
                {
                    appliedSubsNames.Add(rule.Name);

                    var macros = rule.Macros();
                    if (string.IsNullOrEmpty(macros))
                    {
                        macros = "complete()";
                    }
                    else
                    {
                        macros = macros.Replace("\\0", subst.Short);
                    }
                    Log.Trace("Place holder macro: {0}, {1}", macros, rule.Name);
                    _template.Fields.Add(new TemplateField(rule.Name, macros, 0));
                }
            }
        }
예제 #2
0
        private string FillText(string prefix, LiveTemplateMatcher.MatchResult matchResult)
        {
            var matchExpand = matchResult.Expand(prefix);

            Log.Trace("Template text: {0}", matchExpand);
            if (!string.IsNullOrEmpty(matchExpand))
            {
                _template.Text = matchExpand;
                _displayName   = matchResult.ExpandDisplay(prefix);

                FillMacros(prefix, matchResult);
            }
            return(matchExpand);
        }
예제 #3
0
 public static string ExpandDisplay(this LiveTemplateMatcher.MatchResult match, string prefix)
 {
     return(match.Expand(prefix).Replace("$END$", string.Empty));
 }