[vala/wip/printer: 1/6] vala: Add SourceReference.contains()
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/printer: 1/6] vala: Add SourceReference.contains()
- Date: Thu, 9 Apr 2020 16:15:00 +0000 (UTC)
commit fb3c0947d572573a918624228fd7f9078c77a576
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Mar 19 15:58:25 2019 +0100
vala: Add SourceReference.contains()
vala/valasourcereference.vala | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/vala/valasourcereference.vala b/vala/valasourcereference.vala
index 24aeeda45..d0680f705 100644
--- a/vala/valasourcereference.vala
+++ b/vala/valasourcereference.vala
@@ -58,6 +58,26 @@ public class Vala.SourceReference {
using_directives = file.current_using_directives;
}
+ /**
+ * Checks if given source location is part of this source reference.
+ *
+ * @param location a source location
+ * @return whether this source location is part of this
+ */
+ public bool contains (SourceLocation location) {
+ if (location.line > begin.line && location.line < end.line) {
+ return true;
+ } else if (location.line == begin.line && location.line == end.line) {
+ return location.column >= begin.column && location.column <= end.column;
+ } else if (location.line == begin.line) {
+ return location.column >= begin.column;
+ } else if (location.line == end.line) {
+ return location.column <= end.column;
+ } else {
+ return false;
+ }
+ }
+
/**
* Returns a string representation of this source reference.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]