*/
private void _link(ResourceBody o, PPImportedNamesAdapter importedNames, IMessageAcceptor acceptor,
boolean profileThis) {
ResourceExpression resource = (ResourceExpression) o.eContainer();
ClassifierAdapter adapter = ClassifierAdapterFactory.eINSTANCE.adapt(resource);
if(adapter.getClassifier() == ClassifierAdapter.UNKNOWN) {
classifier.classify(resource);
adapter = ClassifierAdapterFactory.eINSTANCE.adapt(resource);
}
CLASSPARAMS: if(adapter.getClassifier() == RESOURCE_IS_CLASSPARAMS) {
// pp: class { classname : parameter => value ... }
final String className = stringConstantEvaluator.doToString(o.getNameExpr());
if(className == null) {
if(canBeAClassReference(o.getNameExpr())) {
acceptor.acceptWarning(
"Can not determine until runtime if this is a valid class reference (parameters not validated).", //
o, // Flag entire body
// PPPackage.Literals.RESOURCE_BODY__NAME_EXPR, //
IPPDiagnostics.ISSUE__RESOURCE_UNKNOWN_TYPE);
}
else {
acceptor.acceptError(
"Not a valid class reference", o, PPPackage.Literals.RESOURCE_BODY__NAME_EXPR,
IPPDiagnostics.ISSUE__NOT_CLASSREF);
}
CrossReferenceAdapter.clear(o.getNameExpr());
break CLASSPARAMS;
}
SearchResult searchResult = ppFinder.findHostClasses(o, className, importedNames);
List<IEObjectDescription> descs = searchResult.getAdjusted();
if(descs.size() < 1) {
if(searchResult.getRaw().size() > 0) {
// Sort of ok
importedNames.addResolved(searchResult.getRaw());
CrossReferenceAdapter.set(o.getNameExpr(), searchResult.getRaw());
acceptor.acceptWarning(
"Found outside current search path (parameters not validated): '" + className + "'", o,
PPPackage.Literals.RESOURCE_BODY__NAME_EXPR, IPPDiagnostics.ISSUE__NOT_ON_PATH);
return; // skip validating parameters
}
// Add unresolved info at resource level
addUnresolved(
importedNames, converter.toQualifiedName(className),
NodeModelUtils.findActualNodeFor(o.getNameExpr()));
// importedNames.addUnresolved(converter.toQualifiedName(className));
CrossReferenceAdapter.clear(o.getNameExpr());
String[] proposals = proposer.computeProposals(
className, ppFinder.getExportedDescriptions(), searchPath, CLASS_AND_TYPE);
acceptor.acceptError(
"Unknown class: '" + className + "'", o, //
PPPackage.Literals.RESOURCE_BODY__NAME_EXPR,
proposalIssue(IPPDiagnostics.ISSUE__RESOURCE_UNKNOWN_TYPE, proposals), //
proposals);
return; // not meaningful to continue (do not report errors for each "inner name")
}
if(descs.size() > 0) {
descs = Lists.newArrayList(Sets.newHashSet(descs));
// Report resolution at resource level
importedNames.addResolved(descs);
CrossReferenceAdapter.set(o.getNameExpr(), descs);
if(descs.size() > 1) {
// this is an ambiguous link - multiple targets available and order depends on the
// order at runtime (may not be the same). ISSUE: o can be a ResourceBody
importedNames.addAmbiguous(descs);
acceptor.acceptWarning(
"Ambiguous reference to: '" + className + "' found in: " +
visibleResourceList(o.eResource(), descs), o,
PPPackage.Literals.RESOURCE_BODY__NAME_EXPR,
IPPDiagnostics.ISSUE__RESOURCE_AMBIGUOUS_REFERENCE,
proposer.computeDistinctProposals(className, descs));
}
// use the first description found to find attributes
internalLinkAttributeOperations(o.getAttributes(), descs.get(0), importedNames, acceptor);
}
}
else if(adapter.getClassifier() != RESOURCE_IS_OVERRIDE || resource.getResourceExpr() instanceof AtExpression) {
// normal resource or override file{} or File[x] { }
IEObjectDescription desc = (IEObjectDescription) adapter.getTargetObjectDescription();
// do not flag undefined parameters as errors if type is unknown
if(desc != null) {
internalLinkAttributeOperations(o.getAttributes(), desc, importedNames, acceptor);
}
}