From: Alan Knowles Date: Tue, 19 Mar 2024 14:04:30 +0000 (+0800) Subject: Changed src/Builder4/Editor.bjssrc/Builder4/Editor.valasrc/Lsp.vala X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=18207253312d44c886ee6b1a8383a565d033486c;p=roobuilder Changed src/Builder4/Editor.bjssrc/Builder4/Editor.valasrc/Lsp.vala --- diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index dd0a0c271..ecc27cc76 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -1038,7 +1038,23 @@ "$ 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" diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index 94dd0ca1c..82de08389 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -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(); diff --git a/src/Lsp.vala b/src/Lsp.vala index ec896ecea..dac361739 100644 --- a/src/Lsp.vala +++ b/src/Lsp.vala @@ -62,6 +62,12 @@ namespace Lsp { } public class Position : Object, Gee.Comparable { + + 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; + + } }