NPE in DegeneratorUtil

Hi Maxim, I'm trying to use com.intellij.degenerator.DegeneratorUtil to degenerate
code. Even for simple code, I get this error:

at com.intellij.degenerator.DegeneratorUtil.a(
at com.intellij.degenerator.DegeneratorUtil.castTo(
at com.intellij.degenerator.CastingVisitor.visitMethodCallExpression(
at com.intellij.psi.impl.source.tree.CompositePsiElement.acceptChildren(
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(
at com.intellij.psi.JavaElementVisitor.visitVariable(

at com.intellij.psi.impl.source.PsiJavaFileBaseImpl.accept(
at net.kano.nully.analysis.nulls.psipreprocess.PreparerForSoot.degenerate(

My degenerate() method looks like this:

private PsiJavaFile degenerate(PsiJavaFile file) {
Project project = file.getProject();
CastingVisitor castingvisitor = new CastingVisitor(project, new ArrayList());
TypeParametersRemovingVisitor typeparametersremovingvisitor
= new TypeParametersRemovingVisitor(project);
PsiJavaFile copy = (PsiJavaFile) file.copy();
ModifyingVisitor modifyingvisitor = new ModifyingVisitor();
return copy;

(I can't use DegeneratorUtil.degenerate() because I want the element itself,
not the text, to preserve my user data.)

I know that degenerator is not officially supported. But if there's something
I'm doing wrong, or some quick fix you could make for the next build, my
project would be a lot better off.


Please sign in to leave a comment.