Skip to content

Commit

Permalink
Merge pull request #49 from teppeis/check-extending-interface
Browse files Browse the repository at this point in the history
Add check for @extends using with @interface.
  • Loading branch information
ama-ch committed Jan 5, 2016
2 parents c3429c1 + bcc1f87 commit a67f024
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lib/parser.js
Expand Up @@ -173,7 +173,7 @@ Parser.prototype.extractToRequire_ = function(parsed, toProvide, comments, opt_r
};

/**
* Require "@implements" classes.
* Require "@implements" classes and "@extends" classes with "@interface".
* @param {Array} comments .
* @return {Array.<string>} .
* @private
Expand All @@ -188,9 +188,28 @@ Parser.prototype.extractToRequireFromJsDoc_ = function(comments) {
if (tag.title === 'implements' && tag.type.type === 'NameExpression') {
prev.push(tag.type.name);
}
});
if (tag.title === 'extends' && tag.type.type === 'NameExpression' &&
this.containsJsDocTag_(jsdoc, 'interface')) {
prev.push(tag.type.name);
}
}, this);
return prev;
}, []);
}.bind(this), []);
};

/**
* @param {!Object} jsdoc .
* @param {string} tagName .
* @return {boolean} .
* @private
*/
Parser.prototype.containsJsDocTag_ = function(jsdoc, tagName) {
for (var i in jsdoc.tags) {
if (jsdoc.tags[i].title === tagName) {
return true;
}
}
return false;
};

/**
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/parse/@extends.js
@@ -0,0 +1,15 @@
/**
* @interface
* @extends {goog.disposable.IDisposable}
*/
var Foo = function() {
};

/**
* @constructor
* @extends {goog.Disposable}
*/
var Foo = function() {
};

// toRequire: goog.disposable.IDisposable

0 comments on commit a67f024

Please sign in to comment.