Search in sources :

Example 51 with BasicEList

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);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) BasicEList(org.eclipse.emf.common.util.BasicEList) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Example 52 with BasicEList

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);
        }
    }
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) XtextSyntaxDiagnostic(org.eclipse.xtext.resource.XtextSyntaxDiagnostic) BasicEList(org.eclipse.emf.common.util.BasicEList) XtextSyntaxDiagnostic(org.eclipse.xtext.resource.XtextSyntaxDiagnostic) ExceptionDiagnostic(org.eclipse.xtext.diagnostics.ExceptionDiagnostic)

Example 53 with BasicEList

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();
}
Also used : OnChangeEvictingCache(org.eclipse.xtext.util.OnChangeEvictingCache) BasicEList(org.eclipse.emf.common.util.BasicEList) Resource(org.eclipse.emf.ecore.resource.Resource) IResourceScopeCache(org.eclipse.xtext.util.IResourceScopeCache) Adapter(org.eclipse.emf.common.notify.Adapter) List(java.util.List) BasicEList(org.eclipse.emf.common.util.BasicEList) ResourceDescription2(com.avaloq.tools.ddk.xtext.resource.ResourceDescription2) Test(org.junit.Test)

Example 54 with BasicEList

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;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 55 with BasicEList

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;
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) BasicEList(org.eclipse.emf.common.util.BasicEList) IContextManager(org.talend.core.model.process.IContextManager)

Aggregations

BasicEList (org.eclipse.emf.common.util.BasicEList)75 Test (org.junit.Test)25 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)16 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)16 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)16 EEFFeatureEditorDialog (org.eclipse.emf.eef.runtime.ui.widgets.EEFFeatureEditorDialog)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)16 GridData (org.eclipse.swt.layout.GridData)16 TdExpression (org.talend.cwm.relational.TdExpression)11 EObject (org.eclipse.emf.ecore.EObject)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)9 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)9 ProductVersion (org.talend.utils.ProductVersion)9 Button (org.eclipse.swt.widgets.Button)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)5 Widget (org.eclipse.smarthome.model.sitemap.Widget)5