Skip to content

Commit

Permalink
Add strings so that error messages don't have {0}'s and {1}'s in them.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126101524
  • Loading branch information
tbreisacher authored and blickly committed Jun 28, 2016
1 parent 90ba984 commit e3745a6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/google/javascript/jscomp/CheckJSDoc.java
Expand Up @@ -173,31 +173,32 @@ private void validateAbstractJsDoc(Node n, JSDocInfo info) {

if (functionNode == null) {
// @abstract annotation on a non-function
report(n, MISPLACED_ANNOTATION);
report(n, MISPLACED_ANNOTATION, "@abstract", "only functions or methods can be abstract");
return;
}

if (NodeUtil.getFunctionBody(functionNode).hasChildren()) {
// @abstract annotation on a function with a non-empty body
report(n, MISPLACED_ANNOTATION);
report(n, MISPLACED_ANNOTATION, "@abstract",
"function with a non-empty body cannot be abstract");
return;
}

if (n.isMemberFunctionDef() && "constructor".equals(n.getString())) {
// @abstract annotation on an ES6 constructor
report(n, MISPLACED_ANNOTATION);
report(n, MISPLACED_ANNOTATION, "@abstract", "constructors cannot be abstract");
return;
}

if (!n.isMemberFunctionDef() && !NodeUtil.isPrototypeMethod(functionNode)) {
// @abstract annotation on a non-method (or static method) in ES5
report(n, MISPLACED_ANNOTATION);
report(n, MISPLACED_ANNOTATION, "@abstract", "only functions or methods can be abstract");
return;
}

if (n.isStaticMember()) {
// @abstract annotation on a static method in ES6
report(n, MISPLACED_ANNOTATION);
report(n, MISPLACED_ANNOTATION, "@abstract", "static methods cannot be abstract");
return;
}
}
Expand Down

0 comments on commit e3745a6

Please sign in to comment.