Search in sources :

Example 1 with TEnumLiteral

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

the class VisibilityAwareMemberScope method isAccepted.

@Override
protected boolean isAccepted(IEObjectDescription description) {
    EObject proxyOrInstance = description.getEObjectOrProxy();
    if (proxyOrInstance != null && !proxyOrInstance.eIsProxy()) {
        if (proxyOrInstance instanceof TMember) {
            TMember member = (TMember) proxyOrInstance;
            MemberVisibility result = checker.isVisible(context, receiverType, member);
            if (!result.visibility)
                this.accessModifierSuggestionStore.put(description.getEObjectURI().toString(), result.accessModifierSuggestion);
            return result.visibility;
        } else if (proxyOrInstance instanceof TEnumLiteral) {
            return checker.isEnumLiteralVisible(context, receiverType);
        }
    }
    return true;
}
Also used : MemberVisibility(org.eclipse.n4js.scoping.accessModifiers.MemberVisibilityChecker.MemberVisibility) TEnumLiteral(org.eclipse.n4js.ts.types.TEnumLiteral) EObject(org.eclipse.emf.ecore.EObject) TMember(org.eclipse.n4js.ts.types.TMember)

Example 2 with TEnumLiteral

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

the class N4EnumLiteralImpl method setDefinedLiteral.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setDefinedLiteral(TEnumLiteral newDefinedLiteral) {
    TEnumLiteral oldDefinedLiteral = definedLiteral;
    definedLiteral = newDefinedLiteral;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.N4_ENUM_LITERAL__DEFINED_LITERAL, oldDefinedLiteral, definedLiteral));
}
Also used : TEnumLiteral(org.eclipse.n4js.ts.types.TEnumLiteral) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 3 with TEnumLiteral

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

the class N4JSResourceDescription method getImportedNames.

@Override
public Iterable<QualifiedName> getImportedNames() {
    if (null == lazyImportedNames) {
        synchronized (this) {
            if (null == lazyImportedNames) {
                // get imported names collected during global scoping
                // the scope provider registers every request in scoping so that by this
                // also all names are collected that cannot be resolved
                Iterable<QualifiedName> superImportedNames = super.getImportedNames();
                // use sorted set to ensure order of items
                final SortedSet<QualifiedName> importedNames;
                if (superImportedNames != null) {
                    importedNames = Sets.newTreeSet(superImportedNames);
                } else {
                    importedNames = Sets.<QualifiedName>newTreeSet();
                }
                // import our own module name to get a proper change notification
                Resource resource = getResource();
                List<EObject> contents = resource.getContents();
                if (contents.size() > 1) {
                    TModule module = (TModule) contents.get(1);
                    importedNames.add(qualifiedNameProvider.getFullyQualifiedName(module));
                }
                final Set<EObject> crossRefTypes = Sets.newHashSet();
                IAcceptor<EObject> acceptor = getCrossRefTypeAcceptor(crossRefTypes);
                crossReferenceComputer.computeCrossRefs(resource, acceptor);
                for (EObject type : crossRefTypes) {
                    if (type instanceof Type) {
                        handleType(importedNames, type);
                    } else if (type instanceof TVariable) {
                        handleTVariable(importedNames, (TVariable) type);
                    } else if (type instanceof TEnumLiteral) {
                        handleTEnumLiteral(importedNames, (TEnumLiteral) type);
                    }
                }
                this.lazyImportedNames = importedNames;
            }
        }
    }
    return lazyImportedNames;
}
Also used : ContainerType(org.eclipse.n4js.ts.types.ContainerType) Type(org.eclipse.n4js.ts.types.Type) TVariable(org.eclipse.n4js.ts.types.TVariable) TEnumLiteral(org.eclipse.n4js.ts.types.TEnumLiteral) QualifiedName(org.eclipse.xtext.naming.QualifiedName) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) TModule(org.eclipse.n4js.ts.types.TModule)

Example 4 with TEnumLiteral

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

the class N4JSResourceDescription method getCrossRefTypeAcceptor.

private IAcceptor<EObject> getCrossRefTypeAcceptor(final Set<EObject> crossRefTypesAddHere) {
    IAcceptor<EObject> acceptor = new IAcceptor<EObject>() {

        @Override
        public void accept(EObject to) {
            if (to instanceof Type || to instanceof TVariable || to instanceof TEnumLiteral) {
                crossRefTypesAddHere.add(to);
            }
            // Add declared type of a field to cross ref types
            if (to instanceof TFunction) {
                TypeRef returnTypeRef = ((TFunction) to).getReturnTypeRef();
                crossRefTypesAddHere.add(returnTypeRef.getDeclaredType());
            }
            if (to instanceof TField) {
                TypeRef typeRef = ((TField) to).getTypeRef();
                crossRefTypesAddHere.add(typeRef.getDeclaredType());
            }
            // In case of TMember, add the containing type as well
            if (to instanceof TMember) {
                TMember casted = (TMember) to;
                ContainerType<?> declaringType = casted.getContainingType();
                crossRefTypesAddHere.add(declaringType);
            }
        }
    };
    return acceptor;
}
Also used : ContainerType(org.eclipse.n4js.ts.types.ContainerType) Type(org.eclipse.n4js.ts.types.Type) TFunction(org.eclipse.n4js.ts.types.TFunction) TVariable(org.eclipse.n4js.ts.types.TVariable) TField(org.eclipse.n4js.ts.types.TField) TEnumLiteral(org.eclipse.n4js.ts.types.TEnumLiteral) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) EObject(org.eclipse.emf.ecore.EObject) IAcceptor(org.eclipse.xtext.util.IAcceptor) TMember(org.eclipse.n4js.ts.types.TMember)

Aggregations

TEnumLiteral (org.eclipse.n4js.ts.types.TEnumLiteral)4 EObject (org.eclipse.emf.ecore.EObject)3 ContainerType (org.eclipse.n4js.ts.types.ContainerType)2 TMember (org.eclipse.n4js.ts.types.TMember)2 TVariable (org.eclipse.n4js.ts.types.TVariable)2 Type (org.eclipse.n4js.ts.types.Type)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 MemberVisibility (org.eclipse.n4js.scoping.accessModifiers.MemberVisibilityChecker.MemberVisibility)1 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)1 TField (org.eclipse.n4js.ts.types.TField)1 TFunction (org.eclipse.n4js.ts.types.TFunction)1 TModule (org.eclipse.n4js.ts.types.TModule)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 IAcceptor (org.eclipse.xtext.util.IAcceptor)1