本文整理汇总了Java中org.eclipse.emf.common.util.TreeIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java TreeIterator.next方法的具体用法?Java TreeIterator.next怎么用?Java TreeIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.TreeIterator
的用法示例。
在下文中一共展示了TreeIterator.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findByNestedRuleCall
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> List<T> findByNestedRuleCall(Class<T> clazz, AbstractRule... rule) {
Set<AbstractRule> rls = new HashSet<AbstractRule>(Arrays.asList(rule));
ArrayList<T> r = new ArrayList<T>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (clazz.isInstance(o)) {
TreeIterator<EObject> ct = o.eAllContents();
while (ct.hasNext()) {
EObject cto = ct.next();
if (cto instanceof RuleCall && rls.contains(((RuleCall) cto).getRule())) {
r.add((T) o);
break;
}
}
i.prune();
}
}
}
return r;
}
示例2: cosem
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
public static void cosem(Resource cosemResource, Root root, Hashtable<String, MeterAsset> allMeterAssets) {
HashSet<PhysicalDevice> devices = new HashSet<>();
HashSet<MeterAssetPhysicalDevicePair> devicePairs = new HashSet<>();
TreeIterator<EObject> cosemIterator = cosemResource.getAllContents();
while (cosemIterator.hasNext()) {
EObject eOb = cosemIterator.next();
if (eOb instanceof PhysicalDevice) {
PhysicalDevice device = (PhysicalDevice) eOb;
devices.add(device);
String idNs = device.getID();
if (allMeterAssets.containsKey(idNs)) {
MeterAssetPhysicalDevicePair pair = GluemodelFactory.eINSTANCE
.createMeterAssetPhysicalDevicePair();
pair.setB(device);
pair.setA(allMeterAssets.get(idNs));
devicePairs.add(pair);
}
}
}
root.getMeterAssetToPhysicalDevice().addAll(devicePairs);
}
示例3: provideHighlightingFor
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
public void provideHighlightingFor(XtextResource resource,
org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor acceptor) {
TreeIterator<EObject> allContents = resource.getAllContents();
while (allContents.hasNext()) {
EObject next = allContents.next();
if (next.eIsProxy()) {
continue;
}
if (next instanceof ElementReferenceExpression) {
if (next instanceof ElementReferenceExpression) {
ElementReferenceExpression expression = (ElementReferenceExpression) next;
provideHighligtingFor(expression, acceptor);
}
}
}
}
示例4: collectNodesWithinSameThisEnvironment
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的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;
}
示例5: getSuperTypeImports
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected List<ImportNormalizer> getSuperTypeImports(Resource res, EReference reference) {
List<ImportNormalizer> result = Lists.newArrayList();
TreeIterator<EObject> allContents = res.getAllContents();
while (allContents.hasNext()) {
EObject next = allContents.next();
if (next instanceof ContractDefinition) {
ContractDefinition contract = (ContractDefinition) next;
EList<ComplexType> superTypes = contract.getSuperTypes();
for (ComplexType complexType : superTypes) {
// if (complexType.eIsProxy() || complexType.getName() ==
// null)
// continue;
ImportNormalizer resolver = createImportedNamespaceResolver(complexType.getName() + ".*", false);
result.add(resolver);
}
allContents.prune();
}
}
return result;
}
示例6: buildMap
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
protected void buildMap(Resource resource, Map<QualifiedName, IEObjectDescription> elements) {
IDefaultResourceDescriptionStrategy strategy = ((XtextResource) resource).getResourceServiceProvider()
.get(IDefaultResourceDescriptionStrategy.class);
TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(resource, false);
IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {
@Override
public void accept(IEObjectDescription description) {
elements.put(description.getQualifiedName(), description);
}
};
while (allProperContents.hasNext()) {
EObject content = allProperContents.next();
if (!strategy.createEObjectDescriptions(content, acceptor)) {
allProperContents.prune();
}
}
}
示例7: undoTextElementToTextNode
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
private static void undoTextElementToTextNode(XMLResource saturnResourceImpl_, Map<Entry, Entry> textNodes_)
{
DocumentRoot o = (DocumentRoot) saturnResourceImpl_.getContents().get(0);
Saturn saturn = (Saturn) o.eContents().get(0);
TreeIterator<EObject> ee = saturn.eAllContents();
while (ee.hasNext())
{
EObject e = ee.next();
if (e == null) continue;
EClass ec = e.eClass();
if (!ValuesPackage.eINSTANCE.getComplexValue().isSuperTypeOf(ec)) continue;
ComplexValue cv = (ComplexValue) e;
for (int i = 0; i < cv.getMixed().size(); i++)
{
FeatureMap.Entry entry = cv.getMixed().get(i);
if (textNodes_.containsKey(entry))
{
Entry textComplexValueEntry = textNodes_.get(entry);
cv.getMixed().set(i, textComplexValueEntry);
}
}
}
}
示例8: findKeywords
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
public List<Keyword> findKeywords(String... keywords) {
Set<String> kwds = new HashSet<String>(Arrays.asList(keywords));
ArrayList<Keyword> r = new ArrayList<Keyword>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Keyword) {
Keyword k = (Keyword) o;
if (kwds.contains(k.getValue()))
r.add(k);
}
}
}
return r;
}
示例9: checkMenuNewChildElementTypeIdRefs
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
* Check that referenced element type are in the registry
*/
@Test
public void checkMenuNewChildElementTypeIdRefs() {
URI createPlatformPluginURI = URI.createPlatformPluginURI(NEW_CHILD_MENU_PATH, true);
ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
Resource resource = resourceSetImpl.getResource(createPlatformPluginURI, true);
TreeIterator<EObject> allContents = resource.getAllContents();
while (allContents.hasNext()) {
EObject eObject = (EObject) allContents.next();
if (eObject instanceof CreationMenu) {
String iconPath = ((CreationMenu) eObject).getIcon();
if (iconPath != null && !"".equals(iconPath)){
try {
Assert.assertNotNull("The icon "+iconPath+" can't be found", FileLocator.find(new URL(iconPath)));
} catch (MalformedURLException e) {
Assert.fail("The new child menu is refering to a malformed url "+iconPath);
}
}
}
}
}
示例10: testExternalFormOfEReference
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Test public void testExternalFormOfEReference() throws Exception {
Registry registry = EPackage.Registry.INSTANCE;
Set<String> uris = Sets.newHashSet(registry.keySet());
for (String string : uris) {
EPackage ePackage = registry.getEPackage(string);
TreeIterator<Object> iterator = EcoreUtil.getAllProperContents(ePackage, true);
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof EReference) {
EReference ref = (EReference) next;
String externalForm = EcoreUtil2.toExternalForm(ref);
assertEquals(ref.toString() + " - " + externalForm, ref, EcoreUtil2.getEReferenceFromExternalForm(registry,externalForm));
}
}
}
}
示例11: checkIsValidConstructorArgument
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected void checkIsValidConstructorArgument(XExpression argument, JvmType containerType) {
TreeIterator<EObject> iterator = EcoreUtil2.eAll(argument);
while(iterator.hasNext()) {
EObject partOfArgumentExpression = iterator.next();
if (partOfArgumentExpression instanceof XFeatureCall || partOfArgumentExpression instanceof XMemberFeatureCall) {
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) partOfArgumentExpression;
XExpression actualReceiver = featureCall.getActualReceiver();
if(actualReceiver instanceof XFeatureCall && ((XFeatureCall)actualReceiver).getFeature() == containerType) {
JvmIdentifiableElement feature = featureCall.getFeature();
if (feature != null && !feature.eIsProxy()) {
if (feature instanceof JvmField) {
if (!((JvmField) feature).isStatic())
error("Cannot refer to an instance field " + feature.getSimpleName() + " while explicitly invoking a constructor",
partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT);
} else if (feature instanceof JvmOperation) {
if (!((JvmOperation) feature).isStatic())
error("Cannot refer to an instance method while explicitly invoking a constructor",
partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT);
}
}
}
} else if(isLocalClassSemantics(partOfArgumentExpression)) {
iterator.prune();
}
}
}
示例12: findKeywordPairs
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
public List<Pair<Keyword, Keyword>> findKeywordPairs(String leftKw, String rightKw) {
ArrayList<Pair<Keyword, Keyword>> pairs = new ArrayList<Pair<Keyword, Keyword>>();
for (AbstractRule ar : getRules())
if (ar instanceof ParserRule && !GrammarUtil.isDatatypeRule((ParserRule) ar)) {
Stack<Keyword> openings = new Stack<Keyword>();
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof Keyword) {
Keyword k = (Keyword) o;
if (leftKw.equals(k.getValue()))
openings.push(k);
else if (rightKw.equals(k.getValue())) {
if (openings.size() > 0)
pairs.add(Tuples.create(openings.pop(), k));
}
}
}
}
return pairs;
}
示例13: computeReferenceDescriptions
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected List<IReferenceDescription> computeReferenceDescriptions() {
final List<IReferenceDescription> referenceDescriptions = Lists.newArrayList();
IAcceptor<IReferenceDescription> acceptor = new IAcceptor<IReferenceDescription>() {
@Override
public void accept(IReferenceDescription referenceDescription) {
referenceDescriptions.add(referenceDescription);
}
};
EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
Map<EObject, IEObjectDescription> eObject2exportedEObjects = createEObject2ExportedEObjectsMap(getExportedObjects());
TreeIterator<EObject> contents = EcoreUtil.getAllProperContents(this.resource, true);
while (contents.hasNext()) {
EObject eObject = contents.next();
URI exportedContainerURI = findExportedContainerURI(eObject, eObject2exportedEObjects);
if (!strategy.createReferenceDescriptions(eObject, exportedContainerURI, acceptor))
contents.prune();
}
return referenceDescriptions;
}
示例14: getEvolvedElements
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
* Returns a container for evolved elements (new and removed) of the given
* model. Elements which are added and again removed between those dates are
* not considered
*
* @param model
* @param originDate
* @param evolvedDate
* @return
*/
public static HyEvolvedElementsContainer getEvolvedElements(EObject model, Date originDate, Date evolvedDate) {
List<EObject> newElements = new ArrayList<EObject>();
List<EObject> removedElements = new ArrayList<EObject>();
TreeIterator<EObject> modelIterator = model.eAllContents();
while (modelIterator.hasNext()) {
EObject modelObject = modelIterator.next();
if (modelObject instanceof HyTemporalElement) {
HyTemporalElement evolvedElement = (HyTemporalElement) modelObject;
boolean validAtOriginDate = isValid(evolvedElement, originDate);
boolean validAtEvolvedDate = isValid(evolvedElement, evolvedDate);
if (validAtEvolvedDate && !validAtOriginDate) {
newElements.add(evolvedElement);
} else if (validAtOriginDate && !validAtEvolvedDate) {
removedElements.add(evolvedElement);
}
}
}
HyEvolvedElementsContainer evolvedElements = new HyEvolvedElementsContainer(newElements, removedElements);
return evolvedElements;
}
示例15: resolveLazyCrossReferences
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
* resolves any lazy cross references in this resource, adding Issues for unresolvable elements to this resource.
* This resource might still contain resolvable proxies after this method has been called.
*
* @param mon a {@link CancelIndicator} can be used to stop the resolution.
*/
public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
while (iterator.hasNext()) {
operationCanceledManager.checkCanceled(monitor);
InternalEObject source = (InternalEObject) iterator.next();
EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
.getEAllStructuralFeatures()).crossReferences();
if (eStructuralFeatures != null) {
for (EStructuralFeature crossRef : eStructuralFeatures) {
operationCanceledManager.checkCanceled(monitor);
resolveLazyCrossReference(source, crossRef);
}
}
}
}