Search in sources :

Example 1 with LiteralOrComputedPropertyName

use of org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName in project n4js by eclipse.

the class N4JSReferenceQueryExecutor method getTargetURIs.

/**
 * Here, we add overridden/overriding members or super/subclasses if needed depending on user preferences when
 * finding references.
 */
@Override
protected Iterable<URI> getTargetURIs(EObject primaryTarget) {
    @SuppressWarnings("restriction") Iterable<URI> originalResult = super.getTargetURIs(primaryTarget);
    List<URI> newResult = Lists.newArrayList(originalResult);
    if (primaryTarget instanceof LiteralOrComputedPropertyName) {
        primaryTarget = primaryTarget.eContainer();
    }
    // Handling for various configurations e.g. consider overriden members
    List<EObject> realTargets = new ArrayList<>();
    if (primaryTarget instanceof TMember && ((TMember) primaryTarget).isComposed()) {
        // In case of composed member, add the constituent members instead.
        List<TMember> constituentMembers = ((TMember) primaryTarget).getConstituentMembers();
        for (TMember constituentMember : constituentMembers) {
            realTargets.add(constituentMember);
        }
    } else {
        // Standard case
        realTargets.add(primaryTarget);
    }
    for (EObject realTarget : realTargets) {
        if (N4JSReferenceQueryExecutor.considerOverridenMethods) {
            // Add overriden members
            if (realTarget instanceof N4MemberDeclaration || // Only consider members within a classifier.Ignore TStructMember.
            (realTarget instanceof TMember && realTarget.eContainer() instanceof TClassifier)) {
                TMember tmember;
                if (primaryTarget instanceof N4MemberDeclaration) {
                    tmember = ((N4MemberDeclaration) primaryTarget).getDefinedTypeElement();
                } else {
                    tmember = (TMember) primaryTarget;
                }
                for (TMember inheritedOrImplementedMember : getInheritedAndImplementedMembers(tmember)) {
                    URI uri = EcoreUtil2.getPlatformResourceOrNormalizedURI(inheritedOrImplementedMember);
                    newResult.add(uri);
                }
            }
        }
    }
    return newResult;
}
Also used : TClassifier(org.eclipse.n4js.ts.types.TClassifier) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName) N4MemberDeclaration(org.eclipse.n4js.n4JS.N4MemberDeclaration) TMember(org.eclipse.n4js.ts.types.TMember) URI(org.eclipse.emf.common.util.URI)

Example 2 with LiteralOrComputedPropertyName

use of org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName in project n4js by eclipse.

the class FieldAccessorImpl method getName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getName() {
    LiteralOrComputedPropertyName _declaredName = this.getDeclaredName();
    String _name = null;
    if (_declaredName != null) {
        _name = _declaredName.getName();
    }
    return _name;
}
Also used : LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)

Example 3 with LiteralOrComputedPropertyName

use of org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName in project n4js by eclipse.

the class FieldAccessorImpl method basicSetDeclaredName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetDeclaredName(LiteralOrComputedPropertyName newDeclaredName, NotificationChain msgs) {
    LiteralOrComputedPropertyName oldDeclaredName = declaredName;
    declaredName = newDeclaredName;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.FIELD_ACCESSOR__DECLARED_NAME, oldDeclaredName, newDeclaredName);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)

Example 4 with LiteralOrComputedPropertyName

use of org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName in project n4js by eclipse.

the class PropertyAssignmentImpl method basicSetDeclaredName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetDeclaredName(LiteralOrComputedPropertyName newDeclaredName, NotificationChain msgs) {
    LiteralOrComputedPropertyName oldDeclaredName = declaredName;
    declaredName = newDeclaredName;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.PROPERTY_ASSIGNMENT__DECLARED_NAME, oldDeclaredName, newDeclaredName);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)

Example 5 with LiteralOrComputedPropertyName

use of org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName in project n4js by eclipse.

the class PropertyAssignmentImpl method isValidName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean isValidName() {
    String _name = this.getName();
    boolean _equals = Objects.equal("prototype", _name);
    if (_equals) {
        return false;
    }
    boolean _and = false;
    String _name_1 = this.getName();
    boolean _equals_1 = Objects.equal("constructor", _name_1);
    if (!_equals_1) {
        _and = false;
    } else {
        LiteralOrComputedPropertyName _declaredName = this.getDeclaredName();
        PropertyNameKind _kind = null;
        if (_declaredName != null) {
            _kind = _declaredName.getKind();
        }
        boolean _tripleNotEquals = (_kind != PropertyNameKind.COMPUTED);
        _and = _tripleNotEquals;
    }
    if (_and) {
        return false;
    }
    return true;
}
Also used : PropertyNameKind(org.eclipse.n4js.n4JS.PropertyNameKind) LiteralOrComputedPropertyName(org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)

Aggregations

LiteralOrComputedPropertyName (org.eclipse.n4js.n4JS.LiteralOrComputedPropertyName)27 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)8 PropertyNameKind (org.eclipse.n4js.n4JS.PropertyNameKind)7 EObject (org.eclipse.emf.ecore.EObject)3 BindingProperty (org.eclipse.n4js.n4JS.BindingProperty)2 Block (org.eclipse.n4js.n4JS.Block)2 CatchBlock (org.eclipse.n4js.n4JS.CatchBlock)2 ExportDeclaration (org.eclipse.n4js.n4JS.ExportDeclaration)2 ExportSpecifier (org.eclipse.n4js.n4JS.ExportSpecifier)2 Expression (org.eclipse.n4js.n4JS.Expression)2 FormalParameter (org.eclipse.n4js.n4JS.FormalParameter)2 FunctionDeclaration (org.eclipse.n4js.n4JS.FunctionDeclaration)2 N4FieldDeclaration (org.eclipse.n4js.n4JS.N4FieldDeclaration)2 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)2 Script (org.eclipse.n4js.n4JS.Script)2 ArrayList (java.util.ArrayList)1 URI (org.eclipse.emf.common.util.URI)1 EPackage (org.eclipse.emf.ecore.EPackage)1 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)1 Annotation (org.eclipse.n4js.n4JS.Annotation)1