Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 01:00
    gavr123456789 commented #174
  • 00:21
    Prince781 commented #174
  • Feb 26 22:14
    gavr123456789 commented #174
  • Feb 26 19:19
    Prince781 commented #174
  • Feb 26 16:56
    gavr123456789 commented #174
  • Feb 20 19:52
    Prince781 commented #174
  • Feb 20 12:16
    astavale commented #174
  • Feb 18 22:33

    benwaffle on master

    ping (compare)

  • Feb 18 20:06
    overlisted commented #156
  • Feb 18 19:40
    overlisted commented #156
  • Feb 17 21:44
    gavr123456789 commented #174
  • Feb 17 21:04
    Prince781 commented #174
  • Feb 17 20:47
    gavr123456789 commented #174
  • Feb 17 20:46
    gavr123456789 opened #174
  • Feb 14 12:23
  • Feb 12 19:24
    harisvsulaiman starred benwaffle/vala-language-server
  • Feb 09 17:38
    overlisted commented #173
  • Feb 09 15:11
    Prince781 edited #173
  • Feb 09 15:00
    Prince781 labeled #173
  • Feb 09 15:00
    Prince781 commented #173
matrixbot
@matrixbot
Prince781 I've already done some work on this. I have a working scanner and I'm still finalizing the grammar. I also have a JSON parser written.
Prince781 The most complicated part I think will be implementing LSP functions to be used from LSTF files, like hover() in the example above.
Prince781 * The most complicated part I think will be implementing all of the LSP functions and structures to be used from LSTF files, like hover() in the example above.
Prince781 But I can just start with a small subset of the LSP and expand it as I develop more test cases for VLS.
matrixbot
@matrixbot

Prince781 > <@Prince781:matrix.org> I also want LSTF to have as few dependencies as possible so that it's easy to compile on many platforms.

Just to clarify, I want it so that all you need to run LSTF is the C standard library, and to compile it a working C compiler. I thought about using GLib, json-glib, jsonrpc-glib but I realized that wouldn't make it easy for other projects to use LSTF for testing.

Prince781 I think this is something that could be used to test all the language servers out there, like clangd or tsserver.
Prince781 Basically LSTF should be something that can be easily integrated as a subproject that's built to test language servers.
Daniel Espinosa Ortiz
@esodan_gitlab
@Prince781 don't loose your time. GVls has a client using GLib/JSON and JSONRPC/GLib you can use. GVls has a JSON/Variant/GObject parser with simple Vala annotations on GObject's properties, so you don't need to write potentially buggy parser. Better all GVls is written in Vala
Daniel Espinosa Ortiz
@esodan_gitlab
lets see this code:
/**
 * Completion options.
 */
public class GVls.CompletionOptionsInfo : GLib.Object, VariantObject, CompletionOptions {
  [Description (nick="resolveProvider")]
  public bool resolve_provider { get; set; }
  [Description (nick="triggerCharacters")]
  public Container trigger_characters { get; set; }

  construct {
    trigger_characters = new GVls.ContainerHashList ();
  }
}
matrixbot
@matrixbot
Prince781 As I said, I don't want it written in Vala because that carries with it a lot of dependencies (GLib and all its dependencies).
Daniel Espinosa Ortiz
@esodan_gitlab

Above code is an example how easy is to implement a GObject class that can be serialized to Variant and used in JSONRPC. Look at the annotations, nick is used to tell GVls.VariantObject to scan object's properties and serialize/deserialize to GLib.Variant using its to_variant() and parse_variant() methods. The nick name is the name used in JSON. Also, here you have a list of JSON objects items, represented by GVls.Container which in turn is a GLib.ListModel and should hold GVls.VariantObject implementors in order to serialize them to/from a JSON list. Look that implementing GVls.VariantObjectdoesn't require to implement complex methods; all properties are detected automatically and converted according with its type.

GVls has a lot of utility objects you can use as properties or to add in a GVls.Container (JSON list), like strings and booleans. GVls.VariantObjectis tolerant on missing items from JSON object representation when deserializing.

Prince781 As I said, I don't want it written in Vala because that carries with it a lot of dependencies (GLib and all its dependencies).

VLS is written in Vala, so your code is already dependant on Vala and GLib. Your test depend on your code, so will depend on GLib/Vala. Now is time to re-use the work from all in order to reduce the tiem to implement new features.

matrixbot
@matrixbot
Prince781 Daniel Espinosa Ortiz (Gitter): correct, VLS is written in Vala. But I want LSTF to be used for other language server projects.
Prince781 Not just VLS
Princeton Ferro
@Prince781
Ugh the matrix <-> Gitter bridge sucks for this. I'll just use gitter to chat with you.
Daniel Espinosa Ortiz
@esodan_gitlab

Prince781 Daniel Espinosa Ortiz (Gitter): correct, VLS is written in Vala. But I want LSTF to be used for other language server projects.

Why? That makes no sense. GVls will provide you what you need in short and will help you to concentrate on VLS not in another project; GVls can be used to test any other LSP implementation client or server.

GVls client can be re-used by elementary Code or any other one required a high performance serializer to JSON. That should not be a problem, if they don't worry to use GLib/GObject.

Is inconsistent to write VLS in Vala and wanting to write a code not depending on Vala or GObject.

In order to impulse Vala, we need to write more Vala code.

Princeton Ferro
@Prince781
@esodan_gitlab LSTF is a separate project from VLS. That's what you have to understand. The goal with LSTF is to write a general framework that makes it easy to write simple tests for any language server implementing the LSP.

lets see this code:

/**
 * Completion options.
 */
public class GVls.CompletionOptionsInfo : GLib.Object, VariantObject, CompletionOptions {
  [Description (nick="resolveProvider")]
  public bool resolve_provider { get; set; }
  [Description (nick="triggerCharacters")]
  public Container trigger_characters { get; set; }

  construct {
    trigger_characters = new GVls.ContainerHashList ();
  }
}

I don't even know what the point of this example is. Yes, I see that you can easily serialize data. But this is not a test case for a language server.

GVls does not have a simple way for me to write a test case that checks the response from a language server.
Daniel Espinosa Ortiz
@esodan_gitlab
@Prince781 is your choice about how to spend your time.

GVls does not have a simple way for me to write a test case that checks the response from a language server.

Please take a time to review the code in tests cases:

class Tests {
  static int main (string[] args)
  {
    GLib.Intl.setlocale (GLib.LocaleCategory.ALL, "");
    Test.init (ref args);
    Test.add_func ("/gvls/lsp/completion/glib",
    ()=>{
      var loop = new MainLoop ();
      var server = new GVlsp.ServerInetLocal ();
      var client = new GVlsp.ClientInetLocal ();
      bool initialized = false;
      server.run ();
      server.did_initialization.connect (()=>{
        message ("Server Initialized!");
        assert (server.initialized);
        initialized = server.initialized;
      });
      client.did_initialization.connect (()=>{
        assert (client.initialized);
        message ("Initialization request sent");
        for (int i = 0; i < 10000; i++) {
          if (initialized) {
            break;
          }
        }
        assert (client.capabilities != null);
        assert (client.capabilities.text_document != null);
        assert (client.capabilities.text_document.completion != null);
        assert (client.capabilities.text_document.completion.completion_item != null);
        var doc_format = client.capabilities.text_document.completion.completion_item.documentation_format;
        assert (doc_format != null);
        assert (doc_format.get_n_items () == 2);
        var f1 = doc_format.get_item (0) as MarkupKindObject;
        assert (f1 != null);
        assert (f1.@value == MarkupKind.PLAIN_TEXT);
        assert (f1.to_string () == "plaintext");
        var f2 = doc_format.get_item (1) as MarkupKindObject;
        assert (f2 != null);
        assert (f2.@value == MarkupKind.MARKDOWN);
        assert (f2.to_string () == "markdown");
        var ik = client.capabilities.text_document.completion.completion_item_kind;
        assert (ik != null);
        assert (ik.value_set != null);
        assert (ik.value_set.get_n_items () == 10);
        var ik1 = ik.value_set.get_item (0) as CompletionItemKindObject;
        assert (ik1 != null);
        assert (ik1.get_enum () == CompletionItemKind.TEXT);
        var docsym = client.capabilities.text_document.document_symbol;
        assert (docsym != null);
        var symk = docsym.symbol_kind;
        assert (symk != null);
        assert (symk.value_set != null);
        assert (symk.value_set.get_n_items () == 10);
        var symk1 = symk.value_set.get_item (0) as SymbolKindObject;
        assert (symk1 != null);
        assert (symk1.get_enum () == GVls.SymbolKind.NAMESPACE);

        var ro = client.capabilities.workspace.workspace_edit.resource_operations;
        assert (ro != null);
        assert (ro.get_n_items () == 3);
        var ro1 = ro.get_item (0) as ResourceOperationKindObject;
        assert (ro1 != null);
        assert (ro1.get_enum () == ResourceOperationKind.CREATE);
        loop.quit ();
      });
      Idle.add (()=>{
        message ("Start Request for Server initialization");
        GLib.File d = GLib.File.new_for_path (TestConfig.SRC_DIR);
        assert (d.query_exists ());
        client.initialize.begin (d.get_uri (), (obj, res)=>{
          try  {
            client.initialize.end (res);
          } catch (GLib.Error e) {
            warning ("Error requesting initialization: %s", e.message);
          }
        });
        return Source.REMOVE;
      });
      loop.run ();
    });
    return Test.run ();
  }
}
Daniel Espinosa Ortiz
@esodan_gitlab
Above is the simplest example on how GVls is tested. Look at client.initialize() is a method in the client that sends JSONRPC request and client.did_initialization() signal is used to detect when the server response; client.capabilitiesis used to check how the object whas initialized but you can use client.server_capabilitiesto access the server response after initialization.
This is the code implementing GVls.Client.initilize():
internal async void initialize (string? uri) throws GLib.Error
  {
    Variant response = new Variant ("ms", null);
    var pars = new InitializeParamsInfo ();
    File folder = null;
    if (uri == null) {
      folder = GLib.File.new_for_path (GLib.Environment.get_home_dir ());
    } else {
      folder = File.new_for_uri (uri);
    }
    if (!folder.query_exists ()) {
      throw new GVls.ClientError.INVALID_URI_ERROR (_("Invalid initializaion URI for root folder"));
    }
    workspace.folders.add (folder);
    pars.root_uri = folder.get_uri ();
    pars.capabilities = capabilities;
    if (vala_configuration != null) {
      pars.initialization_options = vala_configuration.to_variant ();
    }
    yield rpc_client.call_async ("initialize",  pars.to_variant (), cancellable, out response);
    server_capabilities = new ServerCapabilitiesInfo ();
    server_capabilities.parse_variant (response);
    initialized = true;
    did_initialization ();
    notify_initialized.begin ();
  }
Above you can see how the response from the server is deserialized from Variant using server_capabilities.parse_variant (response);
benwaffle
@benwaffle:matrix.org
[m]
nice
aeldemery.de
@aeldemery.de:matrix.org
[m]
Is this a new channel?
benwaffle
@benwaffle:matrix.org
[m]
matrix.org turned all gitter.im chats into matrix rooms
Prince781
@Prince781:matrix.org
[m]
Very nice
aeldemery.de
@aeldemery.de:matrix.org
[m]
Prince781 Hi, have you seen my MR?
ricotz
@ricotz:matrix.org
[m]
aeldemery.de you want to use '#if VALA_0_52'
aeldemery.de
@aeldemery.de:matrix.org
[m]
ricotz: thanks for the suggestion. Would you please review the changes, let me know if any changes still required. Thanks.
ricotz
@ricotz:matrix.org
[m]
aeldemery.de I would not align preprocessor directives with the code
aeldemery.de
@aeldemery.de:matrix.org
[m]
ricotz: done. Thanks.
Prince781
@Prince781:matrix.org
[m]
aeldemery.de I'm reviewing your patch now
Prince781
@Prince781:matrix.org
[m]
sorry...had to do something yesterday
I tried compiling your patch and it doesn't work, because I don't think you can use Vala.LoopStatement?
aeldemery.de
@aeldemery.de:matrix.org
[m]
Prince781 Thanks for taking the time and effort to improve vls. If you have a recent Vala compiler after the commit b3ee5b0f like I do, you shouldn't have any problem compiling my MR. Based on the recommendation from ricotz adding preprocessor conditional compilation should be enough. Otherwise one has to adapt meson to determine this information.
Prince781
@Prince781:matrix.org
[m]
hmm...
I tried compiling with the wip/meson branch
I'll try with that commit
Prince781
@Prince781:matrix.org
[m]
okay, everything compiles and works
aeldemery.de
@aeldemery.de:matrix.org
[m]
Super
Ilya Maximov
@overlisted
hi i made this issue and i think it's not very hard to fix benwaffle/vala-language-server#173
the copr repo doesn't work on fedora 33
aeldemery.de
@aeldemery.de:matrix.org
[m]
You can instead clone the repo and install it with meson/ninja
Ilya Maximov
@overlisted
that will create uncontrollable mess in my filesystem
files that don't belong to any package
meh
Prince781
@Prince781:matrix.org
[m]
@overlisted: I replied to your issue now. I forgot to officially deprecate the copr repo. You can get packages from our OBS repo here: https://software.opensuse.org//download.html?project=home%3APrince781&package=vala-language-server
Ilya Maximov
@overlisted
ohh thank you