public CreatePsiRuleContext(CreatePsiRuleTarget target) { myTarget = target; myAnchor = target.Anchor; myOffset = myAnchor.GetNavigationRange().TextRange.EndOffset; myDocument = myAnchor.GetSourceFile().Document; myRuleName = myTarget.Reference.GetTreeNode() as IRuleName; }
public static void ReplaceChild(ITreeNode parent, ITreeNode nameNode, string name) { if (name.IsEmpty()) { throw new ArgumentException("name shouldn't be empty", "name"); } using (WriteLockCookie.Create(parent.IsPhysical())) { IRuleName ruleName = PsiElementFactory.GetInstance(parent.GetPsiModule()).CreateIdentifierExpression(name); LowLevelModificationUtil.ReplaceChildRange(nameNode, nameNode, ruleName.FirstChild); } }
public override void VisitRuleName(IRuleName ruleName, IHighlightingConsumer consumer) { DocumentRange colorConstantRange = ruleName.GetDocumentRange(); ResolveResultWithInfo resolve = ruleName.RuleNameReference.Resolve(); bool isRuleResolved = resolve.Result.DeclaredElement != null || (resolve.Result.Candidates.Count > 0); if (isRuleResolved) { AddHighLighting(colorConstantRange, ruleName, consumer, new PsiRuleHighlighting(ruleName)); } else { AddHighLighting(colorConstantRange, ruleName, consumer, new PsiUnresolvedRuleReferenceHighlighting(ruleName)); } base.VisitRuleName(ruleName, consumer); }