Skip to content

Commit 9011e04

Browse files
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).
1 parent 2ad9cf1 commit 9011e04

File tree

1 file changed

+3
-2
lines changed
  • eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls

1 file changed

+3
-2
lines changed

eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/BootProjectTester.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.eclipse.jdt.core.IClasspathEntry;
1919
import org.eclipse.jdt.core.IJavaProject;
2020
import org.eclipse.jdt.core.JavaCore;
21+
import org.eclipse.jdt.internal.core.JavaProject;
2122
import org.eclipse.jface.text.IDocument;
2223
import org.eclipse.lsp4e.LSPEclipseUtils;
2324
import org.springsource.ide.eclipse.commons.internal.core.CorePlugin;
@@ -36,7 +37,7 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
3637
}
3738
if (resource != null) {
3839
IProject project = resource.getProject();
39-
if (project != null) {
40+
if (project != null && JavaProject.hasJavaNature(project)) {
4041
IJavaProject jp = JavaCore.create(project);
4142
if (jp != null) {
4243
return isProjectWithDependency(jp, "spring-boot");
@@ -52,7 +53,7 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
5253
}
5354
if (resource != null) {
5455
IProject project = resource.getProject();
55-
if (project != null) {
56+
if (project != null && JavaProject.hasJavaNature(project)) {
5657
IJavaProject jp = JavaCore.create(project);
5758
if (jp != null) {
5859
return isProjectWithDependency(jp, (String) args[0]);

0 commit comments

Comments
 (0)