Ensure commons-language-server is independent from java/maven projects

This commit is contained in:
BoykoAlex
2016-12-08 19:17:29 -05:00
parent 0725b703e6
commit e9f7cd46ba
52 changed files with 166 additions and 152 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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);
}