Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6268)

Unified Diff: Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/ContextTrackingState.java

Issue 137553005: DevTools: [JsDocValidator] Refactor JsDoc annotation checkers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Limit the thread count by the number of validated files Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5bb88a127f4fb5c217389ea54b6f89d6d3724346
--- /dev/null
+++ b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/ContextTrackingState.java
@@ -0,0 +1,66 @@
+package org.chromium.devtools.jsdoc.checks;
+
+import com.google.javascript.rhino.head.ast.AstNode;
+
+import org.chromium.devtools.jsdoc.ValidatorContext;
+import org.chromium.devtools.jsdoc.checks.TypeRecord.InheritanceEntry;
+
+import java.util.ArrayDeque;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ContextTrackingState {
+ private final ValidatorContext context;
+
+ ContextTrackingState(ValidatorContext context) {
+ this.context = context;
+ }
+
+ private final TypeRecord NULL_TYPE_RECORD = new TypeRecord(
+ null,
+ false,
+ Collections.<InheritanceEntry>emptyList(),
+ Collections.<InheritanceEntry>emptyList());
+ private final FunctionRecord NULL_FUNCTION_RECORD =
+ new FunctionRecord(null, false, null, null, null);
+
+ final Map<String, TypeRecord> typeRecordsByTypeName = new HashMap<>();
+ final Deque<TypeRecord> typeRecords = new ArrayDeque<>();
+ final Deque<FunctionRecord> functionRecords = new ArrayDeque<>();
+
+ TypeRecord getCurrentTypeRecord() {
+ TypeRecord result = typeRecords.isEmpty()
+ ? NULL_TYPE_RECORD
+ : typeRecords.peekLast();
+ return result == NULL_TYPE_RECORD ? null : result;
+ }
+
+ FunctionRecord getCurrentFunctionRecord() {
+ FunctionRecord result = functionRecords.isEmpty()
+ ? NULL_FUNCTION_RECORD
+ : functionRecords.peekLast();
+ return result == NULL_FUNCTION_RECORD ? null : result;
+ }
+
+ ValidatorContext getContext() {
+ return context;
+ }
+
+ Map<String, TypeRecord> getTypeRecordsByTypeName() {
+ return typeRecordsByTypeName;
+ }
+
+ String getNodeText(AstNode node) {
+ return getContext().getNodeText(node);
+ }
+
+ void addTypeRecord(TypeRecord record) {
+ typeRecords.addLast(record == null ? NULL_TYPE_RECORD : record);
+ }
+
+ void addFunctionRecord(FunctionRecord record) {
+ functionRecords.addLast(record == null ? NULL_FUNCTION_RECORD : record);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698