if (proposals.length == expectedProposals.length) {
for (ExpectedProposal expectedProposal : pdttFile
.getExpectedProposals()) {
boolean found = false;
for (CompletionProposal proposal : proposals) {
IModelElement modelElement = proposal.getModelElement();
if (modelElement == null) {
if (new String(proposal.getName())
.equalsIgnoreCase(expectedProposal.name)) { // keyword
found = true;
break;
}
} else if (modelElement.getElementType() == expectedProposal.type) {
if (modelElement instanceof AliasType) {
if (((AliasType) modelElement).getAlias().equals(
expectedProposal.name)) {
found = true;
break;
}
} else if ((modelElement instanceof FakeConstructor)
&& (modelElement.getParent() instanceof AliasType)) {
if (((AliasType) modelElement.getParent())
.getAlias().equals(expectedProposal.name)) {
found = true;
break;
}
} else {
if (modelElement.getElementName().equalsIgnoreCase(
expectedProposal.name)) {
found = true;
break;
}
}
} else if (modelElement.getElementType() == expectedProposal.type
&& new String(proposal.getName())
.equalsIgnoreCase(expectedProposal.name)) {
// for phar include
found = true;
break;
}
}
if (!found) {
proposalsEqual = false;
break;
}
}
} else {
proposalsEqual = false;
}
if (!proposalsEqual) {
StringBuilder errorBuf = new StringBuilder();
errorBuf.append("\nEXPECTED COMPLETIONS LIST:\n-----------------------------\n");
errorBuf.append(pdttFile.getExpected());
errorBuf.append("\nACTUAL COMPLETIONS LIST:\n-----------------------------\n");
for (CompletionProposal p : proposals) {
IModelElement modelElement = p.getModelElement();
if (modelElement == null
|| modelElement.getElementName() == null) {
errorBuf.append("keyword(").append(p.getName())
.append(")\n");
} else {
switch (modelElement.getElementType()) {
case IModelElement.FIELD:
errorBuf.append("field");
break;
case IModelElement.METHOD:
errorBuf.append("method");
break;
case IModelElement.TYPE:
errorBuf.append("type");
break;
}
if (modelElement instanceof AliasType) {
errorBuf.append('(')
.append(((AliasType) modelElement).getAlias())
.append(")\n");
} else {
errorBuf.append('(')
.append(modelElement.getElementName())
.append(")\n");
}
}
}
fail(errorBuf.toString());