in src/resolver/model.js [72:121]
initProp(nodes) {
const object = this.object;
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
const prop = new PropItem();
prop.belong = object.index;
prop.name = _escape(node.fieldName.lexeme) || _string(node.fieldName);
prop.type = this.resolveTypeItem(node.fieldValue, node);
prop.modify.push(Modify.public());
if (node.required) {
prop.addNote(new NoteItem('required', true));
}
if (node.tokenRange) {
let annotations = this.resolveAnnotations(
this.getFrontComments(node.tokenRange[0]),
object.index
);
annotations.forEach(c => {
object.addBodyNode(c);
});
}
for (let i = 0; i < node.attrs.length; i++) {
const attr = node.attrs[i];
let value;
if (typeof attr.attrValue.string !== 'undefined') {
value = attr.attrValue.string;
} else if (typeof attr.attrValue.value !== 'undefined') {
value = attr.attrValue.value;
} else if (typeof attr.attrValue.lexeme !== 'undefined') {
value = attr.attrValue.lexeme;
}
let note = new NoteItem(
attr.attrName.lexeme,
value
);
prop.addNote(note);
}
object.addBodyNode(prop);
}
if (nodes[nodes.length - 1] && nodes[nodes.length - 1].tokenRange) {
let annotations = this.resolveAnnotations(
this.getBackComments(nodes[nodes.length - 1].tokenRange[1]),
object.index
);
annotations.forEach(c => {
object.addBodyNode(c);
});
}
}