if (hasPropertyWithName(name)) {
return;
}
// do add property
int nameOffset = nameNode.getValueOffset();
AngularScopePropertyElement property = new AngularScopePropertyElementImpl(
name,
nameOffset,
node.getRightHandSide().getBestType());
nameNode.setToolkitElement(property);
properties.add(property);
}
private SimpleStringLiteral getNameNode(Expression node) {
if (node instanceof IndexExpression) {
IndexExpression indexExpression = (IndexExpression) node;
Expression target = indexExpression.getTarget();
Expression index = indexExpression.getIndex();
if (index instanceof SimpleStringLiteral && isContext(target)) {
return (SimpleStringLiteral) index;
}
}
return null;
}
private boolean hasPropertyWithName(String name) {
for (AngularScopePropertyElement property : properties) {
if (property.getName().equals(name)) {
return true;
}
}
return false;
}