src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Mon, 29 Jan 2024 09:23:25 +0000 (17:23 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 29 Jan 2024 09:23:25 +0000 (17:23 +0800)
src/Builder4/Editor.vala

src/Builder4/Editor.bjs
src/Builder4/Editor.vala

index 43aa9ef..40a3dc0 100644 (file)
            ""
           ]
          },
-         "| bool checkSyntax" : [
-          " () {",
-          " ",
-          "    ",
-          "    var str = this.toString();",
-          "    ",
-          "    // needed???",
-          "    if (this.error_line > 0) {",
-          "         Gtk.TextIter start;",
-          "         Gtk.TextIter end;     ",
-          "        this.el.get_bounds (out start, out end);",
-          "",
-          "        this.el.remove_source_marks (start, end, null);",
-          "    }",
-          "    if (str.length < 1) {",
-          "        print(\"checkSyntax - empty string?\\n\");",
-          "        return true;",
-          "    }",
-          "    ",
-          "    // bit presumptiona",
-          "    if (_this.file.xtype == \"PlainFile\") {",
-          "    ",
-          "        // assume it's gtk...",
-          "         var  oldcode =_this.file.toSource();",
-          "        _this.file.setSource(str);",
-          "\t    BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
-          "    \t_this.file.getLanguageServer().document_change(_this.file);",
-          "",
-          "        _this.file.setSource(oldcode);",
-          "        ",
-          "\t\t ",
-          "        return true;",
-          "    ",
-          "    }",
-          "   if (_this.file == null) {",
-          "       return true;",
-          "   }",
-          " ",
-          "    ",
-          "",
-          "      ",
-          "     ",
-          "    GLib.debug(\"calling validate\");    ",
-          "    // clear the buttons.",
-          " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
-          "\t\treturn true ;",
-          "\t}",
-          "\tvar oldcode  = _this.prop.val;",
-          "\t",
-          "\t_this.prop.val = str;",
-          "\t_this.node.updated_count++;",
-          "    _this.file.getLanguageServer().document_change(_this.file);",
-          "    _this.node.updated_count++;",
-          "    _this.prop.val = oldcode;",
-          "    ",
-          "    ",
-          "    //print(\"done mark line\\n\");",
-          "     ",
-          "    return true; // at present allow saving - even if it's invalid..",
-          "}",
-          ""
-         ],
-         "| bool highlightErrors" : [
-          "( Gee.HashMap<int,string> validate_res) {",
-          "         ",
-          "\tthis.error_line = validate_res.size;",
-          "",
-          "\tif (this.error_line < 1) {",
-          "\t\treturn true;",
-          "\t}",
-          "\tvar tlines = this.el.get_line_count ();",
-          "\tGtk.TextIter iter;",
-          "\tvar valiter = validate_res.map_iterator();",
-          "\twhile (valiter.next()) {",
-          "",
-          "\t//        print(\"get inter\\n\");",
-          "\t\tvar eline = valiter.get_key();",
-          "\t\tif (eline > tlines) {",
-          "\t\t\tcontinue;",
-          "\t\t}",
-          "\t\tthis.el.get_iter_at_line( out iter, eline);",
-          "\t\t//print(\"mark line\\n\");",
-          "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
-          "\t}   ",
-          "\treturn false;",
-          "}"
-         ],
-         "| bool highlightErrorsJson" : [
+         "| bool OLDhighlightErrorsJson" : [
           "(string type, Json.Object obj) {",
           "\tGtk.TextIter start;",
           "\tGtk.TextIter end;     ",
           "\t}",
           ""
          ],
+         "| bool checkSyntax" : [
+          " () {",
+          " ",
+          "    ",
+          "    var str = this.toString();",
+          "    ",
+          "    // needed???",
+          "    if (this.error_line > 0) {",
+          "         Gtk.TextIter start;",
+          "         Gtk.TextIter end;     ",
+          "        this.el.get_bounds (out start, out end);",
+          "",
+          "        this.el.remove_source_marks (start, end, null);",
+          "    }",
+          "    if (str.length < 1) {",
+          "        print(\"checkSyntax - empty string?\\n\");",
+          "        return true;",
+          "    }",
+          "    ",
+          "    // bit presumptiona",
+          "    if (_this.file.xtype == \"PlainFile\") {",
+          "    ",
+          "        // assume it's gtk...",
+          "         var  oldcode =_this.file.toSource();",
+          "        _this.file.setSource(str);",
+          "\t    BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
+          "    \t_this.file.getLanguageServer().document_change(_this.file);",
+          "",
+          "        _this.file.setSource(oldcode);",
+          "        ",
+          "\t\t ",
+          "        return true;",
+          "    ",
+          "    }",
+          "   if (_this.file == null) {",
+          "       return true;",
+          "   }",
+          " ",
+          "    ",
+          "",
+          "      ",
+          "     ",
+          "    GLib.debug(\"calling validate\");    ",
+          "    // clear the buttons.",
+          " \tif (_this.prop.name == \"xns\" || _this.prop.name == \"xtype\") {",
+          "\t\treturn true ;",
+          "\t}",
+          "\tvar oldcode  = _this.prop.val;",
+          "\t",
+          "\t_this.prop.val = str;",
+          "\t_this.node.updated_count++;",
+          "    _this.file.getLanguageServer().document_change(_this.file);",
+          "    _this.node.updated_count++;",
+          "    _this.prop.val = oldcode;",
+          "    ",
+          "    ",
+          "    //print(\"done mark line\\n\");",
+          "     ",
+          "    return true; // at present allow saving - even if it's invalid..",
+          "}",
+          ""
+         ],
+         "| bool highlightErrors" : [
+          "( Gee.HashMap<int,string> validate_res) {",
+          "         ",
+          "\tthis.error_line = validate_res.size;",
+          "",
+          "\tif (this.error_line < 1) {",
+          "\t\treturn true;",
+          "\t}",
+          "\tvar tlines = this.el.get_line_count ();",
+          "\tGtk.TextIter iter;",
+          "\tvar valiter = validate_res.map_iterator();",
+          "\twhile (valiter.next()) {",
+          "",
+          "\t//        print(\"get inter\\n\");",
+          "\t\tvar eline = valiter.get_key();",
+          "\t\tif (eline > tlines) {",
+          "\t\t\tcontinue;",
+          "\t\t}",
+          "\t\tthis.el.get_iter_at_line( out iter, eline);",
+          "\t\t//print(\"mark line\\n\");",
+          "\t\tthis.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
+          "\t}   ",
+          "\treturn false;",
+          "}"
+         ],
          "| string toString" : [
           "  () {",
           "    ",
index f6ead77..e95f647 100644 (file)
@@ -861,66 +861,7 @@ public class Editor : Object
                }
 
                // user defined functions
-               public bool checkSyntax () {
-                
-                   
-                   var str = this.toString();
-                   
-                   // needed???
-                   if (this.error_line > 0) {
-                        Gtk.TextIter start;
-                        Gtk.TextIter end;     
-                       this.el.get_bounds (out start, out end);
-               
-                       this.el.remove_source_marks (start, end, null);
-                   }
-                   if (str.length < 1) {
-                       print("checkSyntax - empty string?\n");
-                       return true;
-                   }
-                   
-                   // bit presumptiona
-                   if (_this.file.xtype == "PlainFile") {
-                   
-                       // assume it's gtk...
-                        var  oldcode =_this.file.toSource();
-                       _this.file.setSource(str);
-                           BuilderApplication.showSpinner("appointment soon","document change pending");
-                       _this.file.getLanguageServer().document_change(_this.file);
-               
-                       _this.file.setSource(oldcode);
-                       
-                                
-                       return true;
-                   
-                   }
-                  if (_this.file == null) {
-                      return true;
-                  }
-                
-                   
-               
-                     
-                    
-                   GLib.debug("calling validate");    
-                   // clear the buttons.
-                       if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
-                               return true ;
-                       }
-                       var oldcode  = _this.prop.val;
-                       
-                       _this.prop.val = str;
-                       _this.node.updated_count++;
-                   _this.file.getLanguageServer().document_change(_this.file);
-                   _this.node.updated_count++;
-                   _this.prop.val = oldcode;
-                   
-                   
-                   //print("done mark line\n");
-                    
-                   return true; // at present allow saving - even if it's invalid..
-               }
-               public bool highlightErrorsJson (string type, Json.Object obj) {
+               public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
                        Gtk.TextIter start;
                        Gtk.TextIter end;     
                        this.el.get_bounds (out start, out end);
@@ -1031,6 +972,65 @@ public class Editor : Object
                
                
                        }
+               public bool checkSyntax () {
+                
+                   
+                   var str = this.toString();
+                   
+                   // needed???
+                   if (this.error_line > 0) {
+                        Gtk.TextIter start;
+                        Gtk.TextIter end;     
+                       this.el.get_bounds (out start, out end);
+               
+                       this.el.remove_source_marks (start, end, null);
+                   }
+                   if (str.length < 1) {
+                       print("checkSyntax - empty string?\n");
+                       return true;
+                   }
+                   
+                   // bit presumptiona
+                   if (_this.file.xtype == "PlainFile") {
+                   
+                       // assume it's gtk...
+                        var  oldcode =_this.file.toSource();
+                       _this.file.setSource(str);
+                           BuilderApplication.showSpinner("appointment soon","document change pending");
+                       _this.file.getLanguageServer().document_change(_this.file);
+               
+                       _this.file.setSource(oldcode);
+                       
+                                
+                       return true;
+                   
+                   }
+                  if (_this.file == null) {
+                      return true;
+                  }
+                
+                   
+               
+                     
+                    
+                   GLib.debug("calling validate");    
+                   // clear the buttons.
+                       if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
+                               return true ;
+                       }
+                       var oldcode  = _this.prop.val;
+                       
+                       _this.prop.val = str;
+                       _this.node.updated_count++;
+                   _this.file.getLanguageServer().document_change(_this.file);
+                   _this.node.updated_count++;
+                   _this.prop.val = oldcode;
+                   
+                   
+                   //print("done mark line\n");
+                    
+                   return true; // at present allow saving - even if it's invalid..
+               }
                public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
                         
                        this.error_line = validate_res.size;