Merge pull request #887 from asger-semmle/jsdoc-accessors

Approved by xiemaisi
This commit is contained in:
semmle-qlci
2019-02-06 16:30:48 +00:00
committed by GitHub
10 changed files with 84 additions and 1 deletions

View File

@@ -29,7 +29,10 @@ class ExprOrType extends @exprortype, Documentable {
not exists(getOwnDocumentation()) and
if getParent() instanceof Property
then result = getParent().(Property).getDocumentation()
else result = getEnclosingStmt().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()
)
}
}
/**