[vala/wip/printer: 3/6] vala: Add CodeNode reference to SourceReference
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/printer: 3/6] vala: Add CodeNode reference to SourceReference
- Date: Thu, 9 Apr 2020 16:15:10 +0000 (UTC)
commit 1a3f054ec71ebfc67bdde5fb612929eae1ff06f0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Apr 8 16:43:03 2020 +0200
vala: Add CodeNode reference to SourceReference
vala/valacodenode.vala | 14 +++++++++++++-
vala/valasourcereference.vala | 5 +++++
2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index 05ba53a0a..21dca7c88 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -38,7 +38,18 @@ public abstract class Vala.CodeNode {
* References the location in the source file where this code node has
* been written.
*/
- public SourceReference? source_reference { get; set; }
+ public SourceReference? source_reference {
+ get {
+ return _source_reference;
+ }
+ set {
+ _source_reference = value;
+ // source references are re-used in transformed nodes, keep original node reference
+ if (_source_reference != null && _source_reference.node == null) {
+ _source_reference.node = this;
+ }
+ }
+ }
public bool unreachable { get; set; }
@@ -70,6 +81,7 @@ public abstract class Vala.CodeNode {
}
private AttributeCache[] attributes_cache;
+ SourceReference? _source_reference;
static int last_temp_nr = 0;
static int next_attribute_cache_index = 0;
diff --git a/vala/valasourcereference.vala b/vala/valasourcereference.vala
index d0680f705..be79e197e 100644
--- a/vala/valasourcereference.vala
+++ b/vala/valasourcereference.vala
@@ -31,6 +31,11 @@ public class Vala.SourceReference {
*/
public weak SourceFile file { get; set; }
+ /**
+ * The code node of the referenced source code.
+ */
+ public weak CodeNode? node { get; set; }
+
/**
* The begin of the referenced source code.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]