use of org.eclipse.n4js.scoping.utils.UnresolvableObjectDescription in project n4js by eclipse.
the class IsInScopeWithOptionalPositionPredicate method apply.
@Override
public boolean apply(String nameWithPosition) {
String name = getNameFromNameWithPosition(nameWithPosition);
String position = getPositionFromNameWithPosition(nameWithPosition);
QualifiedName qualifiedName = converter.toQualifiedName(name);
IEObjectDescription desc = scope.getSingleElement(qualifiedName);
if (desc != null && !(desc instanceof IEObjectDescriptionWithError) && !(desc instanceof UnresolvableObjectDescription)) {
if (!Strings.isNullOrEmpty(position)) {
String nameWithPositionOfScopeELement = descriptionToNameWithPosition(currentURI, withLineNumber, desc);
String positionOfScopeElement = getPositionFromNameWithPosition(nameWithPositionOfScopeELement);
if (position.equals(positionOfScopeElement)) {
return true;
}
} else {
return true;
}
}
return false;
}
use of org.eclipse.n4js.scoping.utils.UnresolvableObjectDescription in project n4js by eclipse.
the class ErrorAwareLinkingService method getLinkedObjects.
@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
final EClass requiredType = ref.getEReferenceType();
if (requiredType == null)
return Collections.<EObject>emptyList();
final String crossRefString = getCrossRefNodeAsString(context, ref, node);
if (crossRefString != null && !crossRefString.equals("")) {
final IScope scope = getScope(context, ref);
QualifiedName qualifiedLinkName = qualifiedNameConverter.toQualifiedName(crossRefString);
IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
if (IEObjectDescriptionWithError.isErrorDescription(eObjectDescription) && context.eResource() != null && !n4jsCore.isNoValidate(context.eResource().getURI())) {
addError(context, node, IEObjectDescriptionWithError.getDescriptionWithError(eObjectDescription));
} else if (eObjectDescription instanceof UnresolvableObjectDescription) {
return Collections.<EObject>singletonList((EObject) context.eGet(ref, false));
}
if (eObjectDescription != null) {
EObject candidate = eObjectDescription.getEObjectOrProxy();
if (!candidate.eIsProxy() && candidate.eResource() == null) {
// Error is necessary since EMF catches all exceptions in EcoreUtil#resolve
throw new AssertionError("Found an instance without resource and without URI");
}
// if supported, mark object description as used
if (eObjectDescription instanceof IUsageAwareEObjectDescription) {
((IUsageAwareEObjectDescription) eObjectDescription).markAsUsed();
}
return Collections.singletonList(candidate);
}
}
return Collections.emptyList();
}
Aggregations