Search in sources :

Example 11 with AbstractModule

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

the class RepoRelativePathHolder method evadeStaticPolyfillResource.

/**
 * Static polyfill modules are integrated into their corresponding polyfill aware modules. Whenever a static
 * polyfill module is found, this method retrieves the corresponding aware module and returns its resource.
 */
private Resource evadeStaticPolyfillResource(IdentifiableElement idElement) {
    AbstractModule module = idElement.getContainingModule();
    if (// happens when executing tests
    module == null)
        return null;
    Resource res = module.eResource();
    return res;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) AbstractModule(org.eclipse.n4js.ts.types.AbstractModule)

Example 12 with AbstractModule

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

the class SourceEntryFactory method create.

/**
 * Factory method used for any source element.
 */
static SourceEntry create(RepoRelativePathHolder rrph, RepoRelativePath rrpType, IdentifiableElement idElement) {
    AbstractModule containingModule = idElement.getContainingModule();
    if (containingModule == null)
        return null;
    String module = containingModule.getModuleSpecifier().toString();
    String elName = getElementName(idElement);
    String delimiter = getDelimiter(idElement);
    String property = getProperty(idElement);
    RepoRelativePath rrpElement = rrph.get(idElement);
    return newInstance(rrpType, rrpElement, module, elName, delimiter, property, idElement);
}
Also used : RepoRelativePath(org.eclipse.n4js.jsdoc2spec.RepoRelativePath) AbstractModule(org.eclipse.n4js.ts.types.AbstractModule)

Example 13 with AbstractModule

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

the class ImportDeclarationImpl method setModule.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setModule(AbstractModule newModule) {
    AbstractModule oldModule = module;
    module = newModule;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.IMPORT_DECLARATION__MODULE, oldModule, module));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) AbstractModule(org.eclipse.n4js.ts.types.AbstractModule)

Example 14 with AbstractModule

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

the class ScriptApiTracker method interfaceApiSupertypeWalker.

/**
 * This methods takes an API-Element and pulls the projectComparisons along the suptertype chain.
 *
 * Does nothing if apiElement is null.
 *
 * @param filter
 *            applied to each encountered projectComparison
 * @param actionProvider
 *            function to apply on filtered ProjectComparinsonEntries.
 * @param apiElement
 *            concrete API element to start from.
 */
public <T extends TClassifier> void interfaceApiSupertypeWalker(Predicate<? super ProjectComparisonEntry> filter, Function<T, Consumer<? super ProjectComparisonEntry>> actionProvider, ProjectComparisonAdapter projectComparisonAdapter, /* ProjectComparisonEntry compareEntry, */
T apiElement, Class<T> castGuard) {
    if (apiElement == null) {
        // from projects
        return;
    }
    LinkedHashSet<T> toBeProcessedSuperInterfaces = new LinkedHashSet<>();
    LinkedHashSet<T> processedSuperInterfaces = new LinkedHashSet<>();
    // Yes it is correct ~Not correct~, since we need VirtualMethods for the direct missing parts:: //
    toBeProcessedSuperInterfaces.add(apiElement);
    while (!toBeProcessedSuperInterfaces.isEmpty()) {
        Iterator<T> iter = toBeProcessedSuperInterfaces.iterator();
        T pivot = iter.next();
        iter.remove();
        // do not process built-in types
        if (TypeUtils.isBuiltIn(pivot)) {
            continue;
        }
        // collect to be processed:
        includeAdditionsSuperInterfaces2(toBeProcessedSuperInterfaces, processedSuperInterfaces, pivot, castGuard);
        // go over methods.
        // Is the superInterface from the same Project ? If not it cannot be an API problem of this
        // implementation.
        AbstractModule superModule = pivot.getContainingModule();
        if (superModule instanceof TModule) {
            // not required for TDeclaredModule
            ProjectComparisonEntry useCompareEntry = projectComparisonAdapter.getEntryFor((TModule) superModule);
            if (useCompareEntry == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("No comparison found for pivot = " + pivot.getName());
                }
            } else {
                // Is there an API entry at all ? --> If not it was just a normal implementation of some library ?
                ProjectComparisonEntry superInterfaceCompareEntry = useCompareEntry.getChildForElementAPI(pivot);
                if (superInterfaceCompareEntry != null) {
                    // Is there a difference between this API and the implementations ?
                    if (superInterfaceCompareEntry.hasChildren()) {
                        // get the ones which are missing implementations; others are real errors and will not be
                        // touched!
                        superInterfaceCompareEntry.allChildren().filter(filter).forEach(actionProvider.apply(pivot));
                    }
                }
            // end if superInterfaceCompareEntry != null
            }
        } else if (superModule == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("-#- could not get module for super-classifier: " + pivot.getName() + " of type " + pivot.getTypeAsString() + " providedByRuntime=" + pivot.isProvidedByRuntime());
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TModule(org.eclipse.n4js.ts.types.TModule) ProjectComparisonEntry(org.eclipse.n4js.tooling.compare.ProjectComparisonEntry) AbstractModule(org.eclipse.n4js.ts.types.AbstractModule)

Example 15 with AbstractModule

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

the class UserDataMapper method computeCrossRefs.

private static Set<URI> computeCrossRefs(N4JSResource resource) {
    final Set<URI> result = new LinkedHashSet<>();
    final Script script = resource.getScript();
    if (script != null && !script.eIsProxy()) {
        for (ScriptElement elem : script.getScriptElements()) {
            if (elem instanceof ImportDeclaration) {
                final AbstractModule module = ((ImportDeclaration) elem).getModule();
                if (module != null && !module.eIsProxy()) {
                    final Resource targetRes = module.eResource();
                    if (targetRes != null) {
                        final URI uri = targetRes.getURI();
                        if (uri != null) {
                            result.add(uri);
                        }
                    }
                }
            }
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Script(org.eclipse.n4js.n4JS.Script) ScriptElement(org.eclipse.n4js.n4JS.ScriptElement) ImportDeclaration(org.eclipse.n4js.n4JS.ImportDeclaration) XMIResource(org.eclipse.emf.ecore.xmi.XMIResource) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI) AbstractModule(org.eclipse.n4js.ts.types.AbstractModule)

Aggregations

AbstractModule (org.eclipse.n4js.ts.types.AbstractModule)15 TModule (org.eclipse.n4js.ts.types.TModule)5 TMember (org.eclipse.n4js.ts.types.TMember)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 LinkedHashSet (java.util.LinkedHashSet)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 XMIResource (org.eclipse.emf.ecore.xmi.XMIResource)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 RepoRelativePath (org.eclipse.n4js.jsdoc2spec.RepoRelativePath)1 ImportDeclaration (org.eclipse.n4js.n4JS.ImportDeclaration)1 NamedImportSpecifier (org.eclipse.n4js.n4JS.NamedImportSpecifier)1 NamespaceImportSpecifier (org.eclipse.n4js.n4JS.NamespaceImportSpecifier)1 Script (org.eclipse.n4js.n4JS.Script)1 ScriptElement (org.eclipse.n4js.n4JS.ScriptElement)1 N4JSResource (org.eclipse.n4js.resource.N4JSResource)1 ProjectComparisonEntry (org.eclipse.n4js.tooling.compare.ProjectComparisonEntry)1