Cleaner dependency injection for BootJavaLanguageServer

This commit is contained in:
Kris De Volder
2017-10-18 16:20:42 -07:00
parent 71dabb8d6c
commit 5ea32cf751
19 changed files with 388 additions and 268 deletions

View File

@@ -24,9 +24,18 @@ public interface ProjectObserver {
void created(IJavaProject project);
void changed(IJavaProject project);
void deleted(IJavaProject project);
}
}
void addListener(Listener listener);
void removeListener(Listener listener);
ProjectObserver NULL = new ProjectObserver() {
@Override
public void addListener(Listener listener) {
}
@Override
public void removeListener(Listener listener) {
}
};
}

View File

@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2017 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.util;
/**
* A factory that is aware of the language server context. Use this to inject
* dependencies into a {@link SimpleLanguageServer} implementation when the
* instantiation of the injected component itself depends on the language server (or
* some of its services).
*
* Note: It is starting to 'smell' like we should really be using some kind of dependency
* injection framework to deal with stuff like this.
*/
@FunctionalInterface
public interface LSFactory<T> {
T create(SimpleLanguageServer server);
}

View File

@@ -798,5 +798,4 @@ public class Editor {
this.selectionStart = this.selectionEnd = doc.toOffset(position);
}
}

View File

@@ -17,7 +17,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
@@ -613,4 +612,5 @@ public class LanguageServerHarness<S extends SimpleLanguageServer> {
public S getServer() {
return server;
}
}