Drop non-generated NavigateToDecompiledLibraryTest
It relies on internal data structure
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public abstract class AbstractClass public constructor() {
|
||||
}]]
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public abstract class ClassWithAbstractAndOpenMembers public constructor() {
|
||||
[public abstract val abstractVal: kotlin.String]
|
||||
|
||||
[public abstract var abstractVar: kotlin.String]
|
||||
|
||||
[public open val openVal: kotlin.String /* compiled code */]
|
||||
|
||||
[public open val openValWithGetter: kotlin.String /* compiled code */]
|
||||
|
||||
[public open var openVar: kotlin.String /* compiled code */]
|
||||
|
||||
[public open var openVarWithGetter: kotlin.String /* compiled code */]
|
||||
|
||||
[public abstract fun abstractFun(): kotlin.Unit]
|
||||
|
||||
[public open fun openFun(): kotlin.Unit { /* compiled code */ }]
|
||||
}]]
|
||||
@@ -1,10 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final class ClassWithConstructor public constructor(a: kotlin.String, b: kotlin.Any) {
|
||||
[public constructor(a: kotlin.String) { /* compiled code */ }]
|
||||
|
||||
[public final val a: kotlin.String /* compiled code */]
|
||||
}]]
|
||||
@@ -1,14 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final enum class Color private constructor(rgb: kotlin.Int) : kotlin.Enum<testData.libraries.Color> {
|
||||
[[RED,]]
|
||||
|
||||
[[GREEN,]]
|
||||
|
||||
[[BLUE;]]
|
||||
|
||||
[public final val rgb: kotlin.Int /* compiled code */]
|
||||
}]]
|
||||
@@ -1,6 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[public fun func(str: kotlin.String): kotlin.Unit { /* compiled code */ }]
|
||||
@@ -1,4 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
@@ -1,36 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[public val globalVal: testData.libraries.Pair<kotlin.Int, kotlin.String> /* compiled code */]
|
||||
|
||||
[public val globalValWithGetter: kotlin.Long /* compiled code */]
|
||||
|
||||
[public val kotlin.Int.exProp: kotlin.Int /* compiled code */]
|
||||
|
||||
[public val kotlin.String.exProp: kotlin.String /* compiled code */]
|
||||
|
||||
[public val <T> testData.libraries.Pair<T, T>.exProp: kotlin.String /* compiled code */]
|
||||
|
||||
[public fun <T : kotlin.CharSequence> funWithTypeParam(t: T): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun <T : kotlin.Number> funWithTypeParam(t: T): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun func(): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun func(cs: kotlin.CharSequence): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun func(a: kotlin.Int, b: kotlin.Int): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun func(a: kotlin.Int, b: kotlin.String /* = compiled code */): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun <T> genericFunc(): T { /* compiled code */ }]
|
||||
|
||||
[public fun main(args: kotlin.Array<kotlin.String>): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun processDouble(d: kotlin.Double): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public fun processDouble(d: testData.libraries.Double): kotlin.Unit { /* compiled code */ }]
|
||||
|
||||
[public inline fun <T> T.filter(predicate: (T) -> kotlin.Boolean): T? { /* compiled code */ }]
|
||||
@@ -1,8 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public object NamedObject {
|
||||
[public final val objectMember: kotlin.Int /* compiled code */]
|
||||
}]]
|
||||
@@ -1,7 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final class SimpleClass public constructor() {
|
||||
}]]
|
||||
@@ -1,7 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[public interface SimpleTrait {
|
||||
}]
|
||||
@@ -1,7 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final class SimpleTraitImpl public constructor() : testData.libraries.SimpleTrait {
|
||||
}]]
|
||||
@@ -1,16 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final class WithInnerAndObject public constructor() {
|
||||
[[public companion object {
|
||||
[public final fun foo(): kotlin.Unit { /* compiled code */ }]
|
||||
}]]
|
||||
|
||||
[[public final class MyInner public constructor() {
|
||||
[public interface MyInnerInner {
|
||||
[public abstract fun innerInnerMethod(): kotlin.Unit]
|
||||
}]
|
||||
}]]
|
||||
}]]
|
||||
@@ -1,9 +0,0 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package testData.libraries
|
||||
|
||||
[[public final class WithTraitClassObject public constructor() {
|
||||
[[public companion object : testData.libraries.SimpleTrait {
|
||||
}]]
|
||||
}]]
|
||||
+3
-3
@@ -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.
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.decompiler
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import org.jetbrains.kotlin.idea.caches.IDEKotlinBinaryClassCache
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.findTestLibraryRoot
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -50,7 +50,7 @@ abstract class AbstractInternalCompiledClassesTest : KotlinLightCodeInsightFixtu
|
||||
}
|
||||
|
||||
protected fun doTest(fileKind: String, acceptFile: VirtualFile.() -> Boolean, performTest: VirtualFile.() -> Unit) {
|
||||
val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!!
|
||||
val root = findTestLibraryRoot(myModule!!)!!
|
||||
var foundAtLeastOneFile = false
|
||||
root.checkRecursively {
|
||||
if (acceptFile()) {
|
||||
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.navigation;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile;
|
||||
import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor;
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class NavigateToDecompiledLibraryTest extends LightCodeInsightFixtureTestCase {
|
||||
protected static final String PACKAGE = "testData.libraries";
|
||||
protected static final String TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/decompiler/navigation";
|
||||
|
||||
private VirtualFile classFile;
|
||||
|
||||
public void testAbstractClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testClassWithAbstractAndOpenMembers() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testColor() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleClass() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleTrait() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSimpleTraitImpl() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWithInnerAndObject() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWithTraitClassObject() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testClassWithConstructor() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNamedObject() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMainKt() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExtraKt() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
classFile = getClassFile(PACKAGE, getTestName(false), myModule);
|
||||
PsiFile decompiledPsiFile = PsiManager.getInstance(getProject()).findFile(classFile);
|
||||
assertNotNull(decompiledPsiFile);
|
||||
assertTrue("Expecting kotlin class file, was: " + decompiledPsiFile.getClass(), decompiledPsiFile instanceof KtClsFile);
|
||||
Map<String, KtDeclaration> map = getRenderedDescriptorToKotlinPsiMap(
|
||||
(KtFile) decompiledPsiFile, ((KtClsFile) decompiledPsiFile).getRenderedDescriptorsToRange()
|
||||
);
|
||||
String decompiledTextWithMarks = getDecompiledTextWithMarks(map);
|
||||
|
||||
assertSameLinesWithFile(TEST_DATA_PATH + "/decompiled/" + getTestName(false) + ".kt", decompiledTextWithMarks);
|
||||
}
|
||||
|
||||
private String getDecompiledTextWithMarks(Map<String, KtDeclaration> map) {
|
||||
String decompiledText = getDecompiledText();
|
||||
|
||||
int[] openings = new int[decompiledText.length() + 1];
|
||||
int[] closings = new int[decompiledText.length() + 1];
|
||||
for (KtDeclaration ktDeclaration : map.values()) {
|
||||
TextRange textRange = ktDeclaration.getTextRange();
|
||||
openings[textRange.getStartOffset()]++;
|
||||
closings[textRange.getEndOffset()]++;
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i <= decompiledText.length(); i++) {
|
||||
result.append(StringUtil.repeat("]", closings[i]));
|
||||
result.append(StringUtil.repeat("[", openings[i]));
|
||||
if (i < decompiledText.length()) {
|
||||
result.append(decompiledText.charAt(i));
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String getDecompiledText() {
|
||||
Document document = FileDocumentManager.getInstance().getDocument(classFile);
|
||||
assertNotNull(document);
|
||||
return document.getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Map<String, KtDeclaration> getRenderedDescriptorToKotlinPsiMap(
|
||||
@NotNull KtFile file, @NotNull Map<String, TextRange> renderedDescriptorsToRanges
|
||||
) {
|
||||
Map<String, KtDeclaration> renderedDescriptorsToJetDeclarations = Maps.newHashMap();
|
||||
for (Map.Entry<String, TextRange> renderedDescriptorToRange : renderedDescriptorsToRanges.entrySet()) {
|
||||
String renderedDescriptor = renderedDescriptorToRange.getKey();
|
||||
TextRange range = renderedDescriptorToRange.getValue();
|
||||
KtDeclaration ktDeclaration = PsiTreeUtil.findElementOfClassAtRange(file, range.getStartOffset(), range.getEndOffset(),
|
||||
KtDeclaration.class);
|
||||
assert ktDeclaration != null : "Can't find declaration at " + range + ": "
|
||||
+ file.getText().substring(range.getStartOffset(), range.getEndOffset());
|
||||
renderedDescriptorsToJetDeclarations.put(renderedDescriptor, ktDeclaration);
|
||||
}
|
||||
return renderedDescriptorsToJetDeclarations;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return new JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/library", false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile getClassFile(
|
||||
@NotNull String packageName,
|
||||
@NotNull String className,
|
||||
@NotNull Module module
|
||||
) {
|
||||
VirtualFile root = findTestLibraryRoot(module);
|
||||
assertNotNull(root);
|
||||
VirtualFile packageDir = root.findFileByRelativePath(packageName.replace(".", "/"));
|
||||
assertNotNull(packageDir);
|
||||
VirtualFile classFile = packageDir.findChild(className + ".class");
|
||||
assertNotNull(classFile);
|
||||
return classFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static VirtualFile getKjsmFile(
|
||||
@NotNull String packageName,
|
||||
@NotNull String className,
|
||||
@NotNull Module module
|
||||
) {
|
||||
VirtualFile root = findTestLibraryRoot(module);
|
||||
assertNotNull(root);
|
||||
root.refresh(false, true);
|
||||
VirtualFile packageDir = root.findFileByRelativePath(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME + "/" + packageName.replace(".", "/"));
|
||||
assertNotNull(packageDir);
|
||||
VirtualFile classFile = packageDir.findChild(className + ".kjsm");
|
||||
assertNotNull(classFile);
|
||||
return classFile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile findTestLibraryRoot(@NotNull Module module) {
|
||||
for (OrderEntry orderEntry : ModuleRootManager.getInstance(module).getOrderEntries()) {
|
||||
if (orderEntry instanceof LibraryOrderEntry) {
|
||||
return findTestLibraryRoot((LibraryOrderEntry) orderEntry);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static VirtualFile findTestLibraryRoot(@NotNull LibraryOrderEntry library) {
|
||||
return library.getFiles(OrderRootType.CLASSES)[0];
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -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.
|
||||
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.kotlin.idea.decompiler.stubBuilder
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.findTestLibraryRoot
|
||||
import org.jetbrains.kotlin.idea.test.KotlinJdkAndLibraryProjectDescriptor
|
||||
import java.io.File
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
class ClsStubBuilderForWrongAbiVersionTest : AbstractClsStubBuilderTest() {
|
||||
|
||||
@@ -29,7 +29,7 @@ class ClsStubBuilderForWrongAbiVersionTest : AbstractClsStubBuilderTest() {
|
||||
fun testClass() = testStubsForFileWithWrongAbiVersion("ClassWithWrongAbiVersion")
|
||||
|
||||
private fun testStubsForFileWithWrongAbiVersion(className: String) {
|
||||
val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!!
|
||||
val root = findTestLibraryRoot(myModule!!)!!
|
||||
val result = root.findClassFileByName(className)
|
||||
testClsStubsForFile(result, null)
|
||||
}
|
||||
|
||||
+15
-4
@@ -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,17 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.textBuilder
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest
|
||||
import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.ModuleKind
|
||||
import org.jetbrains.kotlin.idea.test.configureAs
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
abstract class AbstractDecompiledTextFromJsMetadataTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory, true) {
|
||||
override fun getFileToDecompile(): VirtualFile =
|
||||
NavigateToDecompiledLibraryTest.getKjsmFile(TEST_PACKAGE, getTestName(false), myModule!!)
|
||||
override fun getFileToDecompile(): VirtualFile = getKjsmFile(TEST_PACKAGE, getTestName(false), myModule!!)
|
||||
|
||||
override fun checkPsiFile(psiFile: PsiFile) =
|
||||
assertTrue(psiFile is KtDecompiledFile, "Expecting decompiled kotlin javascript file, was: " + psiFile.javaClass)
|
||||
@@ -40,3 +40,14 @@ abstract class AbstractDecompiledTextFromJsMetadataTest(baseDirectory: String) :
|
||||
abstract class AbstractCommonDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledText")
|
||||
|
||||
abstract class AbstractJsDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledTextJs")
|
||||
|
||||
fun getKjsmFile(
|
||||
packageName: String,
|
||||
className: String,
|
||||
module: Module
|
||||
): VirtualFile {
|
||||
val root = findTestLibraryRoot(module)!!
|
||||
root.refresh(false, true)
|
||||
val packageDir = root.findFileByRelativePath(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME + "/" + packageName.replace(".", "/"))!!
|
||||
return packageDir.findChild(className + ".kjsm")!!
|
||||
}
|
||||
+25
-4
@@ -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,16 +16,18 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.textBuilder
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
abstract class AbstractDecompiledTextTest(baseDirectory: String, allowKotlinPackage: Boolean)
|
||||
: AbstractDecompiledTextBaseTest(baseDirectory, allowKotlinPackage = allowKotlinPackage) {
|
||||
override fun getFileToDecompile(): VirtualFile =
|
||||
NavigateToDecompiledLibraryTest.getClassFile(TEST_PACKAGE, getTestName(false), myModule!!)
|
||||
override fun getFileToDecompile(): VirtualFile = getClassFile(TEST_PACKAGE, getTestName(false), myModule!!)
|
||||
|
||||
override fun checkPsiFile(psiFile: PsiFile) =
|
||||
assertTrue(psiFile is KtClsFile, "Expecting decompiled kotlin file, was: " + psiFile.javaClass)
|
||||
@@ -34,3 +36,22 @@ abstract class AbstractDecompiledTextTest(baseDirectory: String, allowKotlinPack
|
||||
abstract class AbstractCommonDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledText", true)
|
||||
|
||||
abstract class AbstractJvmDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledTextJvm", false)
|
||||
|
||||
fun findTestLibraryRoot(module: Module): VirtualFile? {
|
||||
for (orderEntry in ModuleRootManager.getInstance(module).orderEntries) {
|
||||
if (orderEntry is LibraryOrderEntry) {
|
||||
return orderEntry.getFiles(OrderRootType.CLASSES)[0]
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getClassFile(
|
||||
packageName: String,
|
||||
className: String,
|
||||
module: Module
|
||||
): VirtualFile {
|
||||
val root = findTestLibraryRoot(module)!!
|
||||
val packageDir = root.findFileByRelativePath(packageName.replace(".", "/"))!!
|
||||
return packageDir.findChild(className + ".class")!!
|
||||
}
|
||||
+2
-3
@@ -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.
|
||||
@@ -22,7 +22,6 @@ import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.decompiler.AbstractInternalCompiledClassesTest
|
||||
import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile
|
||||
import org.jetbrains.kotlin.idea.decompiler.common.INCOMPATIBLE_ABI_VERSION_GENERAL_COMMENT
|
||||
import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest
|
||||
import org.jetbrains.kotlin.idea.decompiler.stubBuilder.findClassFileByName
|
||||
import org.jetbrains.kotlin.idea.test.KotlinJdkAndLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
@@ -42,7 +41,7 @@ class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClassesTest
|
||||
fun testPackagePartWithWrongAbiVersion() = doTest("Wrong_packageKt")
|
||||
|
||||
fun doTest(name: String) {
|
||||
val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!!
|
||||
val root = findTestLibraryRoot(myModule!!)!!
|
||||
checkFileWithWrongAbiVersion(root.findClassFileByName(name))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user