package org.springframework.ide.vscode.commons.languageserver.java;

import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.util.IDocument;

public class DefaultJavaProjectFinder implements JavaProjectFinder {

	private final IJavaProjectFinderStrategy[] STRATEGIES = new IJavaProjectFinderStrategy[] {
		new JavaProjectWithClasspathFileFinderStrategy(),
		new MavenProjectFinderStrategy()
	};

	@Override
	public IJavaProject find(IDocument d) {
		for (IJavaProjectFinderStrategy strategy : STRATEGIES) {
			try {
				return strategy.find(d);
			} catch (Throwable t) {
				// Log perhaps?
			}
		}
		return null;
	}
}

@@ -60,19 +60,17 @@
 er.java;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -126,17 +126,16 @@
 Project;
-%0D
 %0Aimport 
@@ -203,19 +203,17 @@
 ocument;
-%0D%0A%0D
+%0A
 %0Apublic 
@@ -273,19 +273,17 @@
 Finder %7B
-%0D%0A%0D
+%0A
 %0A%09privat
@@ -366,17 +366,16 @@
 tegy%5B%5D %7B
-%0D
 %0A%09%09new J
@@ -418,17 +418,16 @@
 ategy(),
-%0D
 %0A%09%09new M
@@ -457,16 +457,13 @@
 gy()
-%0D
 %0A%09%7D;
-%0D%0A%0D
+%0A
 %0A%09@O
@@ -469,17 +469,16 @@
 Override
-%0D
 %0A%09public
@@ -510,17 +510,16 @@
 ent d) %7B
-%0D
 %0A%09%09for (
@@ -569,17 +569,16 @@
 EGIES) %7B
-%0D
 %0A%09%09%09try 
@@ -582,39 +582,107 @@
 ry %7B
-%0D
 %0A%09%09%09%09
-return strategy.find(d);%0D
+IJavaProject project = strategy.find(d);%0A%09%09%09%09if (project != null) %7B%0A%09%09%09%09%09return project;%0A%09%09%09%09%7D
 %0A%09%09%09
@@ -704,17 +704,16 @@
 ble t) %7B
-%0D
 %0A%09%09%09%09// 
@@ -728,20 +728,17 @@
 aps?
-%0D
 %0A%09%09%09%7D
-%0D
 %0A%09%09%7D
-%0D
 %0A%09%09r
@@ -752,13 +752,10 @@
 ull;
-%0D
 %0A%09%7D
-%0D
 %0A%7D
-%0D
 %0A

Handle null found project for default java project finder