PPPackage.Literals.LITERAL_NAME_OR_REFERENCE__VALUE, //
IPPDiagnostics.ISSUE__REQUIRED_EXPRESSION);
return;
}
Expression param = statements.get(idx);
List<Expression> parameterList = null;
if(param instanceof ExprList)
parameterList = ((ExprList) param).getExpressions();
else
parameterList = Lists.newArrayList(param);
int parameterIndex = -1;
for(Expression pe : parameterList) {
parameterIndex++;
final String className = stringConstantEvaluator.doToString(pe);
if(className != null) {
SearchResult searchResult = ppFinder.findHostClasses(s, className, importedNames);
List<IEObjectDescription> foundClasses = searchResult.getAdjusted(); // findHostClasses(o, className, importedNames);
if(foundClasses.size() > 1) {
// ambiguous
importedNames.addAmbiguous(foundClasses);
if(param instanceof ExprList)
acceptor.acceptWarning(
"Ambiguous reference to: '" + className + "' found in: " +
visibleResourceList(s.eResource(), foundClasses), //
param, //
PPPackage.Literals.EXPR_LIST__EXPRESSIONS,
parameterIndex, //
IPPDiagnostics.ISSUE__RESOURCE_AMBIGUOUS_REFERENCE,
proposer.computeDistinctProposals(className, foundClasses));
else
acceptor.acceptWarning(
"Ambiguous reference to: '" + className + "' found in: " +
visibleResourceList(s.eResource(), foundClasses), //
param.eContainer(), param.eContainingFeature(),
idx, //
IPPDiagnostics.ISSUE__RESOURCE_AMBIGUOUS_REFERENCE,
proposer.computeDistinctProposals(className, foundClasses));
}
else if(foundClasses.size() < 1) {
if(searchResult.getRaw().size() > 0) {
// sort of ok
importedNames.addResolved(searchResult.getRaw());
CrossReferenceAdapter.set(pe, searchResult.getRaw());
if(param instanceof ExprList)
acceptor.acceptWarning(
"Found outside current search path: '" + className + "'", param,
PPPackage.Literals.EXPR_LIST__EXPRESSIONS, parameterIndex,
IPPDiagnostics.ISSUE__NOT_ON_PATH);
else
acceptor.acceptWarning("Found outside current search path: '" + className + "'", //
param.eContainer(), param.eContainingFeature(), idx, // IPPDiagnostics.ISSUE__NOT_ON_PATH);
IPPDiagnostics.ISSUE__NOT_ON_PATH);
}
else {
// not found
// record unresolved name at resource level
addUnresolved(importedNames, className, NodeModelUtils.findActualNodeFor(pe));
// importedNames.addUnresolved(converter.toQualifiedName(className));
CrossReferenceAdapter.clear(pe);
String[] proposals = proposer.computeProposals(
className, ppFinder.getExportedDescriptions(), searchPath, CLASS_AND_TYPE);
String issueCode = proposalIssue(IPPDiagnostics.ISSUE__RESOURCE_UNKNOWN_TYPE, proposals);
if(param instanceof ExprList) {
acceptor.acceptError("Unknown class: '" + className + "'", //
param, //
PPPackage.Literals.EXPR_LIST__EXPRESSIONS, parameterIndex, //
issueCode, //
proposals);
}
else {
acceptor.acceptError("Unknown class: '" + className + "'", //
param.eContainer(), param.eContainingFeature(), idx, //
issueCode, //
proposals);
}
}
}
else {
// found
importedNames.addResolved(foundClasses);
CrossReferenceAdapter.set(pe, foundClasses);
}
}
else {
CrossReferenceAdapter.clear(pe);
// warning or error depending on if this is a reasonable class reference expr or not
String msg = null;
boolean error = false;
if(canBeAClassReference(pe)) {
msg = "Can not determine until runtime if this is a valid class reference";
}
else {
msg = "Not an acceptable parameter. Function '" + name + "' requires a class reference.";
error = true;
}
if(param instanceof ExprList)
acceptor.accept(error
? Severity.ERROR
: Severity.WARNING, msg, //
param, //
PPPackage.Literals.EXPR_LIST__EXPRESSIONS, parameterIndex, //
IPPDiagnostics.ISSUE__RESOURCE_UNKNOWN_TYPE);
else
acceptor.accept(error
? Severity.ERROR
: Severity.WARNING, msg, //
param.eContainer(), param.eContainingFeature(), idx, //
IPPDiagnostics.ISSUE__RESOURCE_UNKNOWN_TYPE);
}
}
}
}