Search in sources :

Example 6 with ExportableElement

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

the class N4ClassDeclarationImpl method getExportedName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getExportedName() {
    boolean _isExported = this.isExported();
    if (_isExported) {
        EObject _eContainer = this.eContainer();
        final ExportDeclaration exportDecl = ((ExportDeclaration) _eContainer);
        boolean _isDefaultExport = exportDecl.isDefaultExport();
        if (_isDefaultExport) {
            return "default";
        }
        final ExportableElement me = this;
        String _switchResult = null;
        boolean _matched = false;
        if (me instanceof NamedElement) {
            _matched = true;
            _switchResult = ((NamedElement) me).getName();
        }
        if (!_matched) {
            if (me instanceof IdentifiableElement) {
                _matched = true;
                _switchResult = ((IdentifiableElement) me).getName();
            }
        }
        return _switchResult;
    }
    return null;
}
Also used : ExportableElement(org.eclipse.n4js.n4JS.ExportableElement) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) ExportDeclaration(org.eclipse.n4js.n4JS.ExportDeclaration) NamedElement(org.eclipse.n4js.n4JS.NamedElement)

Example 7 with ExportableElement

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

the class ExportDeclarationImpl method basicSetExportedElement.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetExportedElement(ExportableElement newExportedElement, NotificationChain msgs) {
    ExportableElement oldExportedElement = exportedElement;
    exportedElement = newExportedElement;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.EXPORT_DECLARATION__EXPORTED_ELEMENT, oldExportedElement, newExportedElement);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ExportableElement(org.eclipse.n4js.n4JS.ExportableElement) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 8 with ExportableElement

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

the class N4JSDocumentationProvider method getDocumentationNodes.

/**
 * Returns documentation nodes for N4JS AST and type elements (in which case the method returns the nodes of the
 * corresponding AST element). If the AST element has no documentation nodes itself, but is an exportable element,
 * then the documentation of the export statement is returned if present.
 */
@Override
public List<INode> getDocumentationNodes(EObject object) {
    final EObject astNode = N4JSASTUtils.getCorrespondingASTNode(object);
    if (astNode != null) {
        List<INode> nodes = super.getDocumentationNodes(astNode);
        if (nodes.isEmpty() && astNode instanceof VariableDeclaration) {
            TypeRef typeRef = ((VariableDeclaration) astNode).getDeclaredTypeRef();
            if (typeRef != null) {
                nodes = getDocumentationNodes(typeRef);
            }
        }
        if (nodes.isEmpty()) {
            if (astNode instanceof ExportedVariableDeclaration && astNode.eContainer() instanceof ExportedVariableStatement) {
                EList<VariableDeclaration> decls = ((ExportedVariableStatement) astNode.eContainer()).getVarDecl();
                if (decls.size() == 1) {
                    return getDocumentationNodes(astNode.eContainer());
                }
            }
            if (astNode instanceof ExportableElement && astNode.eContainer() instanceof ExportDeclaration) {
                nodes = super.getDocumentationNodes(astNode.eContainer());
            }
        }
        if (nodes.isEmpty()) {
            // failure case, was ASI grabbing the doc?
            // backward search for first non-hidden element, over-stepping if it is a LeafNodeWithSyntaxError from
            // ASI.
            ICompositeNode ptNodeOfASTNode = NodeModelUtils.getNode(astNode);
            LeafNode lNode = searchLeafNodeDocumentation(ptNodeOfASTNode);
            if (lNode != null) {
                return Collections.<INode>singletonList(lNode);
            }
        }
        return nodes;
    }
    return super.getDocumentationNodes(object);
}
Also used : ExportedVariableDeclaration(org.eclipse.n4js.n4JS.ExportedVariableDeclaration) ExportableElement(org.eclipse.n4js.n4JS.ExportableElement) INode(org.eclipse.xtext.nodemodel.INode) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) EObject(org.eclipse.emf.ecore.EObject) LeafNode(org.eclipse.xtext.nodemodel.impl.LeafNode) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) ExportedVariableDeclaration(org.eclipse.n4js.n4JS.ExportedVariableDeclaration) VariableDeclaration(org.eclipse.n4js.n4JS.VariableDeclaration) ExportDeclaration(org.eclipse.n4js.n4JS.ExportDeclaration) ExportedVariableStatement(org.eclipse.n4js.n4JS.ExportedVariableStatement)

Example 9 with ExportableElement

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

the class N4TypeDeclarationImpl method getExportedName.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getExportedName() {
    boolean _isExported = this.isExported();
    if (_isExported) {
        EObject _eContainer = this.eContainer();
        final ExportDeclaration exportDecl = ((ExportDeclaration) _eContainer);
        boolean _isDefaultExport = exportDecl.isDefaultExport();
        if (_isDefaultExport) {
            return "default";
        }
        final ExportableElement me = this;
        String _switchResult = null;
        boolean _matched = false;
        if (me instanceof NamedElement) {
            _matched = true;
            _switchResult = ((NamedElement) me).getName();
        }
        if (!_matched) {
            if (me instanceof IdentifiableElement) {
                _matched = true;
                _switchResult = ((IdentifiableElement) me).getName();
            }
        }
        return _switchResult;
    }
    return null;
}
Also used : ExportableElement(org.eclipse.n4js.n4JS.ExportableElement) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) ExportDeclaration(org.eclipse.n4js.n4JS.ExportDeclaration) NamedElement(org.eclipse.n4js.n4JS.NamedElement)

Aggregations

ExportableElement (org.eclipse.n4js.n4JS.ExportableElement)9 ExportDeclaration (org.eclipse.n4js.n4JS.ExportDeclaration)8 EObject (org.eclipse.emf.ecore.EObject)7 NamedElement (org.eclipse.n4js.n4JS.NamedElement)6 IdentifiableElement (org.eclipse.n4js.ts.types.IdentifiableElement)6 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 ExportedVariableStatement (org.eclipse.n4js.n4JS.ExportedVariableStatement)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ExportedVariableDeclaration (org.eclipse.n4js.n4JS.ExportedVariableDeclaration)1 ScriptElement (org.eclipse.n4js.n4JS.ScriptElement)1 VariableDeclaration (org.eclipse.n4js.n4JS.VariableDeclaration)1 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)1 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)1 INode (org.eclipse.xtext.nodemodel.INode)1 LeafNode (org.eclipse.xtext.nodemodel.impl.LeafNode)1