[vala/staging: 2/5] parser: Allow custom invocations of parse_file()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/5] parser: Allow custom invocations of parse_file()
- Date: Tue, 2 Jan 2018 12:09:55 +0000 (UTC)
commit 71da3b84e23f9d97edaa1735f0e761304519d1f2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Dec 25 12:04:01 2017 +0100
parser: Allow custom invocations of parse_file()
Use CodeContext of SourceFile if needed
https://bugzilla.gnome.org/show_bug.cgi?id=791936
vala/valagenieparser.vala | 8 ++++++++
vala/valagirparser.vala | 8 ++++++++
vala/valaparser.vala | 10 +++++++++-
3 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 8c92e95..dfffa23 100644
--- a/vala/valagenieparser.vala
+++ b/vala/valagenieparser.vala
@@ -399,6 +399,11 @@ public class Vala.Genie.Parser : CodeVisitor {
}
public void parse_file (SourceFile source_file) {
+ var has_global_context = (context != null);
+ if (!has_global_context) {
+ context = source_file.context;
+ }
+
scanner = new Scanner (source_file);
scanner.parse_file_comments ();
scanner.indent_spaces = 0;
@@ -430,6 +435,9 @@ public class Vala.Genie.Parser : CodeVisitor {
}
scanner = null;
+ if (!has_global_context) {
+ context = null;
+ }
}
void skip_symbol_name () throws ParseError {
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index edc580c..de5d772 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1375,6 +1375,11 @@ public class Vala.GirParser : CodeVisitor {
}
public void parse_file (SourceFile source_file) {
+ var has_global_context = (context != null);
+ if (!has_global_context) {
+ context = source_file.context;
+ }
+
metadata_stack = new ArrayList<Metadata> ();
metadata = Metadata.empty;
cheader_filenames = null;
@@ -1391,6 +1396,9 @@ public class Vala.GirParser : CodeVisitor {
reader = null;
this.current_source_file = null;
+ if (!has_global_context) {
+ context = null;
+ }
}
void next () {
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index de3ee64..1b1a06f 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -80,7 +80,7 @@ public class Vala.Parser : CodeVisitor {
}
public override void visit_source_file (SourceFile source_file) {
- if (context.run_output || source_file.filename.has_suffix (".vala") ||
source_file.filename.has_suffix (".vapi")) {
+ if ((context != null && context.run_output) || source_file.filename.has_suffix (".vala") ||
source_file.filename.has_suffix (".vapi")) {
parse_file (source_file);
}
}
@@ -322,6 +322,11 @@ public class Vala.Parser : CodeVisitor {
}
public void parse_file (SourceFile source_file) {
+ var has_global_context = (context != null);
+ if (!has_global_context) {
+ context = source_file.context;
+ }
+
scanner = new Scanner (source_file);
parse_file_comments ();
@@ -345,6 +350,9 @@ public class Vala.Parser : CodeVisitor {
}
scanner = null;
+ if (!has_global_context) {
+ context = null;
+ }
}
void parse_file_comments () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]