From 06a88f417c656543c57aeda2234878a43933d564 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 22 Mar 2016 16:25:29 +0300 Subject: [PATCH] Uast: support beforeVisit() and afterVisit() in visitor --- plugins/uast-common/src/org/jetbrains/uast/UastVisitor.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/uast-common/src/org/jetbrains/uast/UastVisitor.kt b/plugins/uast-common/src/org/jetbrains/uast/UastVisitor.kt index 81ee36a9ad4..319ec19ac18 100644 --- a/plugins/uast-common/src/org/jetbrains/uast/UastVisitor.kt +++ b/plugins/uast-common/src/org/jetbrains/uast/UastVisitor.kt @@ -54,8 +54,12 @@ abstract class UastVisitor { open fun visitThisExpression(node: UThisExpression): Boolean = false open fun visitSuperExpression(node: USuperExpression): Boolean = false + open fun beforeVisit(node: UElement) {} + open fun afterVisit(node: UElement) {} + fun handle(node: UElement): Boolean { - return when (node) { + beforeVisit(node) + val result = when (node) { is UFile -> visitFile(node) is UClass -> visitClass(node) @@ -91,6 +95,8 @@ abstract class UastVisitor { is USuperExpression -> visitSuperExpression(node) else -> true } + afterVisit(node) + return result } open fun process(element: UElement) {