本文整理汇总了Java中org.eclipse.lsp4j.services.LanguageClient类的典型用法代码示例。如果您正苦于以下问题:Java LanguageClient类的具体用法?Java LanguageClient怎么用?Java LanguageClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageClient类属于org.eclipse.lsp4j.services包,在下文中一共展示了LanguageClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
public static void main(final String[] args) {
try {
ServerModule _serverModule = new ServerModule();
final Injector injector = Guice.createInjector(_serverModule);
final LanguageServer languageServer = injector.<LanguageServer>getInstance(LanguageServer.class);
final ServerSocketChannel serverSocket = ServerSocketChannel.open();
InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 5007);
serverSocket.bind(_inetSocketAddress);
final SocketChannel socketChannel = serverSocket.accept();
InputStream _newInputStream = Channels.newInputStream(socketChannel);
OutputStream _newOutputStream = Channels.newOutputStream(socketChannel);
PrintWriter _printWriter = new PrintWriter(System.out);
final Launcher<LanguageClient> launcher = LSPLauncher.createServerLauncher(languageServer, _newInputStream, _newOutputStream, true, _printWriter);
launcher.startListening().get();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例2: setup
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Before public void setup() throws IOException {
PipedInputStream inClient = new PipedInputStream();
PipedOutputStream outClient = new PipedOutputStream();
PipedInputStream inServer = new PipedInputStream();
PipedOutputStream outServer = new PipedOutputStream();
inClient.connect(outServer);
outClient.connect(inServer);
server = new AssertingEndpoint();
serverLauncher = LSPLauncher.createServerLauncher(ServiceEndpoints.toServiceObject(server, LanguageServer.class), inServer, outServer);
serverListening = serverLauncher.startListening();
client = new AssertingEndpoint();
clientLauncher = LSPLauncher.createClientLauncher(ServiceEndpoints.toServiceObject(client, LanguageClient.class), inClient, outClient);
clientListening = clientLauncher.startListening();
}
示例3: launch
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Override
public LanguageServer launch(String projectPath, LanguageClient client)
throws LanguageServerException {
try {
Socket socket = new Socket(host, port);
socket.setKeepAlive(true);
InputStream inputStream = socket.getInputStream();
OutputStream outputStream = socket.getOutputStream();
Launcher<LanguageServer> launcher =
Launcher.createLauncher(client, LanguageServer.class, inputStream, outputStream);
launcher.startListening();
return launcher.getRemoteProxy();
} catch (IOException e) {
throw new LanguageServerException(
"Can't launch language server for project: " + projectPath, e);
}
}
示例4: PomReconciler
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
public PomReconciler(
MavenProjectManager mavenProjectManager,
EditorWorkingCopyManager editorWorkingCopyManager,
EventService eventService,
LanguageClient client) {
this.mavenProjectManager = mavenProjectManager;
this.editorWorkingCopyManager = editorWorkingCopyManager;
this.eventService = eventService;
this.client = client;
editorContentUpdateEventSubscriber =
new EventSubscriber<EditorWorkingCopyUpdatedEvent>() {
@Override
public void onEvent(EditorWorkingCopyUpdatedEvent event) {
onEditorContentUpdated(event);
}
};
eventService.subscribe(editorContentUpdateEventSubscriber);
}
示例5: run
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
/**
* Listen for requests from the parent node process. Send replies asynchronously. When the
* request stream is closed, wait for 5s for all outstanding responses to compute, then return.
*/
public static void run(Socket connection) throws IOException {
JavaLanguageServer server = new JavaLanguageServer();
Launcher<LanguageClient> launcher =
LSPLauncher.createServerLauncher(
server, connection.getInputStream(), connection.getOutputStream());
server.installClient(launcher.getRemoteProxy());
launcher.startListening();
LOG.info(String.format("java.version is %s", System.getProperty("java.version")));
}
示例6: installClient
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
void installClient(LanguageClient client) {
this.client.complete(client);
Handler sendToClient =
new Handler() {
@Override
public void publish(LogRecord record) {
String message = record.getMessage();
if (record.getThrown() != null) {
StringWriter trace = new StringWriter();
record.getThrown().printStackTrace(new PrintWriter(trace));
message += "\n" + trace;
}
client.logMessage(
new MessageParams(
messageType(record.getLevel().intValue()), message));
}
private MessageType messageType(int level) {
if (level >= Level.SEVERE.intValue()) return MessageType.Error;
else if (level >= Level.WARNING.intValue()) return MessageType.Warning;
else if (level >= Level.INFO.intValue()) return MessageType.Info;
else return MessageType.Log;
}
@Override
public void flush() {}
@Override
public void close() throws SecurityException {}
};
Logger.getLogger("").addHandler(sendToClient);
}
示例7: JavaWorkspaceService
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
JavaWorkspaceService(
CompletableFuture<LanguageClient> client,
JavaLanguageServer server,
JavaTextDocumentService textDocuments) {
this.client = client;
this.server = server;
this.textDocuments = textDocuments;
}
示例8: getJavaLanguageServer
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
private static JavaLanguageServer getJavaLanguageServer(
Path workspaceRoot, LanguageClient client) {
JavaLanguageServer server = new JavaLanguageServer();
InitializeParams init = new InitializeParams();
init.setRootPath(workspaceRoot.toString());
server.initialize(init);
server.installClient(client);
server.maxItems = 100;
return server;
}
示例9: initialize
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Override
public void initialize(final ILanguageServerAccess access) {
this.access = access;
this.access.addBuildListener(this);
LanguageClient _languageClient = access.getLanguageClient();
this.client = ServiceEndpoints.<TestLangLSPExtension.CustomClient>toServiceObject(((Endpoint) _languageClient), TestLangLSPExtension.CustomClient.class);
}
示例10: initialize
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
public void initialize(final Iterable<? extends IResourceServiceProvider> allLanguages, final ClientCapabilities capabilities, final LanguageClient client) {
this.client = client;
this.registeredCommands = HashMultimap.<String, IExecutableCommandService>create();
Boolean _elvis = null;
WorkspaceClientCapabilities _workspace = capabilities.getWorkspace();
ExecuteCommandCapabilities _executeCommand = null;
if (_workspace!=null) {
_executeCommand=_workspace.getExecuteCommand();
}
Boolean _dynamicRegistration = null;
if (_executeCommand!=null) {
_dynamicRegistration=_executeCommand.getDynamicRegistration();
}
if (_dynamicRegistration != null) {
_elvis = _dynamicRegistration;
} else {
_elvis = Boolean.valueOf(false);
}
final boolean hasDynamicRegistration = (boolean) _elvis;
for (final IResourceServiceProvider lang : allLanguages) {
{
final IExecutableCommandService service = lang.<IExecutableCommandService>get(IExecutableCommandService.class);
if ((service != null)) {
final List<String> commands = service.initialize();
for (final String c : commands) {
this.registeredCommands.put(c, service);
}
if (hasDynamicRegistration) {
final Function1<String, IDisposable> _function = (String command) -> {
return this.register(command, service);
};
service.initializeDynamicRegistration(_function);
}
}
}
}
}
示例11: setup
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Before
public void setup() {
final Map<String, JsonRpcMethod> methods = ServiceEndpoints.getSupportedMethods(LanguageServer.class);
final Map<String, JsonRpcMethod> clientMethods = ServiceEndpoints.getSupportedMethods(LanguageClient.class);
final HashMap<String, JsonRpcMethod> all = new HashMap<String, JsonRpcMethod>();
all.putAll(methods);
all.putAll(clientMethods);
MessageJsonHandler _messageJsonHandler = new MessageJsonHandler(all);
this.jsonHandler = _messageJsonHandler;
}
示例12: launch
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Override
public final LanguageServer launch(String projectPath, LanguageClient client)
throws LanguageServerException {
Process languageServerProcess = startLanguageServerProcess(projectPath);
waitCheckProcess(languageServerProcess);
return connectToLanguageServer(languageServerProcess, client);
}
示例13: connectToLanguageServer
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Override
protected LanguageServer connectToLanguageServer(
Process languageServerProcess, LanguageClient client) throws LanguageServerException {
Launcher<LanguageServer> launcher =
Launcher.createLauncher(
client,
LanguageServer.class,
languageServerProcess.getInputStream(),
languageServerProcess.getOutputStream());
launcher.startListening();
return launcher.getRemoteProxy();
}
示例14: testFindServer
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Test
public void testFindServer() throws Exception {
ServerCapabilities cap = registry.initialize(PREFIX + FILE_PATH);
assertNotNull(cap);
assertEquals(cap, serverCapabilities);
Mockito.verify(initializer)
.initialize(eq(languageServerLauncher), any(LanguageClient.class), eq(PROJECT_PATH));
}
示例15: connectToLanguageServer
import org.eclipse.lsp4j.services.LanguageClient; //导入依赖的package包/类
@Override
protected LanguageServer connectToLanguageServer(
final Process languageServerProcess, LanguageClient client) {
Launcher<LanguageServer> launcher =
Launcher.createLauncher(
client,
LanguageServer.class,
languageServerProcess.getInputStream(),
languageServerProcess.getOutputStream());
launcher.startListening();
return launcher.getRemoteProxy();
}