[vala/1270-remove-static-codecontext-access: 22/44] CodeNode: add CodeContext property
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/1270-remove-static-codecontext-access: 22/44] CodeNode: add CodeContext property
- Date: Mon, 3 Jan 2022 23:53:27 +0000 (UTC)
commit f6742a9f9964f0e4472e3799a0582b15190b28b7
Author: Daniel Espinosa <esodan gmail com>
Date: Sat Jan 1 22:05:17 2022 -0600
CodeNode: add CodeContext property
vala/valacodenode.vala | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index 4ca44c8d9..52757d9b6 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -29,6 +29,10 @@ using GLib;
* compilation process.
*/
public abstract class Vala.CodeNode {
+ /**
+ * Current context.
+ */
+ public weak CodeContext context { get; protected set; }
/**
* Parent of this code node.
*/
@@ -429,6 +433,28 @@ public abstract class Vala.CodeNode {
public virtual void get_error_types (Collection<DataType> collection, SourceReference?
source_reference = null) {
}
+ /**
+ * Traverse tree for the current {@link CodeContext}
+ */
+ public CodeContext traverse_for_context () {
+ CodeContext ctx = null;
+ if (this is Namespace) {
+ ctx = this.context;
+ }
+
+ CodeNode parent = parent_node;
+ while (ctx == null) {
+ parent = parent.parent_node;
+ if (parent == null) {
+ break;
+ }
+
+ ctx = parent.context;
+ }
+
+ return ctx;
+ }
+
public static string get_temp_name () {
return "." + (++last_temp_nr).to_string ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]