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);
}
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);
}
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);
}
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;
}
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();
}
Aggregations