From 7dad1831e92b56ce1867724e6cf9aa07bcf8b6ff Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Mon, 4 Apr 2016 18:37:18 +0300 Subject: [PATCH] Generate stubs only for files from jar #EA-78399 fixed --- .../idea/decompiler/js/KotlinJavaScriptStubBuilder.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt index b07d7aa5638..e1a32bc4f82 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/js/KotlinJavaScriptStubBuilder.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.decompiler.js +import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.compiled.ClsStubBuilder import com.intellij.psi.impl.compiled.ClassFileStubBuilder @@ -41,7 +42,8 @@ class KotlinJavaScriptStubBuilder : ClsStubBuilder() { override fun buildFileStub(content: FileContent): PsiFileStub<*>? { val file = content.file - if (JsMetaFileUtils.isKotlinJavaScriptInternalCompiledFile(file)) return null + if (file.fileSystem.protocol != StandardFileSystems.JAR_PROTOCOL || + JsMetaFileUtils.isKotlinJavaScriptInternalCompiledFile(file)) return null return doBuildFileStub(file) } @@ -54,10 +56,9 @@ class KotlinJavaScriptStubBuilder : ClsStubBuilder() { val moduleDirectory = JsMetaFileUtils.getModuleDirectory(file) val stringsFileName = KotlinJavascriptSerializedResourcePaths.getStringTableFilePath(packageFqName) - val stringsFile = moduleDirectory.findFileByRelativePath(stringsFileName) - assert(stringsFile != null) { "strings file not found: $stringsFileName" } + val stringsFile = moduleDirectory.findFileByRelativePath(stringsFileName) ?: error("strings file not found: $stringsFileName") - val nameResolver = NameResolverImpl.read(ByteArrayInputStream(stringsFile!!.contentsToByteArray(false))) + val nameResolver = NameResolverImpl.read(ByteArrayInputStream(stringsFile.contentsToByteArray(false))) val components = createStubBuilderComponents(file, nameResolver) if (isPackageHeader) {