fix #7968 - language server support for syntax check and completion
[roobuilder] / src / Builder4 / MainWindow.vala
index 76242bb..65636a6 100644 (file)
             this.el.close_request.connect( ( ) => {
                 Resources.singleton().disconnect(_this.statusbar.handler_id);
                 
+                
+                this.windowstate.file.getLanguageServer().document_close(
+                       this.windowstate.file
+               );
+                
                 BuilderApplication.removeWindow(this);
                 
                 if (BuilderApplication.windows.size  < 1) {
-            
+                       this.windowstate.file.getLanguageServer().exit();
                        BuilderApplication.singleton(  null ).quit();
                 }
                return true;
         }
 
         // user defined functions
-        public void updateErrors (Palete.ValaCompileRequest? req) {
+        public void updateErrors () {
         
-               if (req == null) {
-         
-                   _this.statusbar_errors.el.hide();
-                       _this.statusbar_warnings.el.hide();
-                       _this.statusbar_depricated.el.hide();
-                       return;
-               }
+        
+               GLib.debug("updateErrors");
                
+               var pr = this.windowstate.project.getErrors("ERR");
                
                this.statusbar_errors.setNotices(
-                       req.errorByType.get("ERR"),
-                       req.totalErrors("ERR"),
-                       req.totalErrors("ERR", this.windowstate.file)
+                       pr,
+                       this.windowstate.file.getErrors("ERR")
                );
+               
                this.statusbar_warnings.setNotices(
-                       req.errorByType.get("WARN"),
-                       req.totalErrors("WARN"),
-                       req.totalErrors("WARN", this.windowstate.file)
+                       this.windowstate.project.getErrors("WARN"),
+                       this.windowstate.file.getErrors("WARN")
                );
                this.statusbar_depricated.setNotices(
-                       req.errorByType.get("DEPR"),
-                       req.totalErrors("DEPR"),
-                       req.totalErrors("DEPR", this.windowstate.file)
+                       this.windowstate.project.getErrors("DEPR"),
+                       this.windowstate.file.getErrors("DEPR")
                );
-        
+         
                _this.statusbar_run.el.hide();
         
-               if (req.totalErrors("ERR") < 1) {
+               if (pr.get_n_items() < 1) {
                        _this.statusbar_run.el.show();
-               }
+               } 
                
         }
         public void initChildren () {
 
                 // 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();
+                  
                 });
             }
 
             // user defined functions
-            public void setNotices (GLib.ListStore nots, int qty, int tf) {
+            public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) {
                 
-                 if (qty < 1 ) {
+                 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(tf,qty);
-                this.notices = nots;
-               if (this.popup != null && this.popup.el.visible) {
-                        this.popup.show(this.notices, this.el);
+                this.el.label = "%d/%d Errors".printf((int)fe.get_n_items(),(int)nots.get_n_items());
+            
+                
+             
+               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;
                 });
             }
 
             // user defined functions
-            public void setNotices (GLib.ListStore nots, int qty, int tf) {
+            public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) {
                 
-                if (qty < 1 ) {
+                 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(tf,qty);
-                 this.notices = nots;
-                if (this.popup != null && this.popup.el.visible) {
-                        this.popup.show(this.notices, this.el);
-                }
                 
+                this.el.show();
+                this.el.label = "%d/%d Warnings".printf((int)fe.get_n_items(),(int)nots.get_n_items());
             
+                
+             
+               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();
+                  
                 });
             }
 
             // user defined functions
-            public void setNotices (GLib.ListStore nots, int qty, int tf) {
-                if (qty < 1) {
+            public void setNotices (GLib.ListStore nots, GLib.ListStore fe ) {
+                
+                 if (nots.get_n_items() < 1 ) {
                        this.el.hide();
-                       if (this.popup != null && this.popup.el.visible) {
-                                this.popup.el.hide();
+                       if (this.popup != null) {
+                               this.popup.el.hide();
                        }
-             
                        return;
-               }
+                }
                 
                 this.el.show();
+                this.el.label = "%d/%d Depricated".printf((int)fe.get_n_items(),(int)nots.get_n_items());
+            
                 
-                this.el.label = "%d/%d Depricated".printf(tf,qty);
-                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);
+                
             }
         }
 
                            _this.windowstate.compile_results.el.show(); // show currently running.
                        return;
                        }
-                       BuilderApplication.valacompilequeue.addFile( 
-                                                               Palete.ValaCompileRequestType.RUN, 
-                                                               _this.windowstate.file, "", true ) ;
-                
+                       
+                       var req = new Palete.ValaCompileRequest(
+                               Palete.ValaCompileRequestType.RUN,
+                               _this.windowstate.file,
+                               null,
+                               null,
+                               ""
+                       );
+                       req.run();
+                        
                        _this.windowstate.compile_results.el.set_parent(this.el);
                        _this.windowstate.compile_results.show(this.el,true);