boolean isStatic = node.isStatic();
Token property = node.getPropertyKeyword();
FunctionBody body = node.getBody();
if (property == null) {
SimpleIdentifier methodName = node.getName();
String nameOfMethod = methodName.getName();
if (nameOfMethod.equals(TokenType.MINUS.getLexeme())
&& node.getParameters().getParameters().size() == 0) {
nameOfMethod = "unary-";
}
MethodElementImpl element = new MethodElementImpl(nameOfMethod, methodName.getOffset());
element.setAbstract(node.isAbstract());
element.setFunctions(holder.getFunctions());
element.setLabels(holder.getLabels());
element.setLocalVariables(holder.getLocalVariables());
element.setParameters(holder.getParameters());
element.setStatic(isStatic);
if (body.isAsynchronous()) {
element.setAsynchronous(true);
}
if (body.isGenerator()) {
element.setGenerator(true);
}
currentHolder.addMethod(element);
methodName.setStaticElement(element);
} else {
SimpleIdentifier propertyNameNode = node.getName();
String propertyName = propertyNameNode.getName();
FieldElementImpl field = (FieldElementImpl) currentHolder.getField(propertyName);
if (field == null) {
field = new FieldElementImpl(node.getName().getName(), -1);
field.setFinal(true);
field.setStatic(isStatic);
field.setSynthetic(true);
currentHolder.addField(field);
}
if (matches(property, Keyword.GET)) {
PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(propertyNameNode);
getter.setFunctions(holder.getFunctions());
getter.setLabels(holder.getLabels());
getter.setLocalVariables(holder.getLocalVariables());
if (body.isAsynchronous()) {
getter.setAsynchronous(true);
}
if (body.isGenerator()) {
getter.setGenerator(true);
}
getter.setVariable(field);
getter.setAbstract(body instanceof EmptyFunctionBody && node.getExternalKeyword() == null);
getter.setGetter(true);
getter.setStatic(isStatic);
field.setGetter(getter);
currentHolder.addAccessor(getter);
propertyNameNode.setStaticElement(getter);
} else {
PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(propertyNameNode);
setter.setFunctions(holder.getFunctions());
setter.setLabels(holder.getLabels());
setter.setLocalVariables(holder.getLocalVariables());
setter.setParameters(holder.getParameters());
if (body.isAsynchronous()) {
setter.setAsynchronous(true);
}
if (body.isGenerator()) {
setter.setGenerator(true);
}
setter.setVariable(field);
setter.setAbstract(body instanceof EmptyFunctionBody
&& !matches(node.getExternalKeyword(), Keyword.EXTERNAL));
setter.setSetter(true);
setter.setStatic(isStatic);
field.setSetter(setter);
field.setFinal(false);
currentHolder.addAccessor(setter);
propertyNameNode.setStaticElement(setter);
}
}
holder.validate();
} catch (Exception ex) {
if (node.getName().getStaticElement() == null) {