summaryrefslogtreecommitdiff
path: root/vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-12-25 12:04:01 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2018-01-02 12:42:02 +0100
commit71da3b84e23f9d97edaa1735f0e761304519d1f2 (patch)
tree202e7f220d8a81eca55088033220032d3bdd8ab3 /vala
parent016fa852b56d5c7f5863defffba1411a656c2661 (diff)
downloadvala-71da3b84e23f9d97edaa1735f0e761304519d1f2.tar.gz
parser: Allow custom invocations of parse_file()
Use CodeContext of SourceFile if needed https://bugzilla.gnome.org/show_bug.cgi?id=791936
Diffstat (limited to 'vala')
-rw-r--r--vala/valagenieparser.vala8
-rw-r--r--vala/valagirparser.vala8
-rw-r--r--vala/valaparser.vala10
3 files changed, 25 insertions, 1 deletions
diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala
index 8c92e9599..dfffa23a7 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 edc580c68..de5d7727c 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 de3ee64b9..1b1a06f66 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 () {