prop = propBuf.toString();
propBuf.setLength(0);
} else {
if(lastEnteredState == null) {
if(propDescr.has(Util.TYPE)) {
final ModelType type = propDescr.get(Util.TYPE).asType();
if(type.equals(ModelType.OBJECT)) {
return Collections.singletonList("{");
} else if(type.equals(ModelType.LIST)) {
return Collections.singletonList("[");
}
}
}
final List<String> mentionedProps = getMentionedProps(mentionedIndex);
if (mentionedProps == null || mentionedProps.isEmpty() || lastEnteredState.equals(ListItemSeparatorState.ID)) {
final List<String> candidates = new ArrayList<String>(propType.keys());
if (mentionedProps != null) {
candidates.removeAll(mentionedProps);
}
Collections.sort(candidates);
return candidates;
} else {
return Collections.emptyList();
}
}
}
if(TextState.ID.equals(lastEnteredState)) {
if(!propType.has(prop)) {
return Collections.emptyList();
}
propType = propType.get(prop);
final List<ModelNode> allowed;
if(!propType.has(Util.ALLOWED)) {
if(isBoolean(propType)) {
allowed = BOOLEAN_LIST;
} else {
return Collections.<String>emptyList();
}
} else {
allowed = propType.get(Util.ALLOWED).asList();
}
final List<String> candidates = new ArrayList<String>();
if(propBuf.length() > 0) {
final String value = propBuf.toString();
for (ModelNode candidate : allowed) {
final String candidateStr = candidate.asString();
if(candidateStr.startsWith(value)) {
candidates.add(candidateStr);
}
}
} else {
for (ModelNode candidate : allowed) {
candidates.add(candidate.asString());
}
}
Collections.sort(candidates);
return candidates;
}
final List<String> candidates;
if(EqualsState.ID.equals(lastEnteredState)) {
final List<ModelNode> allowed;
if(isBoolean(propType)) {
allowed = BOOLEAN_LIST;
} else {
if(!propType.has(prop)) {
return Collections.emptyList();
}
propType = propType.get(prop);
if(!propType.has(Util.ALLOWED)) {
if(propType.has(Util.VALUE_TYPE)) {
final ModelNode propValueType = propType.get(Util.VALUE_TYPE);
try {
propValueType.asType();
return Collections.emptyList();
} catch(IllegalArgumentException e) {
if(propType.has(Util.TYPE)) {
final ModelType type = propType.get(Util.TYPE).asType();
if(type.equals(ModelType.OBJECT)) {
return Collections.singletonList("{");
} else if(type.equals(ModelType.LIST)) {
return Collections.singletonList("[");
}
}
}
}