Fix JavaModelException with non-Java projects (#1188)

Added a check that the JDT project uses to confirm the project is a Java
project. JavaCore#create will return an object even if the project isn't
a Java project and is therefore insufficient. Bring up the context menu
on non Java projects to the see the JME logged without this fix
(possibly other repercussions as well).
This commit is contained in:
Brian Fernandes
2024-02-16 20:40:22 +05:30
committed by GitHub
parent 2ad9cf1ff3
commit 9011e040f9

View File

@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jface.text.IDocument;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.springsource.ide.eclipse.commons.internal.core.CorePlugin;
@@ -36,7 +37,7 @@ public class BootProjectTester extends PropertyTester {
}
if (resource != null) {
IProject project = resource.getProject();
if (project != null) {
if (project != null && JavaProject.hasJavaNature(project)) {
IJavaProject jp = JavaCore.create(project);
if (jp != null) {
return isProjectWithDependency(jp, "spring-boot");
@@ -52,7 +53,7 @@ public class BootProjectTester extends PropertyTester {
}
if (resource != null) {
IProject project = resource.getProject();
if (project != null) {
if (project != null && JavaProject.hasJavaNature(project)) {
IJavaProject jp = JavaCore.create(project);
if (jp != null) {
return isProjectWithDependency(jp, (String) args[0]);