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

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

Issue 199733011: DevTools: [JsDocValidator] Avoid false-positive function receiver-related errors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/RequiredThisAnnotationChecker.java
diff --git a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/RequiredThisAnnotationChecker.java b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/RequiredThisAnnotationChecker.java
deleted file mode 100644
index 191ad535c06c80bf7dca667a503bdcdd11845100..0000000000000000000000000000000000000000
--- a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/RequiredThisAnnotationChecker.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.chromium.devtools.jsdoc.checks;
-
-import com.google.javascript.rhino.head.Token;
-import com.google.javascript.rhino.head.ast.AstNode;
-import com.google.javascript.rhino.head.ast.FunctionNode;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public final class RequiredThisAnnotationChecker extends ContextTrackingChecker {
-
- private final Set<FunctionRecord> functionsRequiringThisAnnotation = new HashSet<>();
-
- @Override
- void enterNode(AstNode node) {
- if (node.getType() == Token.THIS) {
- FunctionRecord function = getState().getCurrentFunctionRecord();
- if (function == null) {
- return;
- }
- if (!function.isTopLevelFunction() && !function.isConstructor) {
- functionsRequiringThisAnnotation.add(function);
- }
- return;
- }
- }
-
- @Override
- void leaveNode(AstNode node) {
- if (node.getType() != Token.FUNCTION) {
- return;
- }
-
- ContextTrackingState state = getState();
- FunctionRecord function = state.getCurrentFunctionRecord();
- FunctionNode functionNode = (FunctionNode) node;
- if (!functionsRequiringThisAnnotation.contains(function)) {
- AstNode functionNameNode = AstUtil.getFunctionNameNode(functionNode);
- if (functionNameNode != null && !function.isTopLevelFunction() &&
- hasAnnotationTag(functionNode, "this")) {
- reportErrorAtNodeStart(
- functionNameNode,
- "@this annotation found for function not referencing 'this'");
- }
- return;
- }
- AstNode functionNameNode = AstUtil.getFunctionNameNode(functionNode);
- if (functionNameNode != null && !hasAnnotationTag(functionNode, "this")) {
- reportErrorAtNodeStart(
- functionNameNode,
- "@this annotation is required for functions referencing 'this'");
- }
- }
-}

Powered by Google App Engine
This is Rietveld 408576698