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;
}
}
}
}
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();
}
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);
}
Aggregations