src/Builder4/WindowRooView.bjs
authorAlan Knowles <alan@roojs.com>
Tue, 7 Jun 2016 08:35:09 +0000 (16:35 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 7 Jun 2016 08:35:09 +0000 (16:35 +0800)
src/Builder4/WindowRooView.vala

src/Builder4/WindowRooView.bjs
src/Builder4/WindowRooView.vala

index d1112ed..9ebc0ce 100644 (file)
            "int error_line" : "-1",
            "| bool highlightErrors" : "( Gee.HashMap<int,string> validate_res) {\n         \n    this.error_line = validate_res.size;\n\t\n    if (this.error_line < 1) {\n          return true;\n    }\n    var tlines = this.el.get_line_count ();\n    Gtk.TextIter iter;\n    var valiter = validate_res.map_iterator();\n    while (valiter.next()) {\n    \n//        print(\"get inter\\n\");\n        var eline = valiter.get_key();\n        if (eline > tlines) {\n            continue;\n        }\n        this.el.get_iter_at_line( out iter, eline);\n        //print(\"mark line\\n\");\n        this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);\n    }   \n    return false;\n}",
            "|   string toString" : "  () {\n    \n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    this.el.get_start_iter(out s);\n    this.el.get_end_iter(out e);\n    var ret = this.el.get_text(s,e,true);\n    //print(\"TO STRING? \" + ret);\n    return ret;\n}\n ",
-           "|   bool checkSyntax" : " () {\n \n   \n    var str = this.toString();\n    \n    // needed???\n    if (this.error_line > 0) {\n         Gtk.TextIter start;\n         Gtk.TextIter end;     \n        this.el.get_bounds (out start, out end);\n\n        this.el.remove_source_marks (start, end, null);\n    }\n    \n    if (str.length < 1) {\n        print(\"checkSyntax - empty string?\\n\");\n        return true;\n    }\n    \n   if (_this.file == null) {\n       return true;\n   }\n    var p = Palete.factory(_this.file.xtype);  // returns Roo | Gtk  | PlainFile \n    \n \n    if (_this.file.language != \"js\") {\n\t\treturn;\n\t}\n\t\n        \n\n  \t\tvar res =  this.highlightErrors(p.validateJavascript(\n            str, \n             \"\", // _this.key, \n            \"file\", //_this.ptype,\n            _this.file,\n            null\n        ));    \n        \n    }\n        \n        \n    print(\"calling validate vala\\n\");    \n    \n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
+           "|   bool checkSyntax" : " () {\n \n   \n    var str = this.toString();\n    \n    // needed???\n    if (this.error_line > 0) {\n         Gtk.TextIter start;\n         Gtk.TextIter end;     \n        this.el.get_bounds (out start, out end);\n\n        this.el.remove_source_marks (start, end, null);\n    }\n    \n    if (str.length < 1) {\n        print(\"checkSyntax - empty string?\\n\");\n        return true;\n    }\n    \n   if (_this.file == null) {\n       return true;\n   }\n    var p = Palete.factory(_this.file.xtype);  // returns Roo | Gtk  | PlainFile \n    \n \n    if (_this.file.language != \"js\") {\n\t\treturn;\n\t}\n\t\n        \n\n\tvar res =  this.highlightErrors(p.validateJavascript(\n        str, \n         \"\", // _this.key, \n        \"file\", //_this.ptype,\n        _this.file,\n        null\n    ));    \n        \n    if (!res) { // an error in the code.. don't save it..\n\t    return; \n    }\n        \n        \n    print(\"calling validate vala\\n\");    \n    \n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
            "* pack" : "set_buffer",
            "xtype" : "SourceBuffer",
            "$ xns" : "Gtk"
index 382a996..f697a5e 100644 (file)
@@ -1385,14 +1385,16 @@ public class Xcls_WindowRooView : Object
                
                 
         
-                       var res =  this.highlightErrors(p.validateJavascript(
-                    str, 
-                     "", // _this.key, 
-                    "file", //_this.ptype,
-                    _this.file,
-                    null
-                ));    
+               var res =  this.highlightErrors(p.validateJavascript(
+                str, 
+                 "", // _this.key, 
+                "file", //_this.ptype,
+                _this.file,
+                null
+            ));    
                 
+            if (!res) { // an error in the code.. don't save it..
+                   return; 
             }