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:

java.lang.NullPointerException
at com.intellij.degenerator.DegeneratorUtil.a(DegeneratorUtil.java:7)
at com.intellij.degenerator.DegeneratorUtil.castTo(DegeneratorUtil.java:64)
at com.intellij.degenerator.CastingVisitor.visitMethodCallExpression(CastingVisitor.java:7)
at com.intellij.psi.impl.source.tree.java.PsiMethodCallExpressionImpl.accept(PsiMethodCallExpressionImpl.java:1)
at com.intellij.psi.impl.source.tree.CompositePsiElement.acceptChildren(CompositePsiElement.java:42)
at com.intellij.psi.PsiRecursiveElementVisitor.visitElement(PsiRecursiveElementVisitor.java:21)
at com.intellij.psi.JavaElementVisitor.visitVariable(JavaElementVisitor.java:326)

at com.intellij.psi.impl.source.PsiJavaFileBaseImpl.accept(PsiJavaFileBaseImpl.java:161)
at net.kano.nully.analysis.nulls.psipreprocess.PreparerForSoot.degenerate(PreparerForSoot.java:128)

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);
file.accept(castingvisitor);
file.accept(typeparametersremovingvisitor);
PsiJavaFile copy = (PsiJavaFile) file.copy();
ModifyingVisitor modifyingvisitor = new ModifyingVisitor();
copy.accept(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.

Thanks,
-Keith


Please sign in to leave a comment.