Search in sources :

Example 1 with NamedElement

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

the class FunctionDeclarationImpl 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 2 with NamedElement

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

the class ExportedVariableStatementImpl 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 3 with NamedElement

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

the class AnnotationListImpl 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) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) ExportDeclaration(org.eclipse.n4js.n4JS.ExportDeclaration) NamedElement(org.eclipse.n4js.n4JS.NamedElement)

Example 4 with NamedElement

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

the class ExportableElementImpl 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) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) ExportDeclaration(org.eclipse.n4js.n4JS.ExportDeclaration) NamedElement(org.eclipse.n4js.n4JS.NamedElement)

Example 5 with NamedElement

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

the class HyperlinkXpectMethod method getTargetDescription.

private String getTargetDescription(XtextResource resource, IHyperlink hyperlink) {
    final StringBuffer sb = new StringBuffer();
    // append hyperlink text. Only consider the element name and ignore the qualified part.
    String hyperlinkText = hyperlink.getHyperlinkText();
    hyperlinkText = hyperlinkText.substring(hyperlinkText.lastIndexOf('.') + 1);
    if (hyperlinkText != null)
        sb.append(hyperlinkText);
    else
        sb.append("<no hyperlink text>");
    // append description of target element (path from the element to the root of the AST)
    final EObject target = getTarget(resource, hyperlink);
    if (target != null) {
        // build chain of ancestor AST elements
        sb.append(": ");
        final int startLen = sb.length();
        EObject currTarget = target;
        while (currTarget != null) {
            if (currTarget instanceof NamedElement || currTarget instanceof IdentifiableElement) {
                if (sb.length() > startLen)
                    sb.append(" in ");
                String name = currTarget instanceof NamedElement ? ((NamedElement) currTarget).getName() : ((IdentifiableElement) currTarget).getName();
                if (name == null || name.trim().length() == 0)
                    name = "<unnamed>";
                else
                    name = "\"" + name + "\"";
                sb.append(name + "(" + currTarget.eClass().getName() + ")");
            }
            currTarget = currTarget.eContainer();
        }
        // add URI of resource
        final URI targetResURI = target.eResource() != null ? target.eResource().getURI() : null;
        final String fname = targetResURI != null ? targetResURI.lastSegment() : null;
        if (fname != null && fname.trim().length() > 0) {
            sb.append(" in file ");
            sb.append(fname);
        }
    }
    return sb.toString();
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IdentifiableElement(org.eclipse.n4js.ts.types.IdentifiableElement) NamedElement(org.eclipse.n4js.n4JS.NamedElement) URI(org.eclipse.emf.common.util.URI)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)8 NamedElement (org.eclipse.n4js.n4JS.NamedElement)8 IdentifiableElement (org.eclipse.n4js.ts.types.IdentifiableElement)7 ExportDeclaration (org.eclipse.n4js.n4JS.ExportDeclaration)6 ExportableElement (org.eclipse.n4js.n4JS.ExportableElement)6 InternalEObject (org.eclipse.emf.ecore.InternalEObject)5 ArrayDeque (java.util.ArrayDeque)1 URI (org.eclipse.emf.common.util.URI)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ParameterParser (org.eclipse.xpect.parameter.ParameterParser)1 Xpect (org.eclipse.xpect.runner.Xpect)1 ICrossEReferenceAndEObject (org.eclipse.xpect.xtext.lib.util.XtextOffsetAdapter.ICrossEReferenceAndEObject)1 TypeResource (org.eclipse.xtext.common.types.access.TypeResource)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1