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