use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.
the class JdtBasedTypeFactory method createAnnotationValues.
protected void createAnnotationValues(IBinding annotated, JvmAnnotationTarget result) {
try {
resolveAnnotations.start();
IAnnotationBinding[] annotationBindings = annotated.getAnnotations();
if (annotationBindings.length != 0) {
InternalEList<JvmAnnotationReference> annotations = (InternalEList<JvmAnnotationReference>) result.getAnnotations();
for (IAnnotationBinding annotation : annotationBindings) {
annotations.addUnique(createAnnotationReference(annotation));
}
}
} catch (AbortCompilation aborted) {
if (aborted.problem.getID() == IProblem.IsClassPathCorrect) {
// ignore
} else {
log.info("Couldn't resolve annotations of " + annotated, aborted);
}
} finally {
resolveAnnotations.stop();
}
}
use of org.eclipse.emf.ecore.util.InternalEList in project statecharts by Yakindu.
the class AbstractSCTResource method resolveLazyCrossReference.
// copied from xtext LazyLinkingResource
protected void resolveLazyCrossReference(InternalEObject source, EStructuralFeature crossRef, CancelIndicator monitor) {
if (crossRef.isDerived())
return;
if (crossRef.isMany()) {
@SuppressWarnings("unchecked") InternalEList<EObject> list = (InternalEList<EObject>) source.eGet(crossRef);
for (int i = 0; i < list.size(); i++) {
EObject proxy = list.basicGet(i);
if (proxy.eIsProxy()) {
URI proxyURI = ((InternalEObject) proxy).eProxyURI();
if (getURI().equals(proxyURI.trimFragment())) {
final String fragment = proxyURI.fragment();
if (encoder.isCrossLinkFragment(this, fragment) && !monitor.isCanceled()) {
EObject target = getEObject(fragment);
if (target != null) {
try {
source.eSetDeliver(false);
list.setUnique(i, target);
} finally {
source.eSetDeliver(true);
}
}
}
}
}
}
} else {
EObject proxy = (EObject) source.eGet(crossRef, false);
if (proxy != null && proxy.eIsProxy()) {
URI proxyURI = ((InternalEObject) proxy).eProxyURI();
if (getURI().equals(proxyURI.trimFragment())) {
final String fragment = proxyURI.fragment();
if (encoder.isCrossLinkFragment(this, fragment) && !monitor.isCanceled()) {
EObject target = getEObject(fragment);
if (target != null) {
try {
source.eSetDeliver(false);
source.eSet(crossRef, target);
} finally {
source.eSetDeliver(true);
}
}
}
}
}
}
}
use of org.eclipse.emf.ecore.util.InternalEList in project statecharts by Yakindu.
the class DerivedEObjectEList method size.
@Override
public int size() {
if (sourceFeatureIDs != null) {
EList<Object> values = new UniqueEList.FastCompare<Object>();
for (int i = 0; i < sourceFeatureIDs.length; i++) {
int sourceFeatureID = sourceFeatureIDs[i];
if (owner.eIsSet(sourceFeatureID)) {
EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
Object value = owner.eGet(sourceFeatureID, false, true);
if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
FeatureMap featureMap = (FeatureMap) value;
for (int j = 0, size = featureMap.size(); j < size; j++) {
value = featureMap.getValue(j);
if (isIncluded(featureMap.getEStructuralFeature(j)) ? value != null : isIncluded(value)) {
values.add(value);
}
}
} else if (isIncluded(sourceFeature)) {
if (sourceFeature.isMany()) {
InternalEList<?> valuesList = (InternalEList<?>) value;
if (valuesList instanceof RandomAccess) {
for (int j = 0, size = valuesList.size(); j < size; j++) {
values.add(valuesList.basicGet(j));
}
} else {
for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
values.add(v.next());
}
}
} else if (value != null) {
values.add(value);
}
} else {
if (sourceFeature.isMany()) {
InternalEList<?> valuesList = (InternalEList<?>) value;
if (valuesList instanceof RandomAccess) {
for (int j = 0, size = valuesList.size(); j < size; j++) {
value = valuesList.basicGet(j);
if (isIncluded(value)) {
values.add(value);
}
}
} else {
for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
value = v.next();
if (isIncluded(value)) {
values.add(value);
}
}
}
} else if (isIncluded(value)) {
values.add(value);
}
}
}
}
return values.size();
}
return 0;
}
use of org.eclipse.emf.ecore.util.InternalEList in project statecharts by Yakindu.
the class DerivedEObjectEList method contains.
@Override
public boolean contains(Object object) {
if (sourceFeatureIDs != null) {
for (int i = 0; i < sourceFeatureIDs.length; i++) {
int sourceFeatureID = sourceFeatureIDs[i];
if (owner.eIsSet(sourceFeatureID)) {
EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
Object value = owner.eGet(sourceFeatureID, true, true);
if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
FeatureMap featureMap = (FeatureMap) value;
for (int j = 0, size = featureMap.size(); j < size; j++) {
value = featureMap.getValue(j);
if (isIncluded(featureMap.getEStructuralFeature(j)) ? value == object : isIncluded(value) && derive(value) == object) {
return true;
}
}
} else if (isIncluded(sourceFeature)) {
if (sourceFeature.isMany() ? ((List<?>) value).contains(object) : value == object) {
return true;
}
} else {
if (sourceFeature.isMany()) {
InternalEList<?> valuesList = (InternalEList<?>) value;
if (valuesList instanceof RandomAccess) {
for (int j = 0, size = valuesList.size(); j < size; j++) {
value = valuesList.basicGet(j);
if (isIncluded(value) && derive(value) == object) {
return true;
}
}
} else {
for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
value = v.next();
if (isIncluded(value) && derive(value) == object) {
return true;
}
}
}
} else if (isIncluded(value) && derive(value) == object) {
return true;
}
}
}
}
}
return false;
}
Aggregations