Fix #8028 - language server performance, fix warnings and critical errors
authorAlan <alan@roojs.com>
Fri, 9 Feb 2024 06:20:43 +0000 (14:20 +0800)
committerAlan <alan@roojs.com>
Fri, 9 Feb 2024 06:20:43 +0000 (14:20 +0800)
24 files changed:
src/Application.vala
src/Builder4/DialogFiles.bjs
src/Builder4/DialogFiles.vala
src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala
src/Builder4/MainWindow.bjs
src/Builder4/MainWindow.vala
src/Builder4/ValaCompileErrors.bjs
src/Builder4/ValaCompileErrors.vala
src/Builder4/WindowLeftProps.bjs
src/Builder4/WindowLeftProps.vala
src/Builder4/WindowLeftTree.bjs
src/Builder4/WindowLeftTree.vala
src/JsRender/JsRender.vala
src/JsRender/Node.vala
src/JsRender/NodeToGlade.vala
src/Palete/CompletionProvider.vala
src/Palete/Gir.vala
src/Palete/GirObject.vala
src/Palete/LanguageClient.vala
src/Palete/LanguageClientVala.vala
src/Palete/ValaCompileRequest.vala
src/Project/Meson.vala
src/Spawn.vala

index a71a68b..340a70d 100644 (file)
                        var css = new Gtk.CssProvider();
                        css.load_from_resource("/css/roobuilder.css");
                        
-                       
                        Gtk.StyleContext.add_provider_for_display(
                                Gdk.Display.get_default(),
                                css     ,
@@ -745,7 +744,7 @@ flutter-project  -  was try and read flutter data (but desnt work.)
 
                                ww.windowstate.updateErrorMarksAll();
                                 
-                               GLib.debug("calling udate Errors of window %s", ww.windowstate.file.targetName());
+                               //GLib.debug("calling udate Errors of window %s", ww.windowstate.file.targetName());
                                ww.updateErrors();
                                ww.windowstate.left_tree.updateErrors();
                                ww.windowstate.left_props.updateErrors();
@@ -769,6 +768,10 @@ flutter-project  -  was try and read flutter data (but desnt work.)
                                                BuilderApplication.showSpinner( "format-justify-fill", msg);                                    
                                                return;
 
+                                       case Palete.LanguageClientAction.DIAG_END:
+                                               BuilderApplication.showSpinner( "", "");
+                                               return;
+
                                        case Palete.LanguageClientAction.OPEN:
                                                BuilderApplication.showSpinner( "document-open", msg);                                  
                                                return;
index fb42372..2fe4f40 100644 (file)
@@ -37,7 +37,7 @@
     "\t\treturn  ;",
     "\t});",
     "\tev.ref(); //?? needed?",
-    "\t(this.el as Gtk.Widget).add_controller(ev);",
+    "\t((Gtk.Widget)this.el).add_controller(ev);",
     "}",
     ""
    ],
index 11e80aa..8918a53 100644 (file)
@@ -105,7 +105,7 @@ public class DialogFiles : Object
                                return  ;
                        });
                        ev.ref(); //?? needed?
-                       (this.el as Gtk.Widget).add_controller(ev);
+                       ((Gtk.Widget)this.el).add_controller(ev);
                }
        }
 
index 1323bb4..34a7818 100644 (file)
             "    this.loading = true;",
             "    var buf = this.el.get_buffer();",
             "    buf.set_text(\"\",0);",
-            "    var sbuf = (GtkSource.Buffer) buf;",
+            " ",
             "\tvar cpos = buf.cursor_position;",
             "    ",
             "   \tprint(\"BEFORE LOAD cursor = %d\\n\", cpos);",
     "",
     "",
     " ",
-    "\tGLib.debug(\"highlight errors\");\t\t ",
+    "\t//GLib.debug(\"highlight errors\");\t\t ",
     "",
     "\t // we should highlight other types of errors..",
     "",
     "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
     "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
     "\t\tthis.last_error_counter = file.error_counter ;",
-    "\t\tGLib.debug(\"higjlight has no errors\");",
+    "\t\t//GLib.debug(\"higjlight has no errors\");",
     "\t\treturn;",
     "\t}",
     " \tif (this.last_error_counter == file.error_counter) {",
index c560f25..c3f9c0e 100644 (file)
@@ -311,7 +311,7 @@ public class Xcls_GtkView : Object
        
        
         
-               GLib.debug("highlight errors");          
+               //GLib.debug("highlight errors");                
        
                 // we should highlight other types of errors..
        
@@ -332,7 +332,7 @@ public class Xcls_GtkView : Object
                        buf.remove_source_marks (start, end, "WARN");
                        buf.remove_source_marks (start, end, "DEPR");
                        this.last_error_counter = file.error_counter ;
-                       GLib.debug("higjlight has no errors");
+                       //GLib.debug("higjlight has no errors");
                        return;
                }
                if (this.last_error_counter == file.error_counter) {
@@ -737,7 +737,7 @@ public class Xcls_GtkView : Object
                    this.loading = true;
                    var buf = this.el.get_buffer();
                    buf.set_text("",0);
-                   var sbuf = (GtkSource.Buffer) buf;
+                
                        var cpos = buf.cursor_position;
                    
                        print("BEFORE LOAD cursor = %d\n", cpos);
index 1b3bee7..63f780d 100644 (file)
              "\tif (!_this.treescroll.el.visible || _this.treeselmodel.el.get_n_items() < 0) {",
              "\t\treturn;",
              "\t}",
-             "\tGLib.debug(",
-             "\t",
-             "\t\t\"searcj key release %d, %d, %d  ?= %d\" , ",
-             "\t\t\t(int) keyval, (int)  keycode, state,",
-             "\t\t\t(int)Gdk.Key.Return",
-             "\t\t);",
+             "\t//GLib.debug(",
+             "\t//\t\"searcj key release %d, %d, %d  ?= %d\" , ",
+             "\t//\t\t(int) keyval, (int)  keycode, state,",
+             "\t//\t\t(int)Gdk.Key.Return",
+             "\t//\t);",
              "\tif (!_this.treescroll.el.visible || _this.treeselmodel.el.get_n_items() < 0) {",
              "\t\treturn;",
              "\t}",
         ],
         "key_released" : [
          "(keyval, keycode, state) => {",
-         "\tGLib.debug(",
-         "\t",
-         "\t\t\"key release %d, %d, %d  ?= %d %d\" , ",
-         "\t\t\t(int) keyval, (int)  keycode, state,",
-         "\t\t\t(int)Gdk.Key.O, Gdk.ModifierType.CONTROL_MASK",
-         "\t\t);",
+         "\t//GLib.debug(",
+         "\t//\t\"key release %d, %d, %d  ?= %d %d\" , ",
+         "\t//\t\t(int) keyval, (int)  keycode, state,",
+         "\t//\t\t(int)Gdk.Key.O, Gdk.ModifierType.CONTROL_MASK",
+         "\t//\t);",
          " \tif (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {",
          " \t\tthis.is_shift = 0;",
          "\t}",
index 0dabf47..adb3f8c 100644 (file)
@@ -1538,12 +1538,11 @@ public class Xcls_MainWindow : Object
                                if (!_this.treescroll.el.visible || _this.treeselmodel.el.get_n_items() < 0) {
                                        return;
                                }
-                               GLib.debug(
-                               
-                                       "searcj key release %d, %d, %d  ?= %d" , 
-                                               (int) keyval, (int)  keycode, state,
-                                               (int)Gdk.Key.Return
-                                       );
+                               //GLib.debug(
+                               //      "searcj key release %d, %d, %d  ?= %d" , 
+                               //              (int) keyval, (int)  keycode, state,
+                               //              (int)Gdk.Key.Return
+                               //      );
                                if (!_this.treescroll.el.visible || _this.treeselmodel.el.get_n_items() < 0) {
                                        return;
                                }
@@ -2841,12 +2840,11 @@ public class Xcls_MainWindow : Object
 
                        //listeners
                        this.el.key_released.connect( (keyval, keycode, state) => {
-                               GLib.debug(
-                               
-                                       "key release %d, %d, %d  ?= %d %d" , 
-                                               (int) keyval, (int)  keycode, state,
-                                               (int)Gdk.Key.O, Gdk.ModifierType.CONTROL_MASK
-                                       );
+                               //GLib.debug(
+                               //      "key release %d, %d, %d  ?= %d %d" , 
+                               //              (int) keyval, (int)  keycode, state,
+                               //              (int)Gdk.Key.O, Gdk.ModifierType.CONTROL_MASK
+                               //      );
                                if (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {
                                        this.is_shift = 0;
                                }
index 3ae7261..ca9a537 100644 (file)
    ],
    "| void updateNotices" : [
     "( GLib.ListStore? ls) {",
-    "\tGLib.debug(\"errors  : update\");",
+    "\t//GLib.debug(\"errors  : update\");",
     "    if (ls == null || ls.get_n_items() < 1) {",
     " \t//    GLib.debug(\"errors  : none available\");",
     "    \treturn;",
index caf2d65..cea0483 100644 (file)
@@ -44,7 +44,7 @@ public class Xcls_ValaCompileErrors : Object
 
        // user defined functions
        public void updateNotices ( GLib.ListStore? ls) {
-               GLib.debug("errors  : update");
+               //GLib.debug("errors  : update");
            if (ls == null || ls.get_n_items() < 1) {
                //    GLib.debug("errors  : none available");
                return;
index b14e7ab..657d9b1 100644 (file)
         "    \t\t ",
         "    \t}",
         "    \t*/",
-        "\t\tGLib.debug(\"Get Widget At Row %d\", (int)row);",
+        "\t\t//GLib.debug(\"Get Widget At Row %d\", (int)row);",
         "        var  child = this.el.get_first_child(); ",
         "    \tvar line_no = -1; ",
         "    \tvar reading_header = true;",
         "",
         "    \twhile (child != null) {",
-        "\t\t\tGLib.debug(\"Got %s\", child.get_type().name());",
+        "\t\t\t//GLib.debug(\"Got %s\", child.get_type().name());",
         "    \t    if (reading_header) {",
         "\t\t\t ",
         "\t\t\t   ",
         "\t\t    }",
         "\t\t    line_no++;",
         "\t\t\tif (line_no == row) {",
-        "\t\t\t\tGLib.debug(\"Returning widget %s\", child.get_type().name());",
+        "\t\t\t\t//GLib.debug(\"Returning widget %s\", child.get_type().name());",
         "\t\t\t    return (Gtk.Widget)child;",
         "\t\t    }",
         "\t        child = child.get_next_sibling(); ",
         "    \t}",
-        "\t\tGLib.debug(\"Rturning null\");",
+        "\t\t//GLib.debug(\"Rturning null\");",
         "        return null;",
         "",
         " }"
     "\t",
     "\t\t ",
     "//        print(\"get inter\\n\");",
-    "\t    var node= file.lineToNode( (int)diag.range.start.line) ;",
-    "\t    if (node == null || node.oid != this.node.oid) {",
+    "\t    var node = file.lineToNode( (int)diag.range.start.line) ;",
+    "\t    if (node == null || this.node == null || node.oid != this.node.oid) {",
     "\t    \tcontinue;",
     "    \t}",
     "    \tvar prop = node.lineToProp( (int)diag.range.start.line) ;",
-    "    \t",
+    "    \tif (prop == null) {",
+    "    \t\tcontinue;",
+    "\t\t}",
     "    \tvar row = _this.selmodel.propToRow(prop);",
     "    \tif (row < 0) {",
     "    \t\tcontinue;",
index 0a7f04d..ceb58d0 100644 (file)
@@ -110,12 +110,14 @@ public class Xcls_LeftProps : Object
                
                         
        //        print("get inter\n");
-                   var node= file.lineToNode( (int)diag.range.start.line) ;
-                   if (node == null || node.oid != this.node.oid) {
+                   var node = file.lineToNode( (int)diag.range.start.line) ;
+                   if (node == null || this.node == null || node.oid != this.node.oid) {
                        continue;
                }
                var prop = node.lineToProp( (int)diag.range.start.line) ;
-               
+               if (prop == null) {
+                       continue;
+                       }
                var row = _this.selmodel.propToRow(prop);
                if (row < 0) {
                        continue;
@@ -1629,13 +1631,13 @@ public class Xcls_LeftProps : Object
                                 
                        }
                        */
-                               GLib.debug("Get Widget At Row %d", (int)row);
+                               //GLib.debug("Get Widget At Row %d", (int)row);
                        var  child = this.el.get_first_child(); 
                        var line_no = -1; 
                        var reading_header = true;
                
                        while (child != null) {
-                                       GLib.debug("Got %s", child.get_type().name());
+                                       //GLib.debug("Got %s", child.get_type().name());
                            if (reading_header) {
                                         
                                           
@@ -1653,12 +1655,12 @@ public class Xcls_LeftProps : Object
                                    }
                                    line_no++;
                                        if (line_no == row) {
-                                               GLib.debug("Returning widget %s", child.get_type().name());
+                                               //GLib.debug("Returning widget %s", child.get_type().name());
                                            return (Gtk.Widget)child;
                                    }
                                child = child.get_next_sibling(); 
                        }
-                               GLib.debug("Rturning null");
+                               //GLib.debug("Rturning null");
                        return null;
                
                 }
index 194e360..fd97955 100644 (file)
            "| int nodeToRow" : [
             "(JsRender.Node node) ",
             "{",
-            "\tvar row = -1;",
+            " ",
             "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
             "\tfor (var i = 0; i < s.n_items; i++) {",
             "\t\t//GLib.debug(\"check node %s\", s.get_item(i).get_type().name());",
             "\t\tvar lr = s.get_item(i) as Gtk.TreeListRow;",
             "\t\t//GLib.debug(\"check node %s\", lr.get_item().get_type().name());",
-            "\t\tif ((lr.get_item() as JsRender.Node).oid == node.oid) {",
+            "\t\tvar nn = (lr.get_item() as JsRender.Node);",
+            "\t\tif (nn != null && nn.oid == node.oid) {",
             "\t\t\treturn i;",
             "\t\t\t",
             "\t\t}",
             ""
            ],
            "| void selectNode" : [
-            "(JsRender.Node node) ",
+            "(JsRender.Node node) ",
             "{",
-            "\tvar row = this.nodeToRow(node);",
             "\tvar s = _this.view.el.model as Gtk.SingleSelection;",
+            "\tif (node == null) {",
+            "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
+            "\t\treturn;",
+            "\t}",
+            "\tvar row = this.nodeToRow(node);",
+            "",
             "\t ",
             "\tif (row < 0) {",
             "\t\t// select none?",
             "\t\tGLib.debug(\"Could not find node\");",
+            "\t\ts.selected=Gtk.INVALID_LIST_POSITION;",
             "\t\treturn;",
             "\t}",
             "\tGLib.debug(\"Select %d\", row);",
        "| int getRowAt" : [
         "(double x,  double  y, out string pos) {",
         "",
+        "\tpos = \"\";",
         "\tvar w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);",
         "\t//GLib.debug(\"got widget %s\", w == null ? \"nothing\" : w.get_type().name());",
         "\tif (w == null) {",
index 0260e7b..6cfa983 100644 (file)
@@ -440,6 +440,7 @@ public class Xcls_WindowLeftTree : Object
                 }
                public int getRowAt (double x,  double  y, out string pos) {
                
+                       pos = "";
                        var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
                        //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
                        if (w == null) {
@@ -1496,13 +1497,14 @@ public class Xcls_WindowLeftTree : Object
                }
                public int nodeToRow (JsRender.Node node) 
                {
-                       var row = -1;
+                
                        var s = _this.view.el.model as Gtk.SingleSelection;
                        for (var i = 0; i < s.n_items; i++) {
                                //GLib.debug("check node %s", s.get_item(i).get_type().name());
                                var lr = s.get_item(i) as Gtk.TreeListRow;
                                //GLib.debug("check node %s", lr.get_item().get_type().name());
-                               if ((lr.get_item() as JsRender.Node).oid == node.oid) {
+                               var nn = (lr.get_item() as JsRender.Node);
+                               if (nn != null && nn.oid == node.oid) {
                                        return i;
                                        
                                }
@@ -1593,14 +1595,20 @@ public class Xcls_WindowLeftTree : Object
                        _this.selmodel.el.set_model(this.el);
                        return this.el;
                }
-               public void selectNode (JsRender.Node node) 
+               public void selectNode (JsRender.Node node) 
                {
-                       var row = this.nodeToRow(node);
                        var s = _this.view.el.model as Gtk.SingleSelection;
+                       if (node == null) {
+                               s.selected=Gtk.INVALID_LIST_POSITION;
+                               return;
+                       }
+                       var row = this.nodeToRow(node);
+               
                         
                        if (row < 0) {
                                // select none?
                                GLib.debug("Could not find node");
+                               s.selected=Gtk.INVALID_LIST_POSITION;
                                return;
                        }
                        GLib.debug("Select %d", row);
index 593d8ff..485f078 100644 (file)
@@ -148,7 +148,11 @@ namespace JsRender {
                                if (!GLib.FileUtils.test(this.path, GLib.FileTest.EXISTS)) {
                                        return null;
                                }
-                               this._icon = File.new_for_path(this.path).query_info("standard::icon",GLib.FileQueryInfoFlags.NONE).get_icon();
+                               try {
+                                       this._icon = File.new_for_path(this.path).query_info("standard::icon",GLib.FileQueryInfoFlags.NONE).get_icon();
+                               } catch(GLib.Error e) {
+                                       return null;
+                               }
                                return this._icon;
                        }
                }
@@ -480,8 +484,11 @@ namespace JsRender {
                        var new_version = this.version + step;
                        var pa = new Json.Parser();
                        //GLib.debug("UNDO RESTORE : %d",  this.version + step);
-                       
-                       pa.load_from_data(this.undo_json.get(new_version));
+                       try {
+                               pa.load_from_data(this.undo_json.get(new_version));
+                       } catch (GLib.Error e) {
+                               return false;
+                       }
                        var node = pa.get_root();
                        this.in_undo = true;
                        this.loadTree(node.get_object(),2); 
@@ -828,7 +835,7 @@ namespace JsRender {
                private void addError(Lsp.Diagnostic diag)
                {
                        
-                       GLib.debug("ADD Error %s", diag.to_string());
+                       //GLib.debug("ADD Error %s", diag.to_string());
                        this.errors.add(diag);
                        this.project.addError(this, diag);
                        
@@ -838,7 +845,7 @@ namespace JsRender {
                 
                public void removeError(Lsp.Diagnostic diag) 
                {
-                       GLib.debug("REMOVE Error %s", diag.to_string());
+                       //GLib.debug("REMOVE Error %s", diag.to_string());
                        this.errors.remove(diag);
                        this.project.removeError(this, diag);
                        this.error_counter++;
index cdc7cf3..73515e9 100644 (file)
@@ -767,31 +767,30 @@ public class JsRender.Node : GLib.Object {
                                case PROP: 
                                case RAW: // should they be the same?
                                
-                                       props += "\n\t" + GLib.Markup.escape_text(prop.rtype) +
+                                       props += "\n\t" + (prop.rtype != null && prop.rtype.length > 0 ? GLib.Markup.escape_text(prop.rtype)  : "") +
                                                " <b>" + GLib.Markup.escape_text(i) +"</b> : " + 
-                                               GLib.Markup.escape_text(val.split("\n")[0]);
+                                               (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
                                                
                                        break;
-                                       
-                       
+                                        
                                
                                case METHOD :
-                                       funcs += "\n\t" + GLib.Markup.escape_text(prop.rtype) +
+                                       funcs += "\n\t" + (prop.rtype != null && prop.rtype.length > 0 ? GLib.Markup.escape_text(prop.rtype)  : "")  +
                                                " <b>" + GLib.Markup.escape_text(i) +"</b> : "  +
-                                               GLib.Markup.escape_text(val.split("\n")[0]);
+                                               (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
                                        break;
                                        
                                 
                                case USER : // user defined.
                                        uprops += "\n\t<b>" + 
                                                GLib.Markup.escape_text(i) +"</b> : " + 
-                                               GLib.Markup.escape_text(val.split("\n")[0]);
+                                               (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
                                        break;
                                        
                                case SPECIAL : // * prop| args | ctor | init
                                        spec += "\n\t<b>" + 
                                                GLib.Markup.escape_text(i) +"</b> : " + 
-                                               GLib.Markup.escape_text(val.split("\n")[0]);
+                                               (val.length > 0 ? GLib.Markup.escape_text(val.split("\n")[0]) : "");
                                        break;
                                        
                                case LISTENER : return  "";  // always raw...
index 874983f..b9d6d00 100644 (file)
@@ -31,7 +31,7 @@ public class JsRender.NodeToGlade : Object {
                ///n.toValaName(file.tree);
                
                
-               GLib.debug("top cls %s / xlcs %s\n ",file.tree.xvala_cls,file.tree.xvala_cls); 
+               //GLib.debug("top cls %s / xlcs %s ",file.tree.xvala_cls,file.tree.xvala_cls); 
                //n.cls = file.tree.xvala_cls;
                //n.xcls = file.tree.xvala_xcls;
                return n.munge();
index 9ef4c63..223b4d1 100644 (file)
@@ -13,7 +13,7 @@ namespace Palete {
                public Editor editor; 
                //public WindowState windowstate;
                public CompletionModel model;
-               global::Gtk.StringFilter filter;
+               global::Gtk.StringFilter? filter = null;
 
                public CompletionProvider(Editor editor)
                {
@@ -33,6 +33,18 @@ namespace Palete {
                  return 200;
                }
                
+               
+               public bool is_trigger(global::Gtk.TextIter  iter, unichar ch)
+               {
+                       if (this.in_populate || ch == 32) {
+                               return false;
+                       }
+                       GLib.debug("should trigger? %c", (int) ch);
+                       
+                       
+                       return true;
+               }
+               
                public  void activate (GtkSource.CompletionContext context, GtkSource.CompletionProposal proposal)
                {
                        GLib.debug("compelte activate");
@@ -187,12 +199,14 @@ namespace Palete {
                internal  async GLib.ListModel populate_async (GtkSource.CompletionContext context, GLib.Cancellable? cancellable) 
                {
                        GLib.debug("pupoulate async");
-                       /*if (!this.in_populate) {
+                       var ret = new GLib.ListStore(typeof(CompletionProposal));
+                       
+                       if (this.in_populate) {
                                GLib.debug("pupoulate async  - skipped waiting for reply");
-                               return null;
+                               return ret;
                        }
                        this.in_populate = true;
-*/
+
                        global::Gtk.TextIter begin, end;
                        Lsp.CompletionList res;
                        if (context.get_bounds (out begin, out end)) {
@@ -210,7 +224,7 @@ namespace Palete {
                                                offset += 2;
                                        }
                                } 
-                               
+                               //  this should not really be slow, as it's a quick repsonse
                                yield this.file.getLanguageServer().document_change_force(this.file, this.editor.tempFileContents());                           
                                try {
                                        GLib.debug("sending request to language server %s", this.file.getLanguageServer().get_type().name());
@@ -218,11 +232,13 @@ namespace Palete {
                                        res = yield this.file.getLanguageServer().completion(this.file, line, offset, 1);
                                } catch (GLib.Error e) {
                                        GLib.debug("got error %s", e.message);
-                                       res = null;
+                                       this.in_populate = false;
+                                       return ret;
                                }
                                
                        } else {
-                               res = null;
+                               this.in_populate = false;
+                               return ret;
                        }
                        
                        GLib.debug("pupoulate async  - got reply");
@@ -247,7 +263,9 @@ namespace Palete {
                {
  
                        //GLib.debug("pupoulate refilter");
-        
+                       if (this.filter == null) {
+                               return;
+                       }
 
                        var word = context.get_word();
                        this.filter.set_search(word);
index 05c731e..648f1c5 100644 (file)
@@ -197,20 +197,20 @@ namespace Palete {
                        var fqn = in_fqn;
                        // swap Gtk.Source* to GtkSource.
                        
-                       GLib.debug("Gir.factoryFqn  search %s", fqn);
+                       //GLib.debug("Gir.factoryFqn  search %s", fqn);
                        var bits = fqn.split(".");
                        if (bits.length < 1) {
-                               GLib.debug("Gir.factoryFqn  fail - missing '.'");
+                               //GLib.debug("Gir.factoryFqn  fail - missing '.'");
                                return null;
                        }
                        
                        var f = (GirObject)factory(project , bits[0]);
 
                        if (bits.length == 1 || f ==null) {
-                               GLib.debug("Gir.factoryFqn  fail - factory failed to load NS");
+                               //GLib.debug("Gir.factoryFqn  fail - factory failed to load NS");
                                return f;
                        }
-                       GLib.debug("Gir.factoryFqn  fetching child %s", fqn.substring(bits[0].length+1));
+                       //GLib.debug("Gir.factoryFqn  fetching child %s", fqn.substring(bits[0].length+1));
                        return f.fetchByFqn(fqn.substring(bits[0].length+1)); // since classes are stored in fqn format...?
                                            
                        
index 5a8361c..f9589f6 100644 (file)
@@ -351,7 +351,7 @@ namespace Palete {
 
  
                public GirObject? fetchByFqn(string fqn) {
-                       GLib.debug("Searching (%s)%s for %s\n", this.nodetype, this.name, fqn);
+                       //                      GLib.debug("Searching (%s)%s for %s", this.nodetype, this.name, fqn);
                        var bits = fqn.split(".");
                        
                        var ret = this.classes.get(bits[0]);
index 0a07c84..67f784a 100644 (file)
@@ -15,6 +15,7 @@ namespace Palete {
                ACCEPT,
                
                DIAG,
+               DIAG_END,
                OPEN,
                SAVE,
                CLOSE,
index c61f24f..cd3e3b0 100644 (file)
@@ -54,7 +54,12 @@ namespace Palete {
                                if (this.change_queue_file == null) {
                                        return true;
                                }
+                               if (this.getting_diagnostics) {
+                                       return true;
+                               }
                                this.countdown--;
+
+                       
                                if (this.countdown < 0){
                                        this.document_change_force.begin(this.change_queue_file,  this.change_queue_file_source, (o, res) => {
                                                this.document_change_force.end(res);
@@ -161,6 +166,7 @@ namespace Palete {
                                        return a.path == b.path;
                                });
                                this.initialized = true;
+                               this.getting_diagnostics = false;
                                return;
                        } catch (GLib.Error e) {
                                GLib.debug ("LS replied with error %s", e.message);
@@ -176,6 +182,7 @@ namespace Palete {
                        if (this.launcher == null) {
                                return;
                        }
+                       this.getting_diagnostics = false;
                        this.in_close = true;
                        GLib.debug("onClose called");
                        
@@ -259,6 +266,7 @@ namespace Palete {
                        
                }
                
+               bool getting_diagnostics = false;
                /***
                
                */
@@ -266,7 +274,15 @@ namespace Palete {
                {
                        //GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));                                     
                        var dg = Json.gobject_deserialize (typeof (Lsp.Diagnostics), Json.gvariant_serialize (return_value)) as Lsp.Diagnostics; 
+                       GLib.debug("got diag for %s", dg.filename);
                        this.log(LanguageClientAction.DIAG, dg.filename);
+                       if (this.project.path == dg.filename) {
+                               this.getting_diagnostics = false;
+                               this.log(LanguageClientAction.DIAG_END, "diagnostics done");
+                               return;
+                       
+                       }
+                       this.getting_diagnostics =true;
                        var f = this.project.getByPath(dg.filename);
                        if (f == null) {
                                //GLib.debug("no file %s", dg.uri);
index aa9b50a..5c05eba 100644 (file)
@@ -67,7 +67,11 @@ namespace Palete {
                        var exe = GLib.Environment.find_program_in_path( "meson");
                        string[] args = { exe ,"setup", "build", "--prefix=/usr" };             
                        GLib.debug("running meson");
-                       this.spawn = new Spawn(this.project.path , args);
+                       try {
+                               this.spawn = new Spawn(this.project.path , args);
+                       } catch (GLib.Error e) {
+                               return -1;
+                       }
                        this.spawn.output_line.connect(( str) => {
                                this.onOutput(str);
                        });
@@ -83,8 +87,11 @@ namespace Palete {
                        }
                        var exe = GLib.Environment.find_program_in_path( "ninja");
                        string[] args = { exe };                
-
-                       this.spawn = new Spawn(this.project.path + "/build" , args);
+                       try {
+                               this.spawn = new Spawn(this.project.path + "/build" , args);
+                       } catch (GLib.Error e) {
+                               return -1;
+                       }
                        this.spawn.output_line.connect(( str) => {
                                this.onOutput(str);
                        });
index e91fc93..16637c2 100644 (file)
@@ -221,7 +221,13 @@ install_data(
                        
                        }
                        gr += "</gresources>\n";
-                       FileUtils.set_contents(this.project.path + "/resources/gresources.xml", gr, gr.length);
+                       try {
+                               FileUtils.set_contents(this.project.path + "/resources/gresources.xml", gr, gr.length);
+                       } catch (GLib.Error e) { 
+                               return "";
+                       }
+                        
+                       
                        
                        this.has_resources = true;
                        
@@ -232,8 +238,7 @@ install_data(
        c_name: '" + this.project.name + "_resources' 
 )";
                        
-                
-                       return "";
+                 
                
                }
                
index cac96f3..3e09e1f 100644 (file)
@@ -325,8 +325,12 @@ public class Spawn : Object
                this.complete.connect( (res, str,  stderr) => {
                        loop.quit ();
                });
+               try {
+                       this.run();
+               } catch (GLib.Error e) {
+                       return -1;
+               }
                
-               this.run();
                 
                loop.run ();
                return this.result;