Search in sources :

Example 1 with ServerModule

use of org.eclipse.xtext.ide.server.ServerModule in project xtext-core by eclipse.

the class ServerLauncher method main.

public static void main(final String[] args) {
    String _name = ServerLauncher.class.getName();
    ServerModule _serverModule = new ServerModule();
    ServerLauncher.launch(_name, args, _serverModule);
}
Also used : ServerModule(org.eclipse.xtext.ide.server.ServerModule)

Example 2 with ServerModule

use of org.eclipse.xtext.ide.server.ServerModule in project xtext-core by eclipse.

the class MultiProjectTest method setup.

@Before
public void setup() {
    ServerModule _serverModule = new ServerModule();
    final Injector injector = Guice.createInjector(Modules2.mixin(_serverModule, new AbstractModule() {

        @Override
        protected void configure() {
            this.<IWorkspaceConfigFactory>bind(IWorkspaceConfigFactory.class).to(MultiProjectWorkspaceConfigFactory.class);
        }
    }));
    injector.injectMembers(this);
    final File workspaceRoot = this.getRoot("test-data");
    File _file = new File(workspaceRoot, "test-project0");
    this.project0 = _file;
    File _file_1 = new File(workspaceRoot, "test-project1");
    this.project1 = _file_1;
    this.project0.mkdir();
    this.project1.mkdir();
    final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> {
        this.diagnostics.put($0, IterableExtensions.<Issue>toList($1));
    };
    this.workspaceManager.initialize(URI.createFileURI(workspaceRoot.getAbsolutePath()), _function, null);
}
Also used : Issue(org.eclipse.xtext.validation.Issue) Injector(com.google.inject.Injector) File(java.io.File) URI(org.eclipse.emf.common.util.URI) IWorkspaceConfigFactory(org.eclipse.xtext.ide.server.IWorkspaceConfigFactory) ServerModule(org.eclipse.xtext.ide.server.ServerModule) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

Example 3 with ServerModule

use of org.eclipse.xtext.ide.server.ServerModule in project xtext-core by eclipse.

the class SocketServerLauncher method main.

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);
    }
}
Also used : LanguageServer(org.eclipse.lsp4j.services.LanguageServer) ServerSocketChannel(java.nio.channels.ServerSocketChannel) SocketChannel(java.nio.channels.SocketChannel) Injector(com.google.inject.Injector) InetSocketAddress(java.net.InetSocketAddress) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) LanguageClient(org.eclipse.lsp4j.services.LanguageClient) ServerSocketChannel(java.nio.channels.ServerSocketChannel) ServerModule(org.eclipse.xtext.ide.server.ServerModule) PrintWriter(java.io.PrintWriter)

Example 4 with ServerModule

use of org.eclipse.xtext.ide.server.ServerModule in project xtext-core by eclipse.

the class AbstractLanguageServerTest method getServerModule.

protected com.google.inject.Module getServerModule() {
    ServerModule _serverModule = new ServerModule();
    final com.google.inject.Module _function = (Binder it) -> {
        AnnotatedBindingBuilder<RequestManager> _bind = it.<RequestManager>bind(RequestManager.class);
        _bind.toInstance(new RequestManager() {

            @Override
            public <V extends Object> CompletableFuture<V> runRead(final Function1<? super CancelIndicator, ? extends V> request) {
                final CompletableFuture<V> result = new CompletableFuture<V>();
                try {
                    final CancelIndicator _function = () -> {
                        return false;
                    };
                    result.complete(request.apply(_function));
                } catch (final Throwable _t) {
                    if (_t instanceof Throwable) {
                        final Throwable e = (Throwable) _t;
                        result.completeExceptionally(e);
                    } else {
                        throw Exceptions.sneakyThrow(_t);
                    }
                }
                return result;
            }

            @Override
            public <U extends Object, V extends Object> CompletableFuture<V> runWrite(final Function0<? extends U> nonCancellable, final Function2<? super CancelIndicator, ? super U, ? extends V> request) {
                final CompletableFuture<V> result = new CompletableFuture<V>();
                try {
                    final CancelIndicator _function = () -> {
                        return false;
                    };
                    result.complete(request.apply(_function, nonCancellable.apply()));
                } catch (final Throwable _t) {
                    if (_t instanceof Throwable) {
                        final Throwable e = (Throwable) _t;
                        result.completeExceptionally(e);
                    } else {
                        throw Exceptions.sneakyThrow(_t);
                    }
                }
                return result;
            }
        });
    };
    return Modules2.mixin(_serverModule, _function);
}
Also used : Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Function0(org.eclipse.xtext.xbase.lib.Functions.Function0) Function2(org.eclipse.xtext.xbase.lib.Functions.Function2) ServerModule(org.eclipse.xtext.ide.server.ServerModule) Binder(com.google.inject.Binder) AnnotatedBindingBuilder(com.google.inject.binder.AnnotatedBindingBuilder) CompletableFuture(java.util.concurrent.CompletableFuture) RequestManager(org.eclipse.xtext.ide.server.concurrent.RequestManager) CancelIndicator(org.eclipse.xtext.util.CancelIndicator)

Example 5 with ServerModule

use of org.eclipse.xtext.ide.server.ServerModule in project xtext-core by eclipse.

the class WorkspaceManagerTest method setup.

@Before
public void setup() {
    try {
        ServerModule _serverModule = new ServerModule();
        final Injector injector = Guice.createInjector(_serverModule);
        injector.injectMembers(this);
        File _file = new File("./test-data/test-project");
        this.root = _file;
        boolean _mkdirs = this.root.mkdirs();
        boolean _not = (!_mkdirs);
        if (_not) {
            Files.cleanFolder(this.root, null, true, false);
        }
        this.root.deleteOnExit();
        final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> {
            this.diagnostics.put($0, IterableExtensions.<Issue>toList($1));
        };
        this.workspaceManger.initialize(this.uriExtensions.withEmptyAuthority(URI.createFileURI(this.root.getAbsolutePath())), _function, null);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Issue(org.eclipse.xtext.validation.Issue) Injector(com.google.inject.Injector) File(java.io.File) URI(org.eclipse.emf.common.util.URI) ServerModule(org.eclipse.xtext.ide.server.ServerModule) Before(org.junit.Before)

Aggregations

ServerModule (org.eclipse.xtext.ide.server.ServerModule)6 Injector (com.google.inject.Injector)3 Before (org.junit.Before)3 File (java.io.File)2 URI (org.eclipse.emf.common.util.URI)2 Issue (org.eclipse.xtext.validation.Issue)2 AbstractModule (com.google.inject.AbstractModule)1 Binder (com.google.inject.Binder)1 AnnotatedBindingBuilder (com.google.inject.binder.AnnotatedBindingBuilder)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 InetSocketAddress (java.net.InetSocketAddress)1 ServerSocketChannel (java.nio.channels.ServerSocketChannel)1 SocketChannel (java.nio.channels.SocketChannel)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 LanguageClient (org.eclipse.lsp4j.services.LanguageClient)1 LanguageServer (org.eclipse.lsp4j.services.LanguageServer)1 IWorkspaceConfigFactory (org.eclipse.xtext.ide.server.IWorkspaceConfigFactory)1