Search in sources :

Example 11 with IEObjectDescription

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);
}
Also used : IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 12 with IEObjectDescription

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);
        }
    }
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XAnnotationElementValuePair(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationElementValuePair) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) CrossReference(org.eclipse.xtext.CrossReference) JvmType(org.eclipse.xtext.common.types.JvmType) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 13 with IEObjectDescription

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);
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EObject(org.eclipse.emf.ecore.EObject) AbstractRule(org.eclipse.xtext.AbstractRule) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 14 with IEObjectDescription

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);
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 15 with IEObjectDescription

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;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextCallHierarchyNode(org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyNode) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)324 Test (org.junit.Test)95 EObject (org.eclipse.emf.ecore.EObject)82 QualifiedName (org.eclipse.xtext.naming.QualifiedName)79 IScope (org.eclipse.xtext.scoping.IScope)56 URI (org.eclipse.emf.common.util.URI)41 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)33 EClass (org.eclipse.emf.ecore.EClass)30 Resource (org.eclipse.emf.ecore.resource.Resource)28 EObjectDescription (org.eclipse.xtext.resource.EObjectDescription)22 AliasedEObjectDescription (org.eclipse.xtext.resource.impl.AliasedEObjectDescription)22 ArrayList (java.util.ArrayList)19 IResourceDescriptions (org.eclipse.xtext.resource.IResourceDescriptions)14 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)12 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)12 StyledString (org.eclipse.jface.viewers.StyledString)12 XtextResource (org.eclipse.xtext.resource.XtextResource)11 StringInputStream (org.eclipse.xtext.util.StringInputStream)11 EReference (org.eclipse.emf.ecore.EReference)10 List (java.util.List)9