From 7f6bb0873d090fc975af67ed2dd845a6bc536340 Mon Sep 17 00:00:00 2001 From: peter Date: Sat, 30 Oct 2010 16:44:27 +0400 Subject: [PATCH] TreeElementPattern.withParents --- .../com/intellij/patterns/TreeElementPattern.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/platform/platform-api/src/com/intellij/patterns/TreeElementPattern.java b/platform/platform-api/src/com/intellij/patterns/TreeElementPattern.java index ba7d7b15478c..c4fb4a387d62 100644 --- a/platform/platform-api/src/com/intellij/patterns/TreeElementPattern.java +++ b/platform/platform-api/src/com/intellij/patterns/TreeElementPattern.java @@ -42,6 +42,21 @@ public abstract class TreeElementPattern... types) { + return with(new PatternCondition("withParents") { + @Override + public boolean accepts(@NotNull T t, ProcessingContext context) { + ParentType current = getParent(t); + for (Class type : types) { + if (current == null || !type.isInstance(current)) { + return false; + } + current = getParent(current); + } + return true; + } + }); + } public Self withParent(@NotNull final Class type) { return withParent(StandardPatterns.instanceOf(type)); }