void (@NotNull final String assignmentVariableName, final String className, final PsiType toType) { final RulesProvider provider = new RulesProvider() { @Override public PsiType migrationType(PsiElement context) { return toType; } @Override public PsiElement victim(PsiClass aClass) { for (PsiLocalVariable variable : PsiTreeUtil.findChildrenOfType(aClass, PsiLocalVariable.class)) { if (assignmentVariableName.equals(variable.getName())) { final PsiAnonymousClass anonymousClass = PsiTreeUtil.findChildOfType(variable.getInitializer(), PsiAnonymousClass.class); assertNotNull(anonymousClass); return anonymousClass.getBaseClassReference().getParameterList(); } } throw new RuntimeException(String.format("Local variable '%s' isn't found in class '%s'", assignmentVariableName, className)); } }; start(provider, className); }