From f056fe0b7bb6a76ad57420ee5c806a242c77fb1b Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 9 Feb 2024 14:20:43 +0800 Subject: [PATCH] Fix #8028 - language server performance, fix warnings and critical errors --- src/Application.vala | 7 ++++-- src/Builder4/DialogFiles.bjs | 2 +- src/Builder4/DialogFiles.vala | 2 +- src/Builder4/GtkView.bjs | 6 ++--- src/Builder4/GtkView.vala | 6 ++--- src/Builder4/MainWindow.bjs | 22 +++++++++---------- src/Builder4/MainWindow.vala | 22 +++++++++---------- src/Builder4/ValaCompileErrors.bjs | 2 +- src/Builder4/ValaCompileErrors.vala | 2 +- src/Builder4/WindowLeftProps.bjs | 16 ++++++++------ src/Builder4/WindowLeftProps.vala | 16 ++++++++------ src/Builder4/WindowLeftTree.bjs | 16 ++++++++++---- src/Builder4/WindowLeftTree.vala | 16 ++++++++++---- src/JsRender/JsRender.vala | 17 ++++++++++----- src/JsRender/Node.vala | 15 ++++++------- src/JsRender/NodeToGlade.vala | 2 +- src/Palete/CompletionProvider.vala | 34 ++++++++++++++++++++++------- src/Palete/Gir.vala | 8 +++---- src/Palete/GirObject.vala | 2 +- src/Palete/LanguageClient.vala | 1 + src/Palete/LanguageClientVala.vala | 16 ++++++++++++++ src/Palete/ValaCompileRequest.vala | 13 ++++++++--- src/Project/Meson.vala | 11 +++++++--- src/Spawn.vala | 6 ++++- 24 files changed, 168 insertions(+), 92 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index a71a68b57..340a70dbc 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -194,7 +194,6 @@ 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; diff --git a/src/Builder4/DialogFiles.bjs b/src/Builder4/DialogFiles.bjs index fb42372ba..2fe4f40db 100644 --- a/src/Builder4/DialogFiles.bjs +++ b/src/Builder4/DialogFiles.bjs @@ -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);", "}", "" ], diff --git a/src/Builder4/DialogFiles.vala b/src/Builder4/DialogFiles.vala index 11e80aa05..8918a53a8 100644 --- a/src/Builder4/DialogFiles.vala +++ b/src/Builder4/DialogFiles.vala @@ -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); } } diff --git a/src/Builder4/GtkView.bjs b/src/Builder4/GtkView.bjs index 1323bb4c4..34a781888 100644 --- a/src/Builder4/GtkView.bjs +++ b/src/Builder4/GtkView.bjs @@ -281,7 +281,7 @@ " 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);", @@ -931,7 +931,7 @@ "", "", " ", - "\tGLib.debug(\"highlight errors\");\t\t ", + "\t//GLib.debug(\"highlight errors\");\t\t ", "", "\t // we should highlight other types of errors..", "", @@ -952,7 +952,7 @@ "\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) {", diff --git a/src/Builder4/GtkView.vala b/src/Builder4/GtkView.vala index c560f2515..c3f9c0e8e 100644 --- a/src/Builder4/GtkView.vala +++ b/src/Builder4/GtkView.vala @@ -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); diff --git a/src/Builder4/MainWindow.bjs b/src/Builder4/MainWindow.bjs index 1b3bee7c5..63f780d4b 100644 --- a/src/Builder4/MainWindow.bjs +++ b/src/Builder4/MainWindow.bjs @@ -670,12 +670,11 @@ "\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}", @@ -1400,12 +1399,11 @@ ], "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}", diff --git a/src/Builder4/MainWindow.vala b/src/Builder4/MainWindow.vala index 0dabf4709..adb3f8c2a 100644 --- a/src/Builder4/MainWindow.vala +++ b/src/Builder4/MainWindow.vala @@ -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; } diff --git a/src/Builder4/ValaCompileErrors.bjs b/src/Builder4/ValaCompileErrors.bjs index 3ae7261ed..ca9a537bd 100644 --- a/src/Builder4/ValaCompileErrors.bjs +++ b/src/Builder4/ValaCompileErrors.bjs @@ -323,7 +323,7 @@ ], "| 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;", diff --git a/src/Builder4/ValaCompileErrors.vala b/src/Builder4/ValaCompileErrors.vala index caf2d6509..cea048359 100644 --- a/src/Builder4/ValaCompileErrors.vala +++ b/src/Builder4/ValaCompileErrors.vala @@ -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; diff --git a/src/Builder4/WindowLeftProps.bjs b/src/Builder4/WindowLeftProps.bjs index b14e7ab5b..657d9b1ea 100644 --- a/src/Builder4/WindowLeftProps.bjs +++ b/src/Builder4/WindowLeftProps.bjs @@ -1078,13 +1078,13 @@ " \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 ", @@ -1102,12 +1102,12 @@ "\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;", "", " }" @@ -1516,12 +1516,14 @@ "\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;", diff --git a/src/Builder4/WindowLeftProps.vala b/src/Builder4/WindowLeftProps.vala index 0a7f04d46..ceb58d01d 100644 --- a/src/Builder4/WindowLeftProps.vala +++ b/src/Builder4/WindowLeftProps.vala @@ -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; } diff --git a/src/Builder4/WindowLeftTree.bjs b/src/Builder4/WindowLeftTree.bjs index 194e3600f..fd9795592 100644 --- a/src/Builder4/WindowLeftTree.bjs +++ b/src/Builder4/WindowLeftTree.bjs @@ -904,13 +904,14 @@ "| 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}", @@ -1027,14 +1028,20 @@ "" ], "| 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);", @@ -1409,6 +1416,7 @@ "| 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) {", diff --git a/src/Builder4/WindowLeftTree.vala b/src/Builder4/WindowLeftTree.vala index 0260e7b06..6cfa983cf 100644 --- a/src/Builder4/WindowLeftTree.vala +++ b/src/Builder4/WindowLeftTree.vala @@ -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); diff --git a/src/JsRender/JsRender.vala b/src/JsRender/JsRender.vala index 593d8ffd3..485f0788e 100644 --- a/src/JsRender/JsRender.vala +++ b/src/JsRender/JsRender.vala @@ -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++; diff --git a/src/JsRender/Node.vala b/src/JsRender/Node.vala index cdc7cf311..73515e9ce 100644 --- a/src/JsRender/Node.vala +++ b/src/JsRender/Node.vala @@ -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) : "") + " " + GLib.Markup.escape_text(i) +" : " + - 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) : "") + " " + GLib.Markup.escape_text(i) +" : " + - 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" + GLib.Markup.escape_text(i) +" : " + - 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" + GLib.Markup.escape_text(i) +" : " + - 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... diff --git a/src/JsRender/NodeToGlade.vala b/src/JsRender/NodeToGlade.vala index 874983f10..b9d6d005c 100644 --- a/src/JsRender/NodeToGlade.vala +++ b/src/JsRender/NodeToGlade.vala @@ -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(); diff --git a/src/Palete/CompletionProvider.vala b/src/Palete/CompletionProvider.vala index 9ef4c63fb..223b4d113 100644 --- a/src/Palete/CompletionProvider.vala +++ b/src/Palete/CompletionProvider.vala @@ -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); diff --git a/src/Palete/Gir.vala b/src/Palete/Gir.vala index 05c731e23..648f1c569 100644 --- a/src/Palete/Gir.vala +++ b/src/Palete/Gir.vala @@ -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...? diff --git a/src/Palete/GirObject.vala b/src/Palete/GirObject.vala index 5a8361c62..f9589f6f7 100644 --- a/src/Palete/GirObject.vala +++ b/src/Palete/GirObject.vala @@ -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]); diff --git a/src/Palete/LanguageClient.vala b/src/Palete/LanguageClient.vala index 0a07c84e8..67f784a6a 100644 --- a/src/Palete/LanguageClient.vala +++ b/src/Palete/LanguageClient.vala @@ -15,6 +15,7 @@ namespace Palete { ACCEPT, DIAG, + DIAG_END, OPEN, SAVE, CLOSE, diff --git a/src/Palete/LanguageClientVala.vala b/src/Palete/LanguageClientVala.vala index c61f24f7c..cd3e3b029 100644 --- a/src/Palete/LanguageClientVala.vala +++ b/src/Palete/LanguageClientVala.vala @@ -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); diff --git a/src/Palete/ValaCompileRequest.vala b/src/Palete/ValaCompileRequest.vala index aa9b50a4c..5c05eba24 100644 --- a/src/Palete/ValaCompileRequest.vala +++ b/src/Palete/ValaCompileRequest.vala @@ -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); }); diff --git a/src/Project/Meson.vala b/src/Project/Meson.vala index e91fc9304..16637c2af 100644 --- a/src/Project/Meson.vala +++ b/src/Project/Meson.vala @@ -221,7 +221,13 @@ install_data( } gr += "\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 ""; + } diff --git a/src/Spawn.vala b/src/Spawn.vala index cac96f388..3e09e1f92 100644 --- a/src/Spawn.vala +++ b/src/Spawn.vala @@ -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; -- 2.39.2