[valadoc] Support for relative searching of symbols
- From: Florian Brosch <flobrosch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [valadoc] Support for relative searching of symbols
- Date: Thu, 15 Oct 2009 21:03:24 +0000 (UTC)
commit e97f21ba63d8e8eca7fd6f5bdde05726e63fc6a7
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Sun Sep 27 12:30:16 2009 +0200
Support for relative searching of symbols
src/libvaladoc/apitree/apitree.vala | 29 +++++++++++++++++++++--------
src/libvaladoc/apitree/class.vala | 2 +-
src/libvaladoc/apitree/enum.vala | 2 +-
src/libvaladoc/apitree/errordomain.vala | 2 +-
src/libvaladoc/apitree/interface.vala | 2 +-
src/libvaladoc/apitree/namespace.vala | 2 +-
src/libvaladoc/apitree/struct.vala | 2 +-
7 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/src/libvaladoc/apitree/apitree.vala b/src/libvaladoc/apitree/apitree.vala
index 9043508..882aa07 100644
--- a/src/libvaladoc/apitree/apitree.vala
+++ b/src/libvaladoc/apitree/apitree.vala
@@ -61,19 +61,18 @@ public class Valadoc.Tree : Vala.CodeVisitor {
}
private DocumentedElement? search_symbol_in_type ( DocumentedElement element, string[] params, int params_offset = 0 ) {
- if (!(element.parent is Enum || element.parent is ErrorDomain))
- return null;
-
+ string[] nparams = null;
if ( params[0] != "this" ) {
- string[] nparams = new string[ params.length+1 ];
+ nparams = new string[ params.length+1 ];
nparams[0] = "this";
for ( int i = 0; params.length > i ; i++ ) {
nparams [i+1] = params[i];
}
- return this.search_symbol_in_symbol ( (DocumentedElement)element.parent, nparams, 0 );
+ } else {
+ nparams = params;
}
- return this.search_symbol_in_symbol ( (DocumentedElement)element.parent, params, 0 );
+ return this.search_symbol_in_symbol (element, nparams, 0);
}
private DocumentedElement? search_symbol_in_symbol ( DocumentedElement element, string[] params, int params_offset = 0 ) {
@@ -118,6 +117,11 @@ public class Valadoc.Tree : Vala.CodeVisitor {
}
private DocumentedElement? search_element ( DocumentedElement? element, string[] params ) {
+ if (element is Field || element is Method || element is Delegate
+ || element is Signal || element is Property || element is Constant) {
+ element = (DocumentedElement) element.parent;
+ }
+
if ( element != null ) {
if ( params[0] == "this" ) {
return search_symbol_in_type ( element, params, 1 );
@@ -140,11 +144,20 @@ public class Valadoc.Tree : Vala.CodeVisitor {
}
public DocumentedElement? search_symbol_str ( DocumentedElement? element, string symname ) {
+ var result = this.search_element (element, split_name (symname));
+ while (result == null && element.parent != null) {
+ var parent_name = element.name;
+ result = this.search_element ( element, split_name (parent_name + "." + symname) );
+ element = (DocumentedElement) element.parent;
+ }
+ return result;
+ }
+
+ private string[] split_name (string symname) {
string[] params = symname.split( ".", -1 );
int i = 0; while ( params[i] != null ) i++;
params.length = i;
-
- return this.search_element ( element, params );
+ return params;
}
public override void visit_namespace ( Vala.Namespace vns ) {
diff --git a/src/libvaladoc/apitree/class.vala b/src/libvaladoc/apitree/class.vala
index d5ed8c3..3139432 100644
--- a/src/libvaladoc/apitree/class.vala
+++ b/src/libvaladoc/apitree/class.vala
@@ -207,7 +207,7 @@ public class Valadoc.Class : DocumentedElement, SymbolAccessibility, Visitable,
if ( !(this.name == params[pos] || params[0] == "this") )
return null;
- if ( params[pos+1] == null )
+ if ( params[pos] == this.name && params[pos+1] == null )
return this;
DocumentedElement? element = this.search_field ( params, pos );
diff --git a/src/libvaladoc/apitree/enum.vala b/src/libvaladoc/apitree/enum.vala
index b3c7143..ced9728 100644
--- a/src/libvaladoc/apitree/enum.vala
+++ b/src/libvaladoc/apitree/enum.vala
@@ -105,7 +105,7 @@ public class Valadoc.Enum : DocumentedElement, SymbolAccessibility, Visitable, M
if ( this.name != params[pos] )
return null;
- if ( params[pos+1] == null )
+ if ( params[pos] == this.name && params[pos+1] == null )
return this;
diff --git a/src/libvaladoc/apitree/errordomain.vala b/src/libvaladoc/apitree/errordomain.vala
index b0190e8..180e69b 100644
--- a/src/libvaladoc/apitree/errordomain.vala
+++ b/src/libvaladoc/apitree/errordomain.vala
@@ -114,7 +114,7 @@ public class Valadoc.ErrorDomain : DocumentedElement, SymbolAccessibility, Visit
if ( this.name != params[pos] )
return null;
- if ( params[pos+1] == null )
+ if ( params[pos] == this.name && params[pos+1] == null )
return this;
DocumentedElement? element = this.search_method ( params, pos );
diff --git a/src/libvaladoc/apitree/interface.vala b/src/libvaladoc/apitree/interface.vala
index 0bab140..4dd7ce5 100644
--- a/src/libvaladoc/apitree/interface.vala
+++ b/src/libvaladoc/apitree/interface.vala
@@ -180,7 +180,7 @@ public class Valadoc.Interface : DocumentedElement, SymbolAccessibility, Visitab
if ( !(this.name == params[pos] || params[0] == "this") )
return null;
- if ( params[pos+1] == null )
+ if ( params[pos] == this.name && params[pos+1] == null )
return this;
DocumentedElement? element = this.search_field ( params, pos );
diff --git a/src/libvaladoc/apitree/namespace.vala b/src/libvaladoc/apitree/namespace.vala
index 904b64f..0533224 100644
--- a/src/libvaladoc/apitree/namespace.vala
+++ b/src/libvaladoc/apitree/namespace.vala
@@ -138,7 +138,7 @@ public class Valadoc.Namespace : DocumentedElement, MethodHandler, FieldHandler,
if ( this.name != params[pos] )
return null;
- if ( params[pos+1] == null )
+ if ( params[pos] == this.name && params[pos+1] == null )
return this;
diff --git a/src/libvaladoc/apitree/struct.vala b/src/libvaladoc/apitree/struct.vala
index 28e5d69..7996ea2 100644
--- a/src/libvaladoc/apitree/struct.vala
+++ b/src/libvaladoc/apitree/struct.vala
@@ -123,7 +123,7 @@ public class Valadoc.Struct : DocumentedElement, SymbolAccessibility, Visitable,
if ( this.name != params[pos] )
return null;
- if ( params[pos+1] == null )
+ if ( params[pos] == this.name && params[pos+1] == null )
return this;
DocumentedElement? element = this.search_field ( params, pos );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]