use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class STextGlobalScopeProvider method getScope.
public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
IScope parentScope = super.getScope(context, reference, filter);
parentScope = new SimpleScope(parentScope, filterPropertiesOfLibrary(context, reference, filter).getAllElements());
final Statechart statechart = getStatechart(context);
parentScope = new TypeSystemAwareScope(parentScope, typeSystem, qualifiedNameProvider, reference.getEReferenceType());
IScope result = new FilteringScope(parentScope, new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
String userData = input.getUserData(DomainRegistry.DOMAIN_ID);
if (userData == null)
return true;
return statechart.getDomainID().equals(userData);
}
});
result = filterAnnotations(reference, result);
return new FilteringScope(result, input -> {
String isVisible = input.getUserData(TypedResourceDescriptionStrategy.IS_VISIBLE_TYPE);
return isVisible == null || Boolean.valueOf(isVisible);
});
}
use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class STextGlobalScopeProvider method getScope.
/**
* Overidden to avoid scope nesting which is not required and slows down because
* of shadowing testing.
*/
@Override
protected IScope getScope(Resource resource, boolean ignoreCase, EClass type, Predicate<IEObjectDescription> filter) {
final LinkedHashSet<URI> uniqueImportURIs = getImportedUris(resource);
IResourceDescriptions descriptions = getResourceDescriptions(resource, uniqueImportURIs);
List<URI> urisAsList = Lists.newArrayList(uniqueImportURIs);
Collections.reverse(urisAsList);
List<IEObjectDescription> objectDescriptions = new ArrayList<IEObjectDescription>();
for (URI uri : urisAsList) {
IScope scope = createLazyResourceScope(IScope.NULLSCOPE, uri, descriptions, type, filter, ignoreCase);
Iterables.addAll(objectDescriptions, scope.getAllElements());
}
return MapBasedScope.createScope(IScope.NULLSCOPE, objectDescriptions);
}
use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class STextScopeProvider method scope_ElementReferenceExpression_reference.
public IScope scope_ElementReferenceExpression_reference(final EObject context, EReference reference) {
IScope namedScope = getNamedTopLevelScope(context, reference);
IScope unnamedScope = getUnnamedTopLevelScope(context, reference);
Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
unnamedScope = new FilteringScope(unnamedScope, predicate);
return new SimpleScope(unnamedScope, namedScope.getAllElements());
}
use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class STextScopeProvider method scope_FeatureCall_feature.
public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
Expression owner = context.getOwner();
EObject element = null;
if (owner instanceof ElementReferenceExpression) {
element = ((ElementReferenceExpression) owner).getReference();
} else if (owner instanceof FeatureCall) {
element = ((FeatureCall) owner).getFeature();
} else {
return getDelegate().getScope(context, reference);
}
IScope scope = IScope.NULLSCOPE;
InferenceResult result = typeInferrer.infer(owner);
Type ownerType = result != null ? result.getType() : null;
if (element instanceof Scope) {
scope = Scopes.scopeFor(((Scope) element).getDeclarations());
return new FilteringScope(scope, predicate);
} else if (ownerType != null) {
scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
}
if (ownerType instanceof ComplexType) {
return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
}
if (ownerType instanceof EnumerationType) {
return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
}
return scope;
}
use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class STextNamesAreUniqueValidationHelper method checkUniqueNames.
/**
* <p>
* {@inheritDoc}
* </p>
* The cancel indicator will be queried everytime a description has been
* processed. It should provide a fast answer about its canceled state.
*/
@Override
public void checkUniqueNames(Iterable<IEObjectDescription> descriptions, CancelIndicator cancelIndicator, ValidationMessageAcceptor acceptor) {
Iterator<IEObjectDescription> iter = descriptions.iterator();
this.nameMap = new HashMap<>();
this.caseInsensitiveMap = new HashMap<>();
this.lastElementMap = new HashMap<>();
if (!iter.hasNext())
return;
while (iter.hasNext()) {
IEObjectDescription description = iter.next();
checkDescriptionForDuplicatedName(description, acceptor);
operationCanceledManager.checkCanceled(cancelIndicator);
}
}
Aggregations