*/
private boolean isFunctionDeclaration() {
if (matchesKeyword(Keyword.VOID)) {
return true;
}
Token afterReturnType = skipTypeName(currentToken);
if (afterReturnType == null) {
// There was no return type, but it is optional, so go back to where we started.
afterReturnType = currentToken;
}
Token afterIdentifier = skipSimpleIdentifier(afterReturnType);
if (afterIdentifier == null) {
// It's possible that we parsed the function name as if it were a type name, so see whether
// it makes sense if we assume that there is no type.
afterIdentifier = skipSimpleIdentifier(currentToken);
}
if (afterIdentifier == null) {
return false;
}
if (isFunctionExpression(afterIdentifier)) {
return true;
}
// It's possible that we have found a getter. While this isn't valid at this point we test for
// it in order to recover better.
if (matchesKeyword(Keyword.GET)) {
Token afterName = skipSimpleIdentifier(currentToken.getNext());
if (afterName == null) {
return false;
}
return tokenMatches(afterName, TokenType.FUNCTION)
|| tokenMatches(afterName, TokenType.OPEN_CURLY_BRACKET);