fix #7968 - language server support for syntax check and completion
[roobuilder] / src / Builder4 / MainWindow.bjs
index 337bf15..d43dd8f 100644 (file)
            "xtype" : "Label"
           },
           {
-           "# GLib.ListStore notices" : "null",
            "$ xns" : "Gtk",
            "Xcls_ValaCompileErrors popup" : "",
            "id" : "statusbar_errors",
            "listeners" : {
             "clicked" : [
              "() => {",
-             "    ",
-             "",
-             "    ",
-             "    if (this.popup == null) {",
-             "        this.popup = new Xcls_ValaCompileErrors();",
-             "        this.popup.window = _this;",
-             "        //this.popup.el.application = _this.el.application;",
-             "\t  //   this.popup.el.set_transient_for( _this.el );",
-             "       this.popup.el.set_parent(this.el);",
-             "    }",
-             "    if (_this.statusbar_compile_spinner.el.spinning) {",
-             "\t\tthis.popup.el.show();    \t",
-             "    \treturn;",
-             "\t}    ",
-             "    this.popup.show(this.notices, this.el);",
-             "    return;",
+             " ",
+             "\tif (this.popup == null) {",
+             "\t\treturn;",
+             "\t}",
+             "   ",
+             "    this.popup.show();",
+             "  ",
              "}"
             ]
            },
            "string label" : "0 Errors",
            "xtype" : "Button",
            "| void setNotices" : [
-            "(GLib.ListStore nots, int qty, int tf) {",
+            "(GLib.ListStore nots, GLib.ListStore fe ) {",
             "    ",
-            "     if (qty < 1 ) {",
+            "     if (nots.get_n_items() < 1 ) {",
             "    \tthis.el.hide();",
-            "    \tif (this.popup != null && this.popup.el.visible) {",
+            "    \tif (this.popup != null) {",
             "    \t\tthis.popup.el.hide();",
             "\t\t}",
             "    \treturn;",
             "    }",
             "    ",
             "    this.el.show();",
-            "    this.el.label = \"%d/%d Errors\".printf(tf,qty);",
-            "    this.notices = nots;",
-            "\tif (this.popup != null && this.popup.el.visible) {",
-            "\t\t this.popup.show(this.notices, this.el);",
+            "    this.el.label = \"%d/%d Errors\".printf((int)fe.get_n_items(),(int)nots.get_n_items());",
+            "",
+            "    ",
+            " ",
+            "\tif (this.popup == null) {",
+            "        this.popup = new Xcls_ValaCompileErrors();",
+            "        this.popup.window = _this;",
+            "      //    this.popup.el.set_transient_for( _this.el );",
+            "        this.popup.el.set_parent(this.el);",
             "    }",
+            "\tthis.popup.updateNotices(nots);",
+            "\t ",
             "}",
             ""
            ]
           },
           {
-           "# GLib.ListStore notices" : "null",
            "$ xns" : "Gtk",
            "Xcls_ValaCompileErrors popup" : "",
            "id" : "statusbar_warnings",
              "() => {",
              " ",
              "\tif (this.popup == null) {",
-             "        this.popup = new Xcls_ValaCompileErrors();",
-             "        this.popup.window = _this;",
-             "      //    this.popup.el.set_transient_for( _this.el );",
-             "        this.popup.el.set_parent(this.el);",
-             "    }",
-             "        if (_this.statusbar_compile_spinner.el.spinning) {",
-             "\t\tthis.popup.el.show();    \t",
-             "    \treturn;",
-             "\t}    ",
-             "    this.popup.show(this.notices, this.el);",
+             "\t\treturn;",
+             "\t}",
+             "   ",
+             "    this.popup.show();",
              "    return;",
              "}"
             ]
            "string label" : "0 Warnings",
            "xtype" : "Button",
            "| void setNotices" : [
-            "(GLib.ListStore nots, int qty, int tf) {",
+            "(GLib.ListStore nots, GLib.ListStore fe ) {",
             "    ",
-            "    if (qty < 1 ) {",
+            "     if (nots.get_n_items() < 1 ) {",
             "    \tthis.el.hide();",
-            "    \tif (this.popup != null && this.popup.el.visible) {",
+            "    \tif (this.popup != null) {",
             "    \t\tthis.popup.el.hide();",
             "\t\t}",
             "    \treturn;",
             "    }",
-            "    this.el.show();",
-            "    this.el.label = \"%d/%d Warnings\".printf(tf,qty);",
-            "     this.notices = nots;",
-            "    if (this.popup != null && this.popup.el.visible) {",
-            "\t\t this.popup.show(this.notices, this.el);",
-            "    }",
             "    ",
+            "    this.el.show();",
+            "    this.el.label = \"%d/%d Warnings\".printf((int)fe.get_n_items(),(int)nots.get_n_items());",
             "",
+            "    ",
+            " ",
+            "\tif (this.popup == null) {",
+            "        this.popup = new Xcls_ValaCompileErrors();",
+            "        this.popup.window = _this;",
+            "      //    this.popup.el.set_transient_for( _this.el );",
+            "        this.popup.el.set_parent(this.el);",
+            "    }",
+            "\tthis.popup.updateNotices(nots);",
+            "\t ",
             "}",
             ""
            ]
            "listeners" : {
             "clicked" : [
              "() => {",
-             "    ",
+             " ",
              "\tif (this.popup == null) {",
-             "        this.popup = new Xcls_ValaCompileErrors();",
-             "        this.popup.window = _this;",
-             "      //  this.popup.el.set_transient_for( _this.el );",
-             "        this.popup.el.set_parent(this.el);",
-             "    }",
-             "    if (_this.statusbar_compile_spinner.el.spinning) {",
-             "\t\tthis.popup.el.show();    \t",
-             "    \treturn;",
-             "\t}    ",
-             "    ",
-             "    this.popup.show(this.notices, this.el);",
-             "    return;",
+             "\t\treturn;",
+             "\t}",
+             "   ",
+             "    this.popup.show();",
+             "  ",
              "}"
             ]
            },
            "string label" : "0 Depricated",
            "xtype" : "Button",
            "| void setNotices" : [
-            "(GLib.ListStore nots, int qty, int tf) {",
-            "    if (qty < 1) {",
+            "",
+            "(GLib.ListStore nots, GLib.ListStore fe ) {",
+            "    ",
+            "     if (nots.get_n_items() < 1 ) {",
             "    \tthis.el.hide();",
-            "    \tif (this.popup != null && this.popup.el.visible) {",
-            "\t\t\t this.popup.el.hide();",
+            "    \tif (this.popup != null) {",
+            "    \t\tthis.popup.el.hide();",
             "\t\t}",
-            " ",
             "    \treturn;",
-            "\t}",
+            "    }",
             "    ",
             "    this.el.show();",
+            "    this.el.label = \"%d/%d Depricated\".printf((int)fe.get_n_items(),(int)nots.get_n_items());",
+            "",
             "    ",
-            "    this.el.label = \"%d/%d Depricated\".printf(tf,qty);",
-            "    this.notices = nots;",
-            "\tif (this.popup != null && this.popup.el.visible) {",
-            "\t\t this.popup.show(this.notices, this.el);",
+            " ",
+            "\tif (this.popup == null) {",
+            "        this.popup = new Xcls_ValaCompileErrors();",
+            "        this.popup.window = _this;",
+            "      //    this.popup.el.set_transient_for( _this.el );",
+            "        this.popup.el.set_parent(this.el);",
             "    }",
+            "\tthis.popup.updateNotices(nots);",
+            "\t ",
             "}",
             ""
            ]
              "\t    _this.windowstate.compile_results.el.show(); // show currently running.",
              "    \treturn;",
              "\t}",
-             "\tBuilderApplication.valacompilequeue.addFile( ",
-             "\t \t\t\t\t\tPalete.ValaCompileRequestType.RUN, ",
-             "\t \t\t\t\t\t_this.windowstate.file, \"\", true ) ;",
-             "",
+             "\t",
+             "\tvar req = new Palete.ValaCompileRequest(",
+             "\t\tPalete.ValaCompileRequestType.RUN,",
+             "\t\t_this.windowstate.file,",
+             "\t\tnull,",
+             "\t\tnull,",
+             "\t\t\"\"",
+             "\t);",
+             "\treq.run();",
+             "\t ",
              "\t_this.windowstate.compile_results.el.set_parent(this.el);",
              "\t_this.windowstate.compile_results.show(this.el,true);",
              "\t         ",
      "( ) => {",
      "\t Resources.singleton().disconnect(_this.statusbar.handler_id);",
      "\t ",
+     "\t ",
+     "\t this.windowstate.file.getLanguageServer().document_close(",
+     "\t \tthis.windowstate.file",
+     " \t);",
+     "\t ",
      "\t BuilderApplication.removeWindow(this);",
      "\t ",
      "\t if (BuilderApplication.windows.size  < 1) {",
-     "",
+     "\t\tthis.windowstate.file.getLanguageServer().exit();",
      "\t\tBuilderApplication.singleton(  null ).quit();",
      "\t }",
      "\treturn true;",
     "}"
    ],
    "| void updateErrors" : [
-    "(Palete.ValaCompileRequest? req) {",
+    "() {",
     "",
-    "\tif (req == null) {",
-    " ",
-    "\t    _this.statusbar_errors.el.hide();",
-    "\t\t_this.statusbar_warnings.el.hide();",
-    "\t\t_this.statusbar_depricated.el.hide();",
-    "\t\treturn;",
-    "\t}",
+    "",
+    " \tGLib.debug(\"updateErrors\");",
     "\t",
+    "\tvar pr = this.windowstate.project.getErrors(\"ERR\");",
     "\t",
     "\tthis.statusbar_errors.setNotices(",
-    "\t\treq.errorByType.get(\"ERR\"),",
-    "\t\treq.totalErrors(\"ERR\"),",
-    "\t\treq.totalErrors(\"ERR\", this.windowstate.file)",
+    "\t\tpr,",
+    "\t\tthis.windowstate.file.getErrors(\"ERR\")",
     "\t);",
+    "\t",
     "\tthis.statusbar_warnings.setNotices(",
-    "\t\treq.errorByType.get(\"WARN\"),",
-    "\t\treq.totalErrors(\"WARN\"),",
-    "\t\treq.totalErrors(\"WARN\", this.windowstate.file)",
+    "\t\tthis.windowstate.project.getErrors(\"WARN\"),",
+    "\t\tthis.windowstate.file.getErrors(\"WARN\")",
     "\t);",
     "\tthis.statusbar_depricated.setNotices(",
-    "\t\treq.errorByType.get(\"DEPR\"),",
-    "\t\treq.totalErrors(\"DEPR\"),",
-    "\t\treq.totalErrors(\"DEPR\", this.windowstate.file)",
+    "\t\tthis.windowstate.project.getErrors(\"DEPR\"),",
+    "\t\tthis.windowstate.file.getErrors(\"DEPR\")",
     "\t);",
-    "",
+    " ",
     "\t_this.statusbar_run.el.hide();",
     "",
-    "\tif (req.totalErrors(\"ERR\") < 1) {",
+    "\tif (pr.get_n_items() < 1) {",
     "\t\t_this.statusbar_run.el.show();",
-    "\t}",
+    "\t} ",
     "\t",
     "}"
    ]