本文整理匯總了Java中org.eclipse.emf.ecore.EObject.eAllContents方法的典型用法代碼示例。如果您正苦於以下問題:Java EObject.eAllContents方法的具體用法?Java EObject.eAllContents怎麽用?Java EObject.eAllContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.EObject
的用法示例。
在下文中一共展示了EObject.eAllContents方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectReferencedTypeVars
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private static Set<TypeVariable> collectReferencedTypeVars(EObject obj, boolean includeChildren,
Set<TypeVariable> addHere) {
final Type declType = obj instanceof TypeRef ? ((TypeRef) obj).getDeclaredType() : null;
if (declType instanceof TypeVariable) {
addHere.add((TypeVariable) declType);
}
if (obj instanceof StructuralTypeRef) {
for (TStructMember m : ((StructuralTypeRef) obj).getStructuralMembers()) {
collectReferencedTypeVars(m, true, addHere);
}
}
if (includeChildren) {
final Iterator<EObject> iter = obj.eAllContents();
while (iter.hasNext()) {
collectReferencedTypeVars(iter.next(), false, addHere);
}
}
return addHere;
}
示例2: collectNodes
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
* Search entire containment tree below 'root' for objects of type 'cls'. If last argument is <code>false</code>,
* then sub trees below a matching node won't be searched.
*/
public static final <T extends EObject> List<T> collectNodes(EObject root, Class<T> cls,
boolean searchForNestedNodes) {
final List<T> result = new ArrayList<>();
final TreeIterator<EObject> iter = root.eAllContents();
while (iter.hasNext()) {
final EObject obj = iter.next();
if (cls.isAssignableFrom(obj.getClass())) {
@SuppressWarnings("unchecked")
final T objCasted = (T) obj;
result.add(objCasted);
if (!searchForNestedNodes)
iter.prune();
}
}
return result;
}
示例3: collectNodesWithinSameThisEnvironment
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
* root usually a function or other ThisProviding environment.
*
* @param root
* function or method.
* @param cls
* Type of element to report.
* @return nodes of (sub-)type cls in the same this-environment
*/
public static final <T extends EObject> List<T> collectNodesWithinSameThisEnvironment(EObject root, Class<T> cls) {
final List<T> result = new ArrayList<>();
final TreeIterator<EObject> iter = root.eAllContents();
while (iter.hasNext()) {
final EObject obj = iter.next();
if (cls.isAssignableFrom(obj.getClass())) {
@SuppressWarnings("unchecked")
final T objCasted = (T) obj;
result.add(objCasted);
}
// check for same environment
if (obj instanceof ThisArgProvider) {
iter.prune();
}
}
return result;
}
示例4: exposeTypesReferencedBy
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private static void exposeTypesReferencedBy(EObject root) {
final TreeIterator<EObject> i = root.eAllContents();
while (i.hasNext()) {
final EObject object = i.next();
for (EReference currRef : object.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer()) {
final Object currTarget = object.eGet(currRef);
if (currTarget instanceof Collection<?>) {
for (Object currObj : (Collection<?>) currTarget) {
exposeType(currObj);
}
} else {
exposeType(currTarget);
}
}
}
}
}
示例5: run
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
public boolean run ( final EObject element, final DiagnosticChain diagnostics, final Map<Object, Object> context )
{
if ( element == null )
{
return true;
}
boolean result = runElement ( element, diagnostics, context );
final TreeIterator<EObject> it = element.eAllContents ();
while ( it.hasNext () )
{
if ( !runElement ( it.next (), diagnostics, context ) )
{
result = false;
}
}
return result;
}
示例6: assertNoDanglingReferences
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
* Asserts that root and the entire object tree below root does not contain any dangling references, i.e.
* cross-references to target {@link EObject}s that are not contained in a {@link Resource}.
*/
public void assertNoDanglingReferences(EObject root) {
final List<String> errMsgs = new ArrayList<>();
final TreeIterator<EObject> iter = root.eAllContents();
while (iter.hasNext()) {
final EObject currObj = iter.next();
if (currObj != null && !currObj.eIsProxy()) {
for (EReference currRef : currObj.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer() && currRef.getEOpposite() == null) {
if (currRef.isMany()) {
@SuppressWarnings("unchecked")
final EList<? extends EObject> targets = (EList<? extends EObject>) currObj.eGet(currRef,
false);
for (EObject currTarget : targets) {
if (isDangling(currTarget)) {
errMsgs.add(getErrorInfoForDanglingEObject(currObj, currRef));
break;
}
}
} else {
final EObject target = (EObject) currObj.eGet(currRef, false);
if (isDangling(target))
errMsgs.add(getErrorInfoForDanglingEObject(currObj, currRef));
}
}
}
}
}
if (!errMsgs.isEmpty())
fail("Expected no dangling references, but found the following: " + Joiner.on("; ").join(errMsgs) + ".");
}
示例7: containsDeferredTypeRefs
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
* Tells if the given object contains a {@link DeferredTypeRef}.
*/
public static boolean containsDeferredTypeRefs(EObject object) {
final Iterator<EObject> i = object.eAllContents();
while (i.hasNext()) {
Object local = i.next();
if (local instanceof DeferredTypeRef) {
return true;
}
}
return false;
}
示例8: isOrContainsRefToTypeVar
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private static boolean isOrContainsRefToTypeVar(EObject obj, boolean checkForInfVars, TypeVariable... typeVars) {
if (obj == null)
return false;
if (isRefToTypeVar(obj, checkForInfVars, typeVars))
return true;
final Iterator<EObject> iter = obj.eAllContents();
while (iter.hasNext()) {
if (isRefToTypeVar(iter.next(), checkForInfVars, typeVars))
return true;
}
return false;
}
示例9: getAllContentsOfTypeStopAt
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private static <T> List<T> getAllContentsOfTypeStopAt(boolean findFirst, EObject eobj, final Class<T> filterType,
final EReference... stopReferences) {
if (eobj == null) {
return Collections.EMPTY_LIST;
}
List<EReference> stopReferencesL = Arrays.asList(stopReferences);
List<T> contentList = new LinkedList<>();
TreeIterator<EObject> tIter = eobj.eAllContents();
while (tIter.hasNext()) {
EObject eObj = tIter.next();
EReference eRef = eObj.eContainmentFeature();
if (stopReferencesL != null && stopReferencesL.contains(eRef)) {
tIter.prune();
} else {
if (filterType.isInstance(eObj)) {
contentList.add((T) eObj);
if (findFirst) {
return contentList;
}
}
}
}
return contentList;
}
示例10: getGeneratedElement
import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private static EObject getGeneratedElement(EObject generatedRoot, EObject existing) {
if (areEquivalent(generatedRoot, existing)) {
return generatedRoot;
}
for (Iterator<EObject> iterator = generatedRoot.eAllContents(); iterator.hasNext();) {
EObject generated = iterator.next();
if (areEquivalent(generated, existing)) {
return generated;
}
}
return null;
}