use of org.jetbrains.kotlin.utils.KotlinJavascriptMetadata in project kotlin by JetBrains.
the class JsConfig method getModuleDescriptors.
@NotNull
public List<JsModuleDescriptor<ModuleDescriptorImpl>> getModuleDescriptors() {
init();
if (moduleDescriptors != null)
return moduleDescriptors;
moduleDescriptors = new SmartList<JsModuleDescriptor<ModuleDescriptorImpl>>();
List<ModuleDescriptorImpl> kotlinModuleDescriptors = new ArrayList<ModuleDescriptorImpl>();
for (KotlinJavascriptMetadata metadataEntry : metadata) {
JsModuleDescriptor<ModuleDescriptorImpl> descriptor = createModuleDescriptor(metadataEntry);
moduleDescriptors.add(descriptor);
kotlinModuleDescriptors.add(descriptor.getData());
}
for (JsModuleDescriptor<ModuleDescriptorImpl> module : moduleDescriptors) {
// TODO: remove downcast
setDependencies(module.getData(), kotlinModuleDescriptors);
}
moduleDescriptors = Collections.unmodifiableList(moduleDescriptors);
return moduleDescriptors;
}
use of org.jetbrains.kotlin.utils.KotlinJavascriptMetadata in project kotlin by JetBrains.
the class LibrarySourcesConfig method checkLibFilesAndReportErrors.
private boolean checkLibFilesAndReportErrors(@NotNull JsConfig.Reporter report, @Nullable Function1<VirtualFile, Unit> action) {
List<String> libraries = getLibraries();
if (libraries.isEmpty()) {
return false;
}
VirtualFileSystem fileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL);
VirtualFileSystem jarFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JAR_PROTOCOL);
Set<String> modules = new HashSet<String>();
for (String path : libraries) {
VirtualFile file;
File filePath = new File(path);
if (!filePath.exists()) {
report.error("Path '" + path + "' does not exist");
return true;
}
if (path.endsWith(".jar") || path.endsWith(".zip")) {
file = jarFileSystem.findFileByPath(path + URLUtil.JAR_SEPARATOR);
} else {
file = fileSystem.findFileByPath(path);
}
if (file == null) {
report.error("File '" + path + "' does not exist or could not be read");
return true;
}
List<KotlinJavascriptMetadata> metadataList = KotlinJavascriptMetadataUtils.loadMetadata(filePath);
if (metadataList.isEmpty()) {
report.warning("'" + path + "' is not a valid Kotlin Javascript library");
continue;
}
for (KotlinJavascriptMetadata metadata : metadataList) {
if (!metadata.getVersion().isCompatible()) {
report.error("File '" + path + "' was compiled with an incompatible version of Kotlin. " + "The binary version of its metadata is " + metadata.getVersion() + ", expected version is " + JsMetadataVersion.INSTANCE);
return true;
}
if (!modules.add(metadata.getModuleName())) {
report.warning("Module \"" + metadata.getModuleName() + "\" is defined in more, than one file");
}
}
if (action != null) {
action.invoke(file);
}
}
return false;
}
Aggregations