Ensure commons-language-server is independent from java/maven projects
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package org.springframework.ide.vscode.commons.languageserver.java;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.IDocument;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
public class DefaultJavaProjectFinder implements JavaProjectFinder {
|
||||
|
||||
private final IJavaProjectFinderStrategy[] strategies;
|
||||
|
||||
public DefaultJavaProjectFinder(IJavaProjectFinderStrategy[] strategies) {
|
||||
this.strategies = strategies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJavaProject find(IDocument d) {
|
||||
for (IJavaProjectFinderStrategy strategy : strategies) {
|
||||
try {
|
||||
IJavaProject project = strategy.find(d);
|
||||
if (project != null) {
|
||||
return project;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.log(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.java;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.IDocument;
|
||||
|
||||
/**
|
||||
* Strategy foe finding Java project for a document
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IJavaProjectFinderStrategy {
|
||||
|
||||
IJavaProject find(IDocument document) throws Exception;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.springframework.ide.vscode.commons.languageserver.java;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.util.IDocument;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface JavaProjectFinder {
|
||||
IJavaProject find(IDocument doc);
|
||||
}
|
||||
Reference in New Issue
Block a user