当前位置: 首页>>代码示例>>Java>>正文


Java EcoreUtil2.isAssignableFrom方法代码示例

本文整理汇总了Java中org.eclipse.xtext.EcoreUtil2.isAssignableFrom方法的典型用法代码示例。如果您正苦于以下问题:Java EcoreUtil2.isAssignableFrom方法的具体用法?Java EcoreUtil2.isAssignableFrom怎么用?Java EcoreUtil2.isAssignableFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.EcoreUtil2的用法示例。


在下文中一共展示了EcoreUtil2.isAssignableFrom方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTypeName

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
/**
 * @Nullable
 */
protected String getTypeName(final EClass c, final EStructuralFeature referingFeature) {
  if ((referingFeature == XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE)) {
    return " to an annotation type";
  }
  if ((c == TypesPackage.Literals.JVM_ENUMERATION_TYPE)) {
    return " to an enum type";
  }
  boolean _isAssignableFrom = EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, c);
  if (_isAssignableFrom) {
    return " to a type";
  }
  if ((c == TypesPackage.Literals.JVM_OPERATION)) {
    return " to an operation";
  }
  return "";
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:UnresolvedFeatureCallTypeAwareMessageProvider.java

示例2: computeReferencedJvmTypeHighlighting

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected void computeReferencedJvmTypeHighlighting(IHighlightedPositionAcceptor acceptor, EObject referencer,
		CancelIndicator cancelIndicator) {
	for (EReference reference : referencer.eClass().getEAllReferences()) {
		EClass referencedType = reference.getEReferenceType();
		if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referencedType)) {
			List<EObject> referencedObjects = EcoreUtil2.getAllReferencedObjects(referencer, reference);
			if (referencedObjects.size() > 0)
				operationCanceledManager.checkCanceled(cancelIndicator);
			for (EObject referencedObject : referencedObjects) {
				EObject resolvedReferencedObject = EcoreUtil.resolve(referencedObject, referencer);
				if (resolvedReferencedObject != null && !resolvedReferencedObject.eIsProxy()) {
					highlightReferenceJvmType(acceptor, referencer, reference, resolvedReferencedObject);
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseHighlightingCalculator.java

示例3: findCrossReferences

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
public List<CrossReference> findCrossReferences(EClassifier... targetEClassifiers) {
	Set<EClassifier> classifiers = new HashSet<EClassifier>(Arrays.asList(targetEClassifiers));
	Collection<EClass> classes = Lists.newArrayList(Iterables.filter(classifiers, EClass.class));
	ArrayList<CrossReference> r = new ArrayList<CrossReference>();
	for (AbstractRule ar : getRules()) {
		TreeIterator<EObject> i = ar.eAllContents();
		while (i.hasNext()) {
			EObject o = i.next();
			if (o instanceof CrossReference) {
				CrossReference c = (CrossReference) o;
				if (classifiers.contains(c.getType().getClassifier()))
					r.add(c);
				else if (c.getType().getClassifier() instanceof EClass)
					for (EClass cls : classes)
						if (EcoreUtil2.isAssignableFrom(cls,(EClass) c.getType().getClassifier())) {
							r.add(c);
							break;
						}
				i.prune();
			}
		}
	}
	return r;

}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:26,代码来源:AbstractElementFinder.java

示例4: isEReferenceTypeApplicable

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
/**
 * @param eReferenceType
 *            the type of the reference that is inspected.
 * @return <code>true</code> if this set contains a subtype of the given eReferenceType.
 */
public boolean isEReferenceTypeApplicable(EClass eReferenceType) {
	if (applicableTypes.isEmpty())
		return true;
	for (EClass applicableType : applicableTypes) {
		if (EcoreUtil2.isAssignableFrom(eReferenceType, applicableType)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:TargetURIKey.java

示例5: getScope

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
@Override
public IScope getScope(Resource resource, EReference reference, Predicate<IEObjectDescription> filter) {
	EClass referenceType = getEReferenceType(resource, reference);
	if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) {
		return typeScopeProvider.getScope(resource, reference, filter);
	}
	if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_CONSTRUCTOR, referenceType)) {
		return typeScopeProvider.getScope(resource, reference, filter);
	}
	return super.getScope(resource, reference, filter);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:TypesAwareDefaultGlobalScopeProvider.java

示例6: findValidAssignmentsForCrossRef

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected Set<AbstractElement> findValidAssignmentsForCrossRef(EObject semanticObj,
		Iterable<AbstractElement> assignedElements, EObject value, INode node) {
	Set<AbstractElement> result = Sets.newLinkedHashSet();
	for (AbstractElement ass : assignedElements) {
		CrossReference crossref = GrammarUtil.containingCrossReference(ass);
		EReference eref = GrammarUtil.getReference(crossref, semanticObj.eClass());
		if (EcoreUtil2.isAssignableFrom(eref.getEReferenceType(), value.eClass())
				&& crossRefSerializer.isValid(semanticObj, crossref, value, node, null))
			result.add(ass);
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:AssignmentFinder.java

示例7: isInstantiatableSubType

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
private boolean isInstantiatableSubType(EClass c, EClass superType) {
	return !c.isAbstract() && !c.isInterface() && EcoreUtil2.isAssignableFrom(superType, c);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:4,代码来源:N4JSLinker.java

示例8: resolve

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
private IEObjectDescription resolve(IEObjectDescription original) {
	if (original != null && original.getEObjectOrProxy().eIsProxy()
			&& EcoreUtil2.isAssignableFrom(type, original.getEClass())) {
		final URI objectURI = original.getEObjectURI();
		final URI resourceURI = objectURI.trimFragment();
		Resource resource = resourceSet.getResource(resourceURI, false);
		if (resource != null && resource.isLoaded()) {
			return original;
		}
		final boolean mustLoadFromSource = canLoadFromDescriptionHelper.mustLoadFromSource(resourceURI,
				resourceSet);
		resource = resourceSet.getResource(resourceURI, mustLoadFromSource);
		if (resource != null && resource.isLoaded()) {
			return original;
		}
		if (mustLoadFromSource) {
			// error case: forced loading failed
			// --> still avoid loading from index; instead simply return 'original' as in other error cases
			return original;
		}
		if (resource == null) {
			resource = resourceSet.createResource(resourceURI);
		}
		if (resource instanceof N4JSResource) {
			if (resource.getContents().isEmpty()) {
				N4JSResource casted = (N4JSResource) resource;
				IResourceDescription resourceDescription = container.getResourceDescription(resourceURI);
				if (resourceDescription != null) {
					if (casted.isLoaded()) {
						// LiveShadowingResourceDescriptions (part of Xtext's rename refactoring)
						// will load that stuff on #getResourceDescription
						return original;
					}
					try {
						if (!casted.loadFromDescription(resourceDescription)) {
							return original;
						}
					} catch (Exception e) {
						casted.unload();
						return original;
					}
				} else {
					return original;
				}
			}
			// resolveProxy is implemented recursively thus we have to avoid
			// that here by decorating the
			// description and return the resolved instance instead
			EObject resolved = resolveObject(objectURI, resource);
			if (resolved == null) {
				return original;
			}
			return new ResolvedDescription(resolved, original);
		}
	}
	return original;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:58,代码来源:UserDataAwareScope.java

示例9: getEObject

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
/**
 * @since 2.4
 */
protected EObject getEObject(String uriFragment, Triple<EObject, EReference, INode> triple) throws AssertionError {
	if (!resolving.add(triple))
		return handleCyclicResolution(triple);
	try {
		Set<String> unresolveableProxies = getUnresolvableURIFragments();
		if (unresolveableProxies.contains(uriFragment))
			return null;
		EReference reference = triple.getSecond();
		try {
			List<EObject> linkedObjects = getLinkingService().getLinkedObjects(
					triple.getFirst(), 
					reference,
					triple.getThird());

			if (linkedObjects.isEmpty()) {
				if (isUnresolveableProxyCacheable(triple))
					unresolveableProxies.add(uriFragment);
				createAndAddDiagnostic(triple);
				return null;
			}
			if (linkedObjects.size() > 1)
				throw new IllegalStateException("linkingService returned more than one object for fragment "
						+ uriFragment);
			EObject result = linkedObjects.get(0);
			if (!EcoreUtil2.isAssignableFrom(reference.getEReferenceType(), result.eClass())) {
				log.error("An element of type " + result.getClass().getName()
						+ " is not assignable to the reference " + reference.getEContainingClass().getName()
						+ "." + reference.getName());
				if (isUnresolveableProxyCacheable(triple))
					unresolveableProxies.add(uriFragment);
				createAndAddDiagnostic(triple);
				return null;
			}
			// remove previously added error markers, since everything should be fine now
			unresolveableProxies.remove(uriFragment);
			removeDiagnostic(triple);
			return result;
		} catch (CyclicLinkingException e) {
			if (e.triple.equals(triple)) {
				log.error(e.getMessage(), e);
				if (isUnresolveableProxyCacheable(triple))
					unresolveableProxies.add(uriFragment);
				createAndAddDiagnostic(triple);
				return null;
			} else {
				throw e;
			}
		}
	} catch (IllegalNodeException ex) {
		createAndAddDiagnostic(triple, ex);
		return null;
	} finally {
		resolving.remove(triple);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:59,代码来源:LazyLinkingResource.java

示例10: isAssignable

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
protected boolean isAssignable(final EClass superType, final EClassifier type) {
  if ((type instanceof EClass)) {
    return EcoreUtil2.isAssignableFrom(superType, ((EClass)type));
  }
  return false;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:7,代码来源:AbstractHierarchyBuilder.java

示例11: isInstantiatableSubType

import org.eclipse.xtext.EcoreUtil2; //导入方法依赖的package包/类
/**
 * Determine whether a type is an instantiable subtype of another type.
 *
 * @param c
 *          EClass to check.
 * @param superType
 *          of which c should be a subtype.
 * @return {@code true}, if c is instantiable and assignment-compatible with {@code superType}.
 */
private static boolean isInstantiatableSubType(final EClass c, final EClass superType) {
  return !c.isAbstract() && !c.isInterface() && EcoreUtil2.isAssignableFrom(superType, c);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:13,代码来源:EClasses.java


注:本文中的org.eclipse.xtext.EcoreUtil2.isAssignableFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。