private ITreeNode CreateExpression(string format, string name) { var node = CreateParser(name + "\n" + ":" + name + "\n" + ";").ParsePsiFile(false) as IPsiFile; if (node == null) { throw new ElementFactoryException(string.Format("Cannot create expression '{0}'", format)); } SandBox.CreateSandBoxFor(node, myModule); var ruleDeclaration = node.FirstChild as IRuleDeclaration; if (ruleDeclaration != null) { IRuleBody ruleBody = ruleDeclaration.Body; ITreeNode child = ruleBody.FirstChild; while (child != null && !(child is IPsiExpression)) { child = child.NextSibling; } while (child != null && !(child is IRuleName)) { child = child.FirstChild; } if (child != null) { return(child); } } throw new ElementFactoryException(string.Format("Cannot create expression '{0}'" + name, format)); }
public override void VisitRuleDeclaration(IRuleDeclaration ruleDeclaration, IHighlightingConsumer consumer) { IRuleBody body = ruleDeclaration.Body; ITreeNode child = PsiTreeUtil.GetFirstChild <IRuleName>(body); var ruleName = child as IRuleName; if (ruleName != null) { if (ruleName.GetText().Equals(ruleDeclaration.DeclaredName)) { consumer.AddHighlighting(new LeftRecursionWarning(ruleName), File); } } base.VisitRuleDeclaration(ruleDeclaration, consumer); }
public override string VisitRuleBody(IRuleBody ruleBodyParam, FormattingStageContext context) { string parentIndent = GetParentIndent(context.Parent); return(parentIndent + StandartIndent); }
public override IEnumerable <string> VisitRuleBody(IRuleBody ruleBodyParam, PsiFmtStageContext context) { return(new[] { " " }); }