Search in sources :

Example 46 with TModule

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

the class N4JSDReader method createTypeSpecInfo.

private void createTypeSpecInfo(Type type, Multimap<String, SpecInfo> specInfoByName) {
    SpecInfo typeInfo = new SpecInfo(type);
    String regionName = KeyUtils.getSpecKeyWithoutProjectFolder(rrph, type);
    specInfoByName.put(regionName, typeInfo);
    Collection<SpecInfo> identicalSpecInfo = specInfoByName.get(regionName);
    if (identicalSpecInfo.size() > 1) {
        SpecInfo polyfillAware = null;
        List<SpecInfo> polyfilling = new LinkedList<>();
        for (SpecInfo si : identicalSpecInfo) {
            Type moduleType = si.specElementRef.getElementAsType();
            if (moduleType != null) {
                TModule typeModule = moduleType.getContainingModule();
                if (typeModule.isStaticPolyfillModule()) {
                    polyfilling.add(si);
                } else if (typeModule.isStaticPolyfillAware()) {
                    polyfillAware = si;
                }
            }
        }
        if (polyfillAware != null) {
            Type polyfillAwareType = polyfillAware.specElementRef.getElementAsType();
            for (SpecInfo si : polyfilling) {
                si.specElementRef.polyfillAware = polyfillAwareType;
            }
        }
    }
}
Also used : ContainerType(org.eclipse.n4js.ts.types.ContainerType) Type(org.eclipse.n4js.ts.types.Type) TModule(org.eclipse.n4js.ts.types.TModule) LinkedList(java.util.LinkedList)

Example 47 with TModule

use of org.eclipse.n4js.ts.types.TModule 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) {
    TModule module = idElement.getContainingModule();
    if (// happens when executing tests
    module == null)
        return null;
    Resource res = module.eResource();
    return res;
// if (!module.isStaticPolyfillModule())
// return res;
// 
// EObject container = idElement;
// while (container != null && !(container instanceof TClass))
// container = container.eContainer();
// if (container == null)
// return res;
// TClass tClass = (TClass) container;
// assert (tClass.isPolyfill());
// 
// TClass superClass = tClass.getSuperClass();
// if (superClass == null) // happens when executing tests
// return res;
// 
// TModule superClassModule = superClass.getContainingModule();
// assert (superClassModule.isStaticPolyfillAware());
// 
// return superClassModule.eResource();
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) TModule(org.eclipse.n4js.ts.types.TModule)

Example 48 with TModule

use of org.eclipse.n4js.ts.types.TModule 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) {
    TModule 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) TModule(org.eclipse.n4js.ts.types.TModule)

Aggregations

TModule (org.eclipse.n4js.ts.types.TModule)48 EObject (org.eclipse.emf.ecore.EObject)12 Resource (org.eclipse.emf.ecore.resource.Resource)8 URI (org.eclipse.emf.common.util.URI)7 Type (org.eclipse.n4js.ts.types.Type)7 TMember (org.eclipse.n4js.ts.types.TMember)6 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)4 Script (org.eclipse.n4js.n4JS.Script)4 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)4 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)4 N4JSResource (org.eclipse.n4js.resource.N4JSResource)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 XMIResource (org.eclipse.emf.ecore.xmi.XMIResource)2 XMIResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)2 ImportDeclaration (org.eclipse.n4js.n4JS.ImportDeclaration)2 ContainerType (org.eclipse.n4js.ts.types.ContainerType)2