A node filter that filters nodes for either a class body static initializer or instance initializer. In the static case only static members are passed, etc.
| 209 | * members are passed, etc. |
| 210 | */ |
| 211 | static class ClassNodeFilter implements BSHBlock.NodeFilter { |
| 212 | public static final int STATIC = 0, INSTANCE = 1, CLASSES = 2; |
| 213 | |
| 214 | public static ClassNodeFilter CLASSSTATIC = new ClassNodeFilter(STATIC); |
| 215 | public static ClassNodeFilter CLASSINSTANCE = new ClassNodeFilter(INSTANCE); |
| 216 | public static ClassNodeFilter CLASSCLASSES = new ClassNodeFilter(CLASSES); |
| 217 | |
| 218 | int context; |
| 219 | |
| 220 | |
| 221 | private ClassNodeFilter(int context) { |
| 222 | this.context = context; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | public boolean isVisible(SimpleNode node) { |
| 227 | if (context == CLASSES) return node instanceof BSHClassDeclaration; |
| 228 | |
| 229 | // Only show class decs in CLASSES |
| 230 | if (node instanceof BSHClassDeclaration) return false; |
| 231 | |
| 232 | if (context == STATIC) return isStatic(node); |
| 233 | |
| 234 | if (context == INSTANCE) return !isStatic(node); |
| 235 | |
| 236 | // ALL |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | |
| 241 | boolean isStatic(SimpleNode node) { |
| 242 | if (node instanceof BSHTypedVariableDeclaration) |
| 243 | return ((BSHTypedVariableDeclaration) node).modifiers != null && ((BSHTypedVariableDeclaration) node).modifiers.hasModifier("static"); |
| 244 | |
| 245 | if (node instanceof BSHMethodDeclaration) |
| 246 | return ((BSHMethodDeclaration) node).modifiers != null && ((BSHMethodDeclaration) node).modifiers.hasModifier("static"); |
| 247 | |
| 248 | // need to add static block here |
| 249 | if (node instanceof BSHBlock) return false; |
| 250 | |
| 251 | return false; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | |
| 256 | public static Object invokeSuperclassMethodImpl(BshClassManager bcm, Object instance, String methodName, Object[] args) throws UtilEvalError, ReflectError, InvocationTargetException { |
nothing calls this directly
no outgoing calls
no test coverage detected