use of org.eclipse.n4js.xtext.scoping.IEObjectDescriptionWithError in project n4js by eclipse.
the class IntersectionMemberScope method getCheckedDescription.
@Override
protected IEObjectDescription getCheckedDescription(String name, TMember member) {
IEObjectDescription description = EObjectDescription.create(member.getName(), member);
QualifiedName qn = QualifiedName.create(name);
boolean allDescrWithError = true;
for (IScope currSubScope : subScopes) {
IEObjectDescription subDescription = currSubScope.getSingleElement(qn);
boolean descrWithError = subDescription == null || subDescription instanceof IEObjectDescriptionWithError;
allDescrWithError &= descrWithError;
}
if (allDescrWithError) {
return createComposedMemberDescriptionWithErrors(description);
}
return description;
}
use of org.eclipse.n4js.xtext.scoping.IEObjectDescriptionWithError in project n4js by eclipse.
the class UnionMemberScope method getCheckedDescription.
@Override
protected IEObjectDescription getCheckedDescription(String name, TMember member) {
IEObjectDescription description = EObjectDescription.create(member.getName(), member);
QualifiedName qn = QualifiedName.create(name);
for (IScope currSubScope : subScopes) {
IEObjectDescription subDescription = currSubScope.getSingleElement(qn);
boolean descrWithError = subDescription == null || subDescription instanceof IEObjectDescriptionWithError;
if (descrWithError) {
return createComposedMemberDescriptionWithErrors(description);
}
}
return description;
}
use of org.eclipse.n4js.xtext.scoping.IEObjectDescriptionWithError 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.xtext.scoping.IEObjectDescriptionWithError in project n4js by eclipse.
the class ComposedMemberDescriptionWithError method initialize.
private boolean initialize() {
if (message == null) {
IEObjectDescription[] descriptions = new IEObjectDescription[subScopes.length];
// use string here, since EnumLiteral is
MapOfIndexes<String> indexesPerMemberType = new MapOfIndexes<>();
// not a TMember!
MapOfIndexes<String> indexesPerCode = new MapOfIndexes<>();
List<String> missingFrom = new ArrayList<>();
final QualifiedName name = getName();
boolean readOnlyField = false;
for (int i = 0; i < max; i++) {
IEObjectDescription description = subScopes[i].getSingleElement(name);
if (description != null) {
descriptions[i] = description;
EObject eobj = description.getEObjectOrProxy();
String type = getMemberTypeName(eobj);
indexesPerMemberType.add(type, i);
if (description instanceof IEObjectDescriptionWithError) {
String subCode = ((IEObjectDescriptionWithError) description).getIssueCode();
indexesPerCode.add(subCode, i);
}
if ("field".equals(type)) {
readOnlyField |= !((TField) eobj).isWriteable();
}
} else {
missingFrom.add(getNameForSubScope(i));
}
}
return initMessageAndCode(missingFrom, indexesPerMemberType, name, readOnlyField, descriptions, indexesPerCode);
}
return false;
}
use of org.eclipse.n4js.xtext.scoping.IEObjectDescriptionWithError in project n4js by eclipse.
the class ComposedMemberScope method getAllLocalElements.
/**
* Returns all elements of union. No erroneous descriptions (instances of IEObjectDescriptionWithError) will be
* considered here, as we assume this method to be called from content assist and we do not want to show wrong
* elements. These descriptions will be returned by {@link #getSingleElement(QualifiedName)} though to show errors
* in case of explicit references to these members.
*/
@Override
protected Iterable<IEObjectDescription> getAllLocalElements() {
// collect all names from subScopes
final Set<String> names = new HashSet<>();
for (IScope currSubScope : subScopes) {
try {
for (IEObjectDescription currDesc : currSubScope.getAllElements()) {
// omit erroneous bindings (they will be provided in getSingleLocalElement... though)
if (!(currDesc instanceof IEObjectDescriptionWithError)) {
String name = currDesc.getName().getLastSegment();
names.add(name);
}
}
} catch (UnsupportedOperationException e) {
// according to API doc of IScope#getAllElements(), scopes are free to throw an
// UnsupportedOperationException --> therefore we catch and ignore this here
}
}
List<IEObjectDescription> descriptions = new ArrayList<>(names.size());
for (String name : names) {
IEObjectDescription description = getSingleLocalElementByName(QualifiedName.create(name));
if (description != null && !(description instanceof IEObjectDescriptionWithError)) {
descriptions.add(description);
}
}
return descriptions;
}
Aggregations