mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-05 00:21:31 +00:00
Do not store external dependencies in ScriptModuleInfo
There is a cache from ScriptModuleInfo to ScriptDependenciesInfo. In case when only script dependencies are changed we won't recreate the facade for them and will obtain external dependencies for ScriptModuleInfo stored in ScriptDependenciesInfo. So we cannot store external dependencies inside ScriptModuleInfo. The same problem is with relatedModuleSourceInfo.
This commit is contained in:
@@ -739,6 +739,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
testClass<AbstractScriptConfigurationHighlightingTest> {
|
||||
model("script/definition/highlighting", extension = null, recursive = false)
|
||||
model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest")
|
||||
}
|
||||
|
||||
testClass<AbstractScriptConfigurationNavigationTest> {
|
||||
|
||||
@@ -737,6 +737,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
testClass<AbstractScriptConfigurationHighlightingTest> {
|
||||
model("script/definition/highlighting", extension = null, recursive = false)
|
||||
model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest")
|
||||
}
|
||||
|
||||
testClass<AbstractScriptConfigurationNavigationTest> {
|
||||
|
||||
@@ -736,6 +736,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
testClass<AbstractScriptConfigurationHighlightingTest> {
|
||||
model("script/definition/highlighting", extension = null, recursive = false)
|
||||
model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest")
|
||||
}
|
||||
|
||||
testClass<AbstractScriptConfigurationNavigationTest> {
|
||||
|
||||
@@ -736,6 +736,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
testClass<AbstractScriptConfigurationHighlightingTest> {
|
||||
model("script/definition/highlighting", extension = null, recursive = false)
|
||||
model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest")
|
||||
}
|
||||
|
||||
testClass<AbstractScriptConfigurationNavigationTest> {
|
||||
|
||||
@@ -35,11 +35,11 @@ data class ScriptModuleInfo(
|
||||
override val moduleOrigin: ModuleOrigin
|
||||
get() = ModuleOrigin.OTHER
|
||||
|
||||
val externalDependencies: ScriptDependencies by lazy {
|
||||
ScriptDependenciesManager.getInstance(project).getScriptDependencies(scriptFile)
|
||||
}
|
||||
val externalDependencies: ScriptDependencies
|
||||
get() = ScriptDependenciesManager.getInstance(project).getScriptDependencies(scriptFile)
|
||||
|
||||
val relatedModuleSourceInfo: ModuleSourceInfo? = getScriptRelatedModuleInfo(project, scriptFile)
|
||||
val relatedModuleSourceInfo: ModuleSourceInfo?
|
||||
get() = getScriptRelatedModuleInfo(project, scriptFile)
|
||||
|
||||
override val name: Name = Name.special("<script ${scriptFile.name} ${scriptDefinition.name}>")
|
||||
|
||||
|
||||
7
idea/testData/script/definition/complex/errorResolver/lib/test/custom.kt
vendored
Normal file
7
idea/testData/script/definition/complex/errorResolver/lib/test/custom.kt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
object KObject {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
7
idea/testData/script/definition/complex/errorResolver/script.kts
vendored
Normal file
7
idea/testData/script/definition/complex/errorResolver/script.kts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
TestDependenciesResolver returns empty dependencies on first request,
|
||||
so ComparasionFailure should fail because 'test' is unresolved
|
||||
Than TestDependenciesResolver returns classpath with classes from 'lib' folder
|
||||
so no errors expected
|
||||
*/
|
||||
test.KObject.foo()
|
||||
27
idea/testData/script/definition/complex/errorResolver/template/template.kt
vendored
Normal file
27
idea/testData/script/definition/complex/errorResolver/template/template.kt
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
package custom.scriptDefinition
|
||||
|
||||
import java.io.File
|
||||
import kotlin.script.dependencies.*
|
||||
import kotlin.script.experimental.dependencies.*
|
||||
import kotlin.script.templates.ScriptTemplateDefinition
|
||||
import kotlin.script.experimental.location.ScriptExpectedLocation
|
||||
import kotlin.script.experimental.location.ScriptExpectedLocations
|
||||
|
||||
var count = 0
|
||||
|
||||
class TestDependenciesResolver : DependenciesResolver {
|
||||
override fun resolve(
|
||||
scriptContents: ScriptContents,
|
||||
environment: Environment
|
||||
): DependenciesResolver.ResolveResult {
|
||||
if (count == 0) {
|
||||
count++
|
||||
return ScriptDependencies.Empty.asSuccess()
|
||||
}
|
||||
return ScriptDependencies(classpath = listOf(environment["lib-classes"] as File)).asSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
@ScriptExpectedLocations([ScriptExpectedLocation.Everywhere])
|
||||
@ScriptTemplateDefinition(TestDependenciesResolver::class, scriptFilePattern = "script.kts")
|
||||
open class Template
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.testFramework.PlatformTestCase
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.exceptionCases.AbstractExceptionCase
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||
import org.jetbrains.kotlin.idea.completion.test.KotlinCompletionTestCase
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionContributor
|
||||
@@ -46,6 +47,7 @@ import org.jetbrains.kotlin.test.util.projectLibrary
|
||||
import org.jetbrains.kotlin.test.util.renderAsGotoImplementation
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.junit.Assert
|
||||
import org.junit.ComparisonFailure
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.script.dependencies.Environment
|
||||
@@ -64,6 +66,20 @@ abstract class AbstractScriptConfigurationHighlightingTest : AbstractScriptConfi
|
||||
InTextDirectivesUtils.isDirectiveDefined(file.text, "// CHECK_INFOS"))
|
||||
}
|
||||
|
||||
fun doComplexTest(path: String) {
|
||||
configureScriptFile(path)
|
||||
assertException(object : AbstractExceptionCase<ComparisonFailure>() {
|
||||
override fun getExpectedExceptionClass(): Class<ComparisonFailure> = ComparisonFailure::class.java
|
||||
|
||||
override fun tryClosure() {
|
||||
checkHighlighting(editor, false, false)
|
||||
}
|
||||
})
|
||||
|
||||
updateScriptDependenciesSynchronously(myFile.virtualFile, project)
|
||||
checkHighlighting(editor, false, false)
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
ApplicationManager.getApplication().isScriptDependenciesUpdaterDisabled = true
|
||||
|
||||
@@ -17,100 +17,121 @@ import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/script/definition/highlighting")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ScriptConfigurationHighlightingTestGenerated extends AbstractScriptConfigurationHighlightingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
@TestMetadata("idea/testData/script/definition/highlighting")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Highlighting extends AbstractScriptConfigurationHighlightingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("acceptedAnnotations")
|
||||
public void testAcceptedAnnotations() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/acceptedAnnotations/");
|
||||
}
|
||||
|
||||
@TestMetadata("additionalImports")
|
||||
public void testAdditionalImports() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/additionalImports/");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInHighlighting() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/script/definition/highlighting"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
}
|
||||
|
||||
@TestMetadata("asyncResolver")
|
||||
public void testAsyncResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/asyncResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("conflictingModule")
|
||||
public void testConflictingModule() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/conflictingModule/");
|
||||
}
|
||||
|
||||
@TestMetadata("customBaseClass")
|
||||
public void testCustomBaseClass() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/customBaseClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("customLibrary")
|
||||
public void testCustomLibrary() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/customLibrary/");
|
||||
}
|
||||
|
||||
@TestMetadata("doNotSpeakAboutJava")
|
||||
public void testDoNotSpeakAboutJava() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/doNotSpeakAboutJava/");
|
||||
}
|
||||
|
||||
@TestMetadata("doNotSpeakAboutJavaLegacy")
|
||||
public void testDoNotSpeakAboutJavaLegacy() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/doNotSpeakAboutJavaLegacy/");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyAsyncResolver")
|
||||
public void testEmptyAsyncResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/emptyAsyncResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("errorResolver")
|
||||
public void testErrorResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/errorResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("javaNestedClass")
|
||||
public void testJavaNestedClass() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/javaNestedClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiModule")
|
||||
public void testMultiModule() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/multiModule/");
|
||||
}
|
||||
|
||||
@TestMetadata("noResolver")
|
||||
public void testNoResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/noResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessor")
|
||||
public void testPropertyAccessor() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/propertyAccessor/");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessorFromModule")
|
||||
public void testPropertyAccessorFromModule() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/propertyAccessorFromModule/");
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/simple/");
|
||||
}
|
||||
|
||||
@TestMetadata("throwingResolver")
|
||||
public void testThrowingResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/throwingResolver/");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("acceptedAnnotations")
|
||||
public void testAcceptedAnnotations() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/acceptedAnnotations/");
|
||||
}
|
||||
@TestMetadata("idea/testData/script/definition/complex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Complex extends AbstractScriptConfigurationHighlightingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doComplexTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("additionalImports")
|
||||
public void testAdditionalImports() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/additionalImports/");
|
||||
}
|
||||
public void testAllFilesPresentInComplex() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/script/definition/complex"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInHighlighting() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/script/definition/highlighting"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
}
|
||||
|
||||
@TestMetadata("asyncResolver")
|
||||
public void testAsyncResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/asyncResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("conflictingModule")
|
||||
public void testConflictingModule() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/conflictingModule/");
|
||||
}
|
||||
|
||||
@TestMetadata("customBaseClass")
|
||||
public void testCustomBaseClass() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/customBaseClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("customLibrary")
|
||||
public void testCustomLibrary() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/customLibrary/");
|
||||
}
|
||||
|
||||
@TestMetadata("doNotSpeakAboutJava")
|
||||
public void testDoNotSpeakAboutJava() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/doNotSpeakAboutJava/");
|
||||
}
|
||||
|
||||
@TestMetadata("doNotSpeakAboutJavaLegacy")
|
||||
public void testDoNotSpeakAboutJavaLegacy() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/doNotSpeakAboutJavaLegacy/");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyAsyncResolver")
|
||||
public void testEmptyAsyncResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/emptyAsyncResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("errorResolver")
|
||||
public void testErrorResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/errorResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("javaNestedClass")
|
||||
public void testJavaNestedClass() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/javaNestedClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiModule")
|
||||
public void testMultiModule() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/multiModule/");
|
||||
}
|
||||
|
||||
@TestMetadata("noResolver")
|
||||
public void testNoResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/noResolver/");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessor")
|
||||
public void testPropertyAccessor() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/propertyAccessor/");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyAccessorFromModule")
|
||||
public void testPropertyAccessorFromModule() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/propertyAccessorFromModule/");
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/simple/");
|
||||
}
|
||||
|
||||
@TestMetadata("throwingResolver")
|
||||
public void testThrowingResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/highlighting/throwingResolver/");
|
||||
@TestMetadata("errorResolver")
|
||||
public void testErrorResolver() throws Exception {
|
||||
runTest("idea/testData/script/definition/complex/errorResolver/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user