Introduce HighlightingWithDependentLibrariesTest

This tests that LibraryInfo dependencies affect source files highlighting
This commit is contained in:
Pavel V. Talanov
2014-09-29 21:11:25 +04:00
parent e25cbcd961
commit a8d77887af
9 changed files with 127 additions and 19 deletions
@@ -0,0 +1,9 @@
package lib1
public open class Base {
public open fun baseFun() {
}
}
public fun acceptBase(b: Base) {
}
@@ -0,0 +1,17 @@
package lib2
import lib1.*
public class Derived(): Base() {
public fun derivedFun() {
}
}
public fun acceptBase(b: Base) {
}
public fun returnBase(): Base = Base()
public fun Base.extendBase(): Unit {
}
@@ -0,0 +1,16 @@
package using.libs
import lib2.extendBase
//check that references to lib1 entities obtained through lib2 are valid
fun main() {
lib1.acceptBase(lib1.Base())
lib2.acceptBase(lib1.Base())
lib2.acceptBase(lib2.Derived())
lib1.acceptBase(lib2.Derived())
lib1.acceptBase(lib2.returnBase())
lib1.Base().extendBase()
lib1.Base().baseFun()
lib2.Derived().baseFun()
lib2.Derived().derivedFun()
}
@@ -37,7 +37,7 @@ public class JdkAndMockLibraryProjectDescriptor extends JetLightProjectDescripto
@Override
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
File libraryJar = MockLibraryUtil.compileLibraryToJar(sourcesPath, withSources);
File libraryJar = MockLibraryUtil.compileLibraryToJar(sourcesPath, "myKotlinLib,", withSources);
String jarUrl = "jar://" + FileUtilRt.toSystemIndependentName(libraryJar.getAbsolutePath()) + "!/";
Library.ModifiableModel libraryModel = model.getModuleLibraryTable().getModifiableModel().createLibrary("myKotlinLib").getModifiableModel();
@@ -0,0 +1,58 @@
/*
* Copyright 2010-2014 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.jet.plugin.caches.resolve
import org.jetbrains.jet.plugin.PluginTestCaseBase
import org.jetbrains.jet.MockLibraryUtil
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.command.WriteCommandAction
import java.io.File
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.vfs.VfsUtil
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar
import org.jetbrains.jet.plugin.JetLightProjectDescriptor
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ModifiableRootModel
import com.intellij.openapi.roots.ContentEntry
public class HighlightingWithDependentLibrariesTest : JetLightCodeInsightFixtureTestCase() {
private val TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/highlightingWithDependentLibraries"
override fun getProjectDescriptor() = object : JetLightProjectDescriptor() {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry?) {
val compiledJar1 = MockLibraryUtil.compileLibraryToJar("$TEST_DATA_PATH/lib1", "lib1", false)
val compiledJar2 = MockLibraryUtil.compileLibraryToJar("$TEST_DATA_PATH/lib2", "lib2", false, compiledJar1.canonicalPath)
model.addLibraryEntry(createLibrary(compiledJar1, "baseLibrary"))
model.addLibraryEntry(createLibrary(compiledJar2, "dependentLibrary"))
}
private fun createLibrary(jarFile: File, name: String): Library {
val library = LibraryTablesRegistrar.getInstance()!!.getLibraryTable(getProject()).createLibrary(name)!!
val model = library.getModifiableModel()
model.addRoot(VfsUtil.getUrlForLibraryRoot(jarFile), OrderRootType.CLASSES)
model.commit()
return library
}
}
public fun testHighlightingWithDependentLibraries() {
myFixture.configureByFile("$TEST_DATA_PATH/module/usingLibs.kt")
myFixture.checkHighlighting(false, false, false)
}
}
@@ -124,7 +124,7 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
if (!IS_TINY_APP_COMPILED) {
String modulePath = getTestAppPath();
CUSTOM_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(CUSTOM_LIBRARY_SOURCES.getPath(), true);
CUSTOM_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(CUSTOM_LIBRARY_SOURCES.getPath(), "debuggerCustomLibrary", true);
String outputDir = modulePath + File.separator + "classes";
String sourcesDir = modulePath + File.separator + "src";