sync
authorAlan Knowles <alan@roojs.com>
Thu, 11 Jan 2024 16:58:40 +0000 (00:58 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 11 Jan 2024 16:58:40 +0000 (00:58 +0800)
17 files changed:
configure.ac
src/Application.vala
src/Builder4/Editor.bjs
src/Builder4/Editor.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/WindowRooView.bjs
src/Builder4/WindowRooView.vala
src/Builder4/WindowState.vala
src/JsRender/JsRender.vala
src/Makefile.am
src/Palete/CompileError.vala
src/Palete/LanguageClient.vala

index 23f639a..e2a0536 100644 (file)
@@ -33,6 +33,8 @@ PKG_CHECK_MODULES(ROOBUILDER, [ zlib
                 libxml-2.0
                 libsoup-3.0 
                 roojspacker-1.4
+                jsonrpc-glib-1.0
+                gio-unix-2.0
 ]) 
 
 dnl --- libvala -- needs to find matching really..
index 09a4639..6fbe813 100644 (file)
                
                void initDebug() 
                {
-               
+                       GLib.Log.set_always_fatal(GLib.LogLevelFlags.LEVEL_CRITICAL);
                        if (BuilderApplication.opt_debug  || BuilderApplication.opt_compile_project == null) {
                                GLib.Log.set_handler(null, 
                                        GLib.LogLevelFlags.LEVEL_DEBUG | GLib.LogLevelFlags.LEVEL_WARNING | GLib.LogLevelFlags.LEVEL_CRITICAL, 
@@ -636,10 +636,8 @@ flutter-project  -  was try and read flutter data (but desnt work.)
                                        continue;
                                }
 
-                               ww.windowstate.code_editor_tab.updateErrorMarks("ERR");
-                               ww.windowstate.code_editor_tab.updateErrorMarks("WARN");
-                               ww.windowstate.code_editor_tab.updateErrorMarks("DEPR");
-                               
+                               ww.windowstate.updateErrorMarksAll();
+                                
                                GLib.debug("calling udate Errors of window %s", ww.windowstate.file.targetName());
                                ww.updateErrors();
                                
index 8b4fd1f..b39c374 100644 (file)
     "\t}",
     "\tvar ar = this.file.getErrors(category);",
     "\tif (ar == null || ar.get_n_items() < 1) {",
-    "\t\tGLib.debug(\"Return has no errors\\n\");",
+    "\t\tGLib.debug(\"highlight %s :  %s has no errors\", this.file.relpath, category);",
     "\t\treturn;",
     "\t}",
     " ",
     "",
     " ",
     "\t",
-    "\tvar offset = 1;",
+    "\tvar offset = 0;",
     "\t ",
     "",
     "\tvar tlines = buf.get_line_count () +1;",
     "\t   ",
     "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
     "\t    buf.create_source_mark( msg, err.category, iter);",
-    "\t    GLib.debug(\"set line %d to %m\", eline, msg);",
-    "\t   // this.marks.set(eline, msg);",
+    "\t    GLib.debug(\"set line %d to %s\", eline, msg);",
+    "\t    //this.marks.set(eline, msg);",
     "\t}",
     "\treturn ;",
     "",
index 16de11b..ede55b4 100644 (file)
                }
                var ar = this.file.getErrors(category);
                if (ar == null || ar.get_n_items() < 1) {
-                       GLib.debug("Return has no errors\n");
+                       GLib.debug("highlight %s :  %s has no errors", this.file.relpath, category);
                        return;
                }
          
         
          
                
-               var offset = 1;
+               var offset = 0;
                 
         
                var tlines = buf.get_line_count () +1;
                   
                        var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg);
                    buf.create_source_mark( msg, err.category, iter);
-                   GLib.debug("set line %d to %m", eline, msg);
-                  // this.marks.set(eline, msg);
+                   GLib.debug("set line %d to %s", eline, msg);
+                   //this.marks.set(eline, msg);
                }
                return ;
         
index 3e9a975..5d63044 100644 (file)
             "}",
             ""
            ],
-           "| void highlightErrorsJson" : [
-            " (string type, Json.Object obj) {",
-            "      Gtk.TextIter start;",
-            "     Gtk.TextIter end;   ",
-            "     ",
-            "     var buf =  this.el.get_buffer();",
-            "       var sbuf = (GtkSource.Buffer)buf;",
-            "        buf.get_bounds (out start, out end);",
-            "        ",
-            "        sbuf.remove_source_marks (start, end, type);",
-            "                 ",
-            "     ",
-            "     // we should highlight other types of errors..",
-            "    ",
-            "    if (!obj.has_member(type)) {",
-            "        GLib.debug(\"Return has no errors\\n\");",
-            "        return  ;",
-            "    }",
-            "    var err = obj.get_object_member(type);",
-            "    ",
-            "    if (_this.file == null) { ",
-            "\t",
-            "        return; // just in case the file has not loaded yet?",
-            "    }",
-            " ",
-            "",
-            "    var valafn = \"\";",
-            "      try {             ",
-            "           var  regex = new Regex(\"\\\\.bjs$\");",
-            "        ",
-            "         ",
-            "            valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
-            "         } catch (GLib.RegexError e) {",
-            "            return;",
-            "        }   ",
-            "",
-            "   if (!err.has_member(valafn)) {",
-            "        GLib.debug(\"File path has no errors\\n\");",
-            "        return  ;",
-            "    }",
-            "    var lines = err.get_object_member(valafn);",
-            "    ",
-            "   ",
-            "    ",
-            "    var tlines = buf.get_line_count () +1;",
-            "    ",
-            "    lines.foreach_member((obj, line, node) => {",
-            "        ",
-            "             Gtk.TextIter iter;",
-            "    //        print(\"get inter\\n\");",
-            "            var eline = int.parse(line) -1  ;",
-            "            GLib.debug(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
-            "            ",
-            "            ",
-            "            if (eline > tlines || eline < 0) {",
-            "                return;",
-            "            }",
-            "            sbuf.get_iter_at_line( out iter, eline);",
-            "            //print(\"mark line\\n\");",
-            "            var msg  = type + \" on line: %d - %s\".printf(eline+1, valafn);",
-            "            var ar = lines.get_array_member(line);",
-            "            for (var i = 0 ; i < ar.get_length(); i++) {",
-            "\t\t    msg += (msg.length > 0) ? \"\\n\" : \"\";",
-            "\t\t    msg += ar.get_string_element(i);",
-            "\t    }",
-            "            ",
-            "            ",
-            "            sbuf.create_source_mark(msg, type, iter);",
-            "        } );",
-            "        return  ;",
-            "    ",
-            " ",
-            "",
-            "",
-            "}"
-           ],
            "| void loadFile" : [
             "( ) {",
             "    this.loading = true;",
             "    ",
             "    ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
             "  ",
-            "    ",
-            "    Gtk.TextIter start;",
-            "    Gtk.TextIter end;     ",
-            "        ",
-            "    sbuf.get_bounds (out start, out end);",
-            "    sbuf.remove_source_marks (start, end, null); // remove all marks..",
-            "    ",
-            "    ",
-            "    if (_this.main_window.windowstate.last_compile_result != null) {",
-            "        var obj = _this.main_window.windowstate.last_compile_result;",
-            "        this.highlightErrorsJson(\"ERR\", obj);",
-            "        this.highlightErrorsJson(\"WARN\", obj);",
-            "        this.highlightErrorsJson(\"DEPR\", obj);\t\t\t",
-            "    }",
-            "    // while (Gtk.events_pending()) {",
-            "     //   Gtk.main_iteration();",
-            "   // }",
+            "     ",
+            "   _this.main_window.windowstate.updateErrorMarksAll(); ",
+            "   ",
+            "  ",
             "    ",
             "    this.loading = false; ",
             "}",
     "   ",
     "}",
     ""
+   ],
+   "| void updateErrorMarks" : [
+    "(string category) {",
+    "\t",
+    " ",
+    "",
+    "\tvar buf = _this.buffer.el;",
+    "\tGtk.TextIter start;",
+    "\tGtk.TextIter end;     ",
+    "\tbuf.get_bounds (out start, out end);",
+    "",
+    "\tbuf.remove_source_marks (start, end, category);",
+    " ",
+    "\tGLib.debug(\"highlight errors\");\t\t ",
+    "",
+    "\t // we should highlight other types of errors..",
+    "",
+    " ",
+    "",
+    "\t ",
+    "\tif (_this.file == null) {",
+    "\t\tGLib.debug(\"file is null?\");",
+    "\t\treturn;",
+    "",
+    "\t}",
+    "\tvar ar = this.file.getErrors(category);",
+    "\tif (ar == null || ar.get_n_items() < 1) {",
+    "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
+    "\t\treturn;",
+    "\t}",
+    " ",
+    "",
+    " ",
+    "\t",
+    "\tvar offset = 0;",
+    "\t ",
+    "",
+    "\tvar tlines = buf.get_line_count () +1;",
+    "\t",
+    " ",
+    "\t ",
+    "\tfor (var i = 0; i < ar.get_n_items();i++) {",
+    "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
+    "\t\t",
+    "\t     Gtk.TextIter iter;",
+    "//        print(\"get inter\\n\");",
+    "\t    var eline = err.line - offset;",
+    "\t    GLib.debug(\"GOT ERROR on line %d -- converted to %d  (offset = %d)\",",
+    "\t    \terr.line ,eline, offset);",
+    "\t    ",
+    "\t    ",
+    "\t    if (eline > tlines || eline < 0) {",
+    "\t        return;",
+    "\t    }",
+    "\t   ",
+    "\t    ",
+    "\t    buf.get_iter_at_line( out iter, eline);",
+    "\t   ",
+    "\t   ",
+    "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
+    "\t    buf.create_source_mark( msg, err.category, iter);",
+    "\t    GLib.debug(\"set line %d to %s\", eline, msg);",
+    "\t    //this.marks.set(eline, msg);",
+    "\t}",
+    "\treturn ;",
+    "",
+    "",
+    "",
+    " ",
+    "",
+    "}"
    ]
   }
  ],
index ef0c8f3..830bd01 100644 (file)
         
             
              
+        }
+        public void updateErrorMarks (string category) {
+               
+         
+        
+               var buf = _this.buffer.el;
+               Gtk.TextIter start;
+               Gtk.TextIter end;     
+               buf.get_bounds (out start, out end);
+        
+               buf.remove_source_marks (start, end, category);
+         
+               GLib.debug("highlight errors");          
+        
+                // we should highlight other types of errors..
+        
+         
+        
+                
+               if (_this.file == null) {
+                       GLib.debug("file is null?");
+                       return;
+        
+               }
+               var ar = this.file.getErrors(category);
+               if (ar == null || ar.get_n_items() < 1) {
+                       GLib.debug("higjlight %s has no errors", category);
+                       return;
+               }
+         
+        
+         
+               
+               var offset = 0;
+                
+        
+               var tlines = buf.get_line_count () +1;
+               
+         
+                
+               for (var i = 0; i < ar.get_n_items();i++) {
+                       var err = (Palete.CompileError) ar.get_item(i);
+                       
+                    Gtk.TextIter iter;
+        //        print("get inter\n");
+                   var eline = err.line - offset;
+                   GLib.debug("GOT ERROR on line %d -- converted to %d  (offset = %d)",
+                       err.line ,eline, offset);
+                   
+                   
+                   if (eline > tlines || eline < 0) {
+                       return;
+                   }
+                  
+                   
+                   buf.get_iter_at_line( out iter, eline);
+                  
+                  
+                       var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg);
+                   buf.create_source_mark( msg, err.category, iter);
+                   GLib.debug("set line %d to %s", eline, msg);
+                   //this.marks.set(eline, msg);
+               }
+               return ;
+        
+        
+        
+         
+        
         }
         public void scroll_to_line (int line) {
           // code preview...
                 
                 ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));
               
-                
-                Gtk.TextIter start;
-                Gtk.TextIter end;     
-                    
-                sbuf.get_bounds (out start, out end);
-                sbuf.remove_source_marks (start, end, null); // remove all marks..
-                
-                
-                if (_this.main_window.windowstate.last_compile_result != null) {
-                    var obj = _this.main_window.windowstate.last_compile_result;
-                    this.highlightErrorsJson("ERR", obj);
-                    this.highlightErrorsJson("WARN", obj);
-                    this.highlightErrorsJson("DEPR", obj);                     
-                }
-                // while (Gtk.events_pending()) {
-                 //   Gtk.main_iteration();
-               // }
+                 
+               _this.main_window.windowstate.updateErrorMarksAll(); 
+               
+              
                 
                 this.loading = false; 
             }
                 }
                 
             
-            }
-            public void highlightErrorsJson (string type, Json.Object obj) {
-                  Gtk.TextIter start;
-                 Gtk.TextIter end;   
-                 
-                 var buf =  this.el.get_buffer();
-                   var sbuf = (GtkSource.Buffer)buf;
-                    buf.get_bounds (out start, out end);
-                    
-                    sbuf.remove_source_marks (start, end, type);
-                             
-                 
-                 // we should highlight other types of errors..
-                
-                if (!obj.has_member(type)) {
-                    GLib.debug("Return has no errors\n");
-                    return  ;
-                }
-                var err = obj.get_object_member(type);
-                
-                if (_this.file == null) { 
-               
-                    return; // just in case the file has not loaded yet?
-                }
-             
-            
-                var valafn = "";
-                  try {             
-                       var  regex = new Regex("\\.bjs$");
-                    
-                     
-                        valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
-                     } catch (GLib.RegexError e) {
-                        return;
-                    }   
-            
-               if (!err.has_member(valafn)) {
-                    GLib.debug("File path has no errors\n");
-                    return  ;
-                }
-                var lines = err.get_object_member(valafn);
-                
-               
-                
-                var tlines = buf.get_line_count () +1;
-                
-                lines.foreach_member((obj, line, node) => {
-                    
-                         Gtk.TextIter iter;
-                //        print("get inter\n");
-                        var eline = int.parse(line) -1  ;
-                        GLib.debug("GOT ERROR on line %s -- converted to %d\n", line,eline);
-                        
-                        
-                        if (eline > tlines || eline < 0) {
-                            return;
-                        }
-                        sbuf.get_iter_at_line( out iter, eline);
-                        //print("mark line\n");
-                        var msg  = type + " on line: %d - %s".printf(eline+1, valafn);
-                        var ar = lines.get_array_member(line);
-                        for (var i = 0 ; i < ar.get_length(); i++) {
-                           msg += (msg.length > 0) ? "\n" : "";
-                           msg += ar.get_string_element(i);
-                   }
-                        
-                        
-                        sbuf.create_source_mark(msg, type, iter);
-                    } );
-                    return  ;
-                
-             
-            
-            
             }
             public string toString () {
                Gtk.TextIter s;
index 2d26268..d43dd8f 100644 (file)
            "xtype" : "Label"
           },
           {
-           "# GLib.ListStore notices" : "null",
            "$ xns" : "Gtk",
            "Xcls_ValaCompileErrors popup" : "",
            "id" : "statusbar_errors",
            "listeners" : {
             "clicked" : [
              "() => {",
-             "    ",
-             "",
-             "    ",
-             "    if (this.popup == null) {",
-             "        this.popup = new Xcls_ValaCompileErrors();",
-             "        this.popup.window = _this;",
-             "        //this.popup.el.application = _this.el.application;",
-             "\t  //   this.popup.el.set_transient_for( _this.el );",
-             "       this.popup.el.set_parent(this.el);",
-             "    }",
-             "    if (_this.statusbar_compile_spinner.el.spinning) {",
-             "\t\tthis.popup.el.show();    \t",
-             "    \treturn;",
-             "\t}    ",
-             "    this.popup.show(this.notices, this.el);",
-             "    return;",
+             " ",
+             "\tif (this.popup == null) {",
+             "\t\treturn;",
+             "\t}",
+             "   ",
+             "    this.popup.show();",
+             "  ",
              "}"
             ]
            },
             "    ",
             "     if (nots.get_n_items() < 1 ) {",
             "    \tthis.el.hide();",
-            "    \tif (this.popup != null && this.popup.el.visible) {",
+            "    \tif (this.popup != null) {",
             "    \t\tthis.popup.el.hide();",
             "\t\t}",
             "    \treturn;",
             "    ",
             "    this.el.show();",
             "    this.el.label = \"%d/%d Errors\".printf((int)fe.get_n_items(),(int)nots.get_n_items());",
-            "    this.notices = nots;",
-            "\tif (this.popup != null && this.popup.el.visible) {",
-            "\t\t this.popup.show(this.notices, this.el);",
+            "",
+            "    ",
+            " ",
+            "\tif (this.popup == null) {",
+            "        this.popup = new Xcls_ValaCompileErrors();",
+            "        this.popup.window = _this;",
+            "      //    this.popup.el.set_transient_for( _this.el );",
+            "        this.popup.el.set_parent(this.el);",
             "    }",
+            "\tthis.popup.updateNotices(nots);",
+            "\t ",
             "}",
             ""
            ]
           },
           {
-           "# GLib.ListStore notices" : "null",
            "$ xns" : "Gtk",
            "Xcls_ValaCompileErrors popup" : "",
            "id" : "statusbar_warnings",
              "() => {",
              " ",
              "\tif (this.popup == null) {",
-             "        this.popup = new Xcls_ValaCompileErrors();",
-             "        this.popup.window = _this;",
-             "      //    this.popup.el.set_transient_for( _this.el );",
-             "        this.popup.el.set_parent(this.el);",
-             "    }",
-             "        if (_this.statusbar_compile_spinner.el.spinning) {",
-             "\t\tthis.popup.el.show();    \t",
-             "    \treturn;",
-             "\t}    ",
-             "    this.popup.show(this.notices, this.el);",
+             "\t\treturn;",
+             "\t}",
+             "   ",
+             "    this.popup.show();",
              "    return;",
              "}"
             ]
             "    ",
             "     if (nots.get_n_items() < 1 ) {",
             "    \tthis.el.hide();",
-            "    \tif (this.popup != null && this.popup.el.visible) {",
+            "    \tif (this.popup != null) {",
             "    \t\tthis.popup.el.hide();",
             "\t\t}",
             "    \treturn;",
             "    ",
             "    this.el.show();",
             "    this.el.label = \"%d/%d Warnings\".printf((int)fe.get_n_items(),(int)nots.get_n_items());",
-            "    this.notices = nots;",
-            "\tif (this.popup != null && this.popup.el.visible) {",
-            "\t\t this.popup.show(this.notices, this.el);",
+            "",
+            "    ",
+            " ",
+            "\tif (this.popup == null) {",
+            "        this.popup = new Xcls_ValaCompileErrors();",
+            "        this.popup.window = _this;",
+            "      //    this.popup.el.set_transient_for( _this.el );",
+            "        this.popup.el.set_parent(this.el);",
             "    }",
+            "\tthis.popup.updateNotices(nots);",
+            "\t ",
             "}",
             ""
            ]
            "listeners" : {
             "clicked" : [
              "() => {",
-             "    ",
+             " ",
              "\tif (this.popup == null) {",
-             "        this.popup = new Xcls_ValaCompileErrors();",
-             "        this.popup.window = _this;",
-             "      //  this.popup.el.set_transient_for( _this.el );",
-             "        this.popup.el.set_parent(this.el);",
-             "    }",
-             "    if (_this.statusbar_compile_spinner.el.spinning) {",
-             "\t\tthis.popup.el.show();    \t",
-             "    \treturn;",
-             "\t}    ",
-             "    ",
-             "    this.popup.show(this.notices, this.el);",
-             "    return;",
+             "\t\treturn;",
+             "\t}",
+             "   ",
+             "    this.popup.show();",
+             "  ",
              "}"
             ]
            },
            "string label" : "0 Depricated",
            "xtype" : "Button",
            "| void setNotices" : [
+            "",
             "(GLib.ListStore nots, GLib.ListStore fe ) {",
             "    ",
             "     if (nots.get_n_items() < 1 ) {",
-            "     \tGLib.debug(\"no deprc - hide\");",
             "    \tthis.el.hide();",
-            "    \tif (this.popup != null && this.popup.el.visible) {",
+            "    \tif (this.popup != null) {",
             "    \t\tthis.popup.el.hide();",
             "\t\t}",
             "    \treturn;",
             "    }",
-            " \tGLib.debug(\"got deprc - hide\");    ",
+            "    ",
             "    this.el.show();",
             "    this.el.label = \"%d/%d Depricated\".printf((int)fe.get_n_items(),(int)nots.get_n_items());",
-            "    this.notices = nots;",
-            "\tif (this.popup != null && this.popup.el.visible) {",
-            "\t\t this.popup.show(this.notices, this.el);",
+            "",
+            "    ",
+            " ",
+            "\tif (this.popup == null) {",
+            "        this.popup = new Xcls_ValaCompileErrors();",
+            "        this.popup.window = _this;",
+            "      //    this.popup.el.set_transient_for( _this.el );",
+            "        this.popup.el.set_parent(this.el);",
             "    }",
+            "\tthis.popup.updateNotices(nots);",
+            "\t ",
             "}",
             ""
            ]
index 2382e70..65636a6 100644 (file)
 
                 // my vars (def)
             public Xcls_ValaCompileErrors popup;
-            public GLib.ListStore notices;
 
             // ctor
             public Xcls_statusbar_errors(Xcls_MainWindow _owner )
                 this.el = new Gtk.Button();
 
                 // my vars (dec)
-                this.notices = null;
 
                 // set gobject values
                 this.el.icon_name = "dialog-error";
 
                 //listeners
                 this.el.clicked.connect( () => {
-                    
-                
-                    
-                    if (this.popup == null) {
-                        this.popup = new Xcls_ValaCompileErrors();
-                        this.popup.window = _this;
-                        //this.popup.el.application = _this.el.application;
-                         //   this.popup.el.set_transient_for( _this.el );
-                       this.popup.el.set_parent(this.el);
-                    }
-                    if (_this.statusbar_compile_spinner.el.spinning) {
-                               this.popup.el.show();           
-                       return;
-                       }    
-                    this.popup.show(this.notices, this.el);
-                    return;
+                 
+                       if (this.popup == null) {
+                               return;
+                       }
+                   
+                    this.popup.show();
+                  
                 });
             }
 
                 
                  if (nots.get_n_items() < 1 ) {
                        this.el.hide();
-                       if (this.popup != null && this.popup.el.visible) {
+                       if (this.popup != null) {
                                this.popup.el.hide();
                        }
                        return;
                 
                 this.el.show();
                 this.el.label = "%d/%d Errors".printf((int)fe.get_n_items(),(int)nots.get_n_items());
-                this.notices = nots;
-               if (this.popup != null && this.popup.el.visible) {
-                        this.popup.show(this.notices, this.el);
+            
+                
+             
+               if (this.popup == null) {
+                    this.popup = new Xcls_ValaCompileErrors();
+                    this.popup.window = _this;
+                  //    this.popup.el.set_transient_for( _this.el );
+                    this.popup.el.set_parent(this.el);
                 }
+               this.popup.updateNotices(nots);
+                
             }
         }
 
 
                 // my vars (def)
             public Xcls_ValaCompileErrors popup;
-            public GLib.ListStore notices;
 
             // ctor
             public Xcls_statusbar_warnings(Xcls_MainWindow _owner )
                 this.el = new Gtk.Button();
 
                 // my vars (dec)
-                this.notices = null;
 
                 // set gobject values
                 this.el.icon_name = "dialog-warning";
                 this.el.clicked.connect( () => {
                  
                        if (this.popup == null) {
-                        this.popup = new Xcls_ValaCompileErrors();
-                        this.popup.window = _this;
-                      //    this.popup.el.set_transient_for( _this.el );
-                        this.popup.el.set_parent(this.el);
-                    }
-                        if (_this.statusbar_compile_spinner.el.spinning) {
-                               this.popup.el.show();           
-                       return;
-                       }    
-                    this.popup.show(this.notices, this.el);
+                               return;
+                       }
+                   
+                    this.popup.show();
                     return;
                 });
             }
                 
                  if (nots.get_n_items() < 1 ) {
                        this.el.hide();
-                       if (this.popup != null && this.popup.el.visible) {
+                       if (this.popup != null) {
                                this.popup.el.hide();
                        }
                        return;
                 
                 this.el.show();
                 this.el.label = "%d/%d Warnings".printf((int)fe.get_n_items(),(int)nots.get_n_items());
-                this.notices = nots;
-               if (this.popup != null && this.popup.el.visible) {
-                        this.popup.show(this.notices, this.el);
+            
+                
+             
+               if (this.popup == null) {
+                    this.popup = new Xcls_ValaCompileErrors();
+                    this.popup.window = _this;
+                  //    this.popup.el.set_transient_for( _this.el );
+                    this.popup.el.set_parent(this.el);
                 }
+               this.popup.updateNotices(nots);
+                
             }
         }
 
 
                 //listeners
                 this.el.clicked.connect( () => {
-                    
+                 
                        if (this.popup == null) {
-                        this.popup = new Xcls_ValaCompileErrors();
-                        this.popup.window = _this;
-                      //  this.popup.el.set_transient_for( _this.el );
-                        this.popup.el.set_parent(this.el);
-                    }
-                    if (_this.statusbar_compile_spinner.el.spinning) {
-                               this.popup.el.show();           
-                       return;
-                       }    
-                    
-                    this.popup.show(this.notices, this.el);
-                    return;
+                               return;
+                       }
+                   
+                    this.popup.show();
+                  
                 });
             }
 
             public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) {
                 
                  if (nots.get_n_items() < 1 ) {
-                       GLib.debug("no deprc - hide");
                        this.el.hide();
-                       if (this.popup != null && this.popup.el.visible) {
+                       if (this.popup != null) {
                                this.popup.el.hide();
                        }
                        return;
                 }
-               GLib.debug("got deprc - hide");    
+                
                 this.el.show();
                 this.el.label = "%d/%d Depricated".printf((int)fe.get_n_items(),(int)nots.get_n_items());
-                this.notices = nots;
-               if (this.popup != null && this.popup.el.visible) {
-                        this.popup.show(this.notices, this.el);
+            
+                
+             
+               if (this.popup == null) {
+                    this.popup = new Xcls_ValaCompileErrors();
+                    this.popup.window = _this;
+                  //    this.popup.el.set_transient_for( _this.el );
+                    this.popup.el.set_parent(this.el);
                 }
+               this.popup.updateNotices(nots);
+                
             }
         }
 
index 80bb461..2dba3d0 100644 (file)
@@ -3,7 +3,6 @@
  "gen_extended" : false,
  "items" : [
   {
-   "# GLib.ListStore notices" : "",
    "# Xcls_MainWindow window" : "",
    "$ xns" : "Gtk",
    "* ctor" : "new Gtk.Popover()",
              "        _this.window.windowstate.fileViewOpen(jsr, true, line);",
              "        ",
              "        if (jsr.path == _this.window.windowstate.file.path) {",
-             "        \t_this.el.hide();",
-             "    \t}",
              "        ",
+             "    \t}",
+             "    \t_this.el.hide();",
              "        ",
              "        return;",
              "    ",
              "    }",
              "    try {",
              "\t\tvar pf = JsRender.JsRender.factory(\"PlainFile\", p, fname.path);",
+             "\t\t_this.el.hide();",
              "\t\t_this.window.windowstate.fileViewOpen(pf, true, line);",
              "    } catch (JsRender.Error e) {}",
              "    // try hiding the left nav..",
    ],
    "xtype" : "Popover",
    "| void show" : [
-    "( GLib.ListStore ls , Gtk.Widget onbtn) {",
-    "",
-    "    ",
+    "(   ) {",
+    "\tGLib.debug(\"errors  : show\");",
+    "\t",
+    "\tif (_this.model.el.get_n_items()  < 1) {",
+    "   ",
+    " \t    GLib.debug(\"errors  : none available\");",
+    "    \treturn;",
+    "\t}",
     " \t//this.el.present();",
     "    //this.el.popup();",
-    "    this.notices = ls;",
-    "   ",
+    "    ",
     "     //print(\"looking for %s\\n\", id);",
     "    // loop through parent childnre",
     "      ",
     "    ",
-    "      this.tree.el.hide(); //<< very important!!!",
+    "     ; //<< very important!!!",
     "      ",
     "   // store.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
     " ",
     "    if (new_w > (w-100)) {",
     "        new_w = w-100;",
     "    }",
+    "    GLib.debug(\"set size\");",
     "    this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));",
     " ",
     "",
     "\t//Gtk.Allocation rect;",
     "\t//onbtn.get_allocation(out rect);",
     "    //this.el.set_pointing_to(rect);",
-    "\tthis.el.present();",
+    "\t//this.el.present();",
+    "\t",
+    "\tGLib.debug(\"call popup\");",
     "    this.el.popup();",
     "    // only need to load once.",
-    " \tif (!this.loaded) {",
-    "\t\tvar tm = new Gtk.TreeListModel(",
-    "\t\t\tls, //..... << that's our store..",
-    "\t\t\tfalse, // passthru",
-    "\t\t\tfalse, // autexpand",
-    "\t\t\t(item) => {",
-    "\t\t\t",
-    "\t\t\t\t return ((Palete.CompileError)item).lines;",
-    "\t\t\t",
-    "\t\t\t}",
-    "\t\t);",
-    "\t ",
-    "\t\t_this.model.el = tm;",
-    "\t\t_this.sortmodel.el.set_model(tm);",
-    "\t\tthis.loaded = true;",
-    "\t }",
+    " \t//if (!this.loaded) {",
+    " \t\t ",
+    "\t\t//this.loaded = true;",
+    "\t //}",
     "\t ",
-    "     this.tree.el.show();   ",
+    "       ",
     "   ",
     "   \t//if (expand != null) {",
     "    //\t_this.compile_tree.el.expand_row(   store.get_path(expand) , true);",
     " //   this.hpane.el.set_position( 0);",
     "}",
     ""
+   ],
+   "| void updateNotices" : [
+    "( GLib.ListStore? ls) {",
+    "\tGLib.debug(\"errors  : update\");",
+    "    if (ls == null || ls.get_n_items() < 1) {",
+    " \t    GLib.debug(\"errors  : none available\");",
+    "    \treturn;",
+    "\t}",
+    "\t",
+    "\tGLib.debug(\"Loading list into tree\");",
+    "\tthis.tree.el.hide();",
+    "\tvar tm = new Gtk.TreeListModel(",
+    "\t\tls, //..... << that's our store..",
+    "\t\tfalse, // passthru",
+    "\t\tfalse, // autexpand",
+    "\t\t(item) => {",
+    "\t\t",
+    "\t\t\t return ((Palete.CompileError)item).lines;",
+    "\t\t",
+    "\t\t}",
+    "\t\t",
+    "\t);",
+    " ",
+    "\t_this.model.el = tm;",
+    "\t_this.sortmodel.el.set_model(tm);",
+    "\t this.tree.el.show();",
+    "}"
    ]
   }
  ],
index fc2fe54..086edbc 100644 (file)
@@ -21,7 +21,6 @@
             // my vars (def)
         public Xcls_MainWindow window;
         public bool loaded;
-        public GLib.ListStore notices;
 
         // ctor
         public Xcls_ValaCompileErrors()
         }
 
         // user defined functions
-        public void show ( GLib.ListStore ls , Gtk.Widget onbtn) {
-        
-            
+        public void updateNotices ( GLib.ListStore? ls) {
+               GLib.debug("errors  : update");
+            if (ls == null || ls.get_n_items() < 1) {
+                   GLib.debug("errors  : none available");
+               return;
+               }
+               
+               GLib.debug("Loading list into tree");
+               this.tree.el.hide();
+               var tm = new Gtk.TreeListModel(
+                       ls, //..... << that's our store..
+                       false, // passthru
+                       false, // autexpand
+                       (item) => {
+                       
+                                return ((Palete.CompileError)item).lines;
+                       
+                       }
+                       
+               );
+         
+               _this.model.el = tm;
+               _this.sortmodel.el.set_model(tm);
+                this.tree.el.show();
+        }
+        public void show (   ) {
+               GLib.debug("errors  : show");
+               
+               if (_this.model.el.get_n_items()  < 1) {
+           
+                   GLib.debug("errors  : none available");
+               return;
+               }
                //this.el.present();
             //this.el.popup();
-            this.notices = ls;
-           
+            
              //print("looking for %s\n", id);
             // loop through parent childnre
               
             
-              this.tree.el.hide(); //<< very important!!!
+             ; //<< very important!!!
               
            // store.set_sort_column_id(0,Gtk.SortType.ASCENDING);
          
@@ -70,6 +98,7 @@
             if (new_w > (w-100)) {
                 new_w = w-100;
             }
+            GLib.debug("set size");
             this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
          
         
                //Gtk.Allocation rect;
                //onbtn.get_allocation(out rect);
             //this.el.set_pointing_to(rect);
-               this.el.present();
+               //this.el.present();
+               
+               GLib.debug("call popup");
             this.el.popup();
             // only need to load once.
-               if (!this.loaded) {
-                       var tm = new Gtk.TreeListModel(
-                               ls, //..... << that's our store..
-                               false, // passthru
-                               false, // autexpand
-                               (item) => {
-                               
-                                        return ((Palete.CompileError)item).lines;
-                               
-                               }
-                       );
-                
-                       _this.model.el = tm;
-                       _this.sortmodel.el.set_model(tm);
-                       this.loaded = true;
-                }
+               //if (!this.loaded) {
+                        
+                       //this.loaded = true;
+                //}
                 
-             this.tree.el.show();   
+               
            
                //if (expand != null) {
             // _this.compile_tree.el.expand_row(   store.get_path(expand) , true);
                         _this.window.windowstate.fileViewOpen(jsr, true, line);
                         
                         if (jsr.path == _this.window.windowstate.file.path) {
-                               _this.el.hide();
-                       }
                         
+                       }
+                       _this.el.hide();
                         
                         return;
                     
                     }
                     try {
                                var pf = JsRender.JsRender.factory("PlainFile", p, fname.path);
+                               _this.el.hide();
                                _this.window.windowstate.fileViewOpen(pf, true, line);
                     } catch (JsRender.Error e) {}
                     // try hiding the left nav..
index 8a05b79..506da32 100644 (file)
             "    ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
             "  ",
             "    ",
-            "    Gtk.TextIter start;",
-            "    Gtk.TextIter end;     ",
-            "        ",
-            "    sbuf.get_bounds (out start, out end);",
-            "    sbuf.remove_source_marks (start, end, null); // remove all marks..",
+            "    _this.main_window.windowstate.updateErrorMarksAll();",
             "    ",
+            "    // what does this do?",
             "     GLib.Timeout.add(500, () => {",
             "",
             "        print(\"RESORTING cursor to = %d\\n\", cpos);",
     "   ",
     "}",
     ""
+   ],
+   "| void updateErrorMarks" : [
+    "(string category) {",
+    "\t",
+    " ",
+    "",
+    "\tvar buf = _this.buffer.el;",
+    "\tGtk.TextIter start;",
+    "\tGtk.TextIter end;     ",
+    "\tbuf.get_bounds (out start, out end);",
+    "",
+    "\tbuf.remove_source_marks (start, end, category);",
+    " ",
+    "\tGLib.debug(\"highlight errors\");\t\t ",
+    "",
+    "\t // we should highlight other types of errors..",
+    "",
+    " ",
+    "",
+    "\t ",
+    "\tif (_this.file == null) {",
+    "\t\tGLib.debug(\"file is null?\");",
+    "\t\treturn;",
+    "",
+    "\t}",
+    "\tvar ar = this.file.getErrors(category);",
+    "\tif (ar == null || ar.get_n_items() < 1) {",
+    "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
+    "\t\treturn;",
+    "\t}",
+    " ",
+    "",
+    " ",
+    "\t",
+    "\tvar offset = 0;",
+    "\t ",
+    "",
+    "\tvar tlines = buf.get_line_count () +1;",
+    "\t",
+    " ",
+    "\t ",
+    "\tfor (var i = 0; i < ar.get_n_items();i++) {",
+    "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
+    "\t\t",
+    "\t     Gtk.TextIter iter;",
+    "//        print(\"get inter\\n\");",
+    "\t    var eline = err.line - offset;",
+    "\t    GLib.debug(\"GOT ERROR on line %d -- converted to %d  (offset = %d)\",",
+    "\t    \terr.line ,eline, offset);",
+    "\t    ",
+    "\t    ",
+    "\t    if (eline > tlines || eline < 0) {",
+    "\t        return;",
+    "\t    }",
+    "\t   ",
+    "\t    ",
+    "\t    buf.get_iter_at_line( out iter, eline);",
+    "\t   ",
+    "\t   ",
+    "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
+    "\t    buf.create_source_mark( msg, err.category, iter);",
+    "\t    GLib.debug(\"set line %d to %s\", eline, msg);",
+    "\t    //this.marks.set(eline, msg);",
+    "\t}",
+    "\treturn ;",
+    "",
+    "",
+    "",
+    " ",
+    "",
+    "}"
    ]
   }
  ],
index 22062d8..e8d16f4 100644 (file)
              
             
              
+        }
+        public void updateErrorMarks (string category) {
+               
+         
+        
+               var buf = _this.buffer.el;
+               Gtk.TextIter start;
+               Gtk.TextIter end;     
+               buf.get_bounds (out start, out end);
+        
+               buf.remove_source_marks (start, end, category);
+         
+               GLib.debug("highlight errors");          
+        
+                // we should highlight other types of errors..
+        
+         
+        
+                
+               if (_this.file == null) {
+                       GLib.debug("file is null?");
+                       return;
+        
+               }
+               var ar = this.file.getErrors(category);
+               if (ar == null || ar.get_n_items() < 1) {
+                       GLib.debug("higjlight %s has no errors", category);
+                       return;
+               }
+         
+        
+         
+               
+               var offset = 0;
+                
+        
+               var tlines = buf.get_line_count () +1;
+               
+         
+                
+               for (var i = 0; i < ar.get_n_items();i++) {
+                       var err = (Palete.CompileError) ar.get_item(i);
+                       
+                    Gtk.TextIter iter;
+        //        print("get inter\n");
+                   var eline = err.line - offset;
+                   GLib.debug("GOT ERROR on line %d -- converted to %d  (offset = %d)",
+                       err.line ,eline, offset);
+                   
+                   
+                   if (eline > tlines || eline < 0) {
+                       return;
+                   }
+                  
+                   
+                   buf.get_iter_at_line( out iter, eline);
+                  
+                  
+                       var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg);
+                   buf.create_source_mark( msg, err.category, iter);
+                   GLib.debug("set line %d to %s", eline, msg);
+                   //this.marks.set(eline, msg);
+               }
+               return ;
+        
+        
+        
+         
+        
         }
         public void scroll_to_line (int line) {
            // code preview...
                 ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));
               
                 
-                Gtk.TextIter start;
-                Gtk.TextIter end;     
-                    
-                sbuf.get_bounds (out start, out end);
-                sbuf.remove_source_marks (start, end, null); // remove all marks..
+                _this.main_window.windowstate.updateErrorMarksAll();
                 
+                // what does this do?
                  GLib.Timeout.add(500, () => {
             
                     print("RESORTING cursor to = %d\n", cpos);
index 2886877..0f3b2e5 100644 (file)
@@ -157,6 +157,30 @@ public class WindowState : Object
                });
                 
        }
+       
+       public void updateErrorMarksAll() 
+       {
+               this.updateErrorMarks("ERR");
+               this.updateErrorMarks("WARN");
+               this.updateErrorMarks("DEPR");
+       
+       }
+       void updateErrorMarks(string cat) 
+       {
+               this.code_editor_tab.updateErrorMarks(cat);
+               switch(this.file.xtype) {
+                       case  "Roo":
+                               this.window_rooview.updateErrorMarks(cat);// foce scroll.
+                               return;
+                       case "Gtk":
+                               this.window_gladeview.updateErrorMarks(cat);
+                               return;
+                        default:
+                               return;
+               }
+       }
+       
+       
 
        public bool leftTreeBeforeChange()
        {
@@ -649,16 +673,8 @@ public class WindowState : Object
                         
 
                }
-               BuilderApplication.updateCompileResults();
-               /*
-               if (file.project.xtype == "Gtk" && file.project.last_request == null ) {
-                               
-                       BuilderApplication.valacompilequeue.addFile( 
-                               Palete.ValaCompileRequestType.PROJECT, 
-                               this.file, "" , true) ;
-                        
-               }
-               */
+
+                
 
                file.getLanguageServer().document_open(file);
 
@@ -704,7 +720,8 @@ public class WindowState : Object
                        //this.win.editpane.el.set_position(this.win.editpane.el.max_position);
                }
                this.win.setTitle();
-                        
+               
+               BuilderApplication.updateCompileResults();       
 
        }
  
index 109f7f7..2248a05 100644 (file)
@@ -79,7 +79,7 @@ namespace JsRender {
                private int _version = 1;   // should we increment this based on the node..?
                public int version {
                        get {
-                               return this._version;
+                               return ++this._version; // increased on every call? - bit of a kludge until we do real versioning
                        }
                        private set {
                                this._version = value;
@@ -138,6 +138,7 @@ namespace JsRender {
                {
                    
                        //this.cn = new GLib.List<JsRender>();
+                       GLib.debug("new jsrender %s", path);
                        this.path = path;
                        this.project = project;
                        this.hasParent = false;
index 0c53e8d..2d5836a 100644 (file)
@@ -149,6 +149,8 @@ roobuilder_PKGS = --pkg glib-2.0  \
                --pkg gobject-introspection-1.0 \
                --pkg libsoup-3.0 \
                --pkg roojspacker-1.4 \
+               --pkg  jsonrpc-glib-1.0 \
+               --pkg gio-unix-2.0 \
                $(roobuilder_LIBVALA) \
                $(roobuilder_GDA) \
                $(roobuilder_WEBKKIT) \
@@ -187,8 +189,10 @@ BUIDERPALETE =  Palete/Gir.vala \
                Palete/CompletionProvider.vala \
                Palete/CompileError.vala \      
                Palete/ValaCompileRequest.vala \
-               Palete/ValaCompileQueue.vala \
                Palete/Javascript.vala \
+               Palete/LanguageClient.vala \
+               Palete/LanguageClientVala.vala \
+               Palete/LanguageClientDummy.vala \
                $(roobuilder_CODEGEN)
                
 #              c/jscore_object_call_as_function.c \
@@ -233,6 +237,7 @@ roobuilder_SOURCES =  Application.vala \
                Main.vala \
                Spawn.vala \
                Resources.vala  \
+               Lsp.vala  \
                $(BUIDERJSRENDER) \
                $(BUIDERPALETE) \
                $(BUIDERPROJECT) \
index f2ba31b..31d7794 100644 (file)
@@ -40,10 +40,7 @@ namespace Palete {
                        this.msg = diag.message;   
                        
                        GLib.debug("new error %s : %d  %s %s", file.path, this.line, this.category, this.msg);
-                       if (!file.errorsByType.has_key(this.category)) {
-                               file.errorsByType.set(this.category, new  GLib.ListStore(typeof(CompileError)));
-                       }
-                       file.errorsByType.get(this.category).append(this);
+                       
                        
                        
                }
index c42609d..ccb744e 100644 (file)
@@ -87,7 +87,7 @@ namespace Palete {
                                this.jsonrpc_client.failed.connect(() => {
                                        GLib.debug("language server server has failed");
                                });
-GLib.debug("sleep - try to connect on gdb?"); Posix.sleep(10);
+
                                this.initialize_server ();
                        } 
                                         
@@ -117,7 +117,6 @@ GLib.debug("sleep - try to connect on gdb?"); Posix.sleep(10);
                
                public void onNotification(string method, Variant? return_value)
                {
-                       GLib.debug("got notification %s : %s",  method , Json.to_string (Json.gvariant_serialize (return_value), true));
                        switch (method) {
                                case "textDocument/publishDiagnostics":
                                        this.onDiagnostic(return_value);
@@ -127,7 +126,7 @@ GLib.debug("sleep - try to connect on gdb?"); Posix.sleep(10);
                                        break;
                                 
                        }
-                       
+                       GLib.debug("got notification %s : %s",  method , Json.to_string (Json.gvariant_serialize (return_value), true));
                        
                }
                
@@ -142,9 +141,15 @@ GLib.debug("sleep - try to connect on gdb?"); Posix.sleep(10);
                                GLib.debug("no file %s", dg.uri);
                                return;
                        }
-                       f.errorsByType.clear();
+                       foreach(var v in f.errorsByType.values) {
+                               v.remove_all();
+                       }
                        foreach(var diag in dg.diagnostics) {
-                               new CompileError.new_from_diagnostic(f, diag);
+                               var ce = new CompileError.new_from_diagnostic(f, diag);
+                               if (!f.errorsByType.has_key(ce.category)) {
+                                       f.errorsByType.set(ce.category, new  GLib.ListStore(typeof(CompileError)));
+                               }
+                               f.errorsByType.get(ce.category).append(ce);
                        }
                        f.project.updateErrorsforFile(f);
                        
@@ -226,7 +231,13 @@ GLib.debug("sleep - try to connect on gdb?"); Posix.sleep(10);
                        if (!this.isReady()) {
                                return;
                        }
-                                                       GLib.debug ("LS send change");
+                       GLib.debug ("LS send change");
+                       var ar = new Json.Array();
+                       var obj = new Json.Object();
+                       obj.set_string_member("text", file.toSource());
+                       ar.add_object_element(obj);
+                       var node = new Json.Node(Json.NodeType.ARRAY);
+                       node.set_array(ar);
                         try {
                                this.jsonrpc_client.send_notification (
                                        "textDocument/didChange",
@@ -235,13 +246,8 @@ GLib.debug("sleep - try to connect on gdb?"); Posix.sleep(10);
                                                        uri: new GLib.Variant.string (file.to_url()),
                                                        version :  new GLib.Variant.uint64 ( (uint64) file.version) 
                                                ),
-                                               contentChanges : new GLib.Variant.array (GLib.VariantType.DICTIONARY, 
-                                                       {  
-                                                                this.buildDict (
-                                                                       text : new GLib.Variant.string (file.toSource())
-                                                               )
-                                                       }
-                                               )
+                                               contentChanges : Json.gvariant_deserialize (node, null)
+                                               
                                        ),
                                        null 
                                );