@Override protected TreeIterator<EObject> getAllLinkableContents(EObject model) { return EcoreUtil2.getAllNonDerivedContents(model, true); } }
private void initializeLocalTypes(JvmFeature feature, XExpression expression) { if (expression != null) { TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); String nameStub = "__" + feature.getDeclaringType().getSimpleName(); while(iterator.hasNext()) { EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub, feature); iterator.prune(); } } } }
/** * Collects all Xtend type declarations and adds them to the list. The types are added * from the innermost to the outermost type declaration. That is, nested classes are * added before their declarators are added. This greatly simplifies the implementation of * {@code isHandled} in the concrete {@link org.eclipse.xtext.xbase.typesystem.internal.AbstractRootedReentrantTypeResolver}. */ private void addXtendTypes(XtendTypeDeclaration declaration, List<EObject> result) { for(XtendMember member: declaration.getMembers()) { TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(member, true); while(iterator.hasNext()) { EObject next = iterator.next(); if (next instanceof XtendTypeDeclaration) { addXtendTypes((XtendTypeDeclaration) next, result); iterator.prune(); } } } result.add(declaration); }
/** Initialize the local class to the given expression. * * @param context the generation context. * @param feature the feature which contains the expression. * @param expression the expression which contains the local class. */ protected void initializeLocalTypes(GenerationContext context, JvmFeature feature, XExpression expression) { if (expression != null) { int localTypeIndex = context.getLocalTypeIndex(); final TreeIterator<EObject> iterator = EcoreUtil2.getAllNonDerivedContents(expression, true); final String nameStub = "__" + feature.getDeclaringType().getSimpleName() + "_"; //$NON-NLS-1$ //$NON-NLS-2$ while (iterator.hasNext()) { final EObject next = iterator.next(); if (next.eClass() == XtendPackage.Literals.ANONYMOUS_CLASS) { inferLocalClass((AnonymousClass) next, nameStub + localTypeIndex, feature); iterator.prune(); ++localTypeIndex; } } context.setLocalTypeIndex(localTypeIndex); } }