From 577921d4f76ed3848104b802a6eb42b7a10dab0e Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Thu, 12 Mar 2015 15:14:46 +0300 Subject: [PATCH] add JsHeaderLibraryDetectionUtils.isJsHeaderLibraryWithSources --- .../idea/framework/JsHeaderLibraryDetectionUtil.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsHeaderLibraryDetectionUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsHeaderLibraryDetectionUtil.kt index 459f8d4bdb0..12e7f321644 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsHeaderLibraryDetectionUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsHeaderLibraryDetectionUtil.kt @@ -20,12 +20,22 @@ package org.jetbrains.kotlin.idea.framework import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.js.JavaScript +import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils import kotlin.platform.platformStatic public object JsHeaderLibraryDetectionUtil { platformStatic public fun isJsHeaderLibraryDetected(classesRoots: List): Boolean = + isJsLibraryWithAcceptedFile(classesRoots) { + val extension = it.getExtension() + JetFileType.EXTENSION == extension || + JavaScript.EXTENSION == extension && KotlinJavascriptMetadataUtils.hasMetadata(String(it.contentsToByteArray(false))) + } + + platformStatic + public fun isJsHeaderLibraryWithSources(classesRoots: List): Boolean = isJsLibraryWithAcceptedFile(classesRoots) { JetFileType.EXTENSION == it.getExtension() } private fun isJsLibraryWithAcceptedFile(classesRoots: List, accept: (VirtualFile) -> Boolean): Boolean {