Search in sources :

Example 16 with IdentifiableElement

use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.

the class IdentifierRefImpl method setId.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setId(IdentifiableElement newId) {
    IdentifiableElement oldId = id;
    id = newId;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.IDENTIFIER_REF__ID, oldId, id));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement)

Example 17 with IdentifiableElement

use of org.eclipse.n4js.ts.types.IdentifiableElement 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 18 with IdentifiableElement

use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.

the class SymbolTableEntryOriginalImpl method setOriginalTarget.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setOriginalTarget(IdentifiableElement newOriginalTarget) {
    IdentifiableElement oldOriginalTarget = originalTarget;
    originalTarget = newOriginalTarget;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ImPackage.SYMBOL_TABLE_ENTRY_ORIGINAL__ORIGINAL_TARGET, oldOriginalTarget, originalTarget));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement)

Example 19 with IdentifiableElement

use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.

the class AccessModifierXpectMethod method calculateActual.

private String calculateActual(EObject context) {
    String actual = null;
    if (context instanceof TMember) {
        TMember tMember = (TMember) context;
        actual = tMember.getMemberAccessModifier().getName();
    } else {
        FunctionDeclaration functionDeclaration = EcoreUtil2.getContainerOfType(context, FunctionDeclaration.class);
        if (functionDeclaration != null) {
            actual = functionDeclaration.getDefinedType().getTypeAccessModifier().getName();
        } else {
            VariableStatement variableStatement = EcoreUtil2.getContainerOfType(context, VariableStatement.class);
            if (variableStatement != null) {
                context = variableStatement.getVarDecl().get(0);
                if (context instanceof ExportedVariableDeclaration) {
                    actual = ((ExportedVariableDeclaration) context).getDefinedVariable().getTypeAccessModifier().getName();
                } else if (context instanceof VariableDeclaration) {
                    actual = "private";
                }
            } else if (context instanceof ExportDeclaration) {
                context = ((ExportDeclaration) context).getExportedElement();
                actual = calculateActual(context);
            } else if (context instanceof ParameterizedPropertyAccessExpression) {
                ParameterizedPropertyAccessExpression ppae = (ParameterizedPropertyAccessExpression) context;
                IdentifiableElement ie = ppae.getProperty();
                actual = calculateActual(ie);
            } else if (context instanceof ParameterizedCallExpression) {
                ParameterizedCallExpression pce = (ParameterizedCallExpression) context;
                Expression targetExpr = pce.getTarget();
                actual = calculateActual(targetExpr);
            } else {
                N4MemberDeclaration member = EcoreUtil2.getContainerOfType(context, N4MemberDeclaration.class);
                N4TypeDeclaration type = EcoreUtil2.getContainerOfType(context, N4TypeDeclaration.class);
                if (type == null && member == null) {
                    actual = "no element with access modifier found";
                } else if (type != null && (member == null || EcoreUtil.isAncestor(member, type))) {
                    actual = type.getDefinedType().getTypeAccessModifier().getName();
                } else {
                    actual = member.getDefinedTypeElement().getMemberAccessModifier().getName();
                }
            }
        }
    }
    return actual;
}
Also used : ExportedVariableDeclaration(org.eclipse.n4js.n4JS.ExportedVariableDeclaration) ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) N4MemberDeclaration(org.eclipse.n4js.n4JS.N4MemberDeclaration) ExportDeclaration(org.eclipse.n4js.n4JS.ExportDeclaration) FunctionDeclaration(org.eclipse.n4js.n4JS.FunctionDeclaration) VariableStatement(org.eclipse.n4js.n4JS.VariableStatement) ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) Expression(org.eclipse.n4js.n4JS.Expression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) ExportedVariableDeclaration(org.eclipse.n4js.n4JS.ExportedVariableDeclaration) VariableDeclaration(org.eclipse.n4js.n4JS.VariableDeclaration) N4TypeDeclaration(org.eclipse.n4js.n4JS.N4TypeDeclaration) TMember(org.eclipse.n4js.ts.types.TMember)

Example 20 with IdentifiableElement

use of org.eclipse.n4js.ts.types.IdentifiableElement in project n4js by eclipse.

the class SymbolOfIdentifierRef method getDeclaration.

@Override
public EObject getDeclaration() {
    VariableDeclaration varDecl = null;
    IdentifiableElement id = ir.getId();
    if (id instanceof TVariable) {
        TVariable tvar = (TVariable) id;
        varDecl = (VariableDeclaration) tvar.getAstElement();
        return varDecl;
    } else {
        // id instanceof VariableDeclaration
        return id;
    }
}
Also used : TVariable(org.eclipse.n4js.ts.types.TVariable) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) VariableDeclaration(org.eclipse.n4js.n4JS.VariableDeclaration)

Aggregations

IdentifiableElement (org.eclipse.n4js.ts.types.IdentifiableElement)27 EObject (org.eclipse.emf.ecore.EObject)12 ExportDeclaration (org.eclipse.n4js.n4JS.ExportDeclaration)7 ExportableElement (org.eclipse.n4js.n4JS.ExportableElement)6 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)6 NamedElement (org.eclipse.n4js.n4JS.NamedElement)5 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)5 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)5 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)5 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)5 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)5 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)5 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)5 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)5 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)5 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)5 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)5 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)5 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)5 Result (org.eclipse.xsemantics.runtime.Result)5