| 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);
|
| + }
|
| +}
|
|
|