use of org.autorefactor.util.NotImplementedException in project AutoRefactor by JnRouvignac.
the class RemoveUnneededThisExpressionRefactoring method thisExpressionRefersToEnclosingType.
private static boolean thisExpressionRefersToEnclosingType(Name thisQualifierName, ASTNode node) {
if (thisQualifierName == null) {
return true;
}
final ASTNode enclosingType = getEnclosingType(node);
if (enclosingType instanceof AnonymousClassDeclaration) {
return false;
}
final AbstractTypeDeclaration ancestor = (AbstractTypeDeclaration) enclosingType;
if (thisQualifierName instanceof SimpleName) {
return isEqual((SimpleName) thisQualifierName, ancestor.getName());
} else if (thisQualifierName instanceof QualifiedName) {
final QualifiedName qn = (QualifiedName) thisQualifierName;
return isEqual(qn.getName(), ancestor.getName()) && thisExpressionRefersToEnclosingType(qn.getQualifier(), ancestor);
}
throw new NotImplementedException(thisQualifierName);
}
use of org.autorefactor.util.NotImplementedException in project AutoRefactor by JnRouvignac.
the class RemoveUnneededThisExpressionRefactoring method isCallingMethodDeclaredInEnclosingType.
private boolean isCallingMethodDeclaredInEnclosingType(MethodInvocation node) {
final ASTNode currentType = getEnclosingType(node);
final IMethodBinding mb = node.resolveMethodBinding();
if (currentType instanceof AnonymousClassDeclaration) {
final AnonymousClassDeclaration c = (AnonymousClassDeclaration) currentType;
final ITypeBinding enclosingTypeBinding = c.resolveBinding();
return enclosingTypeBinding.isSubTypeCompatible(mb.getDeclaringClass());
} else if (currentType instanceof AbstractTypeDeclaration) {
final AbstractTypeDeclaration ed = (AbstractTypeDeclaration) currentType;
final ITypeBinding enclosingTypeBinding = ed.resolveBinding();
return enclosingTypeBinding.isSubTypeCompatible(mb.getDeclaringClass());
}
throw new NotImplementedException(node, node);
}
use of org.autorefactor.util.NotImplementedException in project AutoRefactor by JnRouvignac.
the class PreferenceInitializer method initializeDefaultPreferences.
@Override
public void initializeDefaultPreferences() {
// TODO initialize preferences from the JDT preferences like:
// code style/cleanup/formatting
final IPreferenceStore store = AutoRefactorPlugin.getDefault().getPreferenceStore();
for (PreferenceConstants preference : PreferenceConstants.values()) {
final String name = preference.getName();
final Object defaultValue = preference.getDefaultValue();
if (defaultValue instanceof Boolean) {
store.setDefault(name, (Boolean) defaultValue);
} else if (defaultValue instanceof Integer) {
store.setDefault(name, (Integer) defaultValue);
} else if (defaultValue instanceof Long) {
store.setDefault(name, (Long) defaultValue);
} else if (defaultValue instanceof Double) {
store.setDefault(name, (Double) defaultValue);
} else if (defaultValue instanceof Float) {
store.setDefault(name, (Float) defaultValue);
} else if (defaultValue instanceof String) {
store.setDefault(name, (String) defaultValue);
} else {
throw new NotImplementedException(null, defaultValue);
}
}
for (RefactoringRule refactoringRule : AllRefactoringRules.getAllRefactoringRules()) {
store.setDefault(refactoringRule.getClass().getCanonicalName(), refactoringRule.isByDefault());
}
}
use of org.autorefactor.util.NotImplementedException in project AutoRefactor by JnRouvignac.
the class AbstractUnitTestRefactoring method invokeFail.
private MethodInvocation invokeFail(final ASTNode node, final MethodInvocation originalMethod, final Expression failureMessage) {
final ASTBuilder b = this.ctx.getASTBuilder();
final List<Expression> args = arguments(originalMethod);
if ((args.size() == 1) || (args.size() == 2)) {
return invokeMethod(b, originalMethod, "fail", null, null, failureMessage);
} else {
throw new NotImplementedException(node);
}
}
use of org.autorefactor.util.NotImplementedException in project AutoRefactor by JnRouvignac.
the class RemoveSemiColonRefactoring method visit.
private boolean visit(BodyDeclaration node) {
final BodyDeclaration nextSibling = getNextSibling(node);
final ASTNode parent = node.getParent();
if (nextSibling != null) {
return removeSuperfluousSemiColons(node, getEndPosition(node), nextSibling.getStartPosition());
} else if (parent instanceof AbstractTypeDeclaration) {
final AbstractTypeDeclaration typeDecl = (AbstractTypeDeclaration) parent;
return removeSuperfluousSemiColons(node, getEndPosition(node), getEndPosition(typeDecl) - 1);
} else if (parent instanceof AnonymousClassDeclaration) {
final AnonymousClassDeclaration classDecl = (AnonymousClassDeclaration) parent;
return removeSuperfluousSemiColons(node, getEndPosition(node), getEndPosition(classDecl) - 1);
} else if (parent instanceof CompilationUnit) {
final CompilationUnit cu = (CompilationUnit) parent;
return removeSuperfluousSemiColons(node, getEndPosition(node), getEndPosition(cu) - 1);
} else if (parent instanceof TypeDeclarationStatement) {
return VISIT_SUBTREE;
}
throw new NotImplementedException(node, "for a parent of type " + (parent != null ? parent.getClass().getSimpleName() : null));
}
Aggregations