diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt.as32 b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt.as32 new file mode 100644 index 00000000000..bf033e0c340 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt.as32 @@ -0,0 +1,151 @@ +/* + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve + +import com.intellij.openapi.util.Key +import org.jetbrains.kotlin.container.StorageComponentContainer +import org.jetbrains.kotlin.container.composeContainer +import org.jetbrains.kotlin.container.useInstance +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.UserDataProperty +import org.jetbrains.kotlin.resolve.calls.checkers.* +import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator +import org.jetbrains.kotlin.resolve.checkers.* +import org.jetbrains.kotlin.resolve.lazy.DelegationFilter +import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes +import org.jetbrains.kotlin.storage.LockBasedStorageManager +import org.jetbrains.kotlin.types.DynamicTypesSettings +import java.util.* + +abstract class TargetPlatform(val platformName: String) { + override fun toString() = platformName + + abstract val platformConfigurator: PlatformConfigurator + abstract fun getDefaultImports(includeKotlinComparisons: Boolean): List + open val excludedImports: List get() = emptyList() + + abstract val multiTargetPlatform: MultiTargetPlatform + + object Common : TargetPlatform("Default") { + private val defaultImports = + LockBasedStorageManager().createMemoizedFunction> { includeKotlinComparisons -> + ArrayList().apply { + listOf( + "kotlin.*", + "kotlin.annotation.*", + "kotlin.collections.*", + "kotlin.ranges.*", + "kotlin.sequences.*", + "kotlin.text.*", + "kotlin.io.*" + ).forEach { add(ImportPath.fromString(it)) } + + if (includeKotlinComparisons) { + add(ImportPath.fromString("kotlin.comparisons.*")) + } + } + } + + override fun getDefaultImports(includeKotlinComparisons: Boolean): List = defaultImports(includeKotlinComparisons) + + override val platformConfigurator = + object : PlatformConfigurator( + DynamicTypesSettings(), listOf(), listOf(), listOf(), listOf(), listOf(), + IdentifierChecker.Default, OverloadFilter.Default, PlatformToKotlinClassMap.EMPTY, DelegationFilter.Default, + OverridesBackwardCompatibilityHelper.Default, + DeclarationReturnTypeSanitizer.Default + ) { + override fun configureModuleComponents(container: StorageComponentContainer) { + container.useInstance(SyntheticScopes.Empty) + container.useInstance(TypeSpecificityComparator.NONE) + } + } + + override val multiTargetPlatform: MultiTargetPlatform + get() = MultiTargetPlatform.Common + } +} + +private val DEFAULT_DECLARATION_CHECKERS = listOf( + DataClassDeclarationChecker(), + ConstModifierChecker, + UnderscoreChecker, + InlineParameterChecker, + InfixModifierChecker(), + SinceKotlinAnnotationValueChecker, + RequireKotlinAnnotationValueChecker, + ReifiedTypeParameterAnnotationChecker(), + DynamicReceiverChecker, + DelegationChecker(), + KClassWithIncorrectTypeArgumentChecker, + SuspendOperatorsCheckers, + InlineClassDeclarationChecker +) + +private val DEFAULT_CALL_CHECKERS = listOf( + CapturingInClosureChecker(), InlineCheckerWrapper(), SafeCallChecker(), + DeprecatedCallChecker, CallReturnsArrayOfNothingChecker(), InfixCallChecker(), OperatorCallChecker(), + ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, ApiVersionCallChecker, + CoroutineSuspendCallChecker, BuilderFunctionsCallChecker, DslScopeViolationCallChecker, MissingDependencyClassChecker, + CallableReferenceCompatibilityChecker(), LateinitIntrinsicApplicabilityChecker, + UnderscoreUsageChecker, AssigningNamedArgumentToVarargChecker(), + PrimitiveNumericComparisonCallChecker, LambdaWithSuspendModifierCallChecker +) +private val DEFAULT_TYPE_CHECKERS = emptyList() +private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf( + DeprecatedClassifierUsageChecker(), ApiVersionClassifierUsageChecker, MissingDependencyClassChecker.ClassifierUsage +) +private val DEFAULT_ANNOTATION_CHECKERS = listOf( + ExperimentalMarkerDeclarationAnnotationChecker +) + + +abstract class PlatformConfigurator( + private val dynamicTypesSettings: DynamicTypesSettings, + additionalDeclarationCheckers: List, + additionalCallCheckers: List, + additionalTypeCheckers: List, + additionalClassifierUsageCheckers: List, + additionalAnnotationCheckers: List, + private val identifierChecker: IdentifierChecker, + private val overloadFilter: OverloadFilter, + private val platformToKotlinClassMap: PlatformToKotlinClassMap, + private val delegationFilter: DelegationFilter, + private val overridesBackwardCompatibilityHelper: OverridesBackwardCompatibilityHelper, + private val declarationReturnTypeSanitizer: DeclarationReturnTypeSanitizer +) { + private val declarationCheckers: List = DEFAULT_DECLARATION_CHECKERS + additionalDeclarationCheckers + private val callCheckers: List = DEFAULT_CALL_CHECKERS + additionalCallCheckers + private val typeCheckers: List = DEFAULT_TYPE_CHECKERS + additionalTypeCheckers + private val classifierUsageCheckers: List = + DEFAULT_CLASSIFIER_USAGE_CHECKERS + additionalClassifierUsageCheckers + private val annotationCheckers: List = DEFAULT_ANNOTATION_CHECKERS + additionalAnnotationCheckers + + abstract fun configureModuleComponents(container: StorageComponentContainer) + + val platformSpecificContainer = composeContainer(this::class.java.simpleName) { + useInstance(dynamicTypesSettings) + declarationCheckers.forEach { useInstance(it) } + callCheckers.forEach { useInstance(it) } + typeCheckers.forEach { useInstance(it) } + classifierUsageCheckers.forEach { useInstance(it) } + annotationCheckers.forEach { useInstance(it) } + useInstance(identifierChecker) + useInstance(overloadFilter) + useInstance(platformToKotlinClassMap) + useInstance(delegationFilter) + useInstance(overridesBackwardCompatibilityHelper) + useInstance(declarationReturnTypeSanitizer) + } +} + +fun createContainer(id: String, platform: TargetPlatform, init: StorageComponentContainer.() -> Unit) = + composeContainer(id, platform.platformConfigurator.platformSpecificContainer, init) + + +var KtFile.targetPlatform: TargetPlatform? by UserDataProperty(Key.create("TARGET_PLATFORM")) \ No newline at end of file diff --git a/compiler/tests-common/build.gradle.kts.as32 b/compiler/tests-common/build.gradle.kts.as32 deleted file mode 100644 index e8e570c7e49..00000000000 --- a/compiler/tests-common/build.gradle.kts.as32 +++ /dev/null @@ -1,47 +0,0 @@ - -plugins { - kotlin("jvm") - id("jps-compatible") -} - -dependencies { - testCompile(project(":core:descriptors")) - testCompile(project(":core:descriptors.jvm")) - testCompile(project(":core:deserialization")) - testCompile(project(":compiler:util")) - testCompile(project(":compiler:backend")) - testCompile(project(":compiler:ir.ir2cfg")) - testCompile(project(":compiler:frontend")) - testCompile(project(":compiler:frontend.java")) - testCompile(project(":compiler:util")) - testCompile(project(":compiler:cli-common")) - testCompile(project(":compiler:cli")) - testCompile(project(":compiler:light-classes")) - testCompile(project(":compiler:serialization")) - testCompile(project(":kotlin-preloader")) - testCompile(project(":compiler:daemon-common")) - testCompile(project(":js:js.serializer")) - testCompile(project(":js:js.frontend")) - testCompile(project(":js:js.translator")) - testCompileOnly(project(":plugins:android-extensions-compiler")) - testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) - testCompile(projectTests(":compiler:tests-common-jvm6")) - testCompileOnly(project(":kotlin-reflect-api")) - testCompile(commonDep("junit:junit")) - testCompile(project(":kotlin-scripting-compiler")) - testCompile(project(":kotlin-scripting-misc")) - testCompile(project(":kotlin-script-util")) - testCompile(androidDxJar()) { isTransitive = false } - testCompile(intellijCoreDep()) { includeJars("intellij-core"); isTransitive = false } - testCompile(intellijDep()) { - includeJars("openapi", "idea", "idea_rt", "guava", "trove4j", "picocontainer", "asm-all", "log4j", "jdom", "bootstrap", "annotations", rootProject = rootProject) - isTransitive = false - } -} - -sourceSets { - "main" { } - "test" { projectDefault() } -} - -testsJar {} diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtParsingTestCase.java.as32 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtParsingTestCase.java.as32 new file mode 100644 index 00000000000..8f3c83f41c7 --- /dev/null +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtParsingTestCase.java.as32 @@ -0,0 +1,336 @@ +/* + * Copyright 2000-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. + * 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.test.testFramework; + +import com.intellij.core.CoreASTFactory; +import com.intellij.lang.*; +import com.intellij.lang.impl.PsiBuilderFactoryImpl; +import com.intellij.mock.MockFileDocumentManagerImpl; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.application.PathManager; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.EditorFactory; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.fileEditor.impl.LoadTextUtil; +import com.intellij.openapi.fileTypes.FileTypeFactory; +import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.progress.EmptyProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.progress.impl.CoreProgressManager; +import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.CharsetToolkit; +import com.intellij.pom.PomModel; +import com.intellij.pom.core.impl.PomModelImpl; +import com.intellij.pom.tree.TreeAspect; +import com.intellij.psi.*; +import com.intellij.psi.impl.*; +import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; +import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl; +import com.intellij.psi.util.CachedValuesManager; +import com.intellij.testFramework.LightVirtualFile; +import com.intellij.testFramework.TestDataFile; +import com.intellij.util.CachedValuesManagerImpl; +import com.intellij.util.Function; +import com.intellij.util.messages.MessageBus; +import com.intellij.util.messages.MessageBusFactory; +import junit.framework.TestCase; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.kotlin.test.testFramework.mock.*; +import org.picocontainer.ComponentAdapter; +import org.picocontainer.MutablePicoContainer; + +import java.io.File; +import java.io.IOException; +import java.util.Set; + +@SuppressWarnings("ALL") +public abstract class KtParsingTestCase extends KtPlatformLiteFixture { + public static final Key HARD_REF_TO_DOCUMENT_KEY = Key.create("HARD_REF_TO_DOCUMENT_KEY"); + protected String myFilePrefix = ""; + protected String myFileExt; + protected final String myFullDataPath; + protected PsiFile myFile; + private MockPsiManager myPsiManager; + private PsiFileFactoryImpl myFileFactory; + protected Language myLanguage; + private final ParserDefinition[] myDefinitions; + private final boolean myLowercaseFirstLetter; + + protected KtParsingTestCase(@NonNls @NotNull String dataPath, @NotNull String fileExt, @NotNull ParserDefinition... definitions) { + this(dataPath, fileExt, false, definitions); + } + + protected KtParsingTestCase(@NonNls @NotNull String dataPath, @NotNull String fileExt, boolean lowercaseFirstLetter, @NotNull ParserDefinition... definitions) { + myDefinitions = definitions; + myFullDataPath = getTestDataPath() + "/" + dataPath; + myFileExt = fileExt; + myLowercaseFirstLetter = lowercaseFirstLetter; + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + initApplication(); + ComponentAdapter component = getApplication().getPicoContainer().getComponentAdapter(ProgressManager.class.getName()); + + Extensions.registerAreaClass("IDEA_PROJECT", null); + myProject = new MockProjectEx(getTestRootDisposable()); + myPsiManager = new MockPsiManager(myProject); + myFileFactory = new PsiFileFactoryImpl(myPsiManager); + MutablePicoContainer appContainer = getApplication().getPicoContainer(); + registerComponentInstance(appContainer, MessageBus.class, MessageBusFactory.newMessageBus(getApplication())); + final MockEditorFactory editorFactory = new MockEditorFactory(); + registerComponentInstance(appContainer, EditorFactory.class, editorFactory); + registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function() { + @Override + public Document fun(CharSequence charSequence) { + return editorFactory.createDocument(charSequence); + } + }, HARD_REF_TO_DOCUMENT_KEY)); + registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager()); + registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl()); + registerApplicationService(DefaultASTFactory.class, new CoreASTFactory()); + registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl()); + + registerApplicationService(ProgressManager.class, new CoreProgressManager()); + + myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager))); + myProject.registerService(PsiManager.class, myPsiManager); + + this.registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class); + registerExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class); + + for (ParserDefinition definition : myDefinitions) { + addExplicitExtension(LanguageParserDefinitions.INSTANCE, definition.getFileNodeType().getLanguage(), definition); + } + if (myDefinitions.length > 0) { + configureFromParserDefinition(myDefinitions[0], myFileExt); + } + + // That's for reparse routines + final PomModelImpl pomModel = new PomModelImpl(myProject); + myProject.registerService(PomModel.class, pomModel); + new TreeAspect(pomModel); + } + + public void configureFromParserDefinition(ParserDefinition definition, String extension) { + myLanguage = definition.getFileNodeType().getLanguage(); + myFileExt = extension; + addExplicitExtension(LanguageParserDefinitions.INSTANCE, this.myLanguage, definition); + registerComponentInstance( + getApplication().getPicoContainer(), FileTypeManager.class, + new KtMockFileTypeManager(new KtMockLanguageFileType(myLanguage, myFileExt))); + } + + protected void addExplicitExtension(final LanguageExtension instance, final Language language, final T object) { + instance.addExplicitExtension(language, object); + Disposer.register(myProject, new Disposable() { + @Override + public void dispose() { + instance.removeExplicitExtension(language, object); + } + }); + } + + @Override + protected void registerExtensionPoint(final ExtensionPointName extensionPointName, Class aClass) { + super.registerExtensionPoint(extensionPointName, aClass); + Disposer.register(myProject, new Disposable() { + @Override + public void dispose() { + Extensions.getRootArea().unregisterExtensionPoint(extensionPointName.getName()); + } + }); + } + + protected void registerApplicationService(final Class aClass, T object) { + getApplication().registerService(aClass, object); + Disposer.register(myProject, new Disposable() { + @Override + public void dispose() { + getApplication().getPicoContainer().unregisterComponent(aClass.getName()); + } + }); + } + + public MockProjectEx getProject() { + return myProject; + } + + public MockPsiManager getPsiManager() { + return myPsiManager; + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + myFile = null; + myProject = null; + myPsiManager = null; + } + + protected String getTestDataPath() { + return PathManager.getHomePath(); + } + + @NotNull + public final String getTestName() { + return getTestName(myLowercaseFirstLetter); + } + + protected boolean includeRanges() { + return false; + } + + protected boolean skipSpaces() { + return false; + } + + protected boolean checkAllPsiRoots() { + return true; + } + + protected void doTest(boolean checkResult) { + String name = getTestName(); + try { + String text = loadFile(name + "." + myFileExt); + myFile = createPsiFile(name, text); + ensureParsed(myFile); + assertEquals("light virtual file text mismatch", text, ((LightVirtualFile)myFile.getVirtualFile()).getContent().toString()); + assertEquals("virtual file text mismatch", text, LoadTextUtil.loadText(myFile.getVirtualFile())); + assertEquals("doc text mismatch", text, myFile.getViewProvider().getDocument().getText()); + assertEquals("psi text mismatch", text, myFile.getText()); + ensureCorrectReparse(myFile); + if (checkResult){ + checkResult(name, myFile); + } + else{ + toParseTreeText(myFile, skipSpaces(), includeRanges()); + } + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + protected void doTest(String suffix) throws IOException { + String name = getTestName(); + String text = loadFile(name + "." + myFileExt); + myFile = createPsiFile(name, text); + ensureParsed(myFile); + assertEquals(text, myFile.getText()); + checkResult(name + suffix, myFile); + } + + protected void doCodeTest(String code) throws IOException { + String name = getTestName(); + myFile = createPsiFile("a", code); + ensureParsed(myFile); + assertEquals(code, myFile.getText()); + checkResult(myFilePrefix + name, myFile); + } + + protected PsiFile createPsiFile(String name, String text) { + return createFile(name + "." + myFileExt, text); + } + + protected PsiFile createFile(@NonNls String name, String text) { + LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text); + virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET); + return createFile(virtualFile); + } + + protected PsiFile createFile(LightVirtualFile virtualFile) { + return myFileFactory.trySetupPsiForFile(virtualFile, myLanguage, true, false); + } + + protected void checkResult(@NonNls @TestDataFile String targetDataName, final PsiFile file) throws IOException { + doCheckResult(myFullDataPath, file, checkAllPsiRoots(), targetDataName, skipSpaces(), includeRanges()); + } + + public static void doCheckResult(String testDataDir, + PsiFile file, + boolean checkAllPsiRoots, + String targetDataName, + boolean skipSpaces, + boolean printRanges) throws IOException { + FileViewProvider provider = file.getViewProvider(); + Set languages = provider.getLanguages(); + + if (!checkAllPsiRoots || languages.size() == 1) { + doCheckResult(testDataDir, targetDataName + ".txt", toParseTreeText(file, skipSpaces, printRanges).trim()); + return; + } + + for (Language language : languages) { + PsiFile root = provider.getPsi(language); + String expectedName = targetDataName + "." + language.getID() + ".txt"; + doCheckResult(testDataDir, expectedName, toParseTreeText(root, skipSpaces, printRanges).trim()); + } + } + + protected void checkResult(String actual) throws IOException { + String name = getTestName(); + doCheckResult(myFullDataPath, myFilePrefix + name + ".txt", actual); + } + + protected void checkResult(@TestDataFile @NonNls String targetDataName, String actual) throws IOException { + doCheckResult(myFullDataPath, targetDataName, actual); + } + + public static void doCheckResult(String fullPath, String targetDataName, String actual) throws IOException { + String expectedFileName = fullPath + File.separatorChar + targetDataName; + KtUsefulTestCase.assertSameLinesWithFile(expectedFileName, actual); + } + + protected static String toParseTreeText(PsiElement file, boolean skipSpaces, boolean printRanges) { + return DebugUtil.psiToString(file, skipSpaces, printRanges); + } + + protected String loadFile(@NonNls @TestDataFile String name) throws IOException { + return loadFileDefault(myFullDataPath, name); + } + + public static String loadFileDefault(String dir, String name) throws IOException { + return FileUtil.loadFile(new File(dir, name), CharsetToolkit.UTF8, true).trim(); + } + + public static void ensureParsed(PsiFile file) { + file.accept(new PsiElementVisitor() { + @Override + public void visitElement(PsiElement element) { + element.acceptChildren(this); + } + }); + } + + public static void ensureCorrectReparse(@NotNull PsiFile file) { + String psiToStringDefault = DebugUtil.psiToString(file, false, false); + String fileText = file.getText(); + DiffLog diffLog = (new BlockSupportImpl(file.getProject())).reparseRange( + file, file.getNode(), TextRange.allOf(fileText), fileText, new EmptyProgressIndicator(), fileText); + diffLog.performActualPsiChange(file); + + TestCase.assertEquals(psiToStringDefault, DebugUtil.psiToString(file, false, false)); + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt.as32 b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt.as32 index ec465aa70ae..65951e76900 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt.as32 +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt.as32 @@ -54,7 +54,7 @@ class KotlinCallerChooser( previousTree: Tree?, callback: Consumer> ): CallerChooserBase(declaration, project, title, previousTree, "dummy." + KotlinFileType.EXTENSION, callback) { - override fun createTreeNode(method: PsiElement?, called: com.intellij.util.containers.HashSet, cancelCallback: Runnable): KotlinMethodNode { + override fun createTreeNode(method: PsiElement, called: HashSet, cancelCallback: Runnable): KotlinMethodNode { return KotlinMethodNode(method, called, myProject, cancelCallback) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinInTempDirTest.kt.as32 b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinInTempDirTest.kt.as32 index 1a4a730db83..38bd43f41c6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinInTempDirTest.kt.as32 +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinInTempDirTest.kt.as32 @@ -8,13 +8,13 @@ package org.jetbrains.kotlin.idea.configuration import com.intellij.openapi.util.io.FileUtil import org.junit.Assert import java.io.File -import java.io.IOException +import java.nio.file.Path abstract class AbstractConfigureKotlinInTempDirTest : AbstractConfigureKotlinTest() { - @Throws(IOException::class) - override fun getIprFile(): File { + override fun getProjectDirOrFile(): Path { val tempDir = FileUtil.generateRandomTemporaryPath() FileUtil.createTempDirectory("temp", null) + myFilesToDelete.add(tempDir) FileUtil.copyDir(File(projectRoot), tempDir) @@ -24,8 +24,9 @@ abstract class AbstractConfigureKotlinInTempDirTest : AbstractConfigureKotlinTes if (!File(projectFilePath).exists()) { val dotIdeaPath = projectRoot + "/.idea" Assert.assertTrue("Project file or '.idea' dir should exists in " + projectRoot, File(dotIdeaPath).exists()) - return File(projectRoot) + return File(projectRoot).toPath() } - return File(projectFilePath) + + return File(projectFilePath).toPath() } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt.as32 b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt.as32 index ffa6c40d6ce..46f2a10fae6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt.as32 +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt.as32 @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.idea.framework.KotlinSdkType import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.utils.PathUtil import java.io.File -import java.io.IOException +import java.nio.file.Path abstract class AbstractConfigureKotlinTest : PlatformTestCase() { override fun setUp() { @@ -126,16 +126,14 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() { val modules: Array get() = ModuleManager.getInstance(myProject).modules - @Throws(IOException::class) - override fun getIprFile(): File { + override fun getProjectDirOrFile(): Path { val projectFilePath = projectRoot + "/projectFile.ipr" TestCase.assertTrue("Project file should exists " + projectFilePath, File(projectFilePath).exists()) - return File(projectFilePath) + return File(projectFilePath).toPath() } - @Throws(Exception::class) - override fun doCreateProject(projectFile: File): Project? { - return myProjectManager.loadProject(projectFile.path) + override fun doCreateProject(projectFile: Path): Project { + return myProjectManager.loadProject(projectFile.toFile().path)!! } private val projectName: String diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt.as32 b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt.as32 index d4eb4b8ce50..62f47fa44f1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt.as32 +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt.as32 @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.configuration import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.impl.ApplicationImpl +import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider import org.jetbrains.kotlin.config.LanguageVersion @@ -25,13 +26,15 @@ import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgu import org.jetbrains.kotlin.idea.project.getLanguageVersionSettings import org.jetbrains.kotlin.idea.project.languageVersionSettings import org.junit.Assert +import java.io.File import java.io.IOException +import java.nio.file.Path open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() { @Throws(IOException::class) fun testNoKotlincExistsNoSettingsRuntime10() { val application = ApplicationManager.getApplication() as ApplicationImpl - application.doNotSave(false) + application.isSaveAllowed = true Assert.assertEquals(LanguageVersion.KOTLIN_1_0, module.languageVersionSettings.languageVersion) Assert.assertEquals(LanguageVersion.KOTLIN_1_0, myProject.getLanguageVersionSettings(null).languageVersion) application.saveAll() @@ -40,7 +43,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() fun testNoKotlincExistsNoSettingsLatestRuntime() { val application = ApplicationManager.getApplication() as ApplicationImpl - application.doNotSave(false) + application.isSaveAllowed = true Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion) Assert.assertEquals(LanguageVersion.LATEST_STABLE, myProject.getLanguageVersionSettings(null).languageVersion) application.saveAll() @@ -49,7 +52,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() fun testKotlincExistsNoSettingsLatestRuntimeNoVersionAutoAdvance() { val application = ApplicationManager.getApplication() as ApplicationImpl - application.doNotSave(false) + application.isSaveAllowed = true Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion) Assert.assertEquals(LanguageVersion.LATEST_STABLE, myProject.getLanguageVersionSettings(null).languageVersion) KotlinCommonCompilerArgumentsHolder.getInstance(project).update { @@ -62,7 +65,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() fun testDropKotlincOnVersionAutoAdvance() { val application = ApplicationManager.getApplication() as ApplicationImpl - application.doNotSave(false) + application.isSaveAllowed = true Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion) KotlinCommonCompilerArgumentsHolder.getInstance(project).update { autoAdvanceLanguageVersion = true @@ -97,7 +100,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() fun testLoadAndSaveProjectWithV2FacetConfig() { val moduleFileContentBefore = String(module.moduleFile!!.contentsToByteArray()) val application = ApplicationManager.getApplication() as ApplicationImpl - application.doNotSave(false) + application.isSaveAllowed = true application.saveAll() val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray()) Assert.assertEquals(moduleFileContentBefore, moduleFileContentAfter) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt.as32 b/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt.as32 index afc6882b592..504c9448f77 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt.as32 +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/CommonIntentionActionsTest.kt.as32 @@ -39,15 +39,28 @@ import org.junit.Assert class CommonIntentionActionsTest : LightPlatformCodeInsightFixtureTestCase() { private class SimpleMethodRequest( - project: Project, - override val methodName: String, - override val modifiers: Collection = emptyList(), - override val returnType: ExpectedTypes = emptyList(), - override val annotations: Collection = emptyList(), - override val parameters: List = emptyList(), - override val targetSubstitutor: JvmSubstitutor = PsiJvmSubstitutor(project, PsiSubstitutor.EMPTY) + project: Project, + private val methodName: String, + private val modifiers: Collection = emptyList(), + private val returnType: ExpectedTypes = emptyList(), + private val annotations: Collection = emptyList(), + private val parameters: List>> = emptyList(), + private val targetSubstitutor: JvmSubstitutor = PsiJvmSubstitutor(project, PsiSubstitutor.EMPTY) ) : CreateMethodRequest { - override val isValid: Boolean = true + override fun getTargetSubstitutor(): JvmSubstitutor = targetSubstitutor + + override fun getModifiers() = modifiers + + override fun getMethodName() = methodName + + override fun getAnnotations() = annotations + + override fun getParameters() = parameters + + override fun getReturnType() = returnType + + override fun isValid(): Boolean = true + } private class NameInfo(vararg names: String) : SuggestedNameInfo(names) diff --git a/jps-plugin/build.gradle.kts.as32 b/jps-plugin/build.gradle.kts.as32 index 90688be0dcf..cda3049efd3 100644 --- a/jps-plugin/build.gradle.kts.as32 +++ b/jps-plugin/build.gradle.kts.as32 @@ -16,7 +16,7 @@ dependencies { compile(projectRuntimeJar(":kotlin-preloader")) compile(project(":idea:idea-jps-common")) compileOnly(group = "org.jetbrains", name = "annotations", version = "13.0") - compileOnly(intellijDep()) { includeJars("jdom", "trove4j", "jps-model", "openapi", "util", "asm-all") } + compileOnly(intellijDep()) { includeJars("jdom", "trove4j", "jps-model", "openapi", "platform-api", "util", "asm-all") } compileOnly(intellijDep("jps-standalone")) { includeJars("jps-builders", "jps-builders-6") } testCompileOnly(project(":kotlin-reflect-api")) testCompile(project(":compiler:incremental-compilation-impl")) @@ -26,7 +26,7 @@ dependencies { testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) testCompile(projectTests(":kotlin-build-common")) testCompileOnly(intellijDep("jps-standalone")) { includeJars("jps-builders", "jps-builders-6") } - testCompileOnly(intellijDep()) { includeJars("openapi", "idea", "log4j") } + testCompileOnly(intellijDep()) { includeJars("openapi", "idea", "platform-api", "log4j") } testCompile(intellijDep("jps-build-test")) compilerModules.forEach { testRuntime(project(it)) diff --git a/plugins/android-extensions/android-extensions-jps/build.gradle.kts.as32 b/plugins/android-extensions/android-extensions-jps/build.gradle.kts.as32 deleted file mode 100644 index 712a18454c2..00000000000 --- a/plugins/android-extensions/android-extensions-jps/build.gradle.kts.as32 +++ /dev/null @@ -1,42 +0,0 @@ - -plugins { - kotlin("jvm") - id("jps-compatible") -} - -dependencies { - testRuntime(intellijDep()) - - compile(project(":compiler:util")) - compile(project(":jps-plugin")) - compile(project(":plugins:android-extensions-compiler")) - compileOnly(intellijDep()) { includeJars("openapi", "jps-builders", "jps-model", "jdom") } - compileOnly(intellijPluginDep("android")) { includeJars("jps/android-jps-plugin") } - compile(intellijPluginDep("android")) { includeJars("jps/android-jps-plugin") } - - testCompile(projectTests(":jps-plugin")) - testCompile(project(":compiler:tests-common")) - testCompile(commonDep("junit:junit")) - testCompile(projectDist(":kotlin-test:kotlin-test-jvm")) - testCompile(projectTests(":kotlin-build-common")) - testCompileOnly(intellijDep()) { includeJars("openapi", "jps-builders") } - testCompileOnly(intellijDep("jps-build-test")) { includeJars("jps-build-test") } - testCompileOnly(intellijDep()) { includeJars("jps-model") } - - testRuntime(intellijPluginDep("android")) - testRuntime(intellijPluginDep("smali")) - testRuntime(intellijDep("jps-build-test")) - testRuntime(intellijDep("jps-standalone")) -} - -sourceSets { - "main" { projectDefault() } - "test" { projectDefault() } -} - -projectTest { - workingDir = rootDir - useAndroidSdk() -} - -testsJar {} \ No newline at end of file diff --git a/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts.as32 b/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts.as32 deleted file mode 100644 index 0603f259ac8..00000000000 --- a/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts.as32 +++ /dev/null @@ -1,32 +0,0 @@ - -description = "Kotlin SamWithReceiver IDEA Plugin" - -plugins { - kotlin("jvm") - id("jps-compatible") -} - -jvmTarget = "1.6" - -dependencies { - compile(project(":kotlin-sam-with-receiver-compiler-plugin")) - compile(project(":plugins:annotation-based-compiler-plugins-ide-support")) - compile(project(":compiler:util")) - compile(project(":compiler:frontend")) - compile(project(":compiler:frontend.java")) - compile(project(":idea:idea-core")) - compile(project(":idea:idea-android")) - compile(project(":idea")) - compile(project(":idea:idea-jvm")) - compile(intellijDep()) { includeJars("openapi", "extensions", "util") } -} - -sourceSets { - "main" { projectDefault() } - "test" {} -} - -runtimeJar() - -ideaPlugin() -