JS: add Parameter.getJSDocTag

This commit is contained in:
Asger F
2019-02-05 11:35:16 +00:00
parent e195ac996e
commit 51360d8772
2 changed files with 18 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ class ExprOrType extends @exprortype, Documentable {
not exists(getOwnDocumentation()) and
if getParent() instanceof Property
then result = getParent().(Property).getDocumentation()
else if getParent() instanceof MethodDeclaration
then result = getParent().(MethodDeclaration).getDocumentation()
else result = getEnclosingStmt().getDocumentation()
)
}

View File

@@ -585,6 +585,13 @@ class Parameter extends BindingPattern {
int getNumDecorator() { result = count(getADecorator()) }
override predicate isLValue() { any() }
/**
* Gets the JSDoc tag describing this parameter, if any.
*/
JSDocTag getJSDocTag() {
none() // overridden in SimpleParameter
}
}
/** A parameter declaration that is not an object or array pattern. */
@@ -601,6 +608,15 @@ class SimpleParameter extends Parameter, VarDecl {
result = ssa.getVariable().getAUse()
)
}
override JSDocTag getJSDocTag() {
exists(Function fun |
this = fun.getAParameter() and
result = fun.getDocumentation().getATag() and
result.getTitle() = "param" and
result.getName() = getName()
)
}
}
/**