in lib/parser.js [2376:2424]
fun() {
// function = [ Annotation ] ["static"] "funtion" apiName "(" [ params ] ")" returnType functionBody
const begin = this.getIndex();
let isStatic = false;
let hasThrow = false;
if (this.is(Tag.STATIC)) {
isStatic = true;
this.move();
}
let isAsync = false;
if (this.isWord(Tag.ID, 'async')) {
isAsync = true;
this.move();
}
this.matchWord(Tag.ID, 'function');
const functionName = this.look;
this.match(Tag.ID);
this.match('(');
const params = this.params();
this.match(')');
if (this.isWord(Tag.ID, 'throws')) {
hasThrow = true;
this.move();
}
this.match(':');
const returnType = this.baseType();
let functionBody = null;
let end = this.getIndex();
if (this.look.tag === '{') {
functionBody = this.functionBody();
end = functionBody.tokenRange[1];
} else if (this.look.tag === ';') {
this.move();
}
return {
type: 'function',
isStatic: isStatic,
isAsync: isAsync,
hasThrow: hasThrow,
functionName: functionName,
params: params,
returnType: returnType,
functionBody: functionBody,
tokenRange: [begin, end]
};
}