Commit 6275d29f authored by Daniel Espinosa Ortiz's avatar Daniel Espinosa Ortiz

lsp-local: initial local client work

parent ecbcdda3
Pipeline #42337 failed with stages
in 2 minutes and 50 seconds
......@@ -16,6 +16,10 @@ pkgs = [
'--pkg='+vala_dep_str,
]
if vala_version.version_compare ('>=0.42.0')
pkgs += ['--define=VALA_0_42']
endif
if jsonrpc_dep.found ()
pkgs += ['--pkg=jsonrpc-glib-1.0']
endif
......
......@@ -21,7 +21,7 @@ if vala_version == ''
endif
if vala_version.version_compare ('>=0.42.0')
add_project_arguments ('-DVALA_0_42', language: 'vala')
add_project_arguments ('--define=VALA_0_42', language: 'vala')
endif
gvls_deps = [
......
/* gvls-client-lsp.vala
*
* Copyright 2018 Daniel Espinosa <esodan@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Jsonrpc;
using GLib;
public class GVls.ClientLspLocal : Object, GVls.ClientLsp {
Container _request;
GVls.ServerLsp lsp_server;
IOStream stream;
Jsonrpc.Client _rcp_client;
public Jsonrpc.Client rcp_client { get { return _rcp_client; } }
public Workspace workspace { get; internal set; }
public bool initialized { get; internal set; }
public bool connected { get; internal set; }
public Container request { get { return _request; } }
public Cancellable cancellable { get; set; }
construct {
_request = new GContainer ();
var ostream = new MemoryOutputStream.resizable ();
var istream = new MemoryInputStream ();
stream = new SimpleIOStream (istream, ostream);
lsp_server = new ServerLspStream (stream);
lsp_server.run (stream);
_rcp_client = new Jsonrpc.Client (stream);
}
}
......@@ -19,24 +19,25 @@ using Jsonrpc;
using GLib;
using Json;
public interface GVls.ClientLsp : Jsonrpc.Client
public interface GVls.ClientLsp : GLib.Object
{
public abstract Jsonrpc.Client rcp_client { get; }
public abstract Workspace workspace { get; internal set; }
public abstract IOStream stream { get; internal set; }
public abstract bool initialized { get; internal set; }
public abstract bool connected { get; internal set; }
public abstract Container request { get; }
public abstract Cancellable cancellable { get; set; }
public virtual void connect (IOStream stream, string? path) throws GLib.Error
public virtual void connect (IOStream stream, string? ws_path) throws GLib.Error
requires (workspace != null)
{
this.stream = stream;
var rqi = new RequestItem ("initialize");
var pars = new GInitializeParams ();
Variant @params = new Variant.string (Json.gobject_to_data (pars, null));
pars.root_uri = ws_path;
string pars_str = Json.gobject_to_data (pars, null);
message (pars_str);
Variant @params = new Variant.string (pars_str);
Variant response = null;
call (rqi.method, @params, cancellable, out response);
rcp_client.call (rqi.method, @params, cancellable, out response);
}
}
......
......@@ -154,7 +154,8 @@ public class GVls.GScanner : Object {
case Vala.TokenType.TRY:
case Vala.TokenType.TYPEOF:
#if VALA_0_42
case Vala.TokenType.UNLOCK:
// FIXME: Valadoc ignores conditional
//case Vala.TokenType.UNLOCK:
#endif
case Vala.TokenType.UNOWNED:
case Vala.TokenType.USING:
......
......@@ -28,7 +28,7 @@ public interface GVls.InitializeParams : Object {
* The rootPath of the workspace. Is null
* if no folder is open.
*
* @deprecated in favour of rootUri.
* Deprecated: in favour of rootUri.
*/
[Version (deprecated=true)]
public abstract string? root_path { get; set; }
......@@ -84,9 +84,11 @@ public enum GVls.InitializeError {
UNKNOWN,
/**
* If the protocol version provided by the client can't be handled by the server.
* @deprecated This initialize error got replaced by client capabilities. There is
*
* Deprecated: This initialize error got replaced by client capabilities. There is
* no version handshake in version 3.0x
*/
[Version (deprecated=true)]
UNKNOWN_PROTOCOL_VERSION;
public string to_string () {
string str = "";
......
......@@ -20,11 +20,11 @@ using Jsonrpc;
public class GVls.ServerLspStream : Jsonrpc.Server, ServerLsp
{
public Workspace workspace { get; internal set; }
public IOStream stream { get; internal set; }
public bool initialized { get; internal set; }
public GVls.Server server { get; internal set; }
public ServerLspStream (IOStream stm) {
stream = stm;
server = new GServer ();
workspace = new GWorkspace ();
}
}
......@@ -20,12 +20,11 @@ using Jsonrpc;
public interface GVls.ServerLsp : Jsonrpc.Server
{
public abstract Workspace workspace { get; internal set; }
public abstract IOStream stream { get; internal set; }
public abstract bool initialized { get; internal set; }
public abstract GVls.Server server { get; internal set; }
public virtual void run (IOStream stream)
requires (workspace != null)
{
this.stream = stream;
add_handler ("initialize", initialize);
accept_io_stream (stream);
}
......
......@@ -102,6 +102,7 @@ if jsonrpc_dep.found ()
gvls_deps += [jsonrpc_dep]
gvls_sources += files([
'gvls-client-lsp.vala',
'gvls-client-lsp-local.vala',
'gvls-gworkspace.vala',
'gvls-server-lsp-stream.vala',
'gvls-server-lsp.vala'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment