use of org.eclipse.emf.common.util.TreeIterator in project n4js by eclipse.
the class N4JSLinker method doLinkModel.
/**
* 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
String resourceName = resource.getURI().toString();
try (ClosableMeasurement mes = dcPreProcess.getClosableMeasurement(resourceName)) {
preProcessor.process(resource.getScript(), resource);
}
// AST structure validation
if (!resource.isValidationDisabled()) {
try (ClosableMeasurement m1 = dcValidations.getClosableMeasurement(resourceName);
ClosableMeasurement m2 = dcStructureValidations.getClosableMeasurement(resourceName)) {
getStructureValidator().validate(model, consumer);
}
}
}
});
}
use of org.eclipse.emf.common.util.TreeIterator in project xtext-xtend by eclipse.
the class XtendCompiler method needSyntheticSelfVariable.
@Override
protected boolean needSyntheticSelfVariable(XClosure closure, LightweightTypeReference typeRef) {
JvmType jvmType = typeRef.getType();
TreeIterator<EObject> closureIterator = closure.eAllContents();
while (closureIterator.hasNext()) {
EObject obj1 = closureIterator.next();
if (obj1 instanceof XClosure) {
closureIterator.prune();
} else if (obj1 instanceof XtendTypeDeclaration) {
TreeIterator<EObject> typeIterator = obj1.eAllContents();
while (typeIterator.hasNext()) {
EObject obj2 = typeIterator.next();
if (obj2 instanceof XClosure) {
typeIterator.prune();
} else if (obj2 instanceof XFeatureCall && isReferenceToSelf((XFeatureCall) obj2, jvmType)) {
return true;
}
}
closureIterator.prune();
}
}
return false;
}
use of org.eclipse.emf.common.util.TreeIterator in project xtext-core by eclipse.
the class EMFGeneratorFragment2 method getReferencedEPackages.
protected Set<EPackage> getReferencedEPackages(final List<EPackage> packs) {
final HashSet<EPackage> result = CollectionLiterals.<EPackage>newHashSet();
for (final EPackage pkg : packs) {
{
final TreeIterator<EObject> iterator = pkg.eAllContents();
while (iterator.hasNext()) {
{
final EObject obj = iterator.next();
EList<EObject> _eCrossReferences = obj.eCrossReferences();
for (final EObject crossRef : _eCrossReferences) {
boolean _eIsProxy = crossRef.eIsProxy();
if (_eIsProxy) {
URI _eProxyURI = ((InternalEObject) crossRef).eProxyURI();
String _plus = ("Proxy \'" + _eProxyURI);
String _plus_1 = (_plus + "\' could not be resolved");
EMFGeneratorFragment2.LOG.error(_plus_1);
} else {
final EPackage p = EcoreUtil2.<EPackage>getContainerOfType(crossRef, EPackage.class);
if ((p != null)) {
result.add(p);
}
}
}
}
}
}
}
result.removeAll(packs);
result.remove(EcorePackage.eINSTANCE);
result.remove(XMLTypePackage.eINSTANCE);
result.remove(XMLNamespacePackage.eINSTANCE);
return result;
}
use of org.eclipse.emf.common.util.TreeIterator in project xtext-core by eclipse.
the class LazyLinker method doLinkModel.
@Override
protected void doLinkModel(final EObject model, IDiagnosticConsumer consumer) {
final Multimap<EStructuralFeature.Setting, INode> settingsToLink = ArrayListMultimap.create();
final LinkingDiagnosticProducer producer = new LinkingDiagnosticProducer(consumer);
cache.execWithoutCacheClear(model.eResource(), new IUnitOfWork.Void<Resource>() {
@Override
public void process(Resource state) throws Exception {
TreeIterator<EObject> iterator = getAllLinkableContents(model);
boolean clearAllReferencesRequired = isClearAllReferencesRequired(state);
while (iterator.hasNext()) {
EObject eObject = iterator.next();
if (clearAllReferencesRequired) {
clearReferences(eObject);
}
installProxies(eObject, producer, settingsToLink);
}
}
});
installQueuedLinks(settingsToLink);
}
Aggregations