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

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

Issue 419073005: DevTools: [JSDocValidator] Fix function qualified name detection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a test Created 6 years, 5 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/AstUtil.java
diff --git a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/AstUtil.java b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/AstUtil.java
index fc9dcd107cf26b69581061313a033f6978b06b81..94bec2c7d64a8096625d0a8d8562f4d2da4982c1 100644
--- a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/AstUtil.java
+++ b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/checks/AstUtil.java
@@ -23,11 +23,6 @@ public class AstUtil {
*/
static Node getFunctionNameNode(Node node) {
Preconditions.checkState(node.isFunction());
- Node funNameNode = node.getFirstChild();
- // Don't return the name node for anonymous functions
- if (!funNameNode.getString().isEmpty()) {
- return funNameNode;
- }
Node parent = node.getParent();
if (parent != null) {
@@ -36,8 +31,7 @@ public class AstUtil {
// var name = function() ...
// var name2 = function name1() ...
return parent;
- // FIXME: Perhaps, the setter and getter cases should be handled, too,
- // but this breaks tests.
+ // FIXME: Enable the setter and getter checks.
// case Token.SETTER_DEF:
// case Token.GETTER_DEF:
case Token.STRING_KEY:
@@ -45,15 +39,17 @@ public class AstUtil {
case Token.NUMBER:
return parent;
case Token.ASSIGN:
- if (parent.getLastChild() == node &&
- parent.getFirstChild().getType() == Token.NAME) {
- return parent.getFirstChild();
- }
- return null;
+ int nameType = parent.getFirstChild().getType();
+ // We only consider these types of name nodes as acceptable.
+ return nameType == Token.NAME || nameType == Token.GETPROP
+ ? parent.getFirstChild()
+ : null;
case Token.VAR:
return parent.getFirstChild();
default:
- return null;
+ Node funNameNode = node.getFirstChild();
+ // Don't return the name node for anonymous functions
+ return funNameNode.getString().isEmpty() ? null : funNameNode;
}
}

Powered by Google App Engine
This is Rietveld 408576698