本文整理汇总了Java中org.eclipse.emf.common.util.TreeIterator类的典型用法代码示例。如果您正苦于以下问题:Java TreeIterator类的具体用法?Java TreeIterator怎么用?Java TreeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeIterator类属于org.eclipse.emf.common.util包,在下文中一共展示了TreeIterator类的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: findRuleCalls
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的package包/类
public List<RuleCall> findRuleCalls(AbstractRule... rules) {
Set<AbstractRule> rls = new HashSet<AbstractRule>(Arrays.asList(rules));
ArrayList<RuleCall> r = new ArrayList<RuleCall>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof RuleCall) {
RuleCall c = (RuleCall) o;
if (rls.contains(c.getRule()))
r.add(c);
}
}
}
return r;
}
示例3: 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);
}
示例4: collectNodes
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的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;
}
示例5: 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;
}
示例6: exposeTypesReferencedBy
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的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);
}
}
}
}
}
示例7: doLinkModel
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的package包/类
/**
* Clears the list of encoded URIs in {@link N4JSResource}, installs proxies for all cross references inside the
* parsed model. If validation is enabled finally the {@link ASTStructureValidator} is triggered, that checks the
* now linked AST structure.
*/
@Override
protected void doLinkModel(final EObject model, final IDiagnosticConsumer consumer) {
final LinkingDiagnosticProducer producer = new LinkingDiagnosticProducer(consumer);
getCache().execWithoutCacheClear((N4JSResource) model.eResource(), new IUnitOfWork.Void<N4JSResource>() {
@Override
public void process(N4JSResource resource) throws Exception {
// actual linking
resource.clearLazyProxyInformation();
clearReferences(model);
installProxies(resource, model, producer);
TreeIterator<EObject> iterator = model.eAllContents();
while (iterator.hasNext()) {
EObject eObject = iterator.next();
clearReferences(eObject);
installProxies(resource, eObject, producer);
}
// pre-processing of AST
preProcessor.process(resource.getScript(), resource);
// AST structure validation
if (!resource.isValidationDisabled())
getStructureValidator().validate(model, consumer);
}
});
}
示例8: 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();
}
}
}
示例9: SelectAnyEObjectDialog
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的package包/类
public SelectAnyEObjectDialog(Shell parent, ResourceSet resourceSet, ILabelProvider renderer) {
super(parent, renderer);
_searchedResourceSet = resourceSet;
ArrayList<EObject> all = new ArrayList<EObject>();
EcoreUtil.resolveAll(resourceSet);
for (Resource r : _searchedResourceSet.getResources())
{
for (TreeIterator<EObject> iterator = r.getAllContents(); iterator.hasNext();) {
EObject o = iterator.next();
if(select(o)) all.add(o);
}
}
Object[] elements = all.toArray();
this.setElements(elements);
}
示例10: run
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的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;
}
示例11: 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);
}
}
}
}
示例12: addInitialState
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的package包/类
private void addInitialState() {
if (lastState == null) {
// Creation of the initial state
Set<Resource> allResources = getAllExecutedModelResources();
lastState = fsmTrace.States.StatesFactory.eINSTANCE.createSpecificState();
for (Resource r : allResources) {
for (TreeIterator<EObject> i = r.getAllContents(); i.hasNext();) {
EObject o = i.next();
if (o instanceof org.eclipse.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.NamedElement) {
org.eclipse.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.NamedElement o_cast = (org.eclipse.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.NamedElement) o;
addNewObjectToState(o_cast, lastState);
}
}
}
this.traceRoot.getStates().add(lastState);
}
}
示例13: compute
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param object_p: The model element for which the Contextual Explorer extension is generated
* @return List of object to display in the parent category
* @generated
*/
public List<Object> compute(Object object_p) {
List<Object> result = new ArrayList<Object>();
Resource resource = ((EObject) object_p).eResource();
if (resource != null) {
for (TreeIterator<EObject> iter = resource.getAllContents(); iter.hasNext();) {
EObject eObject = iter.next();
if (eObject instanceof Alarm) {
Alarm referencingElement = (Alarm) eObject;
if (referencingElement.getTimers() != null && referencingElement.getTimers().contains(object_p))
result.add(eObject);
}
}
}
return result;
}
示例14: compute
import org.eclipse.emf.common.util.TreeIterator; //导入依赖的package包/类
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param object_p:
* The model element for which the Contextual Explorer extension
* is generated
* @return List of object to display in the parent category
* @generated
*/
public List<Object> compute(Object object_p) {
List<Object> result = new ArrayList<Object>();
Resource resource = ((EObject) object_p).eResource();
if (resource != null) {
for (TreeIterator<EObject> iter = resource.getAllContents(); iter.hasNext();) {
EObject eObject = iter.next();
if (eObject instanceof Step) {
Step referencingElement = (Step) eObject;
if (referencingElement.getConcurRes() != null && referencingElement.getConcurRes().equals(object_p))
result.add(eObject);
}
}
}
return result;
}
示例15: 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);
}
}
}
}