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

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

Issue 319733002: DevTools: [JsDocValidator] Be smarter about function name and JSDoc detection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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/FunctionReceiverChecker.java
diff --git a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/FunctionReceiverChecker.java b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/FunctionReceiverChecker.java
index 637fc923017262cb2827f567414021033eadca50..1ac4fa79e64f3df918c5aa705288d8f0d0591299 100644
--- a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/FunctionReceiverChecker.java
+++ b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/FunctionReceiverChecker.java
@@ -190,23 +190,29 @@ public final class FunctionReceiverChecker extends ContextTrackingChecker {
private void checkThisAnnotation(FunctionRecord function) {
AstNode functionNameNode = AstUtil.getFunctionNameNode(function.functionNode);
- if (functionNameNode == null) {
+ if (functionNameNode == null && function.jsDocNode == null) {
+ // Do not check anonymous functions without a JSDoc.
return;
}
- boolean hasThisAnnotation = hasAnnotationTag(function.functionNode, "this");
+ AstNode errorTargetNode =
+ functionNameNode == null ? function.jsDocNode : functionNameNode;
+ if (errorTargetNode == null) {
+ errorTargetNode = function.functionNode;
+ }
+ boolean hasThisAnnotation = hasAnnotationTag(function.jsDocNode, "this");
if (hasThisAnnotation == functionReferencesThis(function)) {
return;
}
if (hasThisAnnotation) {
if (!function.isTopLevelFunction()) {
reportErrorAtNodeStart(
- functionNameNode,
+ errorTargetNode,
"@this annotation found for function not referencing 'this'");
}
return;
} else {
reportErrorAtNodeStart(
- functionNameNode,
+ errorTargetNode,
"@this annotation is required for functions referencing 'this'");
}
}
@@ -237,7 +243,7 @@ public final class FunctionReceiverChecker extends ContextTrackingChecker {
private void processFunctionUsesAsArgument(
FunctionRecord function, Set<SymbolicArgument> argumentUses) {
if (argumentUses == null ||
- hasAnnotationTag(function.functionNode, "suppressReceiverCheck")) {
+ hasAnnotationTag(function.jsDocNode, "suppressReceiverCheck")) {
return;
}

Powered by Google App Engine
This is Rietveld 408576698