use of org.eclipse.emf.common.util.BasicEList in project n4js by eclipse.
the class N4JSCrossReferenceComputer method computeCrossRefs.
/*
* Browse all references type by the EClass of the given EObject ignoring References between AST element to its
* defined type and vice versa.
*/
private void computeCrossRefs(Resource resource, EObject from, IAcceptor<EObject> acceptor) {
EList<EReference> references = from.eClass().getEAllReferences();
for (EReference eReference : references) {
// We only follow cross references
if (!eReference.isContainment() && !eReference.isContainer()) {
// Ignore references between AST element and its defined type and vice versa
if (eReference != N4JSPackage.Literals.TYPE_DEFINING_ELEMENT__DEFINED_TYPE && eReference != TypesPackage.Literals.SYNTAX_RELATED_TELEMENT__AST_ELEMENT) {
if (from.eIsSet(eReference)) {
Object val = from.eGet(eReference);
// Handle both toOne and toMany cases
if (!eReference.isMany()) {
EObject to = (EObject) val;
handleReferenceObject(resource, acceptor, to);
} else {
@SuppressWarnings("unchecked") BasicEList<EObject> list = (BasicEList<EObject>) val;
// cases
if (TypesPackage.Literals.TYPE.isSuperTypeOf(eReference.getEReferenceType())) {
for (EObject to : list) {
handleType(resource, acceptor, (Type) to);
}
} else if (TypesPackage.Literals.IDENTIFIABLE_ELEMENT.isSuperTypeOf(eReference.getEReferenceType())) {
for (EObject to : list) {
handleIdentifiableElement(resource, acceptor, (IdentifiableElement) to);
}
} else {
// Handle all other cases
for (EObject to : list) {
handleReferenceObject(resource, acceptor, to);
}
}
}
}
}
}
}
}
use of org.eclipse.emf.common.util.BasicEList in project n4js by eclipse.
the class N4JSResource method addSyntaxErrors.
/**
* This is aware of warnings from the {@link N4JSStringValueConverter}.
*
* Issues from the parser are commonly treated as errors but here we want to create a warning.
*/
@Override
protected void addSyntaxErrors() {
if (isValidationDisabled())
return;
// EList.add unnecessarily checks for uniqueness by default
// so we use #addUnique below to save some CPU cycles for heavily broken
// models
BasicEList<Diagnostic> errorList = (BasicEList<Diagnostic>) getErrors();
BasicEList<Diagnostic> warningList = (BasicEList<Diagnostic>) getWarnings();
for (INode error : getParseResult().getSyntaxErrors()) {
XtextSyntaxDiagnostic diagnostic = createSyntaxDiagnostic(error);
String code = diagnostic.getCode();
if (AbstractN4JSStringValueConverter.WARN_ISSUE_CODE.equals(code) || RegExLiteralConverter.ISSUE_CODE.equals(code) || LegacyOctalIntValueConverter.ISSUE_CODE.equals(code)) {
warningList.addUnique(diagnostic);
} else if (!InternalSemicolonInjectingParser.SEMICOLON_INSERTED.equals(code)) {
errorList.addUnique(diagnostic);
}
}
}
use of org.eclipse.emf.common.util.BasicEList in project dsl-devkit by dsldevkit.
the class BugAig1084 method recursiveLookUp.
/**
* Test that recursive calls to {@link ResourceDescription2#getLookUp()} by {@link ResourceDescription2#computeExportedObjects()} do not cause
* stack-overflow.
*/
@Test
public void recursiveLookUp() {
Resource resource = org.mockito.Mockito.mock(Resource.class);
BasicEList<Adapter> emptyEList = new BasicEList<Adapter>();
org.mockito.Mockito.when(resource.eAdapters()).thenReturn(emptyEList);
IResourceScopeCache cache = new OnChangeEvictingCache();
new ResourceDescription2(resource, null, cache) {
@Override
protected List<IEObjectDescription> computeExportedObjects() {
return Lists.newArrayList(getLookUp().getExportedObjects());
}
}.getExportedObjects();
}
use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class CompositeIndicatorImpl method getAllChildIndicators.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT getAllChildIndicators()
*/
public EList<Indicator> getAllChildIndicators() {
EList<Indicator> allChildIndicators = new BasicEList<Indicator>();
EList<Indicator> childIndicators = getChildIndicators();
for (Indicator indicator : childIndicators) {
if (indicator instanceof CompositeIndicator) {
allChildIndicators.addAll(((CompositeIndicator) indicator).getAllChildIndicators());
} else {
allChildIndicators.add(indicator);
}
}
return allChildIndicators;
}
use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class AbstractMetadataFormPage method getContexts.
/**
* get the context list from the report editor.
*
* @return
*/
protected List<ContextType> getContexts() {
EList<ContextType> el = new BasicEList<ContextType>();
IContextManager contextManager = currentEditor.getContextManager();
contextManager.saveToEmf(el);
return el;
}
Aggregations