Search in sources :

Example 1 with ImportSpecifier

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

the class OriginAwareScope method getSingleElement.

/**
 * Enhanced query-Method marking the originating import as used.
 *
 * @see org.eclipse.xtext.scoping.IScope#getSingleElement(org.eclipse.xtext.naming.QualifiedName)
 */
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
    IEObjectDescription ret = delegatee.getSingleElement(name);
    if (ret == null)
        return null;
    ImportSpecifier origin = origins.get(ret);
    if (origin != null) {
        EObject script = EcoreUtil.getRootContainer(origin);
        if ((script instanceof Script) && ((Script) script).isFlaggedUsageMarkingFinished()) {
        // do nothing as linking phase is over
        } else {
            // return usage aware description
            return getUsageAwareDescription(ret);
        }
    }
    return ret;
}
Also used : ImportSpecifier(org.eclipse.n4js.n4JS.ImportSpecifier) Script(org.eclipse.n4js.n4JS.Script) EObject(org.eclipse.emf.ecore.EObject) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 2 with ImportSpecifier

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

the class N4IDLVersionedImportsTransformation method transformVersionedImportSpecifier.

/**
 * Replaces the given versioned import specifier, by multiple named imports.
 *
 * Only adds new imports for type versions that are actually used in the module.
 */
private void transformVersionedImportSpecifier(VersionedNamedImportSpecifier_IM importSpecifier) {
    // determine the type versions that are actually used in this module
    Collection<SymbolTableEntryOriginal> typeVersionSTEs = findSymbolTableEntriesForVersionedTypeImport(importSpecifier);
    // Add a new named import for each imported type version
    typeVersionSTEs.forEach(ste -> {
        // remove specifier reference from entry (as we have just removed it from the IM)
        ste.setImportSpecifier(null);
        // add new import for this specific version
        addNamedImport(ste, null);
        // obtain newly created specifier via STE
        ImportSpecifier createdSpecifier = ste.getImportSpecifier();
        // make sure to retain trace of the original IM specifier
        getState().tracer.copyTrace(importSpecifier, createdSpecifier);
    });
    // remove implicitly versioned import from IM
    remove(importSpecifier);
}
Also used : ImportSpecifier(org.eclipse.n4js.n4JS.ImportSpecifier) SymbolTableEntryOriginal(org.eclipse.n4js.transpiler.im.SymbolTableEntryOriginal)

Example 3 with ImportSpecifier

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

the class SymbolTableEntryOriginalImpl method setImportSpecifier.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setImportSpecifier(ImportSpecifier newImportSpecifier) {
    ImportSpecifier oldImportSpecifier = importSpecifier;
    importSpecifier = newImportSpecifier;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ImPackage.SYMBOL_TABLE_ENTRY_ORIGINAL__IMPORT_SPECIFIER, oldImportSpecifier, importSpecifier));
}
Also used : ImportSpecifier(org.eclipse.n4js.n4JS.ImportSpecifier) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

ImportSpecifier (org.eclipse.n4js.n4JS.ImportSpecifier)3 EObject (org.eclipse.emf.ecore.EObject)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Script (org.eclipse.n4js.n4JS.Script)1 SymbolTableEntryOriginal (org.eclipse.n4js.transpiler.im.SymbolTableEntryOriginal)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1