Skip to content

Commit

Permalink
eclipse-che#4306 fix NPE in case of invalid java FQN (eclipse-che#4654)
Browse files Browse the repository at this point in the history
Signed-off-by: Even Vidolob <[email protected]>
  • Loading branch information
Evgen Vidolob authored Mar 31, 2017
1 parent 9a29efa commit 2fbe5a4
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.JavaModel;
import org.eclipse.jdt.internal.core.JavaModelManager;
Expand Down Expand Up @@ -89,7 +90,14 @@ public String createMoveRefactoring(CreateMoveRefactoring cmr) throws JavaModelE
if (javaElement.isPack()) {
return javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(javaElement.getPath()));
} else {
return javaProject.findType(javaElement.getPath()).getCompilationUnit();

IType type = javaProject.findType(javaElement.getPath());

//in some cases client may send FQN that doesn't exist
if (type == null) {
throw new IllegalArgumentException("Can't find type: " + javaElement.getPath());
}
return type.getCompilationUnit();

}
} catch (JavaModelException e) {
Expand Down

0 comments on commit 2fbe5a4

Please sign in to comment.