Changed src/Builder4/Editor.bjssrc/Builder4/Editor.valasrc/Lsp.vala
authorAlan Knowles <alan@roojs.com>
Tue, 19 Mar 2024 14:04:30 +0000 (22:04 +0800)
committerAlan Knowles <alan@roojs.com>
Tue, 19 Mar 2024 14:04:30 +0000 (22:04 +0800)
src/Builder4/Editor.bjs
src/Builder4/Editor.vala
src/Lsp.vala

index dd0a0c2..ecc27cc 100644 (file)
                  "$ xns" : "GLib",
                  "* prop" : "root",
                  "id" : "navliststore",
-                 "xtype" : "ListStore"
+                 "xtype" : "ListStore",
+                 "| Lsp.DocumentSymbol)item? symbolAtLine" : [
+                  "(int line) {",
+                  "\tLsp .DocumentSymbol ret = null;",
+                  "\t",
+                  "\tfor(var i = 0; i < this.el.get_n_items();i++) {",
+                  "\t\tvar el = (Lsp.DocumentSymbol)this.el.get_item(i);",
+                  "\t\tvar ret = el.containsLine(i);",
+                  "\t\tif (ret != null) {",
+                  "\t\t\treturn ret;",
+                  "\t\t}",
+                  "\t\t",
+                  "\t}",
+                  "\t",
+                  "\treturn null;",
+                  "}"
+                 ]
                 }
                ],
                "xtype" : "TreeListModel"
index 94dd0ca..82de083 100644 (file)
@@ -1776,7 +1776,7 @@ public class Editor : Object
                        var child_2 = new Xcls_ColumnViewColumn29( _this );
                        child_2.ref();
                        this.el.append_column( child_2.el );
-                       var child_3 = new Xcls_GestureClick34( _this );
+                       var child_3 = new Xcls_GestureClick38( _this );
                        child_3.ref();
                        this.el.add_controller(  child_3.el );
                }
@@ -1961,7 +1961,7 @@ public class Editor : Object
                {
                        _this = _owner;
                        _this.navigationselmodel = this;
-                       var child_1 = new Xcls_SortListModel60( _this );
+                       var child_1 = new Xcls_SortListModel32( _this );
                        child_1.ref();
                        this.el = new Gtk.NoSelection( child_1.el );
 
@@ -1983,7 +1983,7 @@ public class Editor : Object
                         
                }
        }
-       public class Xcls_SortListModel60 : Object
+       public class Xcls_SortListModel32 : Object
        {
                public Gtk.SortListModel el;
                private Editor  _this;
@@ -1992,12 +1992,12 @@ public class Editor : Object
                        // my vars (def)
 
                // ctor
-               public Xcls_SortListModel60(Editor _owner )
+               public Xcls_SortListModel32(Editor _owner )
                {
                        _this = _owner;
-                       var child_1 = new Xcls_TreeListModel171( _this );
+                       var child_1 = new Xcls_TreeListModel33( _this );
                        child_1.ref();
-                       var child_2 = new Xcls_TreeListRowSorter209( _this );
+                       var child_2 = new Xcls_TreeListRowSorter35( _this );
                        child_2.ref();
                        this.el = new Gtk.SortListModel( child_1.el, child_2.el );
 
@@ -2008,7 +2008,7 @@ public class Editor : Object
 
                // user defined functions
        }
-       public class Xcls_TreeListModel171 : Object
+       public class Xcls_TreeListModel33 : Object
        {
                public Gtk.TreeListModel el;
                private Editor  _this;
@@ -2017,7 +2017,7 @@ public class Editor : Object
                        // my vars (def)
 
                // ctor
-               public Xcls_TreeListModel171(Editor _owner )
+               public Xcls_TreeListModel33(Editor _owner )
                {
                        _this = _owner;
                        new Xcls_navliststore( _this );
@@ -2055,10 +2055,24 @@ public class Editor : Object
                }
 
                // user defined functions
+               public Lsp.DocumentSymbol)item? symbolAtLine (int line) {
+                       Lsp .DocumentSymbol ret = null;
+                       
+                       for(var i = 0; i < this.el.get_n_items();i++) {
+                               var el = (Lsp.DocumentSymbol)this.el.get_item(i);
+                               var ret = el.containsLine(i);
+                               if (ret != null) {
+                                       return ret;
+                               }
+                               
+                       }
+                       
+                       return null;
+               }
        }
 
 
-       public class Xcls_TreeListRowSorter209 : Object
+       public class Xcls_TreeListRowSorter35 : Object
        {
                public Gtk.TreeListRowSorter el;
                private Editor  _this;
@@ -2067,10 +2081,10 @@ public class Editor : Object
                        // my vars (def)
 
                // ctor
-               public Xcls_TreeListRowSorter209(Editor _owner )
+               public Xcls_TreeListRowSorter35(Editor _owner )
                {
                        _this = _owner;
-                       var child_1 = new Xcls_StringSorter217( _this );
+                       var child_1 = new Xcls_StringSorter36( _this );
                        child_1.ref();
                        this.el = new Gtk.TreeListRowSorter( child_1.el );
 
@@ -2081,7 +2095,7 @@ public class Editor : Object
 
                // user defined functions
        }
-       public class Xcls_StringSorter217 : Object
+       public class Xcls_StringSorter36 : Object
        {
                public Gtk.StringSorter el;
                private Editor  _this;
@@ -2090,10 +2104,10 @@ public class Editor : Object
                        // my vars (def)
 
                // ctor
-               public Xcls_StringSorter217(Editor _owner )
+               public Xcls_StringSorter36(Editor _owner )
                {
                        _this = _owner;
-                       var child_1 = new Xcls_PropertyExpression224( _this );
+                       var child_1 = new Xcls_PropertyExpression37( _this );
                        child_1.ref();
                        this.el = new Gtk.StringSorter( child_1.el );
 
@@ -2104,7 +2118,7 @@ public class Editor : Object
 
                // user defined functions
        }
-       public class Xcls_PropertyExpression224 : Object
+       public class Xcls_PropertyExpression37 : Object
        {
                public Gtk.PropertyExpression el;
                private Editor  _this;
@@ -2113,7 +2127,7 @@ public class Editor : Object
                        // my vars (def)
 
                // ctor
-               public Xcls_PropertyExpression224(Editor _owner )
+               public Xcls_PropertyExpression37(Editor _owner )
                {
                        _this = _owner;
                        this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
@@ -2130,7 +2144,7 @@ public class Editor : Object
 
 
 
-       public class Xcls_GestureClick34 : Object
+       public class Xcls_GestureClick38 : Object
        {
                public Gtk.GestureClick el;
                private Editor  _this;
@@ -2139,7 +2153,7 @@ public class Editor : Object
                        // my vars (def)
 
                // ctor
-               public Xcls_GestureClick34(Editor _owner )
+               public Xcls_GestureClick38(Editor _owner )
                {
                        _this = _owner;
                        this.el = new Gtk.GestureClick();
index ec896ec..dac3617 100644 (file)
@@ -62,6 +62,12 @@ namespace Lsp {
     }
 
     public  class Position : Object, Gee.Comparable<Position> {
+        
+        public Position.new_line(uint line)
+        {
+               this.line = line;
+               this.character = 0;
+        }
         /**
          * Line position in a document (zero-based).
          */
@@ -444,6 +450,23 @@ namespace Lsp {
                                return this.kind.sort_key().to_string() + "=" + this.name;
                        }
                }
+               
+               public DocumentSymbol? containsLine(int line)
+               {
+                       if (!this.range.contains(new Position.new_line(line))) {
+                               return null;
+                       }
+
+                       for(var i = 0; i < this.children.get_n_items();i++) {
+                               var el = (DocumentSymbol)this.children.get_item(i);
+                               var ret = el.containsLine(line);
+                               if (ret != null) {
+                                       return ret;
+                               }
+                       }
+                       return this;
+                       
+               }
           
           
     }