1 package no.uio.ifi.refaktor.analyze.checkers;
3 import no.uio.ifi.refaktor.analyze.CollectorManager;
4 import no.uio.ifi.refaktor.analyze.collectors.PropertyCollector;
5 import no.uio.ifi.refaktor.analyze.exceptions.IllegalExpressionFoundException;
6 import no.uio.ifi.refaktor.analyze.exceptions.IllegalStatementFoundException;
7 import no.uio.ifi.refaktor.textselection.CompilationUnitTextSelection;
9 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
10 import org.eclipse.jdt.core.dom.ITypeBinding;
11 import org.eclipse.jdt.core.dom.Modifier;
13 // TODO: file bug report
14 class InstantiationOfNonStaticInnerClassChecker extends PropertyCollector implements Checker {
16 public InstantiationOfNonStaticInnerClassChecker(CompilationUnitTextSelection selection) {
21 public boolean visit(ClassInstanceCreation node) {
22 if (!nodeInSelection(node))
25 if (typeIsNonStaticInnerClass(node))
26 throw new IllegalExpressionFoundException(node);
31 private boolean typeIsNonStaticInnerClass(ClassInstanceCreation node) {
32 ITypeBinding typeBinding = node.getType().resolveBinding();
33 assert typeBinding != null;
34 return typeBinding.isMember() && !Modifier.isStatic(typeBinding.getModifiers());
38 public void check() throws IllegalStatementFoundException, IllegalExpressionFoundException {
39 CollectorManager.collectProperties(selection, this);
43 public void clearData() {