use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.
the class XbaseReferenceProposalCreator method queryScope.
@Override
public Iterable<IEObjectDescription> queryScope(IScope scope, EObject model, EReference reference, Predicate<IEObjectDescription> filter) {
if (reference == XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE) {
MultiNameDescriptions.Kind kind;
if (isShowAllProposals()) {
kind = MultiNameDescriptions.Kind.All;
} else if (isShowShortestSugar()) {
kind = MultiNameDescriptions.Kind.Shortest;
} else if (isShowSmartProposals()) {
kind = MultiNameDescriptions.Kind.Smart;
} else if (isShowJavaLikeProposals()) {
kind = MultiNameDescriptions.Kind.Java;
} else {
kind = MultiNameDescriptions.Kind.All;
}
MultiNameDescriptions proposals = new MultiNameDescriptions(kind, nameConverter);
Iterable<IEObjectDescription> allDescriptions = super.queryScope(scope, model, reference, filter);
for (IEObjectDescription description : allDescriptions) {
if (filter.apply(description)) {
proposals.apply(description);
}
}
return proposals.getResult();
}
return super.queryScope(scope, model, reference, filter);
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.
the class XbaseWithAnnotationsProposalProvider method completeXAnnotationElementValuePair_Element.
@Override
public void completeXAnnotationElementValuePair_Element(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
XAnnotation annotationReference = null;
if (model instanceof XAnnotationElementValuePair) {
annotationReference = (XAnnotation) model.eContainer();
} else if (model instanceof XAnnotation) {
annotationReference = (XAnnotation) model;
}
if (annotationReference != null) {
JvmType annotationType = annotationReference.getAnnotationType();
if (annotationType != null && !annotationType.eIsProxy() && annotationType instanceof JvmAnnotationType) {
// do not propose features like #toString, #hashCode etc
JvmAnnotationType casted = (JvmAnnotationType) annotationType;
final Set<JvmOperation> operations = Sets.newHashSet(casted.getDeclaredOperations());
Predicate<IEObjectDescription> predicate = Predicates.and(new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription in) {
return operations.contains(in.getEObjectOrProxy());
}
}, getFeatureDescriptionPredicate(context));
lookupCrossReference(((CrossReference) assignment.getTerminal()), context, acceptor, predicate);
}
}
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.
the class XtextCallHierarchyBuilder method findDeclaration.
@Override
protected IEObjectDescription findDeclaration(final URI objectURI) {
final IEObjectDescription description = this.getDescription(objectURI);
EClass _eClass = null;
if (description != null) {
_eClass = description.getEClass();
}
boolean _isRule = this.isRule(_eClass);
if (_isRule) {
return description;
}
final IUnitOfWork<IEObjectDescription, EObject> _function = (EObject object) -> {
return this.getDescription(EcoreUtil2.<AbstractRule>getContainerOfType(object, AbstractRule.class));
};
return this.<IEObjectDescription>readOnly(objectURI, _function);
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.
the class XtextCallHierarchyLabelProvider method _getStyledText.
protected StyledString _getStyledText(final XtextCallHierarchyNode it) {
IEObjectDescription _element = it.getElement();
boolean _tripleEquals = (_element == null);
if (_tripleEquals) {
return this.hierarchyLabelProvider.getStyledText(it);
}
QualifiedName _qualifiedName = it.getElement().getQualifiedName();
String _plus = ("" + _qualifiedName);
final StyledString styledString = new StyledString(_plus);
IEObjectDescription _grammarDescription = it.getGrammarDescription();
boolean _tripleEquals_1 = (_grammarDescription == null);
if (_tripleEquals_1) {
return styledString;
}
QualifiedName _qualifiedName_1 = it.getGrammarDescription().getQualifiedName();
String _plus_1 = (" - " + _qualifiedName_1);
StyledString _styledString = new StyledString(_plus_1, StyledString.QUALIFIER_STYLER);
return styledString.append(_styledString);
}
use of org.eclipse.xtext.resource.IEObjectDescription in project xtext-eclipse by eclipse.
the class XtextCallHierarchyBuilderTest method internalToExpectation.
@Override
protected String internalToExpectation(final IHierarchyNode node, final IHierarchyBuilder builder) {
final String superExpectation = super.internalToExpectation(node, builder);
if ((node instanceof XtextCallHierarchyNode)) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar: ");
IEObjectDescription _grammarDescription = ((XtextCallHierarchyNode) node).getGrammarDescription();
_builder.append(_grammarDescription);
_builder.newLineIfNotEmpty();
_builder.append(superExpectation);
_builder.newLineIfNotEmpty();
return _builder.toString();
}
return superExpectation;
}
Aggregations