src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 30 Apr 2015 06:10:36 +0000 (14:10 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 30 Apr 2015 06:10:36 +0000 (14:10 +0800)
src/Builder4/Editor.vala

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

index b6c6269..f67c2d5 100644 (file)
@@ -82,7 +82,7 @@
          "id" : "buffer",
          "int error_line" : "-1",
          "|   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    if (this.check_running) {\n        print(\"Check is running\\n\");\n        if (this.check_queued) { \n            print(\"Check is already queued\");\n            return true;\n        }\n        this.check_queued = true;\n        print(\"Adding queued Check \");\n        GLib.Timeout.add_seconds(1, () => {\n            this.check_queued = false;\n            \n            this.checkSyntax();\n            return false;\n        });\n    \n\n        return true;\n    }\n   \n   \n    var p = Palete.factory(_this.file.xtype);   \n    \n    var str = this.toString();\n    \n    string res = \"\";\n    \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    this.check_running = true;\n    \n    \n    if (_this.file.language == \"js\") {\n        this.check_running = false;\n        return _this.highlightErrors(p.validateJavascript(\n            str, \n             _this.key, \n            _this.ptype,\n            _this.file,\n            _this.node\n        ));    \n        \n    }\n        \n    print(\"calling validate code\\n\");    \n    p.validateCode.begin(\n        str, \n         _this.key, \n        _this.ptype,\n        _this.file,\n        _this.node,\n        (obj, res) => {\n            this.check_running = false;\n            var validate_res = p.validateCode.end(res);\n            this.error_line = validate_res.size;\n\n            if (this.error_line < 1) {\n                  return;\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(), \"error\", iter);\n            }   \n            \n        }\n        \n    );\n     \n    \n    \n    //print(\"done mark line\\n\");\n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
+         "|   bool checkSyntax" : " () {\n \n    if (this.check_running) {\n        print(\"Check is running\\n\");\n        if (this.check_queued) { \n            print(\"Check is already queued\");\n            return true;\n        }\n        this.check_queued = true;\n        print(\"Adding queued Check \");\n        GLib.Timeout.add_seconds(1, () => {\n            this.check_queued = false;\n            \n            this.checkSyntax();\n            return false;\n        });\n    \n\n        return true;\n    }\n   \n   \n    var p = Palete.factory(_this.file.xtype);   \n    \n    var str = this.toString();\n    \n    string res = \"\";\n    \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    this.check_running = true;\n    \n    \n    if (_this.file.language == \"js\") {\n        this.check_running = false;\n        return this.highlightErrors(p.validateJavascript(\n            str, \n             _this.key, \n            _this.ptype,\n            _this.file,\n            _this.node\n        ));    \n        \n    }\n        \n    print(\"calling validate code\\n\");    \n    p.validateCode.begin(\n        str, \n         _this.key, \n        _this.ptype,\n        _this.file,\n        _this.node,\n        (obj, res) => {\n            this.check_running = false;\n            var validate_res = p.validateCode.end(res);\n            this.highlightErrors(validate_res);\n\n        }\n        \n    );\n     \n    \n    \n    //print(\"done mark line\\n\");\n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
          "* pack" : "set_buffer",
          "xtype" : "Buffer",
          "bool check_running" : false,
index 616a333..157df77 100644 (file)
@@ -422,7 +422,7 @@ public class Editor : Object
             
             if (_this.file.language == "js") {
                 this.check_running = false;
-                return _this.highlightErrors(p.validateJavascript(
+                return this.highlightErrors(p.validateJavascript(
                     str, 
                      _this.key, 
                     _this.ptype,
@@ -442,26 +442,8 @@ public class Editor : Object
                 (obj, res) => {
                     this.check_running = false;
                     var validate_res = p.validateCode.end(res);
-                    this.error_line = validate_res.size;
+                    this.highlightErrors(validate_res);
         
-                    if (this.error_line < 1) {
-                          return;
-                    }
-                    var tlines = this.el.get_line_count ();
-                    Gtk.TextIter iter;
-                    var valiter = validate_res.map_iterator();
-                    while (valiter.next()) {
-                    
-                //        print("get inter\n");
-                        var eline = valiter.get_key();
-                        if (eline > tlines) {
-                            continue;
-                        }
-                        this.el.get_iter_at_line( out iter, eline);
-                        //print("mark line\n");
-                        this.el.create_source_mark(valiter.get_value(), "error", iter);
-                    }   
-                    
                 }
                 
             );