Index: Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/ContextTrackingState.java |
diff --git a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/ContextTrackingState.java b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/ContextTrackingState.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c98a8827e86bb830e7fb1c452abd26c47950659e |
--- /dev/null |
+++ b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/ContextTrackingState.java |
@@ -0,0 +1,58 @@ |
+package org.chromium.devtools.jsdoc.checks; |
+ |
+import com.google.javascript.rhino.head.ast.AstNode; |
+ |
+import org.chromium.devtools.jsdoc.ValidatorContext; |
+ |
+import java.util.Deque; |
+import java.util.HashMap; |
+import java.util.LinkedList; |
+import java.util.Map; |
+ |
+public class ContextTrackingState { |
+ private final ValidatorContext context; |
+ |
+ ContextTrackingState(ValidatorContext context) { |
+ this.context = context; |
+ } |
+ |
+ final Map<String, TypeRecord> typeRecordsByTypeName = new HashMap<>(); |
+ final Deque<TypeRecord> typeRecords = new LinkedList<>(); |
+ final Deque<FunctionRecord> functionRecords = new LinkedList<>(); |
+ |
+ TypeRecord getCurrentTypeRecord() { |
+ return typeRecords.peekLast(); |
+ } |
+ |
+ FunctionRecord getCurrentFunctionRecord() { |
+ return functionRecords.peekLast(); |
+ } |
+ |
+ ValidatorContext getContext() { |
+ return context; |
+ } |
+ |
+ Map<String, TypeRecord> getTypeRecordsByTypeName() { |
+ return typeRecordsByTypeName; |
+ } |
+ |
+ String getNodeText(AstNode node) { |
+ return getContext().getNodeText(node); |
+ } |
+ |
+ void pushTypeRecord(TypeRecord record) { |
+ typeRecords.addLast(record); |
+ } |
+ |
+ void popTypeRecord() { |
+ typeRecords.removeLast(); |
+ } |
+ |
+ void pushFunctionRecord(FunctionRecord record) { |
+ functionRecords.addLast(record); |
+ } |
+ |
+ void popFunctionRecord() { |
+ functionRecords.removeLast(); |
+ } |
+} |