Search in sources :

Example 21 with EPackage

use of org.eclipse.emf.ecore.EPackage in project n4js by eclipse.

the class EcoreUtilN4Test method testGetAllContentsFilteredIgnoreRootPredicate.

@SuppressWarnings("javadoc")
@Test
public void testGetAllContentsFilteredIgnoreRootPredicate() {
    EPackage root = epack("filteredRoot", // 
    ecl("A"), // 
    ecl("B"), // 
    edt("C"), // 
    epack("notfiltered", ecl("Sub1A"), edt("Sub1C")), // 
    ecl("D"), epack("filtered", ecl("Sub2A"), ecl("Sub2B"), edt("Sub2C")), ecl("E"), edt("F"));
    Iterator<EObject> iter = EcoreUtilN4.getAllContentsFiltered(root, new Predicate<EObject>() {

        @Override
        public boolean apply(EObject input) {
            return !((ENamedElement) input).getName().startsWith("filtered");
        }
    });
    assertEqualsByNames("A,B,C,D,E,F,notfiltered,Sub1A,Sub1C", iter);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) EPackage(org.eclipse.emf.ecore.EPackage) Test(org.junit.Test)

Example 22 with EPackage

use of org.eclipse.emf.ecore.EPackage in project n4js by eclipse.

the class EcoreUtilN4Test method testGetAllContentsFilteredNoMatch.

@SuppressWarnings("javadoc")
@Test
public void testGetAllContentsFilteredNoMatch() {
    EPackage root = epack("root", // 
    epack("filteredSub1", ecl("Sub1A"), edt("Sub1C")), epack("filteredSub2", ecl("Sub2A"), ecl("Sub2B"), edt("Sub2C")));
    Iterator<EObject> iter = EcoreUtilN4.getAllContentsFiltered(root, new Predicate<EObject>() {

        @Override
        public boolean apply(EObject input) {
            return !((ENamedElement) input).getName().startsWith("filtered");
        }
    });
    assertEqualsByNames("", iter);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) EPackage(org.eclipse.emf.ecore.EPackage) Test(org.junit.Test)

Example 23 with EPackage

use of org.eclipse.emf.ecore.EPackage in project n4js by eclipse.

the class EcoreUtilN4Test method testGetAllContentsFilteredEmpty.

@SuppressWarnings("javadoc")
@Test
public void testGetAllContentsFilteredEmpty() {
    EPackage root = epack("root");
    Iterator<EObject> iter = EcoreUtilN4.getAllContentsFiltered(root, new Predicate<EObject>() {

        @Override
        public boolean apply(EObject input) {
            return !((ENamedElement) input).getName().startsWith("filtered");
        }
    });
    assertEqualsByNames("", iter);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) EPackage(org.eclipse.emf.ecore.EPackage) Test(org.junit.Test)

Example 24 with EPackage

use of org.eclipse.emf.ecore.EPackage in project n4js by eclipse.

the class EcoreUtilN4Test method epack.

private EPackage epack(String n, EObject... contents) {
    EPackage p = EcoreFactory.eINSTANCE.createEPackage();
    p.setName(n);
    for (EObject eobj : contents) {
        if (eobj instanceof EPackage) {
            p.getESubpackages().add((EPackage) eobj);
        } else {
            p.getEClassifiers().add((EClassifier) eobj);
        }
    }
    return p;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) EPackage(org.eclipse.emf.ecore.EPackage)

Example 25 with EPackage

use of org.eclipse.emf.ecore.EPackage in project dsl-devkit by dsldevkit.

the class CheckProposalProvider method completeContextVariable_Type.

/**
 * {@inheritDoc}
 */
@Override
public // CHECKSTYLE:OFF
void completeContextVariable_Type(final EObject model, final Assignment assignment, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    // CHECKSTYLE:ON
    completeJavaTypes(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, true, qualifiedNameValueConverter, new Filter() {

        // @Format-Off
        private final Set<String> resourceEClassNames = model.eResource().getResourceSet().getResources().stream().map(resource -> resource.getContents()).flatMap(List::stream).filter(obj -> obj instanceof EPackage).map(obj -> ((EPackage) obj).getEClassifiers()).flatMap(List::stream).map(eClass -> eClass.getEPackage().getName() + '.' + eClass.getName()).collect(Collectors.toSet());

        // @Format-On
        @Override
        public int getSearchFor() {
            return IJavaSearchConstants.INTERFACE;
        }

        @Override
        public boolean accept(final int modifiers, final char[] packageName, final char[] simpleTypeName, final char[][] enclosingTypeNames, final String path) {
            String fullPackageName = new String(packageName);
            String simpleClassName = new String(simpleTypeName);
            String ePackageName = fullPackageName.substring(fullPackageName.lastIndexOf('.') + 1);
            return REGISTERED_ECLASS_NAMES.contains(fullPackageName + '.' + simpleClassName) || resourceEClassNames.contains(ePackageName + '.' + simpleClassName);
        }
    }, acceptor);
    shortCircuit();
}
Also used : CheckImages(com.avaloq.tools.ddk.check.ui.labeling.CheckImages) Inject(com.google.inject.Inject) CheckResourceUtil(com.avaloq.tools.ddk.check.ui.util.CheckResourceUtil) XbaseQualifiedNameValueConverter(org.eclipse.xtext.xbase.conversion.XbaseQualifiedNameValueConverter) TypesPackage(org.eclipse.xtext.common.types.TypesPackage) ContentAssistContext(org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext) TerminalsProposalProvider(org.eclipse.xtext.common.ui.contentassist.TerminalsProposalProvider) IJavaSearchConstants(org.eclipse.jdt.core.search.IJavaSearchConstants) ICompletionProposalAcceptor(org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor) Assignment(org.eclipse.xtext.Assignment) ImmutableSet(com.google.common.collect.ImmutableSet) NLS(org.eclipse.osgi.util.NLS) Strings(org.eclipse.xtext.util.Strings) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) EPackage(org.eclipse.emf.ecore.EPackage) RuleCall(org.eclipse.xtext.RuleCall) Objects(java.util.Objects) Keyword(org.eclipse.xtext.Keyword) CheckPackage(com.avaloq.tools.ddk.check.check.CheckPackage) List(java.util.List) Stream(java.util.stream.Stream) Filter(org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider.Filter) CheckConstants(com.avaloq.tools.ddk.check.CheckConstants) GrammarUtil(org.eclipse.xtext.GrammarUtil) ConcurrentModificationException(java.util.ConcurrentModificationException) Filter(org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider.Filter) List(java.util.List) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

EPackage (org.eclipse.emf.ecore.EPackage)424 ParserRule (org.eclipse.xtext.ParserRule)201 Action (org.eclipse.xtext.Action)196 Parameter (org.eclipse.xtext.Parameter)196 Test (org.junit.Test)101 EClass (org.eclipse.emf.ecore.EClass)85 Resource (org.eclipse.emf.ecore.resource.Resource)50 EObject (org.eclipse.emf.ecore.EObject)39 EClassifier (org.eclipse.emf.ecore.EClassifier)32 URI (org.eclipse.emf.common.util.URI)30 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)23 Grammar (org.eclipse.xtext.Grammar)22 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)16 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)15 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)14 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)14 XtextResource (org.eclipse.xtext.resource.XtextResource)14 EEnum (org.eclipse.emf.ecore.EEnum)13 EReference (org.eclipse.emf.ecore.EReference)12 IOException (java.io.IOException)11