diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreApplicationEnvironment.java.192 b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreApplicationEnvironment.java.192 deleted file mode 100644 index cbb289a3139..00000000000 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreApplicationEnvironment.java.192 +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.cli.jvm.compiler; - -import com.intellij.codeInsight.ContainerProvider; -import com.intellij.codeInsight.runner.JavaMainMethodProvider; -import com.intellij.core.CoreApplicationEnvironment; -import com.intellij.core.JavaCoreApplicationEnvironment; -import com.intellij.lang.MetaLanguage; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.extensions.ExtensionsArea; -import com.intellij.openapi.fileTypes.FileTypeExtensionPoint; -import com.intellij.openapi.vfs.VirtualFileSystem; -import com.intellij.psi.FileContextProvider; -import com.intellij.psi.augment.PsiAugmentProvider; -import com.intellij.psi.augment.TypeAnnotationModifier; -import com.intellij.psi.compiled.ClassFileDecompilers; -import com.intellij.psi.meta.MetaDataContributor; -import com.intellij.psi.stubs.BinaryFileStubBuilders; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem; - -// Mostly a placeholder for the functionality added to the bunch 193 -public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment { - - public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) { - Extensions.cleanRootArea(parentDisposable); - registerExtensionPoints(); - return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode); - } - - private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) { - super(parentDisposable, unitTestMode); - } - - private static void registerExtensionPoints() { - ExtensionsArea area = Extensions.getRootArea(); - - CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class); - CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class); - - CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class); - CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class); - CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class); - - CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class); - CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class); - - CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class); - CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class); - - IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area); - } - - @Nullable - @Override - protected VirtualFileSystem createJrtFileSystem() { - return new CoreJrtFileSystem(); - } -} \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtParsingTestCase.java.192 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtParsingTestCase.java.192 deleted file mode 100644 index 8e34c41a923..00000000000 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtParsingTestCase.java.192 +++ /dev/null @@ -1,332 +0,0 @@ -/* - * 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.*; -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.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.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(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 MockFileTypeManager(new MockLanguageFileType(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/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtPlatformLiteFixture.java.192 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtPlatformLiteFixture.java.192 deleted file mode 100644 index 37b08d64a89..00000000000 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/testFramework/KtPlatformLiteFixture.java.192 +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-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.kotlin.test.testFramework; - -import com.intellij.core.CoreEncodingProjectManager; -import com.intellij.mock.MockApplicationEx; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.extensions.ExtensionPoint; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.extensions.ExtensionsArea; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.vfs.encoding.EncodingManager; -import org.picocontainer.MutablePicoContainer; - -import java.lang.reflect.Modifier; - -public abstract class KtPlatformLiteFixture extends KtUsefulTestCase { - protected MockProjectEx myProject; - - @Override - protected void setUp() throws Exception { - super.setUp(); - Extensions.cleanRootArea(getTestRootDisposable()); - } - - public static MockApplicationEx getApplication() { - return (MockApplicationEx)ApplicationManager.getApplication(); - } - - public void initApplication() { - MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable()); - ApplicationManager.setApplication(instance, FileTypeManager::getInstance, getTestRootDisposable()); - getApplication().registerService(EncodingManager.class, CoreEncodingProjectManager.class); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - clearFields(this); - myProject = null; - } - - protected void registerExtensionPoint(ExtensionPointName extensionPointName, Class aClass) { - registerExtensionPoint(Extensions.getRootArea(), extensionPointName, aClass); - } - - private static void registerExtensionPoint( - ExtensionsArea area, ExtensionPointName extensionPointName, - Class aClass - ) { - String name = extensionPointName.getName(); - if (!area.hasExtensionPoint(name)) { - ExtensionPoint.Kind kind = aClass.isInterface() || (aClass.getModifiers() & Modifier.ABSTRACT) != 0 ? ExtensionPoint.Kind.INTERFACE : ExtensionPoint.Kind.BEAN_CLASS; - area.registerExtensionPoint(name, aClass.getName(), kind); - } - } - - @SuppressWarnings("unchecked") - public static T registerComponentInstance(MutablePicoContainer container, Class key, T implementation) { - Object old = container.getComponentInstance(key); - container.unregisterComponent(key); - container.registerComponentInstance(key, implementation); - return (T)old; - } -} diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 deleted file mode 100644 index 47dccc475f7..00000000000 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt.192 +++ /dev/null @@ -1,1588 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.generators.tests - -import org.jetbrains.kotlin.AbstractDataFlowValueRenderingTest -import org.jetbrains.kotlin.addImport.AbstractAddImportTest -import org.jetbrains.kotlin.addImportAlias.AbstractAddImportAliasTest -import org.jetbrains.kotlin.allopen.AbstractBytecodeListingTestForAllOpen -import org.jetbrains.kotlin.android.parcel.AbstractParcelBoxTest -import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest -import org.jetbrains.kotlin.android.parcel.AbstractParcelIrBoxTest -import org.jetbrains.kotlin.android.parcel.AbstractParcelIrBytecodeListingTest -import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest -import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest -import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidIrBoxTest -import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest -import org.jetbrains.kotlin.asJava.classes.AbstractUltraLightClassLoadingTest -import org.jetbrains.kotlin.asJava.classes.AbstractUltraLightClassSanityTest -import org.jetbrains.kotlin.asJava.classes.AbstractUltraLightFacadeClassTest -import org.jetbrains.kotlin.asJava.classes.AbstractUltraLightScriptLoadingTest -import org.jetbrains.kotlin.checkers.* -import org.jetbrains.kotlin.copyright.AbstractUpdateKotlinCopyrightTest -import org.jetbrains.kotlin.findUsages.AbstractFindUsagesTest -import org.jetbrains.kotlin.findUsages.AbstractFindUsagesWithDisableComponentSearchTest -import org.jetbrains.kotlin.findUsages.AbstractKotlinFindUsagesWithLibraryTest -import org.jetbrains.kotlin.fir.plugin.AbstractFirAllOpenDiagnosticTest -import org.jetbrains.kotlin.formatter.AbstractFormatterTest -import org.jetbrains.kotlin.formatter.AbstractTypingIndentationTestBase -import org.jetbrains.kotlin.generators.tests.generator.TestGroup -import org.jetbrains.kotlin.generators.tests.generator.muteExtraSuffix -import org.jetbrains.kotlin.generators.tests.generator.testGroupSuite -import org.jetbrains.kotlin.generators.util.KT_OR_KTS -import org.jetbrains.kotlin.generators.util.KT_OR_KTS_WITHOUT_DOTS_IN_NAME -import org.jetbrains.kotlin.generators.util.KT_WITHOUT_DOTS_IN_NAME -import org.jetbrains.kotlin.idea.AbstractExpressionSelectionTest -import org.jetbrains.kotlin.idea.AbstractSmartSelectionTest -import org.jetbrains.kotlin.idea.actions.AbstractGotoTestOrCodeActionTest -import org.jetbrains.kotlin.idea.caches.resolve.* -import org.jetbrains.kotlin.idea.codeInsight.* -import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractCodeInsightActionTest -import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateHashCodeAndEqualsActionTest -import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateTestSupportMethodActionTest -import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateToStringActionTest -import org.jetbrains.kotlin.idea.codeInsight.moveUpDown.AbstractMoveLeftRightTest -import org.jetbrains.kotlin.idea.codeInsight.moveUpDown.AbstractMoveStatementTest -import org.jetbrains.kotlin.idea.codeInsight.postfix.AbstractPostfixTemplateProviderTest -import org.jetbrains.kotlin.idea.codeInsight.surroundWith.AbstractSurroundWithTest -import org.jetbrains.kotlin.idea.codeInsight.unwrap.AbstractUnwrapRemoveTest -import org.jetbrains.kotlin.idea.completion.test.* -import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractBasicCompletionHandlerTest -import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractCompletionCharFilterTest -import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractKeywordCompletionHandlerTest -import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractSmartCompletionHandlerTest -import org.jetbrains.kotlin.idea.completion.test.weighers.AbstractBasicCompletionWeigherTest -import org.jetbrains.kotlin.idea.completion.test.weighers.AbstractSmartCompletionWeigherTest -import org.jetbrains.kotlin.idea.configuration.AbstractGradleConfigureProjectByChangingFileTest -import org.jetbrains.kotlin.idea.conversion.copy.AbstractJavaToKotlinCopyPasteConversionTest -import org.jetbrains.kotlin.idea.conversion.copy.AbstractLiteralKotlinToKotlinCopyPasteTest -import org.jetbrains.kotlin.idea.conversion.copy.AbstractLiteralTextToKotlinCopyPasteTest -import org.jetbrains.kotlin.idea.conversion.copy.AbstractTextJavaToKotlinCopyPasteConversionTest -import org.jetbrains.kotlin.idea.coverage.AbstractKotlinCoverageOutputFilesTest -import org.jetbrains.kotlin.idea.debugger.evaluate.AbstractCodeFragmentAutoImportTest -import org.jetbrains.kotlin.idea.debugger.evaluate.AbstractCodeFragmentCompletionHandlerTest -import org.jetbrains.kotlin.idea.debugger.evaluate.AbstractCodeFragmentCompletionTest -import org.jetbrains.kotlin.idea.debugger.evaluate.AbstractCodeFragmentHighlightingTest -import org.jetbrains.kotlin.idea.debugger.test.* -import org.jetbrains.kotlin.idea.debugger.test.sequence.exec.AbstractSequenceTraceTestCase -import org.jetbrains.kotlin.idea.decompiler.navigation.AbstractNavigateJavaToLibrarySourceTest -import org.jetbrains.kotlin.idea.decompiler.navigation.AbstractNavigateToDecompiledLibraryTest -import org.jetbrains.kotlin.idea.decompiler.navigation.AbstractNavigateToLibrarySourceTest -import org.jetbrains.kotlin.idea.decompiler.navigation.AbstractNavigateToLibrarySourceTestWithJS -import org.jetbrains.kotlin.idea.decompiler.stubBuilder.AbstractClsStubBuilderTest -import org.jetbrains.kotlin.idea.decompiler.stubBuilder.AbstractLoadJavaClsStubTest -import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractCommonDecompiledTextFromJsMetadataTest -import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractCommonDecompiledTextTest -import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractJsDecompiledTextFromJsMetadataTest -import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractJvmDecompiledTextTest -import org.jetbrains.kotlin.idea.editor.AbstractMultiLineStringIndentTest -import org.jetbrains.kotlin.idea.editor.backspaceHandler.AbstractBackspaceHandlerTest -import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest -import org.jetbrains.kotlin.idea.filters.AbstractKotlinExceptionFilterTest -import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirLazyResolveTest -import org.jetbrains.kotlin.idea.fir.low.level.api.AbstractFirMultiModuleResolveTest -import org.jetbrains.kotlin.idea.fir.AbstractKtDeclarationAndFirDeclarationEqualityChecker -import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest -import org.jetbrains.kotlin.idea.frontend.api.fir.AbstractResolveCallTest -import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest -import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyWithLibTest -import org.jetbrains.kotlin.idea.highlighter.* -import org.jetbrains.kotlin.idea.imports.AbstractJsOptimizeImportsTest -import org.jetbrains.kotlin.idea.imports.AbstractJvmOptimizeImportsTest -import org.jetbrains.kotlin.idea.index.AbstractKotlinTypeAliasByExpansionShortNameIndexTest -import org.jetbrains.kotlin.idea.inspections.AbstractLocalInspectionTest -import org.jetbrains.kotlin.idea.inspections.AbstractMultiFileLocalInspectionTest -import org.jetbrains.kotlin.idea.intentions.AbstractConcatenatedStringGeneratorTest -import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest -import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest2 -import org.jetbrains.kotlin.idea.intentions.AbstractMultiFileIntentionTest -import org.jetbrains.kotlin.idea.intentions.declarations.AbstractJoinLinesTest -import org.jetbrains.kotlin.idea.internal.AbstractBytecodeToolWindowTest -import org.jetbrains.kotlin.idea.kdoc.AbstractKDocHighlightingTest -import org.jetbrains.kotlin.idea.kdoc.AbstractKDocTypingTest -import org.jetbrains.kotlin.idea.maven.AbstractKotlinMavenInspectionTest -import org.jetbrains.kotlin.idea.maven.configuration.AbstractMavenConfigureProjectByChangingFileTest -import org.jetbrains.kotlin.idea.navigation.* -import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest -import org.jetbrains.kotlin.idea.perf.* -import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest -import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiModuleTest -import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixTest -import org.jetbrains.kotlin.idea.refactoring.AbstractNameSuggestionProviderTest -import org.jetbrains.kotlin.idea.refactoring.copy.AbstractCopyTest -import org.jetbrains.kotlin.idea.refactoring.copy.AbstractMultiModuleCopyTest -import org.jetbrains.kotlin.idea.refactoring.inline.AbstractInlineTest -import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractExtractionTest -import org.jetbrains.kotlin.idea.refactoring.move.AbstractMoveTest -import org.jetbrains.kotlin.idea.refactoring.move.AbstractMultiModuleMoveTest -import org.jetbrains.kotlin.idea.refactoring.pullUp.AbstractPullUpTest -import org.jetbrains.kotlin.idea.refactoring.pushDown.AbstractPushDownTest -import org.jetbrains.kotlin.idea.refactoring.rename.AbstractMultiModuleRenameTest -import org.jetbrains.kotlin.idea.refactoring.rename.AbstractRenameTest -import org.jetbrains.kotlin.idea.refactoring.safeDelete.AbstractMultiModuleSafeDeleteTest -import org.jetbrains.kotlin.idea.refactoring.safeDelete.AbstractSafeDeleteTest -import org.jetbrains.kotlin.idea.repl.AbstractIdeReplCompletionTest -import org.jetbrains.kotlin.idea.resolve.* -import org.jetbrains.kotlin.idea.scratch.AbstractScratchLineMarkersTest -import org.jetbrains.kotlin.idea.scratch.AbstractScratchRunActionTest -import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationCompletionTest -import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationHighlightingTest -import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationNavigationTest -import org.jetbrains.kotlin.idea.script.AbstractScriptDefinitionsOrderTest -import org.jetbrains.kotlin.idea.slicer.AbstractSlicerLeafGroupingTest -import org.jetbrains.kotlin.idea.slicer.AbstractSlicerMultiplatformTest -import org.jetbrains.kotlin.idea.slicer.AbstractSlicerNullnessGroupingTest -import org.jetbrains.kotlin.idea.slicer.AbstractSlicerTreeTest -import org.jetbrains.kotlin.idea.structureView.AbstractKotlinFileStructureTest -import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest -import org.jetbrains.kotlin.idea.stubs.AbstractResolveByStubTest -import org.jetbrains.kotlin.idea.stubs.AbstractStubBuilderTest -import org.jetbrains.kotlin.incremental.* -import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest -import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest -import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest -import org.jetbrains.kotlin.jps.build.* -import org.jetbrains.kotlin.jps.build.dependeciestxt.actualizeMppJpsIncTestCaseDirs -import org.jetbrains.kotlin.jps.incremental.AbstractJsProtoComparisonTest -import org.jetbrains.kotlin.jps.incremental.AbstractJvmProtoComparisonTest -import org.jetbrains.kotlin.jvm.abi.AbstractCompareJvmAbiTest -import org.jetbrains.kotlin.jvm.abi.AbstractCompileAgainstJvmAbiTest -import org.jetbrains.kotlin.jvm.abi.AbstractJvmAbiContentTest -import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest -import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest -import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest -import org.jetbrains.kotlin.kapt3.test.AbstractIrClassFileToSourceStubConverterTest -import org.jetbrains.kotlin.kapt3.test.AbstractIrKotlinKaptContextTest -import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest -import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterMultiFileTest -import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterSingleFileTest -import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinCopyPasteConversionTest -import org.jetbrains.kotlin.nj2k.AbstractTextNewJavaToKotlinCopyPasteConversionTest -import org.jetbrains.kotlin.nj2k.inference.common.AbstractCommonConstraintCollectorTest -import org.jetbrains.kotlin.nj2k.inference.mutability.AbstractMutabilityInferenceTest -import org.jetbrains.kotlin.nj2k.inference.nullability.AbstractNullabilityInferenceTest -import org.jetbrains.kotlin.noarg.AbstractBlackBoxCodegenTestForNoArg -import org.jetbrains.kotlin.noarg.AbstractBytecodeListingTestForNoArg -import org.jetbrains.kotlin.psi.patternMatching.AbstractPsiUnifierTest -import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverScriptTest -import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverTest -import org.jetbrains.kotlin.search.AbstractAnnotatedMembersSearchTest -import org.jetbrains.kotlin.search.AbstractInheritorsSearchTest -import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest -import org.jetbrains.kotlin.test.TargetBackend -import org.jetbrains.kotlin.tools.projectWizard.cli.AbstractProjectTemplateBuildFileGenerationTest -import org.jetbrains.kotlin.tools.projectWizard.cli.AbstractYamlBuildFileGenerationTest -import org.jetbrains.kotlin.tools.projectWizard.wizard.AbstractProjectTemplateNewWizardProjectImportTest -import org.jetbrains.kotlin.tools.projectWizard.wizard.AbstractYamlNewWizardProjectImportTest -import org.jetbrains.kotlinx.serialization.AbstractSerializationIrBytecodeListingTest -import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginBytecodeListingTest -import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginDiagnosticTest - -fun main(args: Array) { - System.setProperty("java.awt.headless", "true") - - testGroupSuite(args) { - testGroup("idea/jvm-debugger/jvm-debugger-test/test", "idea/jvm-debugger/jvm-debugger-test/testData") { - testClass { - model( - "stepping/stepIntoAndSmartStepInto", - pattern = KT_WITHOUT_DOTS_IN_NAME, - testMethod = "doStepIntoTest", - testClassName = "StepInto" - ) - model( - "stepping/stepIntoAndSmartStepInto", - pattern = KT_WITHOUT_DOTS_IN_NAME, - testMethod = "doSmartStepIntoTest", - testClassName = "SmartStepInto" - ) - model( - "stepping/stepInto", - pattern = KT_WITHOUT_DOTS_IN_NAME, - testMethod = "doStepIntoTest", - testClassName = "StepIntoOnly" - ) - model("stepping/stepOut", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepOutTest") - model("stepping/stepOver", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepOverTest") - model("stepping/filters", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doStepIntoTest") - model("stepping/custom", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doCustomTest") - } - - testClass { - model("evaluation/singleBreakpoint", testMethod = "doSingleBreakpointTest") - model("evaluation/multipleBreakpoints", testMethod = "doMultipleBreakpointsTest") - } - - testClass { - model("selectExpression", recursive = false) - model("selectExpression/disallowMethodCalls", testMethod = "doTestWoMethodCalls") - } - - testClass { - model("positionManager", recursive = false, extension = "kt", testClassName = "SingleFile") - model("positionManager", recursive = false, extension = null, testClassName = "MultiFile") - } - - testClass { - model("smartStepInto") - } - - testClass { - model("breakpointApplicability") - } - - testClass { - model("fileRanking") - } - - testClass { - model("asyncStackTrace") - } - - testClass { - model("coroutines") - } - - testClass { - // TODO: implement mapping logic for terminal operations - model("sequence/streams/sequence", excludeDirs = listOf("terminal")) - } - - testClass { - model("continuation") - } - - testClass { - model("xcoroutines") - } - } - - testGroup("idea/tests", "idea/testData") { - testClass { - model("resolve/additionalLazyResolve") - } - - testClass { - model("resolve/partialBodyResolve") - } - - testClass { - model("checker", recursive = false) - model("checker/regression") - model("checker/recovery") - model("checker/rendering") - model("checker/scripts", extension = "kts") - model("checker/duplicateJvmSignature") - model("checker/infos", testMethod = "doTestWithInfos") - model("checker/diagnosticsMessage") - } - - testClass { - model("kotlinAndJavaChecker/javaAgainstKotlin") - model("kotlinAndJavaChecker/javaWithKotlin") - } - - testClass { - model("kotlinAndJavaChecker/javaAgainstKotlin") - model("kotlinAndJavaChecker/javaWithKotlin") - } - - testClass { - model("kotlinAndJavaChecker/javaAgainstKotlin") - } - - testClass { - model("unifier") - } - - testClass { - model("checker/codeFragments", extension = "kt", recursive = false) - model("checker/codeFragments/imports", testMethod = "doTestWithImport", extension = "kt") - } - - testClass { - model("quickfix.special/codeFragmentAutoImport", extension = "kt", recursive = false) - } - - testClass { - model("checker/js") - } - - testClass { - model("quickfix", pattern = "^([\\w\\-_]+)\\.kt$", filenameStartsLowerCase = true) - } - - testClass { - model("navigation/gotoSuper", extension = "test", recursive = false) - } - - testClass { - model("navigation/gotoTypeDeclaration", extension = "test") - } - - testClass { - model("navigation/gotoDeclaration", extension = "test") - } - - testClass { - model( - "parameterInfo", - pattern = "^([\\w\\-_]+)\\.kt$", recursive = true, - excludeDirs = listOf("withLib1/sharedLib", "withLib2/sharedLib", "withLib3/sharedLib") - ) - } - - testClass { - model("navigation/gotoClass", testMethod = "doClassTest") - model("navigation/gotoSymbol", testMethod = "doSymbolTest") - } - - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { - model("decompiler/navigation/usercode") - } - - testClass(annotations = listOf(muteExtraSuffix(".libsrc"))) { - model("decompiler/navigation/userJavaCode", pattern = "^(.+)\\.java$") - } - - testClass(annotations = listOf(muteExtraSuffix(".libsrcjs"))) { - model("decompiler/navigation/usercode", testClassName = "UsercodeWithJSModule") - } - - testClass { - model("decompiler/navigation/usercode") - } - - testClass { - model("navigation/implementations", recursive = false) - } - - testClass { - model("navigation/gotoTestOrCode", pattern = "^(.+)\\.main\\..+\$") - } - - testClass { - model("search/inheritance") - } - - testClass { - model("search/annotations") - } - - testClass { - model("quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile") - } - - testClass { - model("typealiasExpansionIndex") - } - - testClass { - model("highlighter") - } - - testClass { - model("dslHighlighter") - } - - testClass { - model("usageHighlighter") - } - - testClass { - model("folding/noCollapse") - model("folding/checkCollapse", testMethod = "doSettingsFoldingTest") - } - - testClass { - model("codeInsight/surroundWith/if", testMethod = "doTestWithIfSurrounder") - model("codeInsight/surroundWith/ifElse", testMethod = "doTestWithIfElseSurrounder") - model("codeInsight/surroundWith/ifElseExpression", testMethod = "doTestWithIfElseExpressionSurrounder") - model("codeInsight/surroundWith/ifElseExpressionBraces", testMethod = "doTestWithIfElseExpressionBracesSurrounder") - model("codeInsight/surroundWith/not", testMethod = "doTestWithNotSurrounder") - model("codeInsight/surroundWith/parentheses", testMethod = "doTestWithParenthesesSurrounder") - model("codeInsight/surroundWith/stringTemplate", testMethod = "doTestWithStringTemplateSurrounder") - model("codeInsight/surroundWith/when", testMethod = "doTestWithWhenSurrounder") - model("codeInsight/surroundWith/tryCatch", testMethod = "doTestWithTryCatchSurrounder") - model("codeInsight/surroundWith/tryCatchExpression", testMethod = "doTestWithTryCatchExpressionSurrounder") - model("codeInsight/surroundWith/tryCatchFinally", testMethod = "doTestWithTryCatchFinallySurrounder") - model("codeInsight/surroundWith/tryCatchFinallyExpression", testMethod = "doTestWithTryCatchFinallyExpressionSurrounder") - model("codeInsight/surroundWith/tryFinally", testMethod = "doTestWithTryFinallySurrounder") - model("codeInsight/surroundWith/functionLiteral", testMethod = "doTestWithFunctionLiteralSurrounder") - model("codeInsight/surroundWith/withIfExpression", testMethod = "doTestWithSurroundWithIfExpression") - model("codeInsight/surroundWith/withIfElseExpression", testMethod = "doTestWithSurroundWithIfElseExpression") - } - - testClass { - model("joinLines") - } - - testClass { - model("codeInsight/breadcrumbs") - } - - testClass { - model("intentions", pattern = "^([\\w\\-_]+)\\.(kt|kts)$") - } - - testClass { - model("intentions/loopToCallChain", pattern = "^([\\w\\-_]+)\\.kt$") - } - - testClass { - model("concatenatedStringGenerator", pattern = "^([\\w\\-_]+)\\.kt$") - } - - testClass { - model("intentions", pattern = "^(inspections\\.test)$", singleClass = true) - model("inspections", pattern = "^(inspections\\.test)$", singleClass = true) - model("inspectionsLocal", pattern = "^(inspections\\.test)$", singleClass = true) - } - - testClass { - model("inspectionsLocal", pattern = "^([\\w\\-_]+)\\.(kt|kts)$") - } - - testClass { - model("hierarchy/class/type", extension = null, recursive = false, testMethod = "doTypeClassHierarchyTest") - model("hierarchy/class/super", extension = null, recursive = false, testMethod = "doSuperClassHierarchyTest") - model("hierarchy/class/sub", extension = null, recursive = false, testMethod = "doSubClassHierarchyTest") - model("hierarchy/calls/callers", extension = null, recursive = false, testMethod = "doCallerHierarchyTest") - model("hierarchy/calls/callersJava", extension = null, recursive = false, testMethod = "doCallerJavaHierarchyTest") - model("hierarchy/calls/callees", extension = null, recursive = false, testMethod = "doCalleeHierarchyTest") - model("hierarchy/overrides", extension = null, recursive = false, testMethod = "doOverrideHierarchyTest") - } - - testClass { - model("hierarchy/withLib", extension = null, recursive = false) - } - - testClass { - model("codeInsight/moveUpDown/classBodyDeclarations", pattern = KT_OR_KTS, testMethod = "doTestClassBodyDeclaration") - model("codeInsight/moveUpDown/closingBraces", testMethod = "doTestExpression") - model("codeInsight/moveUpDown/expressions", pattern = KT_OR_KTS, testMethod = "doTestExpression") - model("codeInsight/moveUpDown/parametersAndArguments", testMethod = "doTestExpression") - model("codeInsight/moveUpDown/trailingComma", testMethod = "doTestExpressionWithTrailingComma") - } - - testClass { - model("codeInsight/moveLeftRight") - } - - testClass { - model("refactoring/inline", pattern = "^(\\w+)\\.kt$") - } - - testClass { - model("codeInsight/unwrapAndRemove/removeExpression", testMethod = "doTestExpressionRemover") - model("codeInsight/unwrapAndRemove/unwrapThen", testMethod = "doTestThenUnwrapper") - model("codeInsight/unwrapAndRemove/unwrapElse", testMethod = "doTestElseUnwrapper") - model("codeInsight/unwrapAndRemove/removeElse", testMethod = "doTestElseRemover") - model("codeInsight/unwrapAndRemove/unwrapLoop", testMethod = "doTestLoopUnwrapper") - model("codeInsight/unwrapAndRemove/unwrapTry", testMethod = "doTestTryUnwrapper") - model("codeInsight/unwrapAndRemove/unwrapCatch", testMethod = "doTestCatchUnwrapper") - model("codeInsight/unwrapAndRemove/removeCatch", testMethod = "doTestCatchRemover") - model("codeInsight/unwrapAndRemove/unwrapFinally", testMethod = "doTestFinallyUnwrapper") - model("codeInsight/unwrapAndRemove/removeFinally", testMethod = "doTestFinallyRemover") - model("codeInsight/unwrapAndRemove/unwrapLambda", testMethod = "doTestLambdaUnwrapper") - model("codeInsight/unwrapAndRemove/unwrapFunctionParameter", testMethod = "doTestFunctionParameterUnwrapper") - } - - testClass { - model("codeInsight/expressionType") - } - - testClass { - model("codeInsight/renderingKDoc") - } - - testClass { - model("editor/backspaceHandler") - } - - testClass { - model("editor/enterHandler/multilineString") - } - - testClass { - model("editor/quickDoc", pattern = """^([^_]+)\.(kt|java)$""") - } - - testClass { - model("refactoring/safeDelete/deleteClass/kotlinClass", testMethod = "doClassTest") - model("refactoring/safeDelete/deleteClass/kotlinClassWithJava", testMethod = "doClassTestWithJava") - model("refactoring/safeDelete/deleteClass/javaClassWithKotlin", extension = "java", testMethod = "doJavaClassTest") - model("refactoring/safeDelete/deleteObject/kotlinObject", testMethod = "doObjectTest") - model("refactoring/safeDelete/deleteFunction/kotlinFunction", testMethod = "doFunctionTest") - model("refactoring/safeDelete/deleteFunction/kotlinFunctionWithJava", testMethod = "doFunctionTestWithJava") - model("refactoring/safeDelete/deleteFunction/javaFunctionWithKotlin", testMethod = "doJavaMethodTest") - model("refactoring/safeDelete/deleteProperty/kotlinProperty", testMethod = "doPropertyTest") - model("refactoring/safeDelete/deleteProperty/kotlinPropertyWithJava", testMethod = "doPropertyTestWithJava") - model("refactoring/safeDelete/deleteProperty/javaPropertyWithKotlin", testMethod = "doJavaPropertyTest") - model("refactoring/safeDelete/deleteTypeAlias/kotlinTypeAlias", testMethod = "doTypeAliasTest") - model("refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameter", testMethod = "doTypeParameterTest") - model("refactoring/safeDelete/deleteTypeParameter/kotlinTypeParameterWithJava", testMethod = "doTypeParameterTestWithJava") - model("refactoring/safeDelete/deleteValueParameter/kotlinValueParameter", testMethod = "doValueParameterTest") - model("refactoring/safeDelete/deleteValueParameter/kotlinValueParameterWithJava", testMethod = "doValueParameterTestWithJava") - } - - testClass { - model("resolve/references", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("resolve/referenceInJava/binaryAndSource", extension = "java") - model("resolve/referenceInJava/sourceOnly", extension = "java") - } - - testClass { - model("resolve/referenceInJava/binaryAndSource", extension = "java") - } - - testClass { - model("resolve/referenceWithLib", recursive = false) - } - - testClass { - model("resolve/referenceInLib", recursive = false) - } - - testClass { - model("resolve/referenceToJavaWithWrongFileStructure", recursive = false) - } - - testClass { - model("findUsages/kotlin", pattern = """^(.+)\.0\.(kt|kts)$""") - model("findUsages/java", pattern = """^(.+)\.0\.java$""") - model("findUsages/propertyFiles", pattern = """^(.+)\.0\.properties$""") - } - - testClass { - model("findUsages/kotlin/conventions/components", pattern = """^(.+)\.0\.(kt|kts)$""") - } - - testClass { - model("findUsages/libraryUsages", pattern = """^(.+)\.0\.kt$""") - } - - testClass { - model("refactoring/move", extension = "test", singleClass = true) - } - - testClass { - model("refactoring/copy", extension = "test", singleClass = true) - } - - testClass { - model("refactoring/moveMultiModule", extension = "test", singleClass = true) - } - - testClass { - model("refactoring/copyMultiModule", extension = "test", singleClass = true) - } - - testClass { - model("refactoring/safeDeleteMultiModule", extension = "test", singleClass = true) - } - - testClass { - model("multiFileIntentions", extension = "test", singleClass = true, filenameStartsLowerCase = true) - } - - testClass { - model("multiFileLocalInspections", extension = "test", singleClass = true, filenameStartsLowerCase = true) - } - - testClass { - model("multiFileInspections", extension = "test", singleClass = true) - } - - testClass { - model("formatter", pattern = """^([^\.]+)\.after\.kt.*$""") - model( - "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.kt.*$""", - testMethod = "doTestCallSite", testClassName = "FormatterCallSite" - ) - model( - "formatter", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", - testMethod = "doTestInverted", testClassName = "FormatterInverted" - ) - model( - "formatter/trailingComma", pattern = """^([^\.]+)\.call\.after\.inv\.kt.*$""", - testMethod = "doTestInvertedCallSite", testClassName = "FormatterInvertedCallSite" - ) - } - - testClass { - model( - "indentationOnNewline", pattern = """^([^\.]+)\.after\.kt.*$""", testMethod = "doNewlineTest", - testClassName = "DirectSettings" - ) - model( - "indentationOnNewline", pattern = """^([^\.]+)\.after\.inv\.kt.*$""", testMethod = "doNewlineTestWithInvert", - testClassName = "InvertedSettings" - ) - } - - testClass { - model("diagnosticMessage", recursive = false) - } - - testClass { - model("diagnosticMessage/js", recursive = false, targetBackend = TargetBackend.JS) - } - - testClass { - model("refactoring/rename", extension = "test", singleClass = true) - } - - testClass { - model("refactoring/renameMultiModule", extension = "test", singleClass = true) - } - - testClass { - model("codeInsight/outOfBlock", pattern = KT_OR_KTS) - } - - testClass { - model("codeInsight/changeLocality", pattern = KT_OR_KTS) - } - - testClass { - model("dataFlowValueRendering") - } - - testClass { - model("copyPaste/conversion", pattern = """^([^\.]+)\.java$""") - } - - testClass { - model("copyPaste/plainTextConversion", pattern = """^([^\.]+)\.txt$""") - } - - testClass { - model("copyPaste/plainTextLiteral", pattern = """^([^\.]+)\.txt$""") - } - - testClass { - model("copyPaste/literal", pattern = """^([^\.]+)\.kt$""") - } - - testClass { - model( - "copyPaste/imports", - pattern = KT_WITHOUT_DOTS_IN_NAME, - testMethod = "doTestCopy", - testClassName = "Copy", - recursive = false - ) - model( - "copyPaste/imports", - pattern = KT_WITHOUT_DOTS_IN_NAME, - testMethod = "doTestCut", - testClassName = "Cut", - recursive = false - ) - } - - testClass { - model("copyPaste/moveDeclarations", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doTest") - } - - testClass { - model("copyright", pattern = KT_OR_KTS, testMethod = "doTest") - } - - testClass { - model("exitPoints") - } - - testClass { - model("codeInsight/lineMarker") - } - - testClass { - model("codeInsightInLibrary/lineMarker", testMethod = "doTestWithLibrary") - } - - testClass { - model("multiModuleLineMarker", extension = null, recursive = false) - } - - testClass { - model("shortenRefs", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - testClass { - model("addImport", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("addImportAlias", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("smartSelection", testMethod = "doTestSmartSelection", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("structureView/fileStructure", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("expressionSelection", testMethod = "doTestExpressionSelection", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("decompiler/decompiledText", pattern = """^([^\.]+)$""") - } - - testClass { - model("decompiler/decompiledTextJvm", pattern = """^([^\.]+)$""") - } - - testClass { - model("decompiler/decompiledText", pattern = """^([^\.]+)$""", targetBackend = TargetBackend.JS) - } - - testClass { - model("decompiler/decompiledTextJs", pattern = """^([^\.]+)$""", targetBackend = TargetBackend.JS) - } - - testClass { - model("decompiler/stubBuilder", extension = null, recursive = false) - } - - testClass { - model("editor/optimizeImports/jvm", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) - model("editor/optimizeImports/common", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - testClass { - model("editor/optimizeImports/js", pattern = KT_WITHOUT_DOTS_IN_NAME) - model("editor/optimizeImports/common", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("debugger/exceptionFilter", pattern = """^([^\.]+)$""", recursive = false) - } - - testClass { - model("stubs", extension = "kt") - } - - testClass { - model("multiFileHighlighting", recursive = false) - } - - testClass { - model("multiModuleHighlighting/multiplatform/", recursive = false, extension = null) - } - - testClass { - model("multiplatform", recursive = false, extension = null) - } - - testClass { - model("multiModuleQuickFix", extension = null, deep = 1) - } - - testClass { - model("navigation/implementations/multiModule", recursive = false, extension = null) - } - - testClass { - model("navigation/relatedSymbols/multiModule", recursive = false, extension = null) - } - - testClass { - model("navigation/gotoSuper/multiModule", recursive = false, extension = null) - } - - testClass { - model("refactoring/introduceVariable", pattern = KT_OR_KTS, testMethod = "doIntroduceVariableTest") - model("refactoring/extractFunction", pattern = KT_OR_KTS, testMethod = "doExtractFunctionTest") - model("refactoring/introduceProperty", pattern = KT_OR_KTS, testMethod = "doIntroducePropertyTest") - model("refactoring/introduceParameter", pattern = KT_OR_KTS, testMethod = "doIntroduceSimpleParameterTest") - model("refactoring/introduceLambdaParameter", pattern = KT_OR_KTS, testMethod = "doIntroduceLambdaParameterTest") - model("refactoring/introduceJavaParameter", extension = "java", testMethod = "doIntroduceJavaParameterTest") - model("refactoring/introduceTypeParameter", pattern = KT_OR_KTS, testMethod = "doIntroduceTypeParameterTest") - model("refactoring/introduceTypeAlias", pattern = KT_OR_KTS, testMethod = "doIntroduceTypeAliasTest") - model("refactoring/extractSuperclass", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME, testMethod = "doExtractSuperclassTest") - model("refactoring/extractInterface", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME, testMethod = "doExtractInterfaceTest") - } - - testClass { - model("refactoring/pullUp/k2k", extension = "kt", singleClass = true, testClassName = "K2K", testMethod = "doKotlinTest") - model("refactoring/pullUp/k2j", extension = "kt", singleClass = true, testClassName = "K2J", testMethod = "doKotlinTest") - model("refactoring/pullUp/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest") - } - - testClass { - model("refactoring/pushDown/k2k", extension = "kt", singleClass = true, testClassName = "K2K", testMethod = "doKotlinTest") - model("refactoring/pushDown/k2j", extension = "kt", singleClass = true, testClassName = "K2J", testMethod = "doKotlinTest") - model("refactoring/pushDown/j2k", extension = "java", singleClass = true, testClassName = "J2K", testMethod = "doJavaTest") - } - - testClass { - model("coverage/outputFiles") - } - - testClass { - model("internal/toolWindow", recursive = false, extension = null) - } - - testClass("org.jetbrains.kotlin.idea.kdoc.KdocResolveTestGenerated") { - model("kdoc/resolve") - } - - testClass { - model("kdoc/highlighting") - } - - testClass { - model("kdoc/typing") - } - - testClass { - model("codeInsight/generate/testFrameworkSupport") - } - - testClass { - model("codeInsight/generate/equalsWithHashCode") - } - - testClass { - model("codeInsight/generate/secondaryConstructors") - } - - testClass { - model("codeInsight/generate/toString") - } - - testClass { - model("repl/completion") - } - - testClass { - model("codeInsight/postfix") - } - - testClass { - model("script/definition/highlighting", extension = null, recursive = false) - model("script/definition/complex", extension = null, recursive = false, testMethod = "doComplexTest") - } - - testClass { - model("script/definition/navigation", extension = null, recursive = false) - } - - testClass { - model("script/definition/completion", extension = null, recursive = false) - } - - testClass { - model("script/definition/order", extension = null, recursive = false) - } - - testClass { - model("refactoring/nameSuggestionProvider") - } - - testClass { - model("slicer", excludeDirs = listOf("mpp")) - } - - testClass { - model("slicer/inflow", singleClass = true) - } - - testClass { - model("slicer/inflow", singleClass = true) - } - - testClass { - model("slicer/mpp", recursive = false, extension = null) - } - } - - testGroup("idea/idea-fir/tests", "idea/testData") { - testClass { - model("fir/multiModule", recursive = false, extension = null) - } - - testClass { - model("fir/lazyResolve", extension = "test", singleClass = true, filenameStartsLowerCase = true) - } - - testClass { - model("resolve/references", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("checker", recursive = false) - model("checker/regression") - model("checker/recovery") - model("checker/rendering") - model("checker/duplicateJvmSignature") - model("checker/infos") - model("checker/diagnosticsMessage") - } - } - - testGroup("idea/scripting-support/test", "idea/scripting-support/testData") { - testClass { - model( - "scratch", - extension = "kts", - testMethod = "doScratchCompilingTest", - testClassName = "ScratchCompiling", - recursive = false - ) - model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false) - model( - "scratch/multiFile", - extension = null, - testMethod = "doScratchMultiFileTest", - testClassName = "ScratchMultiFile", - recursive = false - ) - - model( - "worksheet", - extension = "ws.kts", - testMethod = "doWorksheetCompilingTest", - testClassName = "WorksheetCompiling", - recursive = false - ) - model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false) - model( - "worksheet/multiFile", - extension = null, - testMethod = "doWorksheetMultiFileTest", - testClassName = "WorksheetMultiFile", - recursive = false - ) - - model( - "scratch/rightPanelOutput", - extension = "kts", - testMethod = "doRightPreviewPanelOutputTest", - testClassName = "ScratchRightPanelOutput", - recursive = false - ) - } - - testClass { - model("scratch/lineMarker", testMethod = "doScratchTest", pattern = KT_OR_KTS) - } - } - - testGroup("idea/idea-maven/test", "idea/idea-maven/testData") { - testClass { - model("configurator/jvm", extension = null, recursive = false, testMethod = "doTestWithMaven") - model("configurator/js", extension = null, recursive = false, testMethod = "doTestWithJSMaven") - } - - testClass { - model("maven-inspections", pattern = "^([\\w\\-]+).xml$", singleClass = true) - } - } - - testGroup("idea/idea-gradle/tests", "idea/testData") { - testClass { - model("configuration/gradle", extension = null, recursive = false, testMethod = "doTestGradle") - model("configuration/gsk", extension = null, recursive = false, testMethod = "doTestGradle") - } - } - - testGroup("idea/tests", "compiler/testData") { - testClass { - model("loadJava/compiledKotlin") - } - - testClass { - model("loadJava/compiledKotlin", testMethod = "doTestCompiledKotlin") - } - - testClass { - model("asJava/lightClasses", excludeDirs = listOf("delegation", "script"), pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("asJava/script/ide", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("asJava/lightClasses", pattern = KT_OR_KTS) - } - testClass { - model("asJava/ultraLightClasses", pattern = KT_OR_KTS) - } - testClass { - model("asJava/ultraLightScripts", pattern = KT_OR_KTS) - } - testClass { - model("asJava/ultraLightFacades", pattern = KT_OR_KTS) - } - - testClass { - model( - "asJava/lightClasses", - excludeDirs = listOf("local", "compilationErrors", "ideRegression"), - pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME - ) - } - } - - testGroup("idea/idea-completion/tests", "idea/idea-completion/testData") { - testClass { - model("injava", extension = "java", recursive = false) - } - - testClass { - model("injava", extension = "java", recursive = false) - } - - testClass { - model("injava/stdlib", extension = "java", recursive = false) - } - - testClass { - model("weighers/basic", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("weighers/smart", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("basic/common") - model("basic/js") - } - - testClass { - model("basic/common") - model("basic/java") - } - - testClass { - model("smart") - } - - testClass { - model("keywords", recursive = false) - } - - testClass { - model("basic/withLib", recursive = false) - } - - testClass { - model("handlers/basic", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("handlers/smart") - } - - testClass { - model("handlers/keywords") - } - - testClass { - model("handlers/charFilter", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("basic/multifile", extension = null, recursive = false) - } - - testClass("MultiFilePrimitiveJvmBasicCompletionTestGenerated") { - model("basic/multifilePrimitive", extension = null, recursive = false) - } - - testClass { - model("smartMultiFile", extension = null, recursive = false) - } - - testClass("KDocCompletionTestGenerated") { - model("kdoc") - } - - testClass { - model("basic/java8") - } - - testClass { - model("incrementalResolve") - } - - testClass { - model("multiPlatform", recursive = false, extension = null) - } - } - - testGroup( - "libraries/tools/new-project-wizard/new-project-wizard-cli/tests", - "libraries/tools/new-project-wizard/new-project-wizard-cli/testData" - ) { - testClass { - model("buildFileGeneration", recursive = false, extension = null) - } - testClass { - model("projectTemplatesBuildFileGeneration", recursive = false, extension = null) - } - } - - testGroup( - "idea/idea-new-project-wizard/tests", - "libraries/tools/new-project-wizard/new-project-wizard-cli/testData" - ) { - fun TestGroup.TestClass.allBuildSystemTests(relativeRootPath: String) { - for (testClass in listOf("GradleKts", "GradleGroovy", "Maven")) { - model( - relativeRootPath, - recursive = false, - extension = null, - testMethod = "doTest${testClass}", - testClassName = testClass - ) - } - } - testClass { - allBuildSystemTests("buildFileGeneration") - } - testClass { - allBuildSystemTests("projectTemplatesBuildFileGeneration") - } - } - - //TODO: move these tests into idea-completion module - testGroup("idea/tests", "idea/idea-completion/testData") { - testClass { - model("handlers/runtimeCast") - } - - testClass { - model("basic/codeFragments", extension = "kt") - } - } - - testGroup("j2k/tests", "j2k/testData") { - testClass { - model("fileOrElement", extension = "java") - } - } - testGroup("j2k/tests", "j2k/testData") { - testClass { - model("multiFile", extension = null, recursive = false) - } - } - testGroup("j2k/tests", "j2k/testData") { - testClass { - model("fileOrElement", extension = "java") - } - } - - testGroup("nj2k/tests", "nj2k/testData") { - testClass { - model("newJ2k", pattern = """^([^\.]+)\.java$""") - } - testClass { - model("inference/common") - } - testClass { - model("inference/nullability") - } - testClass { - model("inference/mutability") - } - testClass { - model("copyPaste", pattern = """^([^\.]+)\.java$""") - } - testClass { - model("copyPastePlainText", pattern = """^([^\.]+)\.txt$""") - } - testClass { - model("multiFile", extension = null, recursive = false) - } - } - - testGroup("jps-plugin/jps-tests/test", "jps-plugin/testData") { - testClass { - model("incremental/multiModule/common", extension = null, excludeParentDirs = true) - model("incremental/multiModule/jvm", extension = null, excludeParentDirs = true) - model("incremental/multiModule/multiplatform/custom", extension = null, excludeParentDirs = true) - model("incremental/pureKotlin", extension = null, recursive = false) - model("incremental/withJava", extension = null, excludeParentDirs = true) - model("incremental/inlineFunCallSite", extension = null, excludeParentDirs = true) - model("incremental/classHierarchyAffected", extension = null, excludeParentDirs = true) - } - - actualizeMppJpsIncTestCaseDirs(testDataRoot, "incremental/multiModule/multiplatform/withGeneratedContent") - - testClass { - model("incremental/multiModule/common", extension = null, excludeParentDirs = true) - } - - testClass { - model( - "incremental/multiModule/multiplatform/withGeneratedContent", extension = null, excludeParentDirs = true, - testClassName = "MultiplatformMultiModule", recursive = true - ) - } - - testClass { - model("incremental/lookupTracker/jvm", extension = null, recursive = false) - } - testClass { - model("incremental/lookupTracker/js", extension = null, recursive = false) - } - testClass { - // todo: investigate why lookups are different from non-klib js - model("incremental/lookupTracker/jsKlib", extension = null, recursive = false) - } - - testClass { - model("incremental/lazyKotlinCaches", extension = null, excludeParentDirs = true) - model("incremental/changeIncrementalOption", extension = null, excludeParentDirs = true) - } - - testClass { - model("incremental/cacheVersionChanged", extension = null, excludeParentDirs = true) - } - - testClass { - model("incremental/cacheVersionChanged", extension = null, excludeParentDirs = true) - } - } - - testGroup("jps-plugin/jps-tests/test", "jps-plugin/testData") { - fun TestGroup.TestClass.commonProtoComparisonTests() { - model("comparison/classSignatureChange", extension = null, excludeParentDirs = true) - model("comparison/classPrivateOnlyChange", extension = null, excludeParentDirs = true) - model("comparison/classMembersOnlyChanged", extension = null, excludeParentDirs = true) - model("comparison/packageMembers", extension = null, excludeParentDirs = true) - model("comparison/unchanged", extension = null, excludeParentDirs = true) - } - - testClass { - commonProtoComparisonTests() - model("comparison/jvmOnly", extension = null, excludeParentDirs = true) - } - - testClass { - commonProtoComparisonTests() - model("comparison/jsOnly", extension = null, excludeParentDirs = true) - } - } - - testGroup("compiler/incremental-compilation-impl/test", "jps-plugin/testData") { - fun incrementalJvmTestData(targetBackend: TargetBackend): TestGroup.TestClass.() -> Unit = { - model("incremental/pureKotlin", extension = null, recursive = false, targetBackend = targetBackend) - model("incremental/classHierarchyAffected", extension = null, recursive = false, targetBackend = targetBackend) - model("incremental/inlineFunCallSite", extension = null, excludeParentDirs = true, targetBackend = targetBackend) - model("incremental/withJava", extension = null, excludeParentDirs = true, targetBackend = targetBackend) - model("incremental/incrementalJvmCompilerOnly", extension = null, excludeParentDirs = true, targetBackend = targetBackend) - } - testClass(init = incrementalJvmTestData(TargetBackend.JVM)) - testClass(init = incrementalJvmTestData(TargetBackend.JVM_IR)) - - testClass { - model("incremental/pureKotlin", extension = null, recursive = false) - model("incremental/classHierarchyAffected", extension = null, recursive = false) - model("incremental/js", extension = null, excludeParentDirs = true) - } - - testClass(annotations = listOf(muteExtraSuffix(".jsklib"))) { - model("incremental/pureKotlin", extension = null, recursive = false) - model("incremental/classHierarchyAffected", extension = null, recursive = false) - model("incremental/js", extension = null, excludeParentDirs = true) - } - - testClass { - model("incremental/pureKotlin", extension = null, recursive = false) - model("incremental/classHierarchyAffected", extension = null, recursive = false) - model("incremental/js", extension = null, excludeParentDirs = true) - } - - testClass { - model("incremental/pureKotlin", extension = null, recursive = false) - model("incremental/classHierarchyAffected", extension = null, recursive = false) - model("incremental/js", extension = null, excludeParentDirs = true) - model("incremental/scopeExpansion", extension = null, excludeParentDirs = true) - } - - testClass { - model("incremental/js/friendsModuleDisabled", extension = null, recursive = false) - } - - testClass { - model("incremental/mpp/allPlatforms", extension = null, excludeParentDirs = true) - model("incremental/mpp/jvmOnly", extension = null, excludeParentDirs = true) - } - testClass { - model("incremental/mpp/allPlatforms", extension = null, excludeParentDirs = true) - } - } - - testGroup( - "plugins/android-extensions/android-extensions-compiler/test", - "plugins/android-extensions/android-extensions-compiler/testData" - ) { - testClass { - model("descriptors", recursive = false, extension = null) - } - - testClass { - model("codegen/android", recursive = false, extension = null, testMethod = "doCompileAgainstAndroidSdkTest") - model("codegen/android", recursive = false, extension = null, testMethod = "doFakeInvocationTest", testClassName = "Invoke") - } - - testClass { - model( - "codegen/android", recursive = false, extension = null, testMethod = "doCompileAgainstAndroidSdkTest", - targetBackend = TargetBackend.JVM_IR - ) - model( - "codegen/android", recursive = false, extension = null, testMethod = "doFakeInvocationTest", testClassName = "Invoke", - targetBackend = TargetBackend.JVM_IR - ) - } - - testClass { - model("codegen/bytecodeShape", recursive = false, extension = null) - } - - testClass { - model("parcel/box", targetBackend = TargetBackend.JVM) - } - - testClass { - model("parcel/box", targetBackend = TargetBackend.JVM_IR) - } - - testClass { - model("parcel/codegen", targetBackend = TargetBackend.JVM) - } - - testClass { - model("parcel/codegen", targetBackend = TargetBackend.JVM_IR) - } - } - - testGroup("plugins/jvm-abi-gen/test", "plugins/jvm-abi-gen/testData") { - testClass { - model("compare", recursive = false, extension = null) - } - - testClass { - model("content", recursive = false, extension = null) - } - - testClass { - model("compile", recursive = false, extension = null) - } - } - - testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") { - testClass { - model("converter") - } - - testClass { - model("kotlinRunner") - } - - testClass { - model("converter", targetBackend = TargetBackend.JVM_IR) - } - - testClass { - model("kotlinRunner", targetBackend = TargetBackend.JVM_IR) - } - } - - testGroup("plugins/kapt3/kapt3-cli/test", "plugins/kapt3/kapt3-cli/testData") { - testClass { - model("argumentParsing", extension = "txt") - } - - testClass { - model("integration", recursive = false, extension = null) - } - } - - testGroup("plugins/allopen/allopen-cli/test", "plugins/allopen/allopen-cli/testData") { - testClass { - model("bytecodeListing", extension = "kt") - } - } - - testGroup("plugins/noarg/noarg-cli/test", "plugins/noarg/noarg-cli/testData") { - testClass { - model("bytecodeListing", extension = "kt") - } - - testClass { - model("box", targetBackend = TargetBackend.JVM) - } - } - - testGroup("plugins/sam-with-receiver/sam-with-receiver-cli/test", "plugins/sam-with-receiver/sam-with-receiver-cli/testData") { - testClass { - model("diagnostics") - } - testClass { - model("script", extension = "kts") - } - } - - testGroup( - "plugins/kotlin-serialization/kotlin-serialization-compiler/test", - "plugins/kotlin-serialization/kotlin-serialization-compiler/testData" - ) { - testClass { - model("diagnostics") - } - - testClass { - model("codegen") - } - - testClass { - model("codegen") - } - } - - testGroup("plugins/fir/fir-plugin-prototype/tests", "plugins/fir/fir-plugin-prototype/testData") { - testClass { - model("") - } - } - - testGroup("idea/performanceTests/test", "idea/testData") { - testClass { - model("copyPaste/conversion", testMethod = "doPerfTest", pattern = """^([^\.]+)\.java$""") - } - - testClass { - model("copyPaste/conversion", testMethod = "doPerfTest", pattern = """^([^\.]+)\.java$""") - } - - testClass { - model("copyPaste/literal", testMethod = "doPerfTest", pattern = """^([^\.]+)\.kt$""") - } - - testClass { - model("highlighter", testMethod = "doPerfTest") - } - - testClass { - model("addImport", testMethod = "doPerfTest", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("indentationOnNewline", testMethod = "doPerfTest", pattern = KT_OR_KTS_WITHOUT_DOTS_IN_NAME) - } - } - - testGroup("idea/performanceTests/test", "idea/idea-completion/testData") { - testClass { - model("incrementalResolve", testMethod = "doPerfTest") - } - - testClass { - model("handlers/basic", testMethod = "doPerfTest", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - - testClass { - model("handlers/smart", testMethod = "doPerfTest") - } - - testClass { - model("handlers/keywords", testMethod = "doPerfTest") - } - - testClass { - model("handlers/charFilter", testMethod = "doPerfTest", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - } - /* - testGroup("plugins/android-extensions/android-extensions-idea/tests", "plugins/android-extensions/android-extensions-idea/testData") { - testClass { - model("android/completion", recursive = false, extension = null) - } - - testClass { - model("android/goto", recursive = false, extension = null) - } - - testClass { - model("android/rename", recursive = false, extension = null) - } - - testClass { - model("android/renameLayout", recursive = false, extension = null) - } - - testClass { - model("android/findUsages", recursive = false, extension = null) - } - - testClass { - model("android/usageHighlighting", recursive = false, extension = null) - } - - testClass { - model("android/extraction", recursive = false, extension = null) - } - - testClass { - model("android/parcel/checker", excludeParentDirs = true) - } - - testClass { - model("android/parcel/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile") - } - } - - testGroup("idea/idea-android/tests", "idea/testData") { - testClass { - model("configuration/android-gradle", pattern = """(\w+)_before\.gradle$""", testMethod = "doTestAndroidGradle") - model("configuration/android-gsk", pattern = """(\w+)_before\.gradle.kts$""", testMethod = "doTestAndroidGradle") - } - - testClass { - model("android/intention", pattern = "^([\\w\\-_]+)\\.kt$") - } - - testClass { - model("android/resourceIntention", extension = "test", singleClass = true) - } - - testClass { - model("android/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile") - } - - testClass { - model("android/lint", excludeParentDirs = true) - } - - testClass { - model("android/lintQuickfix", pattern = "^([\\w\\-_]+)\\.kt$") - } - - testClass { - model("android/folding") - } - - testClass { - model("android/gutterIcon") - } - } - */ - } -} diff --git a/gradle/versions.properties.192 b/gradle/versions.properties.192 deleted file mode 100644 index 5a1ac2618e6..00000000000 --- a/gradle/versions.properties.192 +++ /dev/null @@ -1,17 +0,0 @@ -versions.intellijSdk=192.7142.36 -versions.androidBuildTools=r23.0.1 -versions.idea.NodeJS=181.3494.12 -versions.jar.asm-all=7.0.1 -versions.jar.guava=25.1-jre -versions.jar.groovy-all=2.4.17 -versions.jar.lombok-ast=0.2.3 -versions.jar.swingx-core=1.6.2-2 -versions.jar.kxml2=2.3.0 -versions.jar.streamex=0.6.8 -versions.jar.gson=2.8.5 -versions.jar.oro=2.0.8 -versions.jar.picocontainer=1.2 -versions.jar.lz4-java=1.6.0 -ignore.jar.snappy-in-java=true -versions.gradle-api=4.5.1 -versions.shadow=5.2.0 \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/PerModulePackageCacheService.kt.192 b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/PerModulePackageCacheService.kt.192 deleted file mode 100644 index 173d13202cf..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/PerModulePackageCacheService.kt.192 +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.caches - -import com.intellij.ProjectTopics -import com.intellij.openapi.Disposable -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.ServiceManager -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.module.Module -import com.intellij.openapi.progress.ProcessCanceledException -import com.intellij.openapi.project.Project -import com.intellij.openapi.project.rootManager -import com.intellij.openapi.roots.ModuleRootEvent -import com.intellij.openapi.roots.ModuleRootListener -import com.intellij.openapi.util.Key -import com.intellij.openapi.vfs.VfsUtilCore -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.openapi.vfs.VirtualFileManager -import com.intellij.openapi.vfs.newvfs.BulkFileListener -import com.intellij.openapi.vfs.newvfs.events.* -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiManager -import com.intellij.psi.impl.PsiManagerEx -import com.intellij.psi.impl.PsiTreeChangeEventImpl -import com.intellij.psi.impl.PsiTreeChangePreprocessor -import com.intellij.psi.search.GlobalSearchScope -import com.intellij.util.containers.ContainerUtil -import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.idea.caches.PerModulePackageCacheService.Companion.DEBUG_LOG_ENABLE_PerModulePackageCache -import org.jetbrains.kotlin.idea.caches.PerModulePackageCacheService.Companion.FULL_DROP_THRESHOLD -import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo -import org.jetbrains.kotlin.idea.caches.project.getModuleInfoByVirtualFile -import org.jetbrains.kotlin.idea.caches.project.getNullableModuleInfo -import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil -import org.jetbrains.kotlin.idea.util.getSourceRoot -import org.jetbrains.kotlin.idea.util.sourceRoot -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.KtPackageDirective -import org.jetbrains.kotlin.psi.NotNullableUserDataProperty -import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType -import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.ConcurrentMap - -class KotlinPackageContentModificationListener(private val project: Project) : Disposable { - val connection = project.messageBus.connect() - - companion object { - val LOG = Logger.getInstance(this::class.java) - } - - init { - connection.subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener { - override fun before(events: MutableList) = onEvents(events, false) - override fun after(events: List) = onEvents(events, true) - - private fun isRelevant(event: VFileEvent): Boolean = when (event) { - is VFilePropertyChangeEvent -> false - is VFileCreateEvent -> true - is VFileMoveEvent -> true - is VFileDeleteEvent -> true - is VFileContentChangeEvent -> true - is VFileCopyEvent -> true - else -> { - LOG.warn("Unknown vfs event: ${event.javaClass}") - false - } - } - - fun onEvents(events: List, isAfter: Boolean) { - val service = PerModulePackageCacheService.getInstance(project) - val fileManager = PsiManagerEx.getInstanceEx(project).fileManager - if (events.size >= FULL_DROP_THRESHOLD) { - service.onTooComplexChange() - } else { - events.asSequence() - .filter(::isRelevant) - .filter { - (it.isValid || it !is VFileCreateEvent) && it.file != null - } - .filter { - val vFile = it.file!! - vFile.isDirectory || vFile.fileType == KotlinFileType.INSTANCE - } - .filter { - // It expected that content change events will be duplicated with more precise PSI events and processed - // in KotlinPackageStatementPsiTreeChangePreprocessor, but events might have been missing if PSI view provider - // is absent. - if (it is VFileContentChangeEvent) { - isAfter && fileManager.findCachedViewProvider(it.file) == null - } else { - true - } - } - .filter { - when (val origin = it.requestor) { - is Project -> origin == project - is PsiManager -> origin.project == project - else -> true - } - } - .forEach { event -> service.notifyPackageChange(event) } - } - } - }) - - connection.subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener { - override fun rootsChanged(event: ModuleRootEvent) { - PerModulePackageCacheService.getInstance(project).onTooComplexChange() - } - }) - } - - override fun dispose() { - connection.disconnect() - } -} - -class KotlinPackageStatementPsiTreeChangePreprocessor(private val project: Project) : PsiTreeChangePreprocessor { - override fun treeChanged(event: PsiTreeChangeEventImpl) { - val eFile = event.file ?: event.child as? PsiFile - if (eFile == null) { - LOG.debugIfEnabled(project, true) { "Got PsiEvent: $event without file" } - } - val file = eFile as? KtFile ?: return - - when (event.code) { - PsiTreeChangeEventImpl.PsiEventType.CHILD_ADDED, - PsiTreeChangeEventImpl.PsiEventType.CHILD_MOVED, - PsiTreeChangeEventImpl.PsiEventType.CHILD_REPLACED, - PsiTreeChangeEventImpl.PsiEventType.CHILD_REMOVED -> { - val child = event.child ?: run { - LOG.debugIfEnabled(project, true) { "Got PsiEvent: $event without child" } - return - } - if (child.getParentOfType(false) != null) - ServiceManager.getService(project, PerModulePackageCacheService::class.java).notifyPackageChange(file) - } - PsiTreeChangeEventImpl.PsiEventType.CHILDREN_CHANGED -> { - val parent = event.parent ?: run { - LOG.debugIfEnabled(project, true) { "Got PsiEvent: $event without parent" } - return - } - val childrenOfType = parent.getChildrenOfType() - if ( - (!event.isGenericChange && (childrenOfType.any() || parent is KtPackageDirective)) || - (childrenOfType.any { it.name.isEmpty() } && parent is KtFile) - ) { - ServiceManager.getService(project, PerModulePackageCacheService::class.java).notifyPackageChange(file) - } - } - else -> { - } - } - } - - companion object { - val LOG = Logger.getInstance(this::class.java) - } -} - -private typealias ImplicitPackageData = MutableMap> - -class ImplicitPackagePrefixCache(private val project: Project) { - private val implicitPackageCache = ConcurrentHashMap() - - fun getPrefix(sourceRoot: VirtualFile): FqName { - val implicitPackageMap = implicitPackageCache.getOrPut(sourceRoot) { analyzeImplicitPackagePrefixes(sourceRoot) } - return implicitPackageMap.keys.singleOrNull() ?: FqName.ROOT - } - - internal fun clear() { - implicitPackageCache.clear() - } - - private fun analyzeImplicitPackagePrefixes(sourceRoot: VirtualFile): MutableMap> { - val result = mutableMapOf>() - val ktFiles = sourceRoot.children.filter { it.fileType == KotlinFileType.INSTANCE } - for (ktFile in ktFiles) { - result.addFile(ktFile) - } - return result - } - - private fun ImplicitPackageData.addFile(ktFile: VirtualFile) { - synchronized(this) { - val psiFile = PsiManager.getInstance(project).findFile(ktFile) as? KtFile ?: return - addPsiFile(psiFile, ktFile) - } - } - - private fun ImplicitPackageData.addPsiFile( - psiFile: KtFile, - ktFile: VirtualFile - ) = getOrPut(psiFile.packageFqName) { mutableListOf() }.add(ktFile) - - private fun ImplicitPackageData.removeFile(file: VirtualFile) { - synchronized(this) { - for ((key, value) in this) { - if (value.remove(file)) { - if (value.isEmpty()) remove(key) - break - } - } - } - } - - private fun ImplicitPackageData.updateFile(file: KtFile) { - synchronized(this) { - removeFile(file.virtualFile) - addPsiFile(file, file.virtualFile) - } - } - - internal fun update(event: VFileEvent) { - when (event) { - is VFileCreateEvent -> checkNewFileInSourceRoot(event.file) - is VFileDeleteEvent -> checkDeletedFileInSourceRoot(event.file) - is VFileCopyEvent -> { - val newParent = event.newParent - if (newParent.isValid) { - checkNewFileInSourceRoot(newParent.findChild(event.newChildName)) - } - } - is VFileMoveEvent -> { - checkNewFileInSourceRoot(event.file) - if (event.oldParent.getSourceRoot(project) == event.oldParent) { - implicitPackageCache[event.oldParent]?.removeFile(event.file) - } - } - } - } - - private fun checkNewFileInSourceRoot(file: VirtualFile?) { - if (file == null) return - if (file.getSourceRoot(project) == file.parent) { - implicitPackageCache[file.parent]?.addFile(file) - } - } - - private fun checkDeletedFileInSourceRoot(file: VirtualFile?) { - val directory = file?.parent - if (directory == null || !directory.isValid) return - if (directory.getSourceRoot(project) == directory) { - implicitPackageCache[directory]?.removeFile(file) - } - } - - internal fun update(ktFile: KtFile) { - val parent = ktFile.virtualFile?.parent ?: return - if (ktFile.sourceRoot == parent) { - implicitPackageCache[parent]?.updateFile(ktFile) - } - } -} - -class PerModulePackageCacheService(private val project: Project) : Disposable { - - /* - * Actually an WeakMap>> - */ - private val cache = ContainerUtil.createConcurrentWeakMap>>() - private val implicitPackagePrefixCache = ImplicitPackagePrefixCache(project) - - private val pendingVFileChanges: MutableSet = mutableSetOf() - private val pendingKtFileChanges: MutableSet = mutableSetOf() - - private val projectScope = GlobalSearchScope.projectScope(project) - - internal fun onTooComplexChange() { - clear() - } - - private fun clear() { - synchronized(this) { - pendingVFileChanges.clear() - pendingKtFileChanges.clear() - cache.clear() - implicitPackagePrefixCache.clear() - } - } - - internal fun notifyPackageChange(file: VFileEvent): Unit = synchronized(this) { - pendingVFileChanges += file - } - - internal fun notifyPackageChange(file: KtFile): Unit = synchronized(this) { - pendingKtFileChanges += file - } - - private fun invalidateCacheForModuleSourceInfo(moduleSourceInfo: ModuleSourceInfo) { - LOG.debugIfEnabled(project) { "Invalidated cache for $moduleSourceInfo" } - val perSourceInfoData = cache[moduleSourceInfo.module] ?: return - val dataForSourceInfo = perSourceInfoData[moduleSourceInfo] ?: return - dataForSourceInfo.clear() - } - - private fun checkPendingChanges() = synchronized(this) { - if (pendingVFileChanges.size + pendingKtFileChanges.size >= FULL_DROP_THRESHOLD) { - onTooComplexChange() - } else { - pendingVFileChanges.processPending { event -> - val vfile = event.file ?: return@processPending - // When VirtualFile !isValid (deleted for example), it impossible to use getModuleInfoByVirtualFile - // For directory we must check both is it in some sourceRoot, and is it contains some sourceRoot - if (vfile.isDirectory || !vfile.isValid) { - for ((module, data) in cache) { - val sourceRootUrls = module.rootManager.sourceRootUrls - if (sourceRootUrls.any { url -> - vfile.containedInOrContains(url) - }) { - LOG.debugIfEnabled(project) { "Invalidated cache for $module" } - data.clear() - } - } - } else { - val infoByVirtualFile = getModuleInfoByVirtualFile(project, vfile) - if (infoByVirtualFile == null || infoByVirtualFile !is ModuleSourceInfo) { - LOG.debugIfEnabled(project) { "Skip $vfile as it has mismatched ModuleInfo=$infoByVirtualFile" } - } - (infoByVirtualFile as? ModuleSourceInfo)?.let { - invalidateCacheForModuleSourceInfo(it) - } - } - - implicitPackagePrefixCache.update(event) - } - - pendingKtFileChanges.processPending { file -> - if (file.virtualFile != null && file.virtualFile !in projectScope) { - LOG.debugIfEnabled(project) { - "Skip $file without vFile, or not in scope: ${file.virtualFile?.let { it !in projectScope }}" - } - return@processPending - } - val nullableModuleInfo = file.getNullableModuleInfo() - (nullableModuleInfo as? ModuleSourceInfo)?.let { invalidateCacheForModuleSourceInfo(it) } - if (nullableModuleInfo == null || nullableModuleInfo !is ModuleSourceInfo) { - LOG.debugIfEnabled(project) { "Skip $file as it has mismatched ModuleInfo=$nullableModuleInfo" } - } - implicitPackagePrefixCache.update(file) - } - } - } - - private inline fun MutableCollection.processPending(crossinline body: (T) -> Unit) { - this.removeIf { value -> - try { - body(value) - } catch (pce: ProcessCanceledException) { - throw pce - } catch (exc: Exception) { - // Log and proceed. Otherwise pending object processing won't be cleared and exception will be thrown forever. - LOG.error(exc) - } - - return@removeIf true - } - } - - private fun VirtualFile.containedInOrContains(root: String) = - (VfsUtilCore.isEqualOrAncestor(url, root) - || isDirectory && VfsUtilCore.isEqualOrAncestor(root, url)) - - - fun packageExists(packageFqName: FqName, moduleInfo: ModuleSourceInfo): Boolean { - val module = moduleInfo.module - checkPendingChanges() - - val perSourceInfoCache = cache.getOrPut(module) { - ContainerUtil.createConcurrentSoftMap() - } - val cacheForCurrentModuleInfo = perSourceInfoCache.getOrPut(moduleInfo) { - ContainerUtil.createConcurrentSoftMap() - } - - return cacheForCurrentModuleInfo.getOrPut(packageFqName) { - val packageExists = PackageIndexUtil.packageExists(packageFqName, moduleInfo.contentScope(), project) - LOG.debugIfEnabled(project) { "Computed cache value for $packageFqName in $moduleInfo is $packageExists" } - packageExists - } - } - - fun getImplicitPackagePrefix(sourceRoot: VirtualFile): FqName { - checkPendingChanges() - return implicitPackagePrefixCache.getPrefix(sourceRoot) - } - - override fun dispose() { - clear() - } - - companion object { - const val FULL_DROP_THRESHOLD = 1000 - private val LOG = Logger.getInstance(this::class.java) - - fun getInstance(project: Project): PerModulePackageCacheService = - ServiceManager.getService(project, PerModulePackageCacheService::class.java) - - var Project.DEBUG_LOG_ENABLE_PerModulePackageCache: Boolean - by NotNullableUserDataProperty(Key.create("debug.PerModulePackageCache"), false) - } -} - -private fun Logger.debugIfEnabled(project: Project, withCurrentTrace: Boolean = false, message: () -> String) { - if (ApplicationManager.getApplication().isUnitTestMode && project.DEBUG_LOG_ENABLE_PerModulePackageCache) { - val msg = message() - if (withCurrentTrace) { - val e = Exception().apply { fillInStackTrace() } - this.debug(msg, e) - } else { - this.debug(msg) - } - } -} \ No newline at end of file diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/ScriptExternalHighlightingPass.kt.192 b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/ScriptExternalHighlightingPass.kt.192 deleted file mode 100644 index d137df5dbb9..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/ScriptExternalHighlightingPass.kt.192 +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2010-2017 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.highlighter - -import com.intellij.codeHighlighting.Pass -import com.intellij.codeHighlighting.TextEditorHighlightingPass -import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory -import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar -import com.intellij.codeInsight.daemon.impl.HighlightInfo -import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil -import com.intellij.lang.annotation.Annotation -import com.intellij.lang.annotation.HighlightSeverity -import com.intellij.lang.annotation.HighlightSeverity.* -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.editor.Document -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.project.DumbAware -import com.intellij.openapi.ui.MessageType -import com.intellij.openapi.wm.WindowManager -import com.intellij.openapi.wm.ex.StatusBarEx -import com.intellij.psi.PsiFile -import com.intellij.util.ui.UIUtil -import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink -import org.jetbrains.kotlin.idea.script.ScriptDiagnosticFixProvider -import org.jetbrains.kotlin.psi.KtFile -import kotlin.script.experimental.api.ScriptDiagnostic -import kotlin.script.experimental.api.SourceCode - -class ScriptExternalHighlightingPass( - private val file: KtFile, - document: Document -) : TextEditorHighlightingPass(file.project, document), DumbAware { - override fun doCollectInformation(progress: ProgressIndicator) = Unit - - override fun doApplyInformationToEditor() { - val document = document ?: return - - if (!file.isScript()) return - - val reports = IdeScriptReportSink.getReports(file) - - val annotations = reports.mapNotNull { scriptDiagnostic -> - val (startOffset, endOffset) = scriptDiagnostic.location?.let { computeOffsets(document, it) } ?: 0 to 0 - val exception = scriptDiagnostic.exception - val exceptionMessage = if (exception != null) " ($exception)" else "" - val message = scriptDiagnostic.message + exceptionMessage - val annotation = Annotation( - startOffset, - endOffset, - scriptDiagnostic.severity.convertSeverity() ?: return@mapNotNull null, - message, - message - ) - - // if range is empty, show notification panel in editor - annotation.isFileLevelAnnotation = startOffset == endOffset - - for (provider in ScriptDiagnosticFixProvider.EP_NAME.extensions) { - provider.provideFixes(scriptDiagnostic).forEach { - annotation.registerFix(it) - } - } - - annotation - } - - val infos = annotations.map { HighlightInfo.fromAnnotation(it) } - UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument!!, 0, file.textLength, infos, colorsScheme, id) - } - - private fun computeOffsets(document: Document, position: SourceCode.Location): Pair { - val startLine = position.start.line.coerceLineIn(document) - val startOffset = document.offsetBy(startLine, position.start.col) - - val endLine = position.end?.line?.coerceAtLeast(startLine)?.coerceLineIn(document) ?: startLine - val endOffset = document.offsetBy( - endLine, - position.end?.col ?: document.getLineEndOffset(endLine) - ).coerceAtLeast(startOffset) - - return startOffset to endOffset - } - - private fun Int.coerceLineIn(document: Document) = coerceIn(0, document.lineCount - 1) - - private fun Document.offsetBy(line: Int, col: Int): Int { - return (getLineStartOffset(line) + col).coerceIn(getLineStartOffset(line), getLineEndOffset(line)) - } - - private fun ScriptDiagnostic.Severity.convertSeverity(): HighlightSeverity? { - return when (this) { - ScriptDiagnostic.Severity.FATAL -> ERROR - ScriptDiagnostic.Severity.ERROR -> ERROR - ScriptDiagnostic.Severity.WARNING -> WARNING - ScriptDiagnostic.Severity.INFO -> INFORMATION - ScriptDiagnostic.Severity.DEBUG -> if (ApplicationManager.getApplication().isInternal) INFORMATION else null - } - } - - private fun showNotification(file: KtFile, message: String) { - UIUtil.invokeLaterIfNeeded { - val ideFrame = WindowManager.getInstance().getIdeFrame(file.project) - if (ideFrame != null) { - val statusBar = ideFrame.statusBar as StatusBarEx - statusBar.notifyProgressByBalloon( - MessageType.WARNING, - message, - null, - null - ) - } - } - } - - class Factory(registrar: TextEditorHighlightingPassRegistrar) : ProjectComponent, - TextEditorHighlightingPassFactory { - init { - registrar.registerTextEditorHighlightingPass( - this, - TextEditorHighlightingPassRegistrar.Anchor.BEFORE, - Pass.UPDATE_FOLDING, - false, - false - ) - } - - override fun createHighlightingPass(file: PsiFile, editor: Editor): TextEditorHighlightingPass? { - if (file !is KtFile) return null - return ScriptExternalHighlightingPass(file, editor.document) - } - } -} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/klib/KlibLoadingMetadataCache.kt.192 b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/klib/KlibLoadingMetadataCache.kt.192 deleted file mode 100644 index 9fb565c27cc..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/klib/KlibLoadingMetadataCache.kt.192 +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.klib - -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.BaseComponent - -// FIX ME WHEN BUNCH 192 REMOVED -class KlibLoadingMetadataCache : KlibLoadingMetadataCacheCompat(), BaseComponent { - - companion object { - @JvmStatic - fun getInstance(): KlibLoadingMetadataCache = - ApplicationManager.getApplication().getComponent(KlibLoadingMetadataCache::class.java) - } - -} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/modules/ModuleHighlightUtil2.java.192 b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/modules/ModuleHighlightUtil2.java.192 deleted file mode 100644 index 053f070e51d..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/modules/ModuleHighlightUtil2.java.192 +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2010-2017 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.modules; - -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ModuleRootManager; -import com.intellij.openapi.roots.ProjectFileIndex; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiJavaFile; -import com.intellij.psi.PsiJavaModule; -import com.intellij.psi.PsiManager; -import com.intellij.psi.impl.light.LightJavaModule; -import kotlin.collections.ArraysKt; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.idea.core.FileIndexUtilsKt; - -import java.io.IOException; -import java.io.InputStream; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - -import static com.intellij.psi.PsiJavaModule.MODULE_INFO_FILE; - -// Copied from com.intellij.codeInsight.daemon.impl.analysis.ModuleHighlightUtil -public class ModuleHighlightUtil2 { - private static final Attributes.Name MULTI_RELEASE = new Attributes.Name("Multi-Release"); - - @Nullable - static PsiJavaModule getModuleDescriptor(@NotNull VirtualFile file, @NotNull Project project) { - ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project); - if (index.isInLibrary(file)) { - VirtualFile root; - if ((root = index.getClassRootForFile(file)) != null) { - VirtualFile descriptorFile = root.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE); - if (descriptorFile == null) { - VirtualFile alt = root.findFileByRelativePath("META-INF/versions/9/" + PsiJavaModule.MODULE_INFO_CLS_FILE); - if (alt != null && isMultiReleaseJar(root)) { - descriptorFile = alt; - } - } - if (descriptorFile != null) { - PsiFile psiFile = PsiManager.getInstance(project).findFile(descriptorFile); - if (psiFile instanceof PsiJavaFile) { - return ((PsiJavaFile) psiFile).getModuleDeclaration(); - } - } - else if (root.getFileSystem() instanceof JarFileSystem && "jar".equalsIgnoreCase(root.getExtension())) { - return LightJavaModule.getModule(PsiManager.getInstance(project), root); - } - } - else if ((root = index.getSourceRootForFile(file)) != null) { - VirtualFile descriptorFile = root.findChild(MODULE_INFO_FILE); - if (descriptorFile != null) { - PsiFile psiFile = PsiManager.getInstance(project).findFile(descriptorFile); - if (psiFile instanceof PsiJavaFile) { - return ((PsiJavaFile) psiFile).getModuleDeclaration(); - } - } - } - } - else { - Module module = index.getModuleForFile(file); - if (module != null) { - boolean isTest = FileIndexUtilsKt.isInTestSourceContentKotlinAware(index, file); - VirtualFile modularRoot = ArraysKt.singleOrNull(ModuleRootManager.getInstance(module).getSourceRoots(isTest), - root -> root.findChild(MODULE_INFO_FILE) != null); - if (modularRoot != null) { - VirtualFile moduleInfo = modularRoot.findChild(MODULE_INFO_FILE); - assert moduleInfo != null : modularRoot; - PsiFile psiFile = PsiManager.getInstance(project).findFile(moduleInfo); - if (psiFile instanceof PsiJavaFile) { - return ((PsiJavaFile) psiFile).getModuleDeclaration(); - } - } - } - } - - return null; - } - - private static boolean isMultiReleaseJar(VirtualFile root) { - if (root.getFileSystem() instanceof JarFileSystem) { - VirtualFile manifest = root.findFileByRelativePath(JarFile.MANIFEST_NAME); - if (manifest != null) { - try (InputStream stream = manifest.getInputStream()) { - return Boolean.valueOf(new Manifest(stream).getMainAttributes().getValue(MULTI_RELEASE)); - } - catch (IOException ignored) { - } - } - } - - return false; - } -} diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupCancelService.kt.192 b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupCancelService.kt.192 deleted file mode 100644 index 00fad96f055..00000000000 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupCancelService.kt.192 +++ /dev/null @@ -1,19 +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.completion - -typealias LookupCancelService = LookupCancelWatcher \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupCancelWatcher.kt.192 b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupCancelWatcher.kt.192 deleted file mode 100644 index 46318e0e9c5..00000000000 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupCancelWatcher.kt.192 +++ /dev/null @@ -1,158 +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.completion - -import com.intellij.application.subscribe -import com.intellij.codeInsight.completion.CompletionPhaseListener -import com.intellij.codeInsight.lookup.Lookup -import com.intellij.codeInsight.lookup.LookupEvent -import com.intellij.codeInsight.lookup.LookupListener -import com.intellij.codeInsight.lookup.LookupManager -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.EditorFactory -import com.intellij.openapi.editor.RangeMarker -import com.intellij.openapi.editor.event.CaretEvent -import com.intellij.openapi.editor.event.CaretListener -import com.intellij.openapi.editor.event.EditorFactoryEvent -import com.intellij.openapi.editor.event.EditorFactoryListener -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.Key -import org.jetbrains.kotlin.idea.statistics.CompletionFUSCollector -import org.jetbrains.kotlin.idea.statistics.CompletionFUSCollector.completionStatsData -import org.jetbrains.kotlin.idea.statistics.FinishReasonStats - -class LookupCancelWatcher(val project: Project) : ProjectComponent { - private class Reminiscence(editor: Editor, offset: Int) { - var editor: Editor? = editor - private var marker: RangeMarker? = editor.document.createRangeMarker(offset, offset) - - // forget about auto-popup cancellation when the caret is moved to the start or before it - private var editorListener: CaretListener? = object : CaretListener { - override fun caretPositionChanged(e: CaretEvent) { - if (marker != null && (!marker!!.isValid || editor.logicalPositionToOffset(e.newPosition) <= offset)) { - dispose() - } - } - } - - init { - ApplicationManager.getApplication()!!.assertIsDispatchThread() - editor.caretModel.addCaretListener(editorListener!!) - } - - fun matches(editor: Editor, offset: Int): Boolean { - return editor == this.editor && marker?.startOffset == offset - } - - fun dispose() { - ApplicationManager.getApplication()!!.assertIsDispatchThread() - if (marker != null) { - editor!!.caretModel.removeCaretListener(editorListener!!) - marker = null - editor = null - editorListener = null - } - } - } - - private var lastReminiscence: Reminiscence? = null - - companion object { - fun getInstance(project: Project): LookupCancelWatcher = project.getComponent(LookupCancelWatcher::class.java)!! - - val AUTO_POPUP_AT = Key("LookupCancelWatcher.AUTO_POPUP_AT") - } - - fun wasAutoPopupRecentlyCancelled(editor: Editor, offset: Int): Boolean { - return lastReminiscence?.matches(editor, offset) ?: false - } - - private val lookupCancelListener = object : LookupListener { - override fun lookupCanceled(event: LookupEvent) { - val lookup = event.lookup - if (event.isCanceledExplicitly && lookup.isCompletion) { - val offset = lookup.currentItem?.getUserData(AUTO_POPUP_AT) - if (offset != null) { - lastReminiscence?.dispose() - if (offset <= lookup.editor.document.textLength) { - lastReminiscence = Reminiscence(lookup.editor, offset) - } - } - } - } - } - - override fun initComponent() { - CompletionPhaseListener.TOPIC.subscribe(project, CompletionPhaseListener { isCompletionRunning -> - if (isCompletionRunning) { - if (completionStatsData != null) { - completionStatsData = completionStatsData?.copy(finishReason = FinishReasonStats.INTERRUPTED) - CompletionFUSCollector.log(completionStatsData) - completionStatsData = null - } - completionStatsData = CompletionFUSCollector.CompletionStatsData(System.currentTimeMillis()) - } - - if (!isCompletionRunning) { - completionStatsData = completionStatsData?.copy(finishTime = System.currentTimeMillis()) - } - }) - - EditorFactory.getInstance().addEditorFactoryListener( - object : EditorFactoryListener { - override fun editorReleased(event: EditorFactoryEvent) { - if (lastReminiscence?.editor == event.editor) { - lastReminiscence!!.dispose() - } - } - }, - project - ) - - LookupManager.getInstance(project).addPropertyChangeListener { event -> - if (event.propertyName == LookupManager.PROP_ACTIVE_LOOKUP) { - val lookup = event.newValue as Lookup? - lookup?.addLookupListener(lookupCancelListener) - lookup?.addLookupListener(object : LookupListener { - override fun lookupShown(event: LookupEvent) { - completionStatsData = completionStatsData?.copy(shownTime = System.currentTimeMillis()) - } - - override fun lookupCanceled(event: LookupEvent) { - completionStatsData = completionStatsData?.copy( - finishReason = if (event.isCanceledExplicitly) FinishReasonStats.CANCELLED else FinishReasonStats.HIDDEN - ) - CompletionFUSCollector.log(completionStatsData) - completionStatsData = null - } - - override fun itemSelected(event: LookupEvent) { - val eventLookup = event.lookup - val lookupIndex = eventLookup.items.indexOf(eventLookup.currentItem) - if (lookupIndex >= 0) completionStatsData = completionStatsData?.copy(selectedItem = lookupIndex) - - completionStatsData = completionStatsData?.copy(finishReason = FinishReasonStats.DONE) - CompletionFUSCollector.log(completionStatsData) - completionStatsData = null - } - }) - } - } - } -} diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ml/KotlinContextFeatureProvider.kt.192 b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ml/KotlinContextFeatureProvider.kt.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ml/KotlinMLRankingProvider.kt.192 b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ml/KotlinMLRankingProvider.kt.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/idea-completion/testData/injava/InterfaceDefaultImplsNonImported.java.192 b/idea/idea-completion/testData/injava/InterfaceDefaultImplsNonImported.java.192 deleted file mode 100644 index 1450ed0f319..00000000000 --- a/idea/idea-completion/testData/injava/InterfaceDefaultImplsNonImported.java.192 +++ /dev/null @@ -1,11 +0,0 @@ -public class Testing { - public static void test() { - DefaultImpl - } -} - -// EXIST: { lookupString: "DefaultImpls", tailText: " (defaultImpls.NonAbstractFun)" } -// EXIST: { lookupString: "DefaultImpls", tailText: " (defaultImpls.NonAbstractFunWithExpressionBody)" } -// EXIST: { lookupString: "DefaultImpls", tailText: " (defaultImpls.NonAbstractProperty)" } -// EXIST: { lookupString: "DefaultImpls", tailText: " (defaultImpls.NonAbstractPropertyWithBody)" } -// ABSENT: { lookupString: "DefaultImpls", tailText: " (defaultImpls.AllAbstract)" } \ No newline at end of file diff --git a/idea/idea-completion/testData/injava/stdlib/List.java.192 b/idea/idea-completion/testData/injava/stdlib/List.java.192 deleted file mode 100644 index 953c2a0cc86..00000000000 --- a/idea/idea-completion/testData/injava/stdlib/List.java.192 +++ /dev/null @@ -1,9 +0,0 @@ -public class Testing { - public static void test() { - List - } -} - -// EXIST: EmptyList -// EXIST: { lookupString:List,tailText:" (java.util)" } -// ABSENT: { lookupString:List,tailText:" (kotlin.collections)" } \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt.192 b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt.192 deleted file mode 100644 index 0da5e248c7d..00000000000 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/AbstractKotlinSourceInJavaCompletionTest.kt.192 +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.completion.test - -import com.intellij.codeInsight.completion.CompletionType -import com.intellij.openapi.util.io.FileUtil -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.platform.jvm.JvmPlatforms -import java.io.File - -abstract class AbstractKotlinSourceInJavaCompletionTest : KotlinFixtureCompletionBaseTestCase() { - override fun getPlatform() = JvmPlatforms.unspecifiedJvmPlatform - - override fun doTest(testPath: String) { - val mockPath = RELATIVE_COMPLETION_TEST_DATA_BASE_PATH + "/injava/mockLib" - val mockLibDir = File(mockPath) - fun collectPaths(dir: File): List { - return dir.listFiles()!!.flatMap { - if (it.isDirectory) { - collectPaths(it) - } else listOf(FileUtil.toSystemIndependentName(it.path)) - } - } - - val paths = collectPaths(mockLibDir).toTypedArray() - paths.forEach { path -> - val vFile = myFixture.copyFileToProject(path, path.substring(mockPath.length)) - myFixture.configureFromExistingVirtualFile(vFile) - } - - LightClassComputationControl.testWithControl(project, FileUtil.loadFile(File(testPath))) { - super.doTest(testPath) - } - } - - override fun getProjectDescriptor() = LightCodeInsightFixtureTestCase.JAVA_LATEST - override fun defaultCompletionType() = CompletionType.BASIC -} \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinModelMetadataTest.kt.192 b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinModelMetadataTest.kt.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt.192 b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt.192 deleted file mode 100644 index 5e9e4a59ed2..00000000000 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/KotlinBeforeResolveHighlightingPass.kt.192 +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.highlighter - -import com.intellij.codeHighlighting.Pass -import com.intellij.codeHighlighting.TextEditorHighlightingPass -import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory -import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar -import com.intellij.codeInsight.daemon.impl.AnnotationHolderImpl -import com.intellij.codeInsight.daemon.impl.HighlightInfo -import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil -import com.intellij.lang.annotation.AnnotationSession -import com.intellij.lang.annotation.AnnotationHolder -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.editor.Document -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.extensions.ExtensionPointName -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.project.DumbAware -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile -import com.intellij.psi.PsiRecursiveElementVisitor -import org.jetbrains.kotlin.psi.KtFile - -class KotlinBeforeResolveHighlightingPass( - private val file: KtFile, - document: Document -) : TextEditorHighlightingPass(file.project, document), DumbAware { - - @Volatile - private var annotationHolder: AnnotationHolderImpl? = null - - override fun doCollectInformation(progress: ProgressIndicator) { - val annotationHolder = AnnotationHolderImpl(AnnotationSession(file)) - val visitor = BeforeResolveHighlightingVisitor(annotationHolder) - val extensions = EP_NAME.extensionList.map { it.createVisitor(annotationHolder) } - file.accept(object : PsiRecursiveElementVisitor() { - override fun visitElement(element: PsiElement) { - super.visitElement(element) - element.accept(visitor) - extensions.forEach(element::accept) - } - }) - this.annotationHolder = annotationHolder - } - - override fun doApplyInformationToEditor() { - if (annotationHolder == null) return - - val infos = annotationHolder!!.map { HighlightInfo.fromAnnotation(it) } - - UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument!!, 0, file.textLength, infos, colorsScheme, id) - annotationHolder = null - } - - class Factory(registrar: TextEditorHighlightingPassRegistrar) : ProjectComponent, TextEditorHighlightingPassFactory { - init { - registrar.registerTextEditorHighlightingPass( - this, - TextEditorHighlightingPassRegistrar.Anchor.BEFORE, - Pass.UPDATE_FOLDING, - false, - false - ) - } - - override fun createHighlightingPass(file: PsiFile, editor: Editor): TextEditorHighlightingPass? { - if (file !is KtFile) return null - return KotlinBeforeResolveHighlightingPass(file, editor.document) - } - } - - companion object { - val EP_NAME = ExtensionPointName.create("org.jetbrains.kotlin.beforeResolveHighlightingVisitor") - } -} - -interface BeforeResolveHighlightingExtension { - fun createVisitor(holder: AnnotationHolder): HighlightingVisitor -} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt.192 b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt.192 deleted file mode 100644 index e3d3da0c65e..00000000000 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/util/ApplicationUtils.kt.192 +++ /dev/null @@ -1,61 +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.util.application - -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.command.CommandProcessor -import com.intellij.openapi.components.ServiceManager -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.progress.ProgressIndicatorProvider -import com.intellij.openapi.progress.ProgressManager -import com.intellij.openapi.project.Project - -fun runReadAction(action: () -> T): T { - return ApplicationManager.getApplication().runReadAction(action) -} - -fun runWriteAction(action: () -> T): T { - return ApplicationManager.getApplication().runWriteAction(action) -} - -fun Project.executeWriteCommand(name: String, command: () -> Unit) { - CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null) -} - -fun Project.executeWriteCommand(name: String, groupId: Any? = null, command: () -> T): T { - return executeCommand(name, groupId) { runWriteAction(command) } -} - -fun Project.executeCommand(name: String, groupId: Any? = null, command: () -> T): T { - @Suppress("UNCHECKED_CAST") var result: T = null as T - CommandProcessor.getInstance().executeCommand(this, { result = command() }, name, groupId) - @Suppress("USELESS_CAST") - return result as T -} - -fun runWithCancellationCheck(block: () -> T): T = block() - -inline fun executeOnPooledThread(crossinline action: () -> Unit) = - ApplicationManager.getApplication().executeOnPooledThread { action() } - -inline fun invokeLater(crossinline action: () -> Unit) = - ApplicationManager.getApplication().invokeLater { action() } - -inline fun isUnitTestMode(): Boolean = ApplicationManager.getApplication().isUnitTestMode - -inline fun Project.getServiceSafe(): T = - ServiceManager.getService(this, T::class.java) ?: error("Unable to locate service ${T::class.java.name}") diff --git a/idea/idea-git/src/org/jetbrains/kotlin/git/KotlinExplicitMovementProvider.kt.192 b/idea/idea-git/src/org/jetbrains/kotlin/git/KotlinExplicitMovementProvider.kt.192 deleted file mode 100644 index b6befac5b09..00000000000 --- a/idea/idea-git/src/org/jetbrains/kotlin/git/KotlinExplicitMovementProvider.kt.192 +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.git - -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.Couple -import com.intellij.openapi.util.registry.Registry -import com.intellij.openapi.vcs.FilePath -import git4idea.checkin.GitCheckinExplicitMovementProvider -import org.jetbrains.kotlin.idea.actions.pathBeforeJ2K -import org.jetbrains.kotlin.idea.git.KotlinGitBundle -import java.util.* - -class KotlinExplicitMovementProvider : GitCheckinExplicitMovementProvider() { - init { - Registry.get("git.explicit.commit.renames.prohibit.multiple.calls").setValue(false) - } - - override fun isEnabled(project: Project): Boolean { - return true - } - - override fun getDescription(): String { - return KotlinGitBundle.message("j2k.extra.commit.description") - } - - override fun getCommitMessage(oldCommitMessage: String): String { - return KotlinGitBundle.message("j2k.extra.commit.commit.message") - } - - override fun collectExplicitMovements( - project: Project, - beforePaths: List, - afterPaths: List - ): Collection { - val movedChanges = ArrayList() - for (after in afterPaths) { - val pathBeforeJ2K = after.virtualFile?.pathBeforeJ2K - if (pathBeforeJ2K != null) { - val before = beforePaths.firstOrNull { it.path == pathBeforeJ2K } - if (before != null) { - movedChanges.add(Movement(before, after)) - } - } - } - - return movedChanges - } - - override fun afterMovementsCommitted(project: Project, movedPaths: MutableList>) { - movedPaths.forEach { it.second.virtualFile?.pathBeforeJ2K = null } - } -} diff --git a/idea/idea-gradle-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativeABICompatibilityChecker.kt.192 b/idea/idea-gradle-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativeABICompatibilityChecker.kt.192 deleted file mode 100644 index b7c5daeabff..00000000000 --- a/idea/idea-gradle-native/src/org/jetbrains/kotlin/ide/konan/KotlinNativeABICompatibilityChecker.kt.192 +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.ide.konan - -import com.intellij.ProjectTopics -import com.intellij.notification.Notification -import com.intellij.notification.NotificationType -import com.intellij.openapi.Disposable -import com.intellij.openapi.application.* -import com.intellij.openapi.application.ReadAction.nonBlocking -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.project.Project -import com.intellij.openapi.project.guessProjectDir -import com.intellij.openapi.roots.ModuleRootEvent -import com.intellij.openapi.roots.ModuleRootListener -import com.intellij.openapi.util.text.StringUtilRt -import com.intellij.util.PathUtilRt -import com.intellij.util.concurrency.AppExecutorUtil -import org.jetbrains.concurrency.CancellablePromise -import org.jetbrains.kotlin.idea.caches.project.getModuleInfosFromIdeaModel -import org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryNameUtil.isGradleLibraryName -import org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryNameUtil.parseIDELibraryName -import org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider -import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion -import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME -import org.jetbrains.kotlin.idea.klib.KlibCompatibilityInfo.IncompatibleMetadata - -// FIX ME WHEN BUNCH 192 REMOVED -/** TODO: merge [KotlinNativeABICompatibilityChecker] in the future with [UnsupportedAbiVersionNotificationPanelProvider], KT-34525 */ -class KotlinNativeABICompatibilityChecker(private val project: Project) : ProjectComponent, Disposable { - - private sealed class LibraryGroup(private val ordinal: Int) : Comparable { - - override fun compareTo(other: LibraryGroup) = when { - this == other -> 0 - this is FromDistribution && other is FromDistribution -> kotlinVersion.compareTo(other.kotlinVersion) - else -> ordinal.compareTo(other.ordinal) - } - - data class FromDistribution(val kotlinVersion: String) : LibraryGroup(0) - object ThirdParty : LibraryGroup(1) - object User : LibraryGroup(2) - } - - private val cachedIncompatibleLibraries = HashSet() - - @Volatile - private var backgroundJob: CancellablePromise<*>? = null - - init { - project.messageBus.connect().subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener { - override fun rootsChanged(event: ModuleRootEvent) { - // run when project roots are changes, e.g. on project import - validateKotlinNativeLibraries() - } - }) - } - - override fun projectOpened() { - // run when project is opened - validateKotlinNativeLibraries() - } - - private fun validateKotlinNativeLibraries() { - if (ApplicationManager.getApplication().isUnitTestMode || project.isDisposed) - return - - backgroundJob = nonBlocking> { - val librariesToNotify = getLibrariesToNotifyAbout() - prepareNotifications(librariesToNotify) - } - .finishOnUiThread(ModalityState.defaultModalityState()) { notifications -> - notifications.forEach { - it.notify(project) - } - } - .expireWith(project) // cancel job when project is disposed - .withDocumentsCommitted(project) - .submit(AppExecutorUtil.getAppExecutorService()) - .also { - it.onProcessed { - backgroundJob = null - } - } - } - - private fun getLibrariesToNotifyAbout(): Map { - val incompatibleLibraries = getModuleInfosFromIdeaModel(project) - .filterIsInstance() - .filter { !it.compatibilityInfo.isCompatible } - .associateBy { it.libraryRoot } - - val newEntries = if (cachedIncompatibleLibraries.isNotEmpty()) - incompatibleLibraries.filterKeys { it !in cachedIncompatibleLibraries } - else - incompatibleLibraries - - cachedIncompatibleLibraries.clear() - cachedIncompatibleLibraries.addAll(incompatibleLibraries.keys) - - return newEntries - } - - private fun prepareNotifications(librariesToNotify: Map): List { - if (librariesToNotify.isEmpty()) - return emptyList() - - val librariesByGroups = HashMap, MutableList>>() - librariesToNotify.forEach { (libraryRoot, libraryInfo) -> - val isOldMetadata = (libraryInfo.compatibilityInfo as? IncompatibleMetadata)?.isOlder ?: true - val (libraryName, libraryGroup) = parseIDELibraryName(libraryInfo) - librariesByGroups.computeIfAbsent(libraryGroup to isOldMetadata) { mutableListOf() } += libraryName to libraryRoot - } - - return librariesByGroups.keys.sortedWith( - compareBy( - { (libraryGroup, _) -> libraryGroup }, - { (_, isOldMetadata) -> isOldMetadata } - ) - ).map { key -> - - val (libraryGroup, isOldMetadata) = key - val libraries = - librariesByGroups.getValue(key).sortedWith(compareBy(LIBRARY_NAME_COMPARATOR) { (libraryName, _) -> libraryName }) - - - val message = when (libraryGroup) { - is LibraryGroup.FromDistribution -> { - val libraryNamesInOneLine = libraries - .joinToString(limit = MAX_LIBRARY_NAMES_IN_ONE_LINE) { (libraryName, _) -> libraryName } - val text = KotlinGradleNativeBundle.message( - "error.incompatible.libraries", - libraries.size, libraryGroup.kotlinVersion, libraryNamesInOneLine - ) - val explanation = when (isOldMetadata) { - true -> KotlinGradleNativeBundle.message("error.incompatible.libraries.older") - false -> KotlinGradleNativeBundle.message("error.incompatible.libraries.newer") - } - val recipe = KotlinGradleNativeBundle.message("error.incompatible.libraries.recipe", bundledRuntimeVersion()) - "$text\n\n$explanation\n$recipe" - } - is LibraryGroup.ThirdParty -> { - val text = when (isOldMetadata) { - true -> KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.older", libraries.size) - false -> KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.newer", libraries.size) - } - val librariesLineByLine = libraries.joinToString(separator = "\n") { (libraryName, _) -> libraryName } - val recipe = KotlinGradleNativeBundle.message("error.incompatible.3p.libraries.recipe", bundledRuntimeVersion()) - "$text\n$librariesLineByLine\n\n$recipe" - } - is LibraryGroup.User -> { - val projectRoot = project.guessProjectDir()?.canonicalPath - - fun getLibraryTextToPrint(libraryNameAndRoot: Pair): String { - val (libraryName, libraryRoot) = libraryNameAndRoot - - val relativeRoot = projectRoot?.let { - libraryRoot.substringAfter(projectRoot) - .takeIf { it != libraryRoot } - ?.trimStart('/', '\\') - ?.let { "${'$'}project/$it" } - } ?: libraryRoot - - return KotlinGradleNativeBundle.message("library.name.0.at.1.relative.root", libraryName, relativeRoot) - } - - val text = when (isOldMetadata) { - true -> KotlinGradleNativeBundle.message("error.incompatible.user.libraries.older", libraries.size) - false -> KotlinGradleNativeBundle.message("error.incompatible.user.libraries.newer", libraries.size) - } - val librariesLineByLine = libraries.joinToString(separator = "\n", transform = ::getLibraryTextToPrint) - val recipe = KotlinGradleNativeBundle.message("error.incompatible.user.libraries.recipe", bundledRuntimeVersion()) - "$text\n$librariesLineByLine\n\n$recipe" - } - } - - Notification( - NOTIFICATION_GROUP_ID, - NOTIFICATION_TITLE, - StringUtilRt.convertLineSeparators(message, "
"), - NotificationType.ERROR, - null - ) - } - } - - // returns pair of library name and library group - private fun parseIDELibraryName(libraryInfo: NativeKlibLibraryInfo): Pair { - val ideLibraryName = libraryInfo.library.name?.takeIf(String::isNotEmpty) - if (ideLibraryName != null) { - parseIDELibraryName(ideLibraryName)?.let { (kotlinVersion, libraryName) -> - return libraryName to LibraryGroup.FromDistribution(kotlinVersion) - } - - if (isGradleLibraryName(ideLibraryName)) - return ideLibraryName to LibraryGroup.ThirdParty - } - - return (ideLibraryName ?: PathUtilRt.getFileName(libraryInfo.libraryRoot)) to LibraryGroup.User - } - - override fun dispose() { - backgroundJob?.let(CancellablePromise<*>::cancel) - backgroundJob = null - - cachedIncompatibleLibraries.clear() - } - - companion object { - private val LIBRARY_NAME_COMPARATOR = Comparator { libraryName1, libraryName2 -> - when { - libraryName1 == libraryName2 -> 0 - libraryName1 == KONAN_STDLIB_NAME -> -1 // stdlib must go the first - libraryName2 == KONAN_STDLIB_NAME -> 1 - else -> libraryName1.compareTo(libraryName2) - } - } - - private const val MAX_LIBRARY_NAMES_IN_ONE_LINE = 5 - - private val NOTIFICATION_TITLE get() = KotlinGradleNativeBundle.message("error.incompatible.libraries.title") - private const val NOTIFICATION_GROUP_ID = "Incompatible Kotlin/Native libraries" - } -} diff --git a/idea/idea-gradle/res/fileTemplates/Gradle Kotlin DSL Build Script.gradle.ft.192 b/idea/idea-gradle/res/fileTemplates/Gradle Kotlin DSL Build Script.gradle.ft.192 deleted file mode 100644 index ebc627176ec..00000000000 --- a/idea/idea-gradle/res/fileTemplates/Gradle Kotlin DSL Build Script.gradle.ft.192 +++ /dev/null @@ -1,6 +0,0 @@ -#if (${MODULE_GROUP} && ${MODULE_GROUP} != "") -group = "${MODULE_GROUP}" -#end -#if (${MODULE_VERSION} && ${MODULE_VERSION} != "") -version = "${MODULE_VERSION}" -#end diff --git a/idea/idea-gradle/res/fileTemplates/Gradle Kotlin DSL Settings.gradle.ft.192 b/idea/idea-gradle/res/fileTemplates/Gradle Kotlin DSL Settings.gradle.ft.192 deleted file mode 100644 index f69ee4ccb47..00000000000 --- a/idea/idea-gradle/res/fileTemplates/Gradle Kotlin DSL Settings.gradle.ft.192 +++ /dev/null @@ -1,20 +0,0 @@ -#if (${PROJECT_NAME} && ${PROJECT_NAME} != "") -#if (((!${MODULE_PATH} || ${MODULE_PATH} == "")) && (${MODULE_NAME} && ${MODULE_NAME} != "")) -rootProject.name = '${MODULE_NAME}' -#else -rootProject.name = '${PROJECT_NAME}' -#end -#end -#if (${MODULE_PATH} && ${MODULE_PATH} != "") -#if (${MODULE_FLAT_DIR} == "true")includeFlat '${MODULE_PATH}' -#else -include '${MODULE_PATH}' -#end -#if (${MODULE_NAME} && ${MODULE_NAME} != "" && ${MODULE_PATH} != ${MODULE_NAME}) -findProject(':${MODULE_PATH}')?.name = '${MODULE_NAME}' -#end -#end -#if (${BUILD_FILE_NAME} && ${BUILD_FILE_NAME} != "") -rootProject.buildFileName = '${BUILD_FILE_NAME}' -#end - diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/actions/ShowKotlinGradleDslLogs.kt.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/actions/ShowKotlinGradleDslLogs.kt.192 deleted file mode 100644 index 6a9c9aa2710..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/actions/ShowKotlinGradleDslLogs.kt.192 +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.actions - -import com.intellij.codeInsight.intention.IntentionAction -import com.intellij.ide.actions.ShowFilePathAction -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.project.DumbAware -import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.MessageType -import com.intellij.openapi.ui.popup.JBPopupFactory -import com.intellij.openapi.util.SystemInfo -import com.intellij.openapi.wm.WindowManager -import com.intellij.psi.PsiFile -import com.intellij.ui.BrowserHyperlinkListener -import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle -import java.io.File - -class ShowKotlinGradleDslLogs : IntentionAction, AnAction(), DumbAware { - override fun invoke(project: Project, editor: Editor?, file: PsiFile?) { - openLogsDirIfPresent(project) - } - - override fun actionPerformed(e: AnActionEvent) { - openLogsDirIfPresent(e.project) - } - - override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?) = ShowFilePathAction.isSupported() - - override fun update(e: AnActionEvent) { - val presentation = e.presentation - presentation.isVisible = ShowFilePathAction.isSupported() - presentation.text = NAME - } - - private fun openLogsDirIfPresent(project: Project?) { - val logsDir = findLogsDir() - if (logsDir != null) { - ShowFilePathAction.openDirectory(logsDir) - } else { - val parent = WindowManager.getInstance().getStatusBar(project)?.component - ?: WindowManager.getInstance().findVisibleFrame().rootPane - JBPopupFactory.getInstance() - .createHtmlTextBalloonBuilder( - KotlinIdeaGradleBundle.message( - "text.gradle.dsl.logs.cannot.be.found.automatically.see.how.to.find.logs", - gradleTroubleshootingLink - ), - MessageType.ERROR, - BrowserHyperlinkListener.INSTANCE - ) - .setFadeoutTime(5000) - .createBalloon() - .showInCenterOf(parent) - } - } - - /** The way how to find Gradle logs is described here - * @see org.jetbrains.kotlin.idea.actions.ShowKotlinGradleDslLogs.gradleTroubleshootingLink - */ - private fun findLogsDir(): File? { - val userHome = System.getProperty("user.home") - return when { - SystemInfo.isMac -> File("$userHome/Library/Logs/gradle-kotlin-dsl") - SystemInfo.isLinux -> File("$userHome/.gradle-kotlin-dsl/logs") - SystemInfo.isWindows -> File("$userHome/AppData/Local/gradle-kotlin-dsl/log") - else -> null - }.takeIf { it?.exists() == true } - } - - override fun startInWriteAction() = false - - override fun getText() = NAME - - override fun getFamilyName() = NAME - - companion object { - private const val gradleTroubleshootingLink = "https://docs.gradle.org/current/userguide/kotlin_dsl.html#troubleshooting" - - val NAME = KotlinIdeaGradleBundle.message("action.text.show.kotlin.gradle.dsl.logs.in", ShowFilePathAction.getFileManagerName()) - } -} \ No newline at end of file diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/kotlinResolverUtil.kt.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/kotlinResolverUtil.kt.192 deleted file mode 100644 index cff62c6e167..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/kotlinResolverUtil.kt.192 +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration - -import com.intellij.ide.plugins.PluginManager -import com.intellij.notification.Notification -import com.intellij.notification.NotificationAction -import com.intellij.notification.NotificationType -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.extensions.PluginId -import com.intellij.openapi.project.ProjectManager -import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser -import com.intellij.util.PlatformUtils -import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle - -const val NATIVE_DEBUG_ID = "com.intellij.nativeDebug" - -fun suggestNativeDebug(projectPath: String) { - if (!PlatformUtils.isIdeaUltimate() || - PluginManager.isPluginInstalled(PluginId.getId(NATIVE_DEBUG_ID))) { - return - } - - val project = ProjectManager.getInstance().openProjects.firstOrNull { it.basePath == projectPath } ?: return - - PluginsAdvertiser.NOTIFICATION_GROUP.createNotification( - KotlinIdeaGradleBundle.message("title.plugin.suggestion"), - KotlinIdeaGradleBundle.message("notification.text.native.debug.provides.debugger.for.kotlin.native"), - NotificationType.INFORMATION, null - ).addAction(object : NotificationAction(KotlinIdeaGradleBundle.message("action.text.install")) { - override fun actionPerformed(e: AnActionEvent, notification: Notification) { - PluginsAdvertiser.installAndEnablePlugins(setOf(NATIVE_DEBUG_ID)) { notification.expire() } - } - }).notify(project) -} \ No newline at end of file diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinMPPGradleProjectTaskRunner.java.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinMPPGradleProjectTaskRunner.java.192 deleted file mode 100644 index 552dc5a1ada..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/execution/KotlinMPPGradleProjectTaskRunner.java.192 +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.gradle.execution; - -import com.intellij.build.BuildViewManager; -import com.intellij.compiler.impl.CompilerUtil; -import com.intellij.execution.executors.DefaultRunExecutor; -import com.intellij.openapi.compiler.ex.CompilerPathsEx; -import com.intellij.openapi.externalSystem.model.DataNode; -import com.intellij.openapi.externalSystem.model.ProjectKeys; -import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings; -import com.intellij.openapi.externalSystem.model.project.ModuleData; -import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode; -import com.intellij.openapi.externalSystem.task.TaskCallback; -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ProjectRootModificationTracker; -import com.intellij.openapi.util.UserDataHolderBase; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.CachedValuesManager; -import com.intellij.task.*; -import com.intellij.task.impl.JpsProjectTaskRunner; -import com.intellij.util.SmartList; -import com.intellij.util.SystemProperties; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.FactoryMap; -import com.intellij.util.containers.MultiMap; -import org.intellij.lang.annotations.Language; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.config.KotlinFacetSettings; -import org.jetbrains.kotlin.idea.KotlinIdeaGradleBundle; -import org.jetbrains.kotlin.idea.facet.KotlinFacet; -import org.jetbrains.kotlin.platform.TargetPlatformKt; -import org.jetbrains.kotlin.platform.TargetPlatform; -import org.jetbrains.kotlin.platform.konan.NativePlatformKt; -import org.jetbrains.plugins.gradle.execution.build.CachedModuleDataFinder; -import org.jetbrains.plugins.gradle.execution.build.GradleProjectTaskRunner; -import org.jetbrains.plugins.gradle.service.project.GradleBuildSrcProjectsResolver; -import org.jetbrains.plugins.gradle.service.project.GradleProjectResolverUtil; -import org.jetbrains.plugins.gradle.service.task.GradleTaskManager; -import org.jetbrains.plugins.gradle.settings.GradleProjectSettings; -import org.jetbrains.plugins.gradle.settings.GradleSettings; -import org.jetbrains.plugins.gradle.util.GradleConstants; - -import java.io.File; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import static com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration.PROGRESS_LISTENER_KEY; -import static com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.*; -import static com.intellij.openapi.util.text.StringUtil.*; -import static org.jetbrains.plugins.gradle.execution.GradleRunnerUtil.resolveProjectPath; - -/** - * This is a modified copy of {@link GradleProjectTaskRunner} that allows building Kotlin Common and Kotlin Native modules - * in IDEA by delegating to Gradle builder ("Delegate IDE build/run actions to gradle"). See #KT-27295, #KT-27296. - * - * TODO: Refactor this class to remove duplicated logic when {@link GradleProjectTaskRunner} will allow extending it to - * collect custom Gradle tasks. See #IDEA-204372, #KT-28880. - */ -class KotlinMPPGradleProjectTaskRunner extends ProjectTaskRunner -{ - - @Language("Groovy") - private static final String FORCE_COMPILE_TASKS_INIT_SCRIPT_TEMPLATE = "projectsEvaluated { \n" + - " rootProject.findProject('%s')?.tasks?.withType(AbstractCompile) { \n" + - " outputs.upToDateWhen { false } \n" + - " } \n" + - "}\n"; - - @Override - public void run(@NotNull Project project, - @NotNull ProjectTaskContext context, - @Nullable ProjectTaskNotification callback, - @NotNull Collection tasks) { - MultiMap buildTasksMap = MultiMap.createLinkedSet(); - MultiMap cleanTasksMap = MultiMap.createLinkedSet(); - MultiMap initScripts = MultiMap.createLinkedSet(); - - Map, List> taskMap = JpsProjectTaskRunner.groupBy(tasks); - - List modules = addModulesBuildTasks(taskMap.get(ModuleBuildTask.class), buildTasksMap, initScripts); - // TODO there should be 'gradle' way to build files instead of related modules entirely - List modulesOfFiles = addModulesBuildTasks(taskMap.get(ModuleFilesBuildTask.class), buildTasksMap, initScripts); - - // TODO send a message if nothing to build - Set rootPaths = buildTasksMap.keySet(); - AtomicInteger successCounter = new AtomicInteger(); - AtomicInteger errorCounter = new AtomicInteger(); - - TaskCallback taskCallback = callback == null ? null : new TaskCallback() { - @Override - public void onSuccess() { - handle(true); - } - - @Override - public void onFailure() { - handle(false); - } - - private void handle(boolean success) { - int successes = success ? successCounter.incrementAndGet() : successCounter.get(); - int errors = success ? errorCounter.get() : errorCounter.incrementAndGet(); - if (successes + errors == rootPaths.size()) { - if (!project.isDisposed()) { - // refresh on output roots is required in order for the order enumerator to see all roots via VFS - final List affectedModules = ContainerUtil.concat(modules, modulesOfFiles); - // have to refresh in case of errors too, because run configuration may be set to ignore errors - Collection affectedRoots = ContainerUtil.newHashSet( - CompilerPathsEx.getOutputPaths(affectedModules.toArray(Module.EMPTY_ARRAY))); - if (!affectedRoots.isEmpty()) { - CompilerUtil.refreshOutputRoots(affectedRoots); - } - } - callback.finished(new ProjectTaskResult(false, errors, 0)); - } - } - }; - - // TODO compiler options should be configurable - @Language("Groovy") - String compilerOptionsInitScript = "allprojects {\n" + - " tasks.withType(JavaCompile) {\n" + - " options.compilerArgs += [\"-Xlint:deprecation\"]\n" + - " }" + - "}\n"; - - String gradleVmOptions = GradleSettings.getInstance(project).getGradleVmOptions(); - for (String rootProjectPath : rootPaths) { - Collection buildTasks = buildTasksMap.get(rootProjectPath); - if (buildTasks.isEmpty()) continue; - Collection cleanTasks = cleanTasksMap.get(rootProjectPath); - - ExternalSystemTaskExecutionSettings settings = new ExternalSystemTaskExecutionSettings(); - - File projectFile = new File(rootProjectPath); - final String projectName; - if (projectFile.isFile()) { - projectName = projectFile.getParentFile().getName(); - } - else { - projectName = projectFile.getName(); - } - String executionName = KotlinIdeaGradleBundle.message("build.0.project", projectName); - settings.setExecutionName(executionName); - settings.setExternalProjectPath(rootProjectPath); - settings.setTaskNames(ContainerUtil.collect(ContainerUtil.concat(cleanTasks, buildTasks).iterator())); - //settings.setScriptParameters(scriptParameters); - settings.setVmOptions(gradleVmOptions); - settings.setExternalSystemIdString(GradleConstants.SYSTEM_ID.getId()); - - UserDataHolderBase userData = new UserDataHolderBase(); - userData.putUserData(PROGRESS_LISTENER_KEY, BuildViewManager.class); - - Collection scripts = initScripts.getModifiable(rootProjectPath); - scripts.add(compilerOptionsInitScript); - userData.putUserData(GradleTaskManager.INIT_SCRIPT_KEY, join(scripts, SystemProperties.getLineSeparator())); - userData.putUserData(GradleTaskManager.INIT_SCRIPT_PREFIX_KEY, executionName); - - ExternalSystemUtil.runTask(settings, DefaultRunExecutor.EXECUTOR_ID, project, GradleConstants.SYSTEM_ID, - taskCallback, ProgressExecutionMode.IN_BACKGROUND_ASYNC, false, userData); - } - } - - @Override - public boolean canRun(@NotNull ProjectTask projectTask) { - if (projectTask instanceof ModuleBuildTask) { - final ModuleBuildTask moduleBuildTask = (ModuleBuildTask) projectTask; - final Module module = moduleBuildTask.getModule(); - - if (module.getProject().getPresentableUrl() == null || !GradleProjectSettings.isDelegatedBuildEnabled(module)) { - return false; - } - - if (!isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module)) return false; - - // ---------------------------------------- // - // TODO BEGIN: Extract custom Kotlin logic. // - // ---------------------------------------- // - if (isProjectWithNativeSourceOrCommonProductionSourceModules(module.getProject())) return true; - // ---------------------------------------- // - // TODO END: Extract custom Kotlin logic. // - // ---------------------------------------- // - } - return false; - } - - private static List addModulesBuildTasks(@Nullable Collection projectTasks, - @NotNull MultiMap buildTasksMap, - @NotNull MultiMap initScripts) { - if (ContainerUtil.isEmpty(projectTasks)) return Collections.emptyList(); - - List affectedModules = new SmartList<>(); - Map rootPathsMap = FactoryMap.create(module -> notNullize(resolveProjectPath(module))); - final CachedModuleDataFinder moduleDataFinder = new CachedModuleDataFinder(); - for (ProjectTask projectTask : projectTasks) { - if (!(projectTask instanceof ModuleBuildTask)) continue; - - ModuleBuildTask moduleBuildTask = (ModuleBuildTask)projectTask; - Module module = moduleBuildTask.getModule(); - affectedModules.add(module); - - final String rootProjectPath = rootPathsMap.get(module); - if (isEmpty(rootProjectPath)) continue; - - final String projectId = getExternalProjectId(module); - if (projectId == null) continue; - final String externalProjectPath = getExternalProjectPath(module); - if (externalProjectPath == null || endsWith(externalProjectPath, "buildSrc")) continue; - - final DataNode moduleDataNode = moduleDataFinder.findMainModuleData(module); - if (moduleDataNode == null) continue; - - // all buildSrc runtime projects will be built by gradle implicitly - if (Boolean.parseBoolean(moduleDataNode.getData().getProperty(GradleBuildSrcProjectsResolver.BUILD_SRC_MODULE_PROPERTY))) { - continue; - } - - String gradlePath = GradleProjectResolverUtil.getGradlePath(module); - if (gradlePath == null) continue; - String taskPrefix = endsWithChar(gradlePath, ':') ? gradlePath : (gradlePath + ':'); - - List gradleTasks = ContainerUtil.mapNotNull( - findAll(moduleDataNode, ProjectKeys.TASK), node -> - node.getData().isInherited() ? null : trimStart(node.getData().getName(), taskPrefix)); - - Collection projectInitScripts = initScripts.getModifiable(rootProjectPath); - Collection buildRootTasks = buildTasksMap.getModifiable(rootProjectPath); - final String moduleType = getExternalModuleType(module); - - if (!moduleBuildTask.isIncrementalBuild()) { - projectInitScripts.add(String.format(FORCE_COMPILE_TASKS_INIT_SCRIPT_TEMPLATE, gradlePath)); - } - String assembleTask = "assemble"; - if (GradleConstants.GRADLE_SOURCE_SET_MODULE_TYPE_KEY.equals(moduleType)) { - String sourceSetName = GradleProjectResolverUtil.getSourceSetName(module); - String gradleTask = isEmpty(sourceSetName) || "main".equals(sourceSetName) ? "classes" : sourceSetName + "Classes"; - if (gradleTasks.contains(gradleTask)) { - buildRootTasks.add(taskPrefix + gradleTask); - } - else if ("main".equals(sourceSetName) || "test".equals(sourceSetName)) { - buildRootTasks.add(taskPrefix + assembleTask); - } - // ---------------------------------------- // - // TODO BEGIN: Extract custom Kotlin logic. // - // ---------------------------------------- // - else if (isNativeSourceModule(module)) { - // Add tasks for Kotlin/Native. - buildRootTasks.addAll(addPrefix(findNativeGradleBuildTasks(gradleTasks, sourceSetName), taskPrefix)); - } - else if (isCommonProductionSourceModule(module)) { - // Add tasks for compiling metadata. - buildRootTasks.addAll(addPrefix(findMetadataBuildTasks(gradleTasks, sourceSetName), taskPrefix)); - } - // ---------------------------------------- // - // TODO END: Extract custom Kotlin logic. // - // ---------------------------------------- // - } - else { - if (gradleTasks.contains("classes")) { - buildRootTasks.add(taskPrefix + "classes"); - buildRootTasks.add(taskPrefix + "testClasses"); - } - else if (gradleTasks.contains(assembleTask)) { - buildRootTasks.add(taskPrefix + assembleTask); - } - } - } - return affectedModules; - } - - // ---------------------------------------- // - // TODO BEGIN: Extract custom Kotlin logic. // - // ---------------------------------------- // - private static boolean isProjectWithNativeSourceOrCommonProductionSourceModules(Project project) { - return CachedValuesManager.getManager(project).getCachedValue( - project, - () -> new CachedValueProvider.Result<>( - Arrays.stream(ModuleManager.getInstance(project).getModules()).anyMatch( - module -> isNativeSourceModule(module) || isCommonProductionSourceModule(module) - ), - ProjectRootModificationTracker.getInstance(project) - )); - } - - private static boolean isNativeSourceModule(Module module) { - final KotlinFacet kotlinFacet = KotlinFacet.Companion.get(module); - if (kotlinFacet == null) return false; - - final TargetPlatform platform = kotlinFacet.getConfiguration().getSettings().getTargetPlatform(); - if (platform == null) return false; - - return NativePlatformKt.isNative(platform); - } - - private static boolean isCommonProductionSourceModule(Module module) { - final KotlinFacet kotlinFacet = KotlinFacet.Companion.get(module); - if (kotlinFacet == null) return false; - - final KotlinFacetSettings facetSettings = kotlinFacet.getConfiguration().getSettings(); - if (facetSettings.isTestModule()) return false; - - final TargetPlatform platform = facetSettings.getTargetPlatform(); - if (platform == null) return false; - - return TargetPlatformKt.isCommon(platform); - } - - private static Collection findNativeGradleBuildTasks(Collection gradleTasks, String sourceSetName) { - // First, attempt to find Kotlin/Native convention Gradle task that unites all outputType-specific build tasks. - final String conventionGradleTask = sourceSetName + "Binaries"; - if (gradleTasks.contains(conventionGradleTask)) { - return Collections.singletonList(conventionGradleTask); - } - - // If convention task not found, then attempt to find all appropriate build tasks for the given source set. - final Collection linkPrefixes; - final String targetName; - if (sourceSetName.endsWith("Main")) { - targetName = StringUtil.substringBeforeLast(sourceSetName,"Main"); - linkPrefixes = ContainerUtil.newArrayList("link", "linkMain"); - } - else if (sourceSetName.endsWith("Test")) { - targetName = StringUtil.substringBeforeLast(sourceSetName,"Test"); - linkPrefixes = Collections.singletonList("linkTest"); - } - else { - targetName = sourceSetName; - linkPrefixes = Collections.singletonList("link"); - } - - return linkPrefixes.stream() - // get base task name (without disambiguation classifier) - .map(linkPrefix -> linkPrefix + capitalize(targetName)) - // find all Gradle tasks that start with base task name - .flatMap(nativeTaskName -> gradleTasks.stream().filter(taskName -> taskName.startsWith(nativeTaskName))) - .collect(Collectors.toList()); - } - - private static Collection findMetadataBuildTasks(Collection gradleTasks, String sourceSetName) { - if ("commonMain".equals(sourceSetName)) { - final String metadataTaskName = "metadataMainClasses"; - if (gradleTasks.contains(metadataTaskName)) { - return Collections.singletonList(metadataTaskName); - } - } - - return Collections.emptyList(); - } - - private static Collection addPrefix(Collection tasks, String taskPrefix) { - return tasks.stream().map(task -> taskPrefix + task).collect(Collectors.toList()); - } - // ---------------------------------------- // - // TODO END: Extract custom Kotlin logic. // - // ---------------------------------------- // -} diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/testing/KotlinTestTasksResolver.kt.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/testing/KotlinTestTasksResolver.kt.192 deleted file mode 100644 index 03ea2057af3..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/gradle/testing/KotlinTestTasksResolver.kt.192 +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.gradle.testing - -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.externalSystem.model.DataNode -import com.intellij.openapi.externalSystem.model.ProjectKeys -import com.intellij.openapi.externalSystem.model.project.ModuleData -import com.intellij.openapi.externalSystem.model.project.ProjectData -import com.intellij.openapi.externalSystem.model.task.TaskData -import com.intellij.openapi.externalSystem.util.Order -import com.intellij.openapi.util.registry.Registry -import com.intellij.util.Consumer -import org.gradle.tooling.model.idea.IdeaModule -import org.jetbrains.kotlin.gradle.KotlinMPPGradleModel -import org.jetbrains.kotlin.gradle.KotlinMPPGradleModelBuilder -import org.jetbrains.kotlin.idea.configuration.getMppModel -import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension - -@Order(Int.MIN_VALUE) -open class KotlinTestTasksResolver : AbstractProjectResolverExtension() { - companion object { - private const val ENABLED_REGISTRY_KEY = "kotlin.gradle.testing.enabled" - } - - private val LOG by lazy { Logger.getInstance(KotlinTestTasksResolver::class.java) } - - override fun getToolingExtensionsClasses(): Set> { - return setOf(KotlinMPPGradleModelBuilder::class.java, Unit::class.java) - } - - override fun populateModuleTasks( - gradleModule: IdeaModule, - ideModule: DataNode, - ideProject: DataNode - ): MutableCollection { - if (!Registry.`is`(ENABLED_REGISTRY_KEY)) - return super.populateModuleTasks(gradleModule, ideModule, ideProject) - - val mppModel = resolverCtx.getMppModel(gradleModule) - ?: return super.populateModuleTasks(gradleModule, ideModule, ideProject) - - return postprocessTaskData(mppModel, ideModule, nextResolver.populateModuleTasks(gradleModule, ideModule, ideProject)) - } - - private fun postprocessTaskData( - mppModel: KotlinMPPGradleModel, - ideModule: DataNode, - originalTaskData: MutableCollection - ): MutableCollection { - val testTaskNames = mutableSetOf().apply { - mppModel.targets.forEach { target -> - target.testRunTasks.forEach { testTaskModel -> - add(testTaskModel.taskName) - } - } - } - - fun buildNewTaskDataMarkedAsTest(original: TaskData): TaskData = - TaskData(original.owner, original.name, original.linkedExternalProjectPath, original.description).apply { - group = original.group - type = original.type - isInherited = original.isInherited - - isTest = true - } - - val replacementMap: Map = mutableMapOf().apply { - originalTaskData.forEach { - if (it.name in testTaskNames && !it.isTest) { - put(it, buildNewTaskDataMarkedAsTest(it)) - } - } - } - - ideModule.children.filter { it.data in replacementMap }.forEach { it.clear(true) } - replacementMap.values.forEach { ideModule.createChild(ProjectKeys.TASK, it) } - - return originalTaskData.mapTo(arrayListOf()) { replacementMap[it] ?: it } - } - - override fun enhanceTaskProcessing( - taskNames: MutableList, - jvmParametersSetup: String?, - initScriptConsumer: Consumer, - testExecutionExpected: kotlin.Boolean - ) { - if (!Registry.`is`(ENABLED_REGISTRY_KEY)) - return - - if (testExecutionExpected) { - try { - val addTestListenerScript = javaClass - .getResourceAsStream("/org/jetbrains/kotlin/idea/gradle/testing/addKotlinMppTestListener.groovy") - .bufferedReader() - .readText() - initScriptConsumer.consume(addTestListenerScript) - } catch (e: Exception) { - LOG.error(e) - } - } - - enhanceTaskProcessing(taskNames, jvmParametersSetup, initScriptConsumer) - } - - override fun enhanceTaskProcessing(taskNames: MutableList, jvmAgentSetup: String?, initScriptConsumer: Consumer) { - if (!Registry.`is`(ENABLED_REGISTRY_KEY)) - return - - try { - val testLoggerScript = javaClass - .getResourceAsStream("/org/jetbrains/kotlin/idea/gradle/testing/KotlinMppTestLogger.groovy") - .bufferedReader() - .readText() - - initScriptConsumer.consume(testLoggerScript) - } catch (e: Exception) { - LOG.error(e) - } - } -} \ No newline at end of file diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/jvmTestClassUtils.kt.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/jvmTestClassUtils.kt.192 deleted file mode 100644 index 24523a6148d..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/jvmTestClassUtils.kt.192 +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.run - -import com.intellij.execution.Location -import com.intellij.execution.actions.ConfigurationFromContext -import com.intellij.execution.junit.JUnitConfigurationProducer -import com.intellij.execution.testframework.AbstractPatternBasedConfigurationProducer -import com.intellij.ide.plugins.PluginManager -import com.intellij.openapi.extensions.PluginId.getId -import com.intellij.openapi.util.component1 -import com.intellij.openapi.util.component2 -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiMethod -import org.jetbrains.kotlin.idea.KotlinLanguage - -private val isJUnitEnabled by lazy { isPluginEnabled("JUnit") } -private val isTestNgEnabled by lazy { isPluginEnabled("TestNG-J") } - -private fun isPluginEnabled(id: String): Boolean { - return PluginManager.isPluginInstalled(getId(id)) && id !in PluginManager.getDisabledPlugins() -} - -internal fun ConfigurationFromContext.isJpsJunitConfiguration(): Boolean { - return isProducedBy(JUnitConfigurationProducer::class.java) - || isProducedBy(AbstractPatternBasedConfigurationProducer::class.java) -} - -internal fun canRunJvmTests() = isJUnitEnabled || isTestNgEnabled - -internal fun getTestClassForJvm(location: Location<*>): PsiClass? { - val leaf = location.psiElement ?: return null - - if (leaf.language != KotlinLanguage.INSTANCE) return null - - if (isJUnitEnabled) { - KotlinJUnitRunConfigurationProducer.getTestClass(leaf)?.let { return it } - } - if (isTestNgEnabled) { - KotlinTestNgConfigurationProducer.getTestClassAndMethod(leaf)?.let { (testClass, testMethod) -> - return if (testMethod == null) testClass else null - } - } - return null -} - -internal fun getTestMethodForJvm(location: Location<*>): PsiMethod? { - val leaf = location.psiElement ?: return null - - if (leaf.language != KotlinLanguage.INSTANCE) return null - - if (isJUnitEnabled) { - KotlinJUnitRunConfigurationProducer.getTestMethod(leaf)?.let { return it } - } - if (isTestNgEnabled) { - KotlinTestNgConfigurationProducer.getTestClassAndMethod(leaf)?.second?.let { return it } - } - return null -} \ No newline at end of file diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelResolver.kt.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelResolver.kt.192 deleted file mode 100644 index b397e8790b5..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelResolver.kt.192 +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.scripting.gradle.importing - -import com.intellij.openapi.externalSystem.model.DataNode -import com.intellij.openapi.externalSystem.model.project.ProjectData -import org.gradle.tooling.model.idea.IdeaProject -import org.gradle.tooling.model.kotlin.dsl.KotlinDslScriptsModel -import org.jetbrains.kotlin.gradle.KotlinDslScriptAdditionalTask -import org.jetbrains.kotlin.gradle.KotlinDslScriptModelProvider -import org.jetbrains.kotlin.idea.scripting.gradle.kotlinDslScriptsModelImportSupported -import org.jetbrains.plugins.gradle.model.ProjectImportModelProvider -import org.jetbrains.plugins.gradle.model.ClassSetBuildImportModelProvider - -class KotlinDslScriptModelResolver : KotlinDslScriptModelResolverCommon() { - override fun requiresTaskRunning() = true - - override fun getModelProvider() = KotlinDslScriptModelProvider() - - override fun getProjectsLoadedModelProvider(): ProjectImportModelProvider? { - return ClassSetBuildImportModelProvider( - setOf(KotlinDslScriptAdditionalTask::class.java) - ) - } - - override fun populateProjectExtraModels(gradleProject: IdeaProject, ideProject: DataNode) { - super.populateProjectExtraModels(gradleProject, ideProject) - - populateBuildModels(gradleProject, ideProject) - - resolverCtx.models.includedBuilds.forEach { includedRoot -> - populateBuildModels(includedRoot, ideProject) - } - } - - private fun populateBuildModels( - root: IdeaProject, - ideProject: DataNode - ) { - root.modules.forEach { - if (it.gradleProject.parent == null) { - if (kotlinDslScriptsModelImportSupported(resolverCtx.projectGradleVersion)) { - resolverCtx.getExtraProject(it, KotlinDslScriptsModel::class.java)?.let { model -> - processScriptModel(resolverCtx, model, it.name) - } - } - - saveGradleBuildEnvironment(resolverCtx) - } - } - } -} \ No newline at end of file diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/settings/StandaloneScriptsUIComponent.kt.192 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/settings/StandaloneScriptsUIComponent.kt.192 deleted file mode 100644 index 7f1aae1dce9..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/settings/StandaloneScriptsUIComponent.kt.192 +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.scripting.gradle.settings - -import com.intellij.openapi.project.Project - -class StandaloneScriptsUIComponent(val project: Project) : StandaloneScriptsUIComponentCompat(project) { -} \ No newline at end of file diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/ExternalSystemTestCaseBunch.java.192 b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/ExternalSystemTestCaseBunch.java.192 deleted file mode 100644 index 720e12d8428..00000000000 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/ExternalSystemTestCaseBunch.java.192 +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight.gradle; - -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.Project; -import com.intellij.packaging.artifacts.Artifact; -import com.intellij.task.ProjectTaskManager; - -//BUNCH 193 -class ExternalSystemTestCaseBunch { - - protected static boolean isDefaultRefreshCallback(Object callback) { - return false; - } - - protected static void build(Object[] buildableElements, Project myProject) { - if (buildableElements instanceof Module[]) { - ProjectTaskManager.getInstance(myProject).build((Module[])buildableElements); - } - else if (buildableElements instanceof Artifact[]) { - ProjectTaskManager.getInstance(myProject).build((Artifact[])buildableElements); - } - } - -} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/JvmPluginStartupComponent.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/JvmPluginStartupComponent.kt.192 deleted file mode 100644 index e05d5b57b3e..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/JvmPluginStartupComponent.kt.192 +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea - -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.BaseComponent -import org.jetbrains.kotlin.idea.ThreadTrackerPatcherForTeamCityTesting.patchThreadTracker -import org.jetbrains.kotlin.idea.debugger.filter.addKotlinStdlibDebugFilterIfNeeded -import org.jetbrains.kotlin.idea.util.application.isUnitTestMode - -// FIX ME WHEN BUNCH 192 REMOVED -class JvmPluginStartupComponent : BaseComponent { - override fun getComponentName(): String = JvmPluginStartupComponent::class.java.name - - override fun initComponent() { - if (isUnitTestMode()) { - patchThreadTracker() - } - addKotlinStdlibDebugFilterIfNeeded() - } - - override fun disposeComponent() {} - - companion object { - fun getInstance(): JvmPluginStartupComponent = - ApplicationManager.getApplication().getComponent(JvmPluginStartupComponent::class.java) - } -} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/compiler/KotlinCompilerManager.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/compiler/KotlinCompilerManager.kt.192 deleted file mode 100644 index a6cfe00dcf0..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/compiler/KotlinCompilerManager.kt.192 +++ /dev/null @@ -1,99 +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.compiler - -import com.intellij.diagnostic.PluginException -import com.intellij.ide.plugins.PluginManagerCore -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.compiler.CompilationStatusListener -import com.intellij.openapi.compiler.CompileContext -import com.intellij.openapi.compiler.CompilerManager -import com.intellij.openapi.compiler.CompilerMessageCategory -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.io.FileUtilRt -import com.intellij.openapi.vfs.LocalFileSystem -import com.intellij.util.containers.ContainerUtil -import org.jetbrains.kotlin.config.CompilerRunnerConstants -import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.js.JavaScript -import java.io.PrintStream -import java.io.PrintWriter - -// FIX ME WHEN BUNCH 192 REMOVED -class KotlinCompilerManager(project: Project, manager: CompilerManager) : ProjectComponent { - // Extending PluginException ensures that Exception Analyzer recognizes this as a Kotlin exception - private class KotlinCompilerException(private val text: String) : - PluginException("", PluginManagerCore.getPluginByClassName(KotlinCompilerManager::class.java.name)) { - override fun printStackTrace(s: PrintWriter) { - s.print(text) - } - - override fun printStackTrace(s: PrintStream) { - s.print(text) - } - - @Synchronized - override fun fillInStackTrace(): Throwable { - return this - } - - override fun getStackTrace(): Array { - LOG.error("Somebody called getStackTrace() on KotlinCompilerException") - // Return some stack trace that originates in Kotlin - return UnsupportedOperationException().stackTrace - } - - override val message: String - get() = "" - - } - - companion object { - private val LOG = Logger.getInstance(KotlinCompilerManager::class.java) - - // Comes from external make - private const val PREFIX_WITH_COMPILER_NAME = - CompilerRunnerConstants.KOTLIN_COMPILER_NAME + ": " + CompilerRunnerConstants.INTERNAL_ERROR_PREFIX - private val FILE_EXTS_WHICH_NEEDS_REFRESH = ContainerUtil.immutableSet(JavaScript.DOT_EXTENSION, ".map") - } - - init { - manager.addCompilableFileType(KotlinFileType.INSTANCE) - manager.addCompilationStatusListener(object : CompilationStatusListener { - override fun compilationFinished(aborted: Boolean, errors: Int, warnings: Int, compileContext: CompileContext) { - for (error in compileContext.getMessages(CompilerMessageCategory.ERROR)) { - val message = error.message - if (message.startsWith(CompilerRunnerConstants.INTERNAL_ERROR_PREFIX) || message.startsWith(PREFIX_WITH_COMPILER_NAME)) { - LOG.error(KotlinCompilerException(message)) - } - } - } - - override fun fileGenerated(outputRoot: String, relativePath: String) { - if (ApplicationManager.getApplication().isUnitTestMode) return - val ext = FileUtilRt.getExtension(relativePath).toLowerCase() - if (FILE_EXTS_WHICH_NEEDS_REFRESH.contains(ext)) { - val outFile = "$outputRoot/$relativePath" - val virtualFile = LocalFileSystem.getInstance().findFileByPath(outFile) - ?: error("Virtual file not found for generated file path: $outFile") - virtualFile.refresh( /*async =*/false, /*recursive =*/false) - } - } - }, project) - } -} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt.192 deleted file mode 100644 index e3954f77d31..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinBuildProcessParametersProvider.kt.192 +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.compiler.configuration - -import com.intellij.compiler.server.BuildProcessParametersProvider -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.registry.Registry -import org.jetbrains.kotlin.config.IncrementalCompilation -import org.jetbrains.kotlin.idea.PluginStartupComponent - -class KotlinBuildProcessParametersProvider(private val project: Project) : BuildProcessParametersProvider() { - override fun getVMArguments(): MutableList { - val compilerWorkspaceSettings = KotlinCompilerWorkspaceSettings.getInstance(project) - - val res = arrayListOf() - if (compilerWorkspaceSettings.preciseIncrementalEnabled) { - res.add("-D" + IncrementalCompilation.INCREMENTAL_COMPILATION_JVM_PROPERTY + "=true") - } - if (compilerWorkspaceSettings.incrementalCompilationForJsEnabled) { - res.add("-D" + IncrementalCompilation.INCREMENTAL_COMPILATION_JS_PROPERTY + "=true") - } - if (compilerWorkspaceSettings.enableDaemon) { - res.add("-Dkotlin.daemon.enabled") - } - if (Registry.`is`("kotlin.jps.instrument.bytecode", false)) { - res.add("-Dkotlin.jps.instrument.bytecode=true") - } - PluginStartupComponent.getInstance().aliveFlagPath.let { - if (!it.isBlank()) { - // TODO: consider taking the property name from compiler/daemon/common (check whether dependency will be not too heavy) - res.add("-Dkotlin.daemon.client.alive.path=\"$it\"") - } - } - return res - } -} diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/compat.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/compat.kt.192 deleted file mode 100644 index ad180f89755..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/compat.kt.192 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration - -import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.ReadAction.nonBlocking -import com.intellij.openapi.module.Module -import com.intellij.openapi.project.Project -import com.intellij.util.concurrency.AppExecutorUtil -import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinNotification -import java.util.concurrent.Callable - -fun notify(manager: ConfigureKotlinNotificationManager, project: Project, excludeModules: List) { - nonBlocking(Callable { - ConfigureKotlinNotification.getNotificationState(project, excludeModules) - }) - .expireWith(project) - .finishOnUiThread(ModalityState.any()) { notificationState -> - notificationState?.let { - manager.notify(project, ConfigureKotlinNotification(project, excludeModules, it)) - } - } - .submit(AppExecutorUtil.getAppExecutorService()) -} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt.192 deleted file mode 100644 index 2fd9f57f5b3..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerComponent.kt.192 +++ /dev/null @@ -1,94 +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.configuration.ui - -import com.intellij.notification.NotificationDisplayType -import com.intellij.notification.NotificationsConfiguration -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.runReadAction -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataImportListener -import com.intellij.openapi.project.Project -import com.intellij.openapi.startup.StartupManager -import org.jetbrains.kotlin.idea.configuration.getModulesWithKotlinFiles -import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary -import org.jetbrains.kotlin.idea.configuration.ui.notifications.notifyKotlinStyleUpdateIfNeeded -import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies -import org.jetbrains.kotlin.idea.util.runReadActionInSmartMode -import java.util.concurrent.atomic.AtomicInteger - -class KotlinConfigurationCheckerComponent(val project: Project) : ProjectComponent { - private val syncDepth = AtomicInteger() - - init { - NotificationsConfiguration.getNotificationsConfiguration() - .register(CONFIGURE_NOTIFICATION_GROUP_ID, NotificationDisplayType.STICKY_BALLOON, true) - - val connection = project.messageBus.connect(project) - connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener { - notifyOutdatedBundledCompilerIfNecessary(project) - }) - - notifyKotlinStyleUpdateIfNeeded(project) - } - - override fun projectOpened() { - super.projectOpened() - - StartupManager.getInstance(project).registerPostStartupActivity { - performProjectPostOpenActions() - } - } - - fun performProjectPostOpenActions() { - ApplicationManager.getApplication().executeOnPooledThread { - val modulesWithKotlinFiles = project.runReadActionInSmartMode { - getModulesWithKotlinFiles(project) - } - for (module in modulesWithKotlinFiles) { - runReadAction { - if (project.isDisposed) return@runReadAction - module.getAndCacheLanguageLevelByDependencies() - } - } - } - } - - val isSyncing: Boolean get() = syncDepth.get() > 0 - - fun syncStarted() { - syncDepth.incrementAndGet() - } - - fun syncDone() { - syncDepth.decrementAndGet() - } - - companion object { - const val CONFIGURE_NOTIFICATION_GROUP_ID = "Configure Kotlin in Project" - - fun getInstance(project: Project): KotlinConfigurationCheckerComponent = - project.getComponent(KotlinConfigurationCheckerComponent::class.java) - ?: error("Can't find ${KotlinConfigurationCheckerComponent::class} component") - - fun getInstanceIfNotDisposed(project: Project): KotlinConfigurationCheckerComponent? { - return runReadAction { - if (!project.isDisposed) getInstance(project) else null - } - } - } -} diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerService.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerService.kt.192 deleted file mode 100644 index af3e4c6cb09..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/ui/KotlinConfigurationCheckerService.kt.192 +++ /dev/null @@ -1,19 +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.configuration.ui - -typealias KotlinConfigurationCheckerService = KotlinConfigurationCheckerComponent \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt.192 deleted file mode 100644 index e124ebdb671..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/makeBackup/CreateIncrementalCompilationBackup.kt.192 +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.internal.makeBackup - -import com.intellij.compiler.server.BuildManager -import com.intellij.history.core.RevisionsCollector -import com.intellij.history.integration.LocalHistoryImpl -import com.intellij.history.integration.patches.PatchCreator -import com.intellij.ide.actions.ShowFilePathAction -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.application.PathManager -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.progress.ProgressManager -import com.intellij.openapi.progress.Task -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.io.FileUtil -import com.intellij.openapi.vcs.changes.Change -import com.intellij.util.WaitForProgressToShow -import com.intellij.util.io.ZipUtil -import org.jetbrains.kotlin.idea.KotlinJvmBundle -import org.jetbrains.kotlin.idea.util.application.runReadAction -import java.io.File -import java.io.FileOutputStream -import java.text.SimpleDateFormat -import java.util.* -import java.util.zip.ZipOutputStream - -class CreateIncrementalCompilationBackup : AnAction(KotlinJvmBundle.message("create.backup.for.debugging.kotlin.incremental.compilation")) { - companion object { - const val BACKUP_DIR_NAME = ".backup" - const val PATCHES_TO_CREATE = 5 - - const val PATCHES_FRACTION = .25 - const val LOGS_FRACTION = .05 - const val PROJECT_SYSTEM_FRACTION = .05 - const val ZIP_FRACTION = 1.0 - PATCHES_FRACTION - LOGS_FRACTION - PROJECT_SYSTEM_FRACTION - } - - override fun actionPerformed(e: AnActionEvent) { - val project = e.project!! - val projectBaseDir = File(project.baseDir!!.path) - val backupDir = File(FileUtil.createTempDirectory("makeBackup", null), BACKUP_DIR_NAME) - - ProgressManager.getInstance().run( - object : Task.Backgroundable( - project, - KotlinJvmBundle.message("creating.backup.for.debugging.kotlin.incremental.compilation"), - true - ) { - override fun run(indicator: ProgressIndicator) { - createPatches(backupDir, project, indicator) - copyLogs(backupDir, indicator) - copyProjectSystemDir(backupDir, project, indicator) - - zipProjectDir(backupDir, project, projectBaseDir, indicator) - } - } - ) - } - - private fun createPatches(backupDir: File, project: Project, indicator: ProgressIndicator) { - runReadAction { - val localHistoryImpl = LocalHistoryImpl.getInstanceImpl()!! - val gateway = localHistoryImpl.gateway!! - val localHistoryFacade = localHistoryImpl.facade - - val revisionsCollector = RevisionsCollector( - localHistoryFacade, - gateway.createTransientRootEntry(), - project.baseDir!!.path, - project.locationHash, - null - ) - - var patchesCreated = 0 - - val patchesDir = File(backupDir, "patches") - patchesDir.mkdirs() - - val revisions = revisionsCollector.result!! - for (rev in revisions) { - val label = rev.label - if (label != null && label.startsWith(HISTORY_LABEL_PREFIX)) { - val patchFile = File(patchesDir, label.removePrefix(HISTORY_LABEL_PREFIX) + ".patch") - - indicator.text = KotlinJvmBundle.message("creating.patch.0", patchFile) - indicator.fraction = PATCHES_FRACTION * patchesCreated / PATCHES_TO_CREATE - - val differences = revisions[0].getDifferencesWith(rev)!! - val changes = differences.map { d -> - Change(d.getLeftContentRevision(gateway), d.getRightContentRevision(gateway)) - } - - PatchCreator.create(project, changes, patchFile.path, false, null) - - if (++patchesCreated >= PATCHES_TO_CREATE) { - break - } - } - } - } - } - - private fun copyLogs(backupDir: File, indicator: ProgressIndicator) { - indicator.text = KotlinJvmBundle.message("copying.logs") - indicator.fraction = PATCHES_FRACTION - - val logsDir = File(backupDir, "logs") - FileUtil.copyDir(File(PathManager.getLogPath()), logsDir) - - indicator.fraction = PATCHES_FRACTION + LOGS_FRACTION - } - - private fun copyProjectSystemDir(backupDir: File, project: Project, indicator: ProgressIndicator) { - indicator.text = KotlinJvmBundle.message("copying.project.s.system.dir") - indicator.fraction = PATCHES_FRACTION - - val projectSystemDir = File(backupDir, "project-system") - FileUtil.copyDir(BuildManager.getInstance().getProjectSystemDirectory(project)!!, projectSystemDir) - - indicator.fraction = PATCHES_FRACTION + LOGS_FRACTION + PROJECT_SYSTEM_FRACTION - } - - private fun zipProjectDir(backupDir: File, project: Project, projectDir: File, indicator: ProgressIndicator) { - // files and relative paths - - val files = ArrayList>() // files and relative paths - var totalBytes = 0L - - for (dir in listOf(projectDir, backupDir.parentFile!!)) { - FileUtil.processFilesRecursively( - dir, - /*processor*/ { - if (it!!.isFile - && !it.name.endsWith(".hprof") - && !(it.name.startsWith("make_backup_") && it.name.endsWith(".zip")) - ) { - - indicator.text = KotlinJvmBundle.message("scanning.project.dir.0", it) - - files.add(Pair(it, FileUtil.getRelativePath(dir, it)!!)) - totalBytes += it.length() - } - true - }, - /*directoryFilter*/ { - val name = it!!.name - name != ".git" && name != "out" - } - ) - } - - - val backupFile = File(projectDir, "make_backup_" + SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Date()) + ".zip") - - - val zos = ZipOutputStream(FileOutputStream(backupFile)) - - var processedBytes = 0L - - zos.use { - for ((file, relativePath) in files) { - indicator.text = KotlinJvmBundle.message("adding.file.to.backup.0", relativePath) - indicator.fraction = PATCHES_FRACTION + LOGS_FRACTION + processedBytes.toDouble() / totalBytes * ZIP_FRACTION - - ZipUtil.addFileToZip(zos, file, relativePath, null, null) - - processedBytes += file.length() - } - } - - FileUtil.delete(backupDir) - - WaitForProgressToShow.runOrInvokeLaterAboveProgress( - { - ShowFilePathAction.showDialog( - project, - KotlinJvmBundle.message("successfully.created.backup.0", backupFile.absolutePath), - KotlinJvmBundle.message("created.backup"), - backupFile, - null - ) - }, null, project - ) - } -} diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileModuleInfoProvider.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileModuleInfoProvider.kt.192 deleted file mode 100644 index c646ed03791..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileModuleInfoProvider.kt.192 +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2010-2017 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.scratch - -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.module.ModuleManager -import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesModificationTracker -import org.jetbrains.kotlin.idea.core.script.scriptRelatedModuleName -import org.jetbrains.kotlin.idea.util.projectStructure.getModule -import org.jetbrains.kotlin.parsing.KotlinParserDefinition.Companion.STD_SCRIPT_SUFFIX -import org.jetbrains.kotlin.psi.KtFile - -// FIX ME WHEN BUNCH 192 REMOVED -class ScratchFileModuleInfoProvider(val project: Project) : ProjectComponent { - private val LOG = Logger.getInstance(this.javaClass) - - override fun projectOpened() { - project.messageBus.connect().subscribe(ScratchFileListener.TOPIC, object : ScratchFileListener { - override fun fileCreated(scratchFile: ScratchFile) { - val ktFile = scratchFile.getPsiFile() as? KtFile ?: return - val file = ktFile.virtualFile ?: return - - if (file.extension != STD_SCRIPT_SUFFIX) { - LOG.error("Kotlin Scratch file should have .kts extension. Cannot add scratch panel for ${file.path}") - return - } - - scratchFile.addModuleListener { psiFile, module -> - psiFile.virtualFile.scriptRelatedModuleName = module?.name - - // Drop caches for old module - ScriptDependenciesModificationTracker.getInstance(project).incModificationCount() - // Force re-highlighting - DaemonCodeAnalyzer.getInstance(project).restart(psiFile) - } - - if (file.isKotlinWorksheet) { - val module = file.getModule(project) ?: return - scratchFile.setModule(module) - } else { - val module = file.scriptRelatedModuleName?.let { ModuleManager.getInstance(project).findModuleByName(it) } ?: return - scratchFile.setModule(module) - } - } - }) - } -} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt.192 deleted file mode 100644 index 928d47e4117..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt.192 +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2010-2017 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.scratch.actions - -import com.intellij.icons.AllIcons -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.keymap.KeymapManager -import com.intellij.openapi.keymap.KeymapUtil -import com.intellij.openapi.project.DumbService -import com.intellij.task.ProjectTaskManager -import org.jetbrains.kotlin.idea.KotlinJvmBundle -import org.jetbrains.kotlin.idea.scratch.* -import org.jetbrains.kotlin.idea.scratch.printDebugMessage -import org.jetbrains.kotlin.idea.scratch.LOG as log - -class RunScratchAction : ScratchAction( - KotlinJvmBundle.message("scratch.run.button"), - AllIcons.Actions.Execute -) { - - init { - KeymapManager.getInstance().activeKeymap.getShortcuts("Kotlin.RunScratch").firstOrNull()?.let { - templatePresentation.text += " (${KeymapUtil.getShortcutText(it)})" - } - } - - override fun actionPerformed(e: AnActionEvent) { - val project = e.project ?: return - val scratchFile = getScratchFileFromSelectedEditor(project) ?: return - - doAction(scratchFile, false) - } - - companion object { - fun doAction(scratchFile: ScratchFile, isAutoRun: Boolean) { - val isRepl = scratchFile.options.isRepl - val executor = (if (isRepl) scratchFile.replScratchExecutor else scratchFile.compilingScratchExecutor) ?: return - - log.printDebugMessage("Run Action: isRepl = $isRepl") - - fun executeScratch() { - try { - if (isAutoRun && executor is SequentialScratchExecutor) { - executor.executeNew() - } else { - executor.execute() - } - } catch (ex: Throwable) { - executor.errorOccurs(KotlinJvmBundle.message("exception.occurs.during.run.scratch.action"), ex, true) - } - } - - val isMakeBeforeRun = scratchFile.options.isMakeBeforeRun - log.printDebugMessage("Run Action: isMakeBeforeRun = $isMakeBeforeRun") - - val module = scratchFile.module - log.printDebugMessage("Run Action: module = ${module?.name}") - - if (!isAutoRun && module != null && isMakeBeforeRun) { - val project = scratchFile.project - ProjectTaskManager.getInstance(project).build(arrayOf(module)) { result -> - if (result.isAborted || result.errors > 0) { - executor.errorOccurs(KotlinJvmBundle.message("there.were.compilation.errors.in.module.0", module.name)) - } - - if (DumbService.isDumb(project)) { - DumbService.getInstance(project).smartInvokeLater { - executeScratch() - } - } else { - executeScratch() - } - } - } else { - executeScratch() - } - } - } - - override fun update(e: AnActionEvent) { - super.update(e) - - e.presentation.isEnabled = !ScratchCompilationSupport.isAnyInProgress() - - if (e.presentation.isEnabled) { - e.presentation.text = templatePresentation.text - } else { - e.presentation.text = KotlinJvmBundle.message("other.scratch.file.execution.is.in.progress") - } - - val project = e.project ?: return - val scratchFile = getScratchFileFromSelectedEditor(project) ?: return - - e.presentation.isVisible = !ScratchCompilationSupport.isInProgress(scratchFile) - } -} \ No newline at end of file diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/vcs/BunchCheckinHandler.kt.192 b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/vcs/BunchCheckinHandler.kt.192 deleted file mode 100644 index b9b51209743..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/vcs/BunchCheckinHandler.kt.192 +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.vcs - -import com.intellij.BundleBase.replaceMnemonicAmpersand -import com.intellij.CommonBundle -import com.intellij.ide.plugins.PluginManager -import com.intellij.openapi.extensions.PluginId -import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.Messages -import com.intellij.openapi.ui.Messages.NO -import com.intellij.openapi.ui.Messages.YES -import com.intellij.openapi.util.Key -import com.intellij.openapi.vcs.CheckinProjectPanel -import com.intellij.openapi.vcs.changes.CommitContext -import com.intellij.openapi.vcs.changes.CommitExecutor -import com.intellij.openapi.vcs.checkin.CheckinHandler -import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory -import com.intellij.openapi.vcs.ui.RefreshableOnComponent -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.ui.NonFocusableCheckBox -import com.intellij.util.PairConsumer -import org.jetbrains.kotlin.idea.KotlinJvmBundle -import org.jetbrains.kotlin.psi.NotNullableUserDataProperty -import java.awt.GridLayout -import java.io.File -import javax.swing.JComponent -import javax.swing.JPanel - -private val BUNCH_PLUGIN_ID = PluginId.getId("org.jetbrains.bunch.tool.idea.plugin") - -private var Project.bunchFileCheckEnabled: Boolean - by NotNullableUserDataProperty(Key.create("IS_BUNCH_FILE_CHECK_ENABLED_KOTLIN"), !PluginManager.isPluginInstalled(BUNCH_PLUGIN_ID)) - -class BunchFileCheckInHandlerFactory : CheckinHandlerFactory() { - override fun createHandler(panel: CheckinProjectPanel, commitContext: CommitContext): CheckinHandler { - return BunchCheckInHandler(panel) - } - - class BunchCheckInHandler(private val checkInProjectPanel: CheckinProjectPanel) : CheckinHandler() { - private val project get() = checkInProjectPanel.project - - override fun getBeforeCheckinConfigurationPanel(): RefreshableOnComponent? { - if (PluginManager.isPluginInstalled(BUNCH_PLUGIN_ID)) return null - BunchFileUtils.bunchFile(project) ?: return null - - val bunchFilesCheckBox = NonFocusableCheckBox(replaceMnemonicAmpersand(KotlinJvmBundle.message("check.bunch.files"))) - return object : RefreshableOnComponent { - override fun getComponent(): JComponent { - val panel = JPanel(GridLayout(1, 0)) - panel.add(bunchFilesCheckBox) - return panel - } - - override fun refresh() {} - override fun saveState() { - project.bunchFileCheckEnabled = bunchFilesCheckBox.isSelected - } - - override fun restoreState() { - bunchFilesCheckBox.isSelected = project.bunchFileCheckEnabled - } - } - } - - override fun beforeCheckin( - executor: CommitExecutor?, - additionalDataConsumer: PairConsumer? - ): ReturnResult { - if (!project.bunchFileCheckEnabled) return ReturnResult.COMMIT - - val extensions = BunchFileUtils.bunchExtension(project)?.toSet() ?: return ReturnResult.COMMIT - - val forgottenFiles = HashSet() - val commitFiles = checkInProjectPanel.files.filter { it.isFile }.toSet() - for (file in commitFiles) { - if (file.extension in extensions) continue - - val parent = file.parent ?: continue - val name = file.name - for (extension in extensions) { - val bunchFile = File(parent, "$name.$extension") - if (bunchFile !in commitFiles && bunchFile.exists()) { - forgottenFiles.add(bunchFile) - } - } - } - - if (forgottenFiles.isEmpty()) return ReturnResult.COMMIT - - val projectBaseFile = File(project.basePath) - var filePaths = forgottenFiles.map { it.relativeTo(projectBaseFile).path }.sorted() - if (filePaths.size > 15) { - filePaths = filePaths.take(15) + "..." - } - - when (Messages.showYesNoCancelDialog( - project, - KotlinJvmBundle.message( - "several.bunch.files.haven.t.been.updated.0.do.you.want.to.review.them.before.commit", - filePaths.joinToString("\n") - ), - KotlinJvmBundle.message("button.text.forgotten.bunch.files"), - KotlinJvmBundle.message("button.text.review"), - KotlinJvmBundle.message("button.text.commit"), - CommonBundle.getCancelButtonText(), - Messages.getWarningIcon() - )) { - YES -> { - return ReturnResult.CLOSE_WINDOW - } - NO -> return ReturnResult.COMMIT - } - - return ReturnResult.CANCEL - } - } -} - -object BunchFileUtils { - fun bunchFile(project: Project): VirtualFile? { - val baseDir = project.baseDir ?: return null - return baseDir.findChild(".bunch") - } - - fun bunchExtension(project: Project): List? { - val bunchFile: VirtualFile = bunchFile(project) ?: return null - val file = File(bunchFile.path) - if (!file.exists()) return null - - val lines = file.readLines().map { it.trim() }.filter { it.isNotEmpty() } - if (lines.size <= 1) return null - - return lines.drop(1).map { it.split('_').first() } - } -} diff --git a/idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/KotlinImporterComponentCompat.kt.192 b/idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/KotlinImporterComponentCompat.kt.192 deleted file mode 100644 index f917c597b1b..00000000000 --- a/idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/KotlinImporterComponentCompat.kt.192 +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.maven - -import com.intellij.openapi.module.Module - -// FIX ME WHEN BUNCH 192 REMOVED -internal val Module.kotlinImporterComponent: KotlinImporterComponent - get() = getComponent(KotlinImporterComponent::class.java) ?: throw IllegalStateException("No maven importer state configured") diff --git a/idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/MavenImportListener.kt.192 b/idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/MavenImportListener.kt.192 deleted file mode 100644 index 31c78b66427..00000000000 --- a/idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/MavenImportListener.kt.192 +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.maven - -import com.intellij.openapi.module.Module -import com.intellij.openapi.project.Project -import org.jetbrains.idea.maven.project.MavenImportListener -import org.jetbrains.idea.maven.project.MavenProject -import org.jetbrains.idea.maven.project.MavenProjectsManager -import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService -import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary -import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils.runUnderDisposeAwareIndicator - -// FIX ME WHEN BUNCH 192 REMOVED -class MavenImportListener(val project: Project) : MavenProjectsManager.Listener { - init { - project.messageBus.connect(project).subscribe( - MavenImportListener.TOPIC, - MavenImportListener { _: Collection, _: List -> - runUnderDisposeAwareIndicator(project) { - notifyOutdatedBundledCompilerIfNecessary(project) - KotlinMigrationProjectService.getInstance(project).onImportFinished() - } - } - ) - - MavenProjectsManager.getInstance(project)?.addManagerListener(this) - } - - override fun projectsScheduled() { - runUnderDisposeAwareIndicator(project) { - KotlinMigrationProjectService.getInstance(project).onImportAboutToStart() - } - } -} \ No newline at end of file diff --git a/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/service/IdeaBuildSystemAvailabilityWizardService.kt.192 b/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/service/IdeaBuildSystemAvailabilityWizardService.kt.192 deleted file mode 100644 index 3bf7592ad68..00000000000 --- a/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/service/IdeaBuildSystemAvailabilityWizardService.kt.192 +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.tools.projectWizard.wizard.service - -import com.intellij.ide.plugins.PluginManager -import com.intellij.openapi.extensions.PluginId -import org.jetbrains.kotlin.tools.projectWizard.core.service.BuildSystemAvailabilityWizardService -import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType -import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.isGradle - -class IdeaBuildSystemAvailabilityWizardService : BuildSystemAvailabilityWizardService, IdeaWizardService { - override fun isAvailable(buildSystemType: BuildSystemType): Boolean = when { - buildSystemType.isGradle -> isPluginEnabled("org.jetbrains.plugins.gradle") - buildSystemType == BuildSystemType.Maven -> isPluginEnabled("org.jetbrains.idea.maven") - else -> true - } - - private fun isPluginEnabled(id: String) = - PluginManager.getPlugin(PluginId.getId(id))?.isEnabled == true -} \ No newline at end of file diff --git a/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/service/IdeaGradleWizardService.kt.192 b/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/service/IdeaGradleWizardService.kt.192 deleted file mode 100644 index 606797d657f..00000000000 --- a/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/service/IdeaGradleWizardService.kt.192 +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.tools.projectWizard.wizard.service - -import com.intellij.execution.executors.DefaultRunExecutor -import com.intellij.openapi.actionSystem.ActionPlaces -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.CommonDataKeys -import com.intellij.openapi.actionSystem.impl.SimpleDataContext -import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings -import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode -import com.intellij.openapi.externalSystem.util.ExternalSystemUtil -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.LocalFileSystem -import org.jetbrains.annotations.NonNls -import org.jetbrains.kotlin.tools.projectWizard.core.Reader -import org.jetbrains.kotlin.tools.projectWizard.core.TaskResult -import org.jetbrains.kotlin.tools.projectWizard.core.andThen -import org.jetbrains.kotlin.tools.projectWizard.core.safe -import org.jetbrains.kotlin.tools.projectWizard.core.service.ProjectImportingWizardService -import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.ModuleIR -import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType -import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.isGradle -import org.jetbrains.plugins.gradle.action.ImportProjectFromScriptAction -import org.jetbrains.plugins.gradle.util.GradleConstants -import java.nio.file.Path - -// FIX ME WHEN BUNCH 192 REMOVED -class IdeaGradleWizardService(private val project: Project) : ProjectImportingWizardService, - IdeaWizardService { - override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean = - buildSystemType.isGradle - - // We have to call action directly as there is no common way - // to import Gradle project in all IDEAs from 183 to 193 - override fun importProject( - reader: Reader, - path: Path, - modulesIrs: List, - buildSystem: BuildSystemType - ): TaskResult = performImport(path) andThen createGradleWrapper(path) - - private fun performImport(path: Path) = safe { - val virtualFile = LocalFileSystem.getInstance().findFileByPath(path.toString()) - ?: error("No virtual file found for path $path") - val dataContext = SimpleDataContext.getSimpleContext( - mapOf( - CommonDataKeys.PROJECT.name to project, - CommonDataKeys.VIRTUAL_FILE.name to virtualFile - ), - null - ) - val action = ImportProjectFromScriptAction() - val event = AnActionEvent.createFromAnAction( - action, - /*event=*/ null, - ActionPlaces.UNKNOWN, - dataContext - ) - action.actionPerformed(event) - } - - - private fun createGradleWrapper(path: Path) = safe { - val settings = ExternalSystemTaskExecutionSettings().apply { - externalProjectPath = path.toString() - taskNames = listOf(WRAPPER_TASK_NAME) - externalSystemIdString = GradleConstants.SYSTEM_ID.id - } - - ExternalSystemUtil.runTask( - settings, - DefaultRunExecutor.EXECUTOR_ID, - project, - GradleConstants.SYSTEM_ID, - /*callback=*/ null, - ProgressExecutionMode.NO_PROGRESS_ASYNC - ) - } - - companion object { - @NonNls - private const val WRAPPER_TASK_NAME = "wrapper" - } -} \ No newline at end of file diff --git a/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/ui/firstStep/ActionToolbarImplWrapper.kt.192 b/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/ui/firstStep/ActionToolbarImplWrapper.kt.192 deleted file mode 100644 index 13cf4d2a92c..00000000000 --- a/idea/idea-new-project-wizard/src/org/jetbrains/kotlin/tools/projectWizard/wizard/ui/firstStep/ActionToolbarImplWrapper.kt.192 +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.tools.projectWizard.wizard.ui.firstStep - -import com.intellij.openapi.actionSystem.ActionGroup -import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl -import com.intellij.openapi.keymap.ex.KeymapManagerEx - -// needed for <=192 to work correctly -abstract class ActionToolbarImplWrapper( - place: String, - actionGroup: ActionGroup, - horizontal: Boolean -) : ActionToolbarImpl(place, actionGroup, horizontal, KeymapManagerEx.getInstanceEx()) \ No newline at end of file diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt.192 b/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt.192 deleted file mode 100644 index b0108dacd31..00000000000 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ConsoleCompilerHelper.kt.192 +++ /dev/null @@ -1,49 +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.console - -import com.intellij.execution.ExecutionManager -import com.intellij.execution.Executor -import com.intellij.execution.ui.RunContentDescriptor -import com.intellij.openapi.compiler.CompilerManager -import com.intellij.openapi.module.Module -import com.intellij.openapi.project.Project -import com.intellij.task.ProjectTaskManager - -class ConsoleCompilerHelper( - private val project: Project, - private val module: Module, - private val executor: Executor, - private val contentDescriptor: RunContentDescriptor -) { - - fun moduleIsUpToDate(): Boolean { - val compilerManager = CompilerManager.getInstance(project) - val compilerScope = compilerManager.createModuleCompileScope(module, true) - return compilerManager.isUpToDate(compilerScope) - } - - fun compileModule() { - if (ExecutionManager.getInstance(project).contentManager.removeRunContent(executor, contentDescriptor)) { - ProjectTaskManager.getInstance(project).build(arrayOf(module)) { result -> - if (!module.isDisposed) { - KotlinConsoleKeeper.getInstance(project).run(module, previousCompilationFailed = result.errors > 0) - } - } - } - } -} \ No newline at end of file diff --git a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java.192 b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java.192 deleted file mode 100644 index 637c72e6871..00000000000 --- a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightProjectDescriptor.java.192 +++ /dev/null @@ -1,51 +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.test; - -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleType; -import com.intellij.openapi.module.StdModuleTypes; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.ContentEntry; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.testFramework.LightProjectDescriptor; -import org.jetbrains.annotations.NotNull; - -public class KotlinLightProjectDescriptor extends LightProjectDescriptor { - protected KotlinLightProjectDescriptor() { - } - - public static final KotlinLightProjectDescriptor INSTANCE = new KotlinLightProjectDescriptor(); - - @Override - public ModuleType getModuleType() { - return StdModuleTypes.JAVA; - } - - @Override - public Sdk getSdk() { - return PluginTestCaseBase.mockJdk(); - } - - @Override - public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) { - configureModule(module, model); - } - - public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) { - } -} diff --git a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/compat.kt.192 b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/compat.kt.192 deleted file mode 100644 index 4360cf4ee64..00000000000 --- a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/compat.kt.192 +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.test - -import com.intellij.codeInsight.daemon.impl.EditorTracker -import com.intellij.ide.startup.impl.StartupManagerImpl -import com.intellij.openapi.project.Project -import com.intellij.openapi.startup.StartupManager - -// FIX ME WHEN BUNCH 192 REMOVED -fun editorTrackerProjectOpened(project: Project) { - project.getComponent(EditorTracker::class.java)?.projectOpened() -} - -// FIX ME WHEN BUNCH 193 REMOVED -fun runPostStartupActivitiesOnce(project: Project) { - (StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities() -} \ No newline at end of file diff --git a/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/CoroutineBreakpointFacility.kt.192 b/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/CoroutineBreakpointFacility.kt.192 deleted file mode 100644 index 2bcafa36c36..00000000000 --- a/idea/jvm-debugger/jvm-debugger-core/src/org/jetbrains/kotlin/idea/debugger/stepping/CoroutineBreakpointFacility.kt.192 +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.debugger.stepping - -import com.intellij.debugger.engine.SuspendContextImpl -import com.intellij.debugger.engine.events.SuspendContextCommandImpl -import com.intellij.debugger.ui.breakpoints.RunToCursorBreakpoint -import com.sun.jdi.Location -import com.sun.jdi.Method -import com.sun.jdi.event.LocatableEvent -import org.jetbrains.kotlin.idea.debugger.safeLocation - -object CoroutineBreakpointFacility : AbstractCoroutineBreakpointFacility() { - override fun installCoroutineResumedBreakpoint(context: SuspendContextImpl, location: Location, method: Method): Boolean { - val debugProcess = context.debugProcess - val project = debugProcess.project - - val methodLocation = method.location() - val position = debugProcess.positionManager.getSourcePosition(methodLocation) ?: return false - - val breakpoint = object : RunToCursorBreakpoint(project, position, false) { - override fun processLocatableEvent(action: SuspendContextCommandImpl, event: LocatableEvent?): Boolean { - val result = super.processLocatableEvent(action, event) - if (result) { - stepOverSuspendSwitch(action, debugProcess) - } - - return result - } - } - - breakpoint.setSuspendPolicy(context) - applyEmptyThreadFilter(debugProcess) - breakpoint.createRequest(debugProcess) - debugProcess.setRunToCursorBreakpoint(breakpoint) - - return true - } -} - -fun SuspendContextImpl.getLocationCompat(): Location? { - return this.frameProxy?.safeLocation() -} \ No newline at end of file diff --git a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/GradleProcessOutputInterceptor.kt.192 b/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/GradleProcessOutputInterceptor.kt.192 deleted file mode 100644 index 8380ca3f4be..00000000000 --- a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/GradleProcessOutputInterceptor.kt.192 +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.testFramework - -import com.intellij.openapi.Disposable -import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId -import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent -import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener -import com.intellij.testFramework.PlatformTestUtil.maskExtensions -import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID -import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -import kotlin.test.assertNull -import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener.EP_NAME as EP - -interface GradleProcessOutputInterceptor { - companion object { - fun getInstance(): GradleProcessOutputInterceptor? = EP.extensions.firstIsInstanceOrNull() - - fun install(parentDisposable: Disposable) { - val installedExtensions = EP.extensions - - assertNull( - installedExtensions.firstIsInstanceOrNull(), - "Another ${GradleProcessOutputInterceptor::class.java.simpleName} is already installed" - ) - - maskExtensions( - EP, - listOf(GradleProcessOutputInterceptorImpl()) + installedExtensions, - parentDisposable - ) - } - } - - fun reset() - fun getOutput(): String -} - -private class GradleProcessOutputInterceptorImpl : GradleProcessOutputInterceptor, ExternalSystemTaskNotificationListener { - private val buffer = StringBuilder() - - override fun onTaskOutput(id: ExternalSystemTaskId, text: String, stdOut: Boolean) { - if (id.projectSystemId == GRADLE_SYSTEM_ID && text.isNotEmpty()) - buffer.append(text) - } - - override fun reset() = buffer.setLength(0) - override fun getOutput() = buffer.toString() - - override fun onSuccess(id: ExternalSystemTaskId) = Unit - override fun onFailure(id: ExternalSystemTaskId, e: Exception) = Unit - override fun onStatusChange(event: ExternalSystemTaskNotificationEvent) = Unit - override fun onCancel(id: ExternalSystemTaskId) = Unit - override fun onEnd(id: ExternalSystemTaskId) = Unit - override fun beforeCancel(id: ExternalSystemTaskId) = Unit - override fun onQueued(id: ExternalSystemTaskId, workingDir: String?) = Unit - - @Suppress("UnstableApiUsage") - override fun onStart(id: ExternalSystemTaskId) = Unit -} diff --git a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 b/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 deleted file mode 100644 index 4648dfc3ce7..00000000000 --- a/idea/performanceTests/test/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.192 +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.testFramework - -import com.intellij.ide.startup.impl.StartupManagerImpl -import com.intellij.lang.LanguageAnnotators -import com.intellij.lang.LanguageExtensionPoint -import com.intellij.lang.annotation.Annotator -import com.intellij.openapi.Disposable -import com.intellij.openapi.editor.Document -import com.intellij.openapi.extensions.ExtensionPointName -import com.intellij.openapi.fileEditor.FileDocumentManager -import com.intellij.openapi.project.Project -import com.intellij.openapi.project.ex.ProjectManagerEx -import com.intellij.openapi.startup.StartupManager -import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.impl.PsiDocumentManagerBase -import com.intellij.testFramework.PlatformTestUtil -import com.intellij.testFramework.runInEdtAndWait -import com.intellij.util.ui.UIUtil -import org.jetbrains.kotlin.idea.codeInsight.hints.HintType -import org.jetbrains.kotlin.idea.test.runPostStartupActivitiesOnce - -fun commitAllDocuments() { - val fileDocumentManager = FileDocumentManager.getInstance() - runInEdtAndWait { - fileDocumentManager.saveAllDocuments() - } - - ProjectManagerEx.getInstanceEx().openProjects.forEach { project -> - val psiDocumentManagerBase = PsiDocumentManager.getInstance(project) as PsiDocumentManagerBase - - runInEdtAndWait { - psiDocumentManagerBase.clearUncommittedDocuments() - psiDocumentManagerBase.commitAllDocuments() - } - } -} - -fun commitDocument(project: Project, document: Document) { - val psiDocumentManagerBase = PsiDocumentManager.getInstance(project) as PsiDocumentManagerBase - runInEdtAndWait { - psiDocumentManagerBase.commitDocument(document) - } -} - -fun saveDocument(document: Document) { - val fileDocumentManager = FileDocumentManager.getInstance() - - runInEdtAndWait { - fileDocumentManager.saveDocument(document) - } -} - -fun enableHints(enable: Boolean) = - HintType.values().forEach { it.option.set(enable) } - -fun dispatchAllInvocationEvents() { - runInEdtAndWait { - UIUtil.dispatchAllInvocationEvents() - } -} - -fun loadProjectWithName(path: String, name: String): Project? = - ProjectManagerEx.getInstanceEx().loadProject(name, path) - -fun TestApplicationManager.closeProject(project: Project) { - dispatchAllInvocationEvents() - val projectManagerEx = ProjectManagerEx.getInstanceEx() - projectManagerEx.forceCloseProjectEx(project, true) -} - -fun runStartupActivities(project: Project) { - with(StartupManager.getInstance(project) as StartupManagerImpl) { - scheduleInitialVfsRefresh() - runStartupActivities() - } - runPostStartupActivitiesOnce(project) -} - -fun waitForAllEditorsFinallyLoaded(project: Project) { - // routing is obsolete in 192 -} - -fun replaceWithCustomHighlighter(parentDisposable: Disposable, fromImplementationClass: String, toImplementationClass: String) { - val pointName = ExtensionPointName.create>(LanguageAnnotators.EP_NAME) - val extensionPoint = pointName.getPoint(null) - - val point = LanguageExtensionPoint() - point.language = "kotlin" - point.implementationClass = toImplementationClass - - val extensions = extensionPoint.extensions - val filteredExtensions = - extensions.filter { it.language != "kotlin" || it.implementationClass != fromImplementationClass } - .toList() - // custom highlighter is already registered if filteredExtensions has the same size as extensions - if (filteredExtensions.size < extensions.size) { - PlatformTestUtil.maskExtensions(pointName, filteredExtensions + listOf(point), parentDisposable) - } -} diff --git a/idea/resources-descriptors/META-INF/plugin.xml.192 b/idea/resources-descriptors/META-INF/plugin.xml.192 deleted file mode 100644 index 19eb6fc3579..00000000000 --- a/idea/resources-descriptors/META-INF/plugin.xml.192 +++ /dev/null @@ -1,165 +0,0 @@ - - org.jetbrains.kotlin - - Kotlin - -Getting Started in IntelliJ IDEA
-Getting Started in Android Studio
-Public Slack
-Issue tracker
-]]>
- @snapshot@ - JetBrains - - - - 1.4.0 - Released: August 17, 2020 -
    -
  • New compiler with better type inference.
  • -
  • IR backends for JVM and JS in Alpha mode (requires opt-in).
  • -
  • A new flexible Kotlin Project Wizard for easy creation and configuration of different types of projects.
  • -
  • New IDE functionality to debug coroutines.
  • -
  • IDE performance improvements: many actions, such as project opening and autocomplete suggestions now complete up to 4 times faster.
  • -
  • New language features such as SAM conversions, trailing comma, and other.
  • -
  • Type annotations in the JVM bytecode and new modes for generating default interfaces in Kotlin/JVM.
  • -
  • New Gradle DSL for Kotlin/JS.
  • -
  • Improved performance and interop with Swift and Objective-C in Kotlin/Native.
  • -
  • Support for sharing code in several targets thanks to the hierarchical structure in multiplatform projects.
  • -
  • New collection operators, delegated properties improvements, the double-ended queue implementation ArrayDeque, and much more new things in the standard library.
  • -
- For more details, see What’s New in Kotlin 1.4.0 and this blog post. -

- To get the most out of the changes and improvements introduced in Kotlin 1.4, join our Online Event where you will be able to enjoy four days of Kotlin talks, Q&As with the Kotlin team, and more. - ]]> -
- - com.intellij.modules.platform - - JUnit - org.jetbrains.plugins.gradle - org.jetbrains.plugins.gradle.java - org.jetbrains.plugins.gradle.java - org.intellij.groovy - org.jetbrains.idea.maven - org.jetbrains.idea.maven - TestNG-J - Coverage - com.intellij.java-i18n - org.jetbrains.java.decompiler - Git4Idea - org.jetbrains.debugger.streams - - - - - com.intellij.modules.idea - com.intellij.modules.java - JavaScriptDebugger - com.intellij.copyright - org.intellij.intelliLang - - - - - - - - - - - - - - - - - - - - - - - org.jetbrains.kotlin.idea.versions.KotlinUpdatePluginComponent - - - - - - org.jetbrains.kotlin.idea.completion.LookupCancelWatcher - - - org.jetbrains.kotlin.idea.caches.KotlinPackageContentModificationListener - - - org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectComponent - - - org.jetbrains.kotlin.idea.highlighter.KotlinBeforeResolveHighlightingPass$Factory - - - org.jetbrains.kotlin.idea.refactoring.cutPaste.MoveDeclarationsPassFactory - - - - org.jetbrains.kotlin.idea.highlighter.ScriptExternalHighlightingPass$Factory - - - org.jetbrains.kotlin.idea.caches.trackers.KotlinCodeBlockModificationListener - - - - - - org.jetbrains.kotlin.idea.PluginStartupComponent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/idea/resources/META-INF/jvm.xml.192 b/idea/resources/META-INF/jvm.xml.192 deleted file mode 100644 index 9a98acdc648..00000000000 --- a/idea/resources/META-INF/jvm.xml.192 +++ /dev/null @@ -1,21 +0,0 @@ - - - - org.jetbrains.kotlin.idea.JvmPluginStartupComponent - - - - - - org.jetbrains.kotlin.idea.compiler.KotlinCompilerManager - - - org.jetbrains.kotlin.idea.scratch.ScratchFileModuleInfoProvider - - - - org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent - - - - diff --git a/idea/resources/META-INF/maven.xml.192 b/idea/resources/META-INF/maven.xml.192 deleted file mode 100644 index 494f5b0883e..00000000000 --- a/idea/resources/META-INF/maven.xml.192 +++ /dev/null @@ -1,13 +0,0 @@ - - - - org.jetbrains.kotlin.idea.maven.MavenImportListener - - - - - - org.jetbrains.kotlin.idea.maven.KotlinImporterComponent - - - diff --git a/idea/resources/META-INF/native.xml.192 b/idea/resources/META-INF/native.xml.192 deleted file mode 100644 index 3bc91e85fd4..00000000000 --- a/idea/resources/META-INF/native.xml.192 +++ /dev/null @@ -1,19 +0,0 @@ - - - - org.jetbrains.kotlin.idea.klib.KlibLoadingMetadataCache - - - - - - org.jetbrains.kotlin.ide.konan.KotlinNativeABICompatibilityChecker - - - - - - - - org.jetbrains.plugins.gradle - diff --git a/idea/scripting-support/test/org/jetbrains/kotlin/idea/script/AbstractScriptTemplatesFromDependenciesTest.kt.192 b/idea/scripting-support/test/org/jetbrains/kotlin/idea/script/AbstractScriptTemplatesFromDependenciesTest.kt.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/scripting-support/test/org/jetbrains/kotlin/idea/script/ScriptTemplatesFromDependenciesTestGenerated.java.192 b/idea/scripting-support/test/org/jetbrains/kotlin/idea/script/ScriptTemplatesFromDependenciesTestGenerated.java.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt.192 b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt.192 deleted file mode 100644 index b2842ca486d..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt.192 +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea - -import com.google.gson.GsonBuilder -import com.google.gson.JsonIOException -import com.google.gson.JsonSyntaxException -import com.intellij.ide.actions.ShowFilePathAction -import com.intellij.ide.plugins.* -import com.intellij.ide.util.PropertiesComponent -import com.intellij.notification.NotificationDisplayType -import com.intellij.notification.NotificationGroup -import com.intellij.notification.NotificationListener -import com.intellij.notification.NotificationType -import com.intellij.openapi.Disposable -import com.intellij.openapi.application.* -import com.intellij.openapi.components.ServiceManager -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.extensions.PluginId -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.progress.ProgressManager -import com.intellij.openapi.progress.Task -import com.intellij.openapi.updateSettings.impl.PluginDownloader -import com.intellij.openapi.updateSettings.impl.UpdateSettings -import com.intellij.openapi.util.JDOMUtil -import com.intellij.openapi.util.SystemInfo -import com.intellij.openapi.vfs.CharsetToolkit -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.util.Alarm -import com.intellij.util.io.HttpRequests -import com.intellij.util.text.VersionComparatorUtil -import org.jetbrains.kotlin.idea.update.verify -import java.io.File -import java.io.IOException -import java.io.PrintWriter -import java.io.StringWriter -import java.net.URLEncoder -import java.time.DateTimeException -import java.time.Instant -import java.time.LocalDate -import java.time.ZoneOffset -import java.util.concurrent.TimeUnit - -sealed class PluginUpdateStatus { - val timestamp = System.currentTimeMillis() - - object LatestVersionInstalled : PluginUpdateStatus() - - class Update( - val pluginDescriptor: IdeaPluginDescriptor, - val hostToInstallFrom: String? - ) : PluginUpdateStatus() - - class CheckFailed(val message: String, val detail: String? = null) : PluginUpdateStatus() - - class Unverified(val verifierName: String, val reason: String?, val updateStatus: Update) : PluginUpdateStatus() - - fun mergeWith(other: PluginUpdateStatus): PluginUpdateStatus { - if (other is Update) { - when (this) { - is LatestVersionInstalled -> { - return other - } - is Update -> { - if (VersionComparatorUtil.compare(other.pluginDescriptor.version, pluginDescriptor.version) > 0) { - return other - } - } - is CheckFailed, is Unverified -> { - // proceed to return this - } - } - } - - return this - } - - companion object { - fun fromException(message: String, e: Exception): PluginUpdateStatus { - val writer = StringWriter() - e.printStackTrace(PrintWriter(writer)) - return CheckFailed(message, writer.toString()) - } - } -} - -class KotlinPluginUpdater : Disposable { - private var updateDelay = INITIAL_UPDATE_DELAY - private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, this) - private val notificationGroup = NotificationGroup( - KotlinBundle.message("plugin.updater.notification.group"), - NotificationDisplayType.STICKY_BALLOON, true - ) - - @Volatile - private var checkQueued = false - - @Volatile - private var lastUpdateStatus: PluginUpdateStatus? = null - - fun kotlinFileEdited(file: VirtualFile) { - if (!file.isInLocalFileSystem) return - if (ApplicationManager.getApplication().isUnitTestMode || ApplicationManager.getApplication().isHeadlessEnvironment) return - if (!UpdateSettings.getInstance().isCheckNeeded) return - - val lastUpdateTime = java.lang.Long.parseLong(PropertiesComponent.getInstance().getValue(PROPERTY_NAME, "0")) - if (lastUpdateTime == 0L || System.currentTimeMillis() - lastUpdateTime > CACHED_REQUEST_DELAY) { - queueUpdateCheck { updateStatus -> - when (updateStatus) { - is PluginUpdateStatus.Update -> notifyPluginUpdateAvailable(updateStatus) - is PluginUpdateStatus.CheckFailed -> LOG.info("Plugin update check failed: ${updateStatus.message}, details: ${updateStatus.detail}") - } - true - } - } - } - - private fun queueUpdateCheck(callback: (PluginUpdateStatus) -> Boolean) { - ApplicationManager.getApplication().assertIsDispatchThread() - if (!checkQueued) { - checkQueued = true - alarm.addRequest({ updateCheck(callback) }, updateDelay) - updateDelay *= 2 // exponential backoff - } - } - - fun runUpdateCheck(callback: (PluginUpdateStatus) -> Boolean) { - ApplicationManager.getApplication().executeOnPooledThread { - updateCheck(callback) - } - } - - fun runCachedUpdate(callback: (PluginUpdateStatus) -> Boolean) { - ApplicationManager.getApplication().assertIsDispatchThread() - val cachedStatus = lastUpdateStatus - if (cachedStatus != null && System.currentTimeMillis() - cachedStatus.timestamp < CACHED_REQUEST_DELAY) { - if (cachedStatus !is PluginUpdateStatus.CheckFailed) { - callback(cachedStatus) - return - } - } - - queueUpdateCheck(callback) - } - - private fun updateCheck(callback: (PluginUpdateStatus) -> Boolean) { - var updateStatus: PluginUpdateStatus - if (KotlinPluginUtil.isSnapshotVersion() || KotlinPluginUtil.isPatched()) { - updateStatus = PluginUpdateStatus.LatestVersionInstalled - } else { - try { - updateStatus = checkUpdatesInMainRepository() - - for (host in RepositoryHelper.getPluginHosts().filterNotNull()) { - val customUpdateStatus = checkUpdatesInCustomRepository(host) - updateStatus = updateStatus.mergeWith(customUpdateStatus) - } - } catch (e: Exception) { - updateStatus = PluginUpdateStatus.fromException(KotlinBundle.message("plugin.updater.error.check.failed"), e) - } - } - - lastUpdateStatus = updateStatus - checkQueued = false - - if (updateStatus is PluginUpdateStatus.Update) { - updateStatus = verify(updateStatus) - } - - if (updateStatus !is PluginUpdateStatus.CheckFailed) { - recordSuccessfulUpdateCheck() - } - - ApplicationManager.getApplication().invokeLater({ - callback(updateStatus) - }, ModalityState.any()) - } - - private fun initPluginDescriptor(newVersion: String): IdeaPluginDescriptor { - val originalPlugin = PluginManager.getPlugin(KotlinPluginUtil.KOTLIN_PLUGIN_ID)!! - return PluginNode(KotlinPluginUtil.KOTLIN_PLUGIN_ID).apply { - version = newVersion - name = originalPlugin.name - description = originalPlugin.description - } - } - - private fun checkUpdatesInMainRepository(): PluginUpdateStatus { - val buildNumber = ApplicationInfo.getInstance().apiVersion - val currentVersion = KotlinPluginUtil.getPluginVersion() - val os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8) - val uid = PermanentInstallationID.get() - val pluginId = KotlinPluginUtil.KOTLIN_PLUGIN_ID.idString - val url = - "https://plugins.jetbrains.com/plugins/list?pluginId=$pluginId&build=$buildNumber&pluginVersion=$currentVersion&os=$os&uuid=$uid" - val responseDoc = HttpRequests.request(url).connect { - JDOMUtil.load(it.inputStream) - } - if (responseDoc.name != "plugin-repository") { - return PluginUpdateStatus.CheckFailed( - KotlinBundle.message("plugin.updater.error.unexpected.repository.response"), - JDOMUtil.writeElement(responseDoc, "\n") - ) - } - if (responseDoc.children.isEmpty()) { - // No plugin version compatible with current IDEA build; don't retry updates - return PluginUpdateStatus.LatestVersionInstalled - } - val newVersion = responseDoc.getChild("category")?.getChild("idea-plugin")?.getChild("version")?.text - ?: return PluginUpdateStatus.CheckFailed( - KotlinBundle.message("plugin.updater.error.cant.find.plugin.version"), - JDOMUtil.writeElement(responseDoc, "\n") - ) - val pluginDescriptor = initPluginDescriptor(newVersion) - return updateIfNotLatest(pluginDescriptor, null) - } - - private fun checkUpdatesInCustomRepository(host: String): PluginUpdateStatus { - val plugins = try { - RepositoryHelper.loadPlugins(host, null) - } catch (e: Exception) { - return PluginUpdateStatus.fromException(KotlinBundle.message("plugin.updater.error.custom.repository", host), e) - } - - val kotlinPlugin = plugins.find { pluginDescriptor -> - pluginDescriptor.pluginId == KotlinPluginUtil.KOTLIN_PLUGIN_ID && PluginManagerCore.isCompatible(pluginDescriptor) - } ?: return PluginUpdateStatus.LatestVersionInstalled - - return updateIfNotLatest(kotlinPlugin, host) - } - - private fun updateIfNotLatest(kotlinPlugin: IdeaPluginDescriptor, host: String?): PluginUpdateStatus { - if (VersionComparatorUtil.compare(kotlinPlugin.version, KotlinPluginUtil.getPluginVersion()) <= 0) { - return PluginUpdateStatus.LatestVersionInstalled - } - - return PluginUpdateStatus.Update(kotlinPlugin, host) - } - - private fun recordSuccessfulUpdateCheck() { - PropertiesComponent.getInstance().setValue(PROPERTY_NAME, System.currentTimeMillis().toString()) - updateDelay = INITIAL_UPDATE_DELAY - } - - private fun notifyPluginUpdateAvailable(update: PluginUpdateStatus.Update) { - val notification = notificationGroup.createNotification( - KotlinBundle.message("plugin.updater.notification.title"), - KotlinBundle.message("plugin.updater.notification.message", update.pluginDescriptor.version), - NotificationType.INFORMATION, - NotificationListener { notification, _ -> - notification.expire() - installPluginUpdate(update) { - notifyPluginUpdateAvailable(update) - } - }) - - notification.notify(null) - } - - fun installPluginUpdate( - update: PluginUpdateStatus.Update, - successCallback: () -> Unit = {}, cancelCallback: () -> Unit = {}, errorCallback: () -> Unit = {} - ) { - val descriptor = update.pluginDescriptor - val pluginDownloader = PluginDownloader.createDownloader(descriptor, update.hostToInstallFrom, null) - ProgressManager.getInstance().run(object : Task.Backgroundable( - null, KotlinBundle.message("plugin.updater.downloading"), true, PluginManagerUISettings.getInstance() - ) { - override fun run(indicator: ProgressIndicator) { - var installed = false - var message: String? = null - val prepareResult = try { - pluginDownloader.prepareToInstall(indicator) - } catch (e: IOException) { - LOG.info(e) - message = e.message - false - } - - if (prepareResult) { - installed = true - pluginDownloader.install() - - ApplicationManager.getApplication().invokeLater { - PluginManagerMain.notifyPluginsUpdated(null) - } - } - - ApplicationManager.getApplication().invokeLater { - if (!installed) { - errorCallback() - notifyNotInstalled(message) - } else { - successCallback() - } - } - } - - override fun onCancel() { - cancelCallback() - } - }) - } - - private fun notifyNotInstalled(message: String?) { - val notification = notificationGroup.createNotification( - KotlinBundle.message("plugin.updater.notification.title"), - when (message) { - null -> KotlinBundle.message("plugin.updater.not.installed") - else -> KotlinBundle.message("plugin.updater.not.installed.misc", message) - }, - NotificationType.INFORMATION, - NotificationListener { notification, _ -> - val logFile = File(PathManager.getLogPath(), "idea.log") - ShowFilePathAction.openFile(logFile) - - notification.expire() - } - ) - - notification.notify(null) - } - - override fun dispose() { - } - - companion object { - private const val INITIAL_UPDATE_DELAY = 2000L - private val CACHED_REQUEST_DELAY = TimeUnit.DAYS.toMillis(1) - - private const val PROPERTY_NAME = "kotlin.lastUpdateCheck" - private val LOG = Logger.getInstance(KotlinPluginUpdater::class.java) - - fun getInstance(): KotlinPluginUpdater = ServiceManager.getService(KotlinPluginUpdater::class.java) - - class ResponseParseException(message: String, cause: Exception? = null) : IllegalStateException(message, cause) - - @Suppress("SpellCheckingInspection") - private class PluginDTO { - var cdate: String? = null - var channel: String? = null - - // `true` if the version is seen in plugin site and available for download. - // Maybe be `false` if author requested version deletion. - var listed: Boolean = true - - // `true` if version is approved and verified - var approve: Boolean = true - } - - @Throws(IOException::class, ResponseParseException::class) - fun fetchPluginReleaseDate(pluginId: PluginId, version: String, channel: String?): LocalDate? { - val url = "https://plugins.jetbrains.com/api/plugins/${pluginId.idString}/updates?version=$version" - - val pluginDTOs: Array = try { - HttpRequests.request(url).connect { - GsonBuilder().create().fromJson(it.inputStream.reader(), Array::class.java) - } - } catch (ioException: JsonIOException) { - throw IOException(ioException) - } catch (syntaxException: JsonSyntaxException) { - throw ResponseParseException("Can't parse json response", syntaxException) - } - - val selectedPluginDTO = pluginDTOs - .firstOrNull { - it.listed && it.approve && (it.channel == channel || (it.channel == "" && channel == null)) - } - ?: return null - - val dateString = selectedPluginDTO.cdate ?: throw ResponseParseException("Empty cdate") - - return try { - val dateLong = dateString.toLong() - Instant.ofEpochMilli(dateLong).atZone(ZoneOffset.UTC).toLocalDate() - } catch (e: NumberFormatException) { - throw ResponseParseException("Can't parse long date", e) - } catch (e: DateTimeException) { - throw ResponseParseException("Can't convert to date", e) - } - } - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/PluginStartupActivity.java.192 b/idea/src/org/jetbrains/kotlin/idea/PluginStartupActivity.java.192 deleted file mode 100644 index a60f0e72cbb..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/PluginStartupActivity.java.192 +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2020 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; - - -public class PluginStartupActivity { - - -} diff --git a/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java.192 b/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java.192 deleted file mode 100644 index b7379d8f51f..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java.192 +++ /dev/null @@ -1,149 +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; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathMacros; -import com.intellij.openapi.components.BaseComponent; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.event.DocumentListener; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.updateSettings.impl.UpdateChecker; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.search.searches.IndexPatternSearch; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.diagnostics.DiagnosticFactory; -import org.jetbrains.kotlin.diagnostics.Errors; -import org.jetbrains.kotlin.idea.reporter.KotlinReportSubmitter; -import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinTodoSearcher; -import org.jetbrains.kotlin.js.resolve.diagnostics.ErrorsJs; -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm; -import org.jetbrains.kotlin.resolve.konan.diagnostics.ErrorsNative; -import org.jetbrains.kotlin.utils.PathUtil; - -import java.io.File; -import java.io.IOException; - -import static org.jetbrains.kotlin.idea.TestResourceBundleKt.registerAdditionalResourceBundleInTests; - -public class PluginStartupComponent implements BaseComponent { - private static final Logger LOG = Logger.getInstance(PluginStartupComponent.class); - - private static final String KOTLIN_BUNDLED = "KOTLIN_BUNDLED"; - - public static PluginStartupComponent getInstance() { - return ApplicationManager.getApplication().getComponent(PluginStartupComponent.class); - } - - @Override - @NotNull - public String getComponentName() { - return PluginStartupComponent.class.getName(); - } - - @Override - public void initComponent() { - if (ApplicationManager.getApplication().isUnitTestMode()) { - registerAdditionalResourceBundleInTests(); - } - - registerPathVariable(); - initializeDiagnostics(); - - try { - // API added in 15.0.2 - UpdateChecker.INSTANCE.getExcludedFromUpdateCheckPlugins().add("org.jetbrains.kotlin"); - } - catch (Throwable throwable) { - LOG.debug("Excluding Kotlin plugin updates using old API", throwable); - UpdateChecker.getDisabledToUpdatePlugins().add("org.jetbrains.kotlin"); - } - EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentListener() { - @Override - public void documentChanged(@NotNull DocumentEvent e) { - VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(e.getDocument()); - if (virtualFile != null && virtualFile.getFileType() == KotlinFileType.INSTANCE) { - KotlinPluginUpdater.Companion.getInstance().kotlinFileEdited(virtualFile); - } - } - }); - - ServiceManager.getService(IndexPatternSearch.class).registerExecutor(new KotlinTodoSearcher()); - - KotlinPluginCompatibilityVerifier.checkCompatibility(); - - KotlinReportSubmitter.Companion.setupReportingFromRelease(); - - //todo[Sedunov]: wait for fix in platform to avoid misunderstood from Java newbies (also ConfigureKotlinInTempDirTest) - //KotlinSdkType.Companion.setUpIfNeeded(); - } - - /* - Concurrent access to Errors may lead to the class loading dead lock because of non-trivial initialization in Errors. - As a work-around, all Error classes are initialized beforehand. - It doesn't matter what exact diagnostic factories are used here. - */ - private static void initializeDiagnostics() { - consumeFactory(Errors.DEPRECATION); - consumeFactory(ErrorsJvm.ACCIDENTAL_OVERRIDE); - consumeFactory(ErrorsJs.CALL_FROM_UMD_MUST_BE_JS_MODULE_AND_JS_NON_MODULE); - consumeFactory(ErrorsNative.INCOMPATIBLE_THROWS_INHERITED); - } - - private static void consumeFactory(DiagnosticFactory factory) { - //noinspection ResultOfMethodCallIgnored - factory.getClass(); - } - - private static void registerPathVariable() { - PathMacros macros = PathMacros.getInstance(); - macros.setMacro(KOTLIN_BUNDLED, PathUtil.getKotlinPathsForIdeaPlugin().getHomePath().getPath()); - } - - private String aliveFlagPath; - - public synchronized String getAliveFlagPath() { - if (this.aliveFlagPath == null) { - try { - File flagFile = File.createTempFile("kotlin-idea-", "-is-running"); - flagFile.deleteOnExit(); - this.aliveFlagPath = flagFile.getAbsolutePath(); - } - catch (IOException e) { - this.aliveFlagPath = ""; - } - } - return this.aliveFlagPath; - } - - public synchronized void resetAliveFlag() { - if (this.aliveFlagPath != null) { - File flagFile = new File(this.aliveFlagPath); - if (flagFile.exists()) { - if (flagFile.delete()) { - this.aliveFlagPath = null; - } - } - } - } - - @Override - public void disposeComponent() {} -} diff --git a/idea/src/org/jetbrains/kotlin/idea/PluginStartupService.java.192 b/idea/src/org/jetbrains/kotlin/idea/PluginStartupService.java.192 deleted file mode 100644 index 9a3ed2b5a68..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/PluginStartupService.java.192 +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2020 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; - -import com.intellij.openapi.application.ApplicationManager; - -import java.io.File; -import java.io.IOException; - -public class PluginStartupService { - - -} diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/benchmark/AbstractCompletionBenchmarkAction.kt.192 b/idea/src/org/jetbrains/kotlin/idea/actions/internal/benchmark/AbstractCompletionBenchmarkAction.kt.192 deleted file mode 100644 index 0f268611981..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/benchmark/AbstractCompletionBenchmarkAction.kt.192 +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2010-2017 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.actions.internal.benchmark - -import com.intellij.codeInsight.AutoPopupController -import com.intellij.codeInsight.completion.CompletionType -import com.intellij.codeInsight.navigation.NavigationUtil -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.command.CommandProcessor -import com.intellij.openapi.editor.EditorFactory -import com.intellij.openapi.editor.ScrollType -import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.MessageType -import com.intellij.openapi.ui.popup.JBPopupFactory -import com.intellij.openapi.wm.WindowManager -import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.search.DelegatingGlobalSearchScope -import com.intellij.psi.search.FileTypeIndex -import com.intellij.psi.search.GlobalSearchScope -import com.intellij.ui.components.JBLabel -import com.intellij.ui.components.JBTextField -import com.intellij.uiDesigner.core.GridConstraints -import kotlinx.coroutines.* -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.idea.caches.project.ModuleOrigin -import org.jetbrains.kotlin.idea.caches.project.getNullableModuleInfo -import org.jetbrains.kotlin.idea.completion.CompletionBenchmarkSink -import org.jetbrains.kotlin.idea.core.moveCaret -import org.jetbrains.kotlin.idea.core.util.EDT -import org.jetbrains.kotlin.idea.core.util.getLineCount -import org.jetbrains.kotlin.idea.core.util.toPsiFile -import org.jetbrains.kotlin.idea.util.application.runWriteAction -import org.jetbrains.kotlin.psi.KtFile -import java.util.* -import javax.swing.JFileChooser -import javax.swing.JPanel - -abstract class AbstractCompletionBenchmarkAction : AnAction() { - override fun actionPerformed(e: AnActionEvent) { - val project = e.project ?: return - - val benchmarkSink = CompletionBenchmarkSink.enableAndGet() - val scenario = createBenchmarkScenario(project, benchmarkSink) ?: return - - GlobalScope.launch(EDT) { - scenario.doBenchmark() - CompletionBenchmarkSink.disable() - } - } - - internal abstract fun createBenchmarkScenario( - project: Project, - benchmarkSink: CompletionBenchmarkSink.Impl - ): AbstractCompletionBenchmarkScenario? - - companion object { - fun showPopup(project: Project, text: String) { - val statusBar = WindowManager.getInstance().getStatusBar(project) - JBPopupFactory.getInstance() - .createHtmlTextBalloonBuilder(text, MessageType.ERROR, null) - .setFadeoutTime(5000) - .createBalloon().showInCenterOf(statusBar.component) - } - - internal fun List.randomElement(random: Random): T? = if (this.isNotEmpty()) this[random.nextInt(this.size)] else null - internal fun List.shuffledSequence(random: Random): Sequence = - generateSequence { this.randomElement(random) }.distinct() - - internal fun collectSuitableKotlinFiles(project: Project, filePredicate: (KtFile) -> Boolean): MutableList { - val scope = object : DelegatingGlobalSearchScope(GlobalSearchScope.allScope(project)) { - override fun isSearchOutsideRootModel(): Boolean = false - } - - fun KtFile.isUsableForBenchmark(): Boolean { - val moduleInfo = this.getNullableModuleInfo() ?: return false - if (this.isCompiled || !this.isWritable || this.isScript()) return false - return moduleInfo.moduleOrigin == ModuleOrigin.MODULE - } - - val kotlinVFiles = FileTypeIndex.getFiles(KotlinFileType.INSTANCE, scope) - - return kotlinVFiles - .asSequence() - .mapNotNull { vfile -> (vfile.toPsiFile(project) as? KtFile) } - .filterTo(mutableListOf()) { it.isUsableForBenchmark() && filePredicate(it) } - } - - internal fun JPanel.addBoxWithLabel(tooltip: String, label: String = "$tooltip:", default: String, i: Int): JBTextField { - this.add(JBLabel(label), GridConstraints().apply { row = i; column = 0 }) - val textField = JBTextField().apply { - text = default - toolTipText = tooltip - } - this.add(textField, GridConstraints().apply { row = i; column = 1; fill = GridConstraints.FILL_HORIZONTAL }) - return textField - } - } - - override fun update(e: AnActionEvent) { - e.presentation.isEnabledAndVisible = ApplicationManager.getApplication().isInternal - } -} - -internal abstract class AbstractCompletionBenchmarkScenario( - val project: Project, private val benchmarkSink: CompletionBenchmarkSink.Impl, - val random: Random = Random(), private val timeout: Long = 15000 -) { - - - sealed class Result { - abstract fun toCSV(stringBuilder: StringBuilder) - - open class SuccessResult(val lines: Int, val filePath: String, val first: Long, val full: Long) : Result() { - override fun toCSV(stringBuilder: StringBuilder): Unit = with(stringBuilder) { - append(filePath) - append(", ") - append(lines) - append(", ") - append(first) - append(", ") - append(full) - } - } - - class ErrorResult(val filePath: String) : Result() { - override fun toCSV(stringBuilder: StringBuilder): Unit = with(stringBuilder) { - append(filePath) - append(", ") - append(", ") - append(", ") - } - } - } - - - protected suspend fun typeAtOffsetAndGetResult(text: String, offset: Int, file: KtFile): Result { - NavigationUtil.openFileWithPsiElement(file.navigationElement, false, true) - - val document = - PsiDocumentManager.getInstance(project).getDocument(file) ?: return Result.ErrorResult("${file.virtualFile.path}:O$offset") - - val location = "${file.virtualFile.path}:${document.getLineNumber(offset)}" - - val editor = EditorFactory.getInstance().getEditors(document, project).firstOrNull() ?: return Result.ErrorResult(location) - - - delay(500) - - editor.moveCaret(offset, scrollType = ScrollType.CENTER) - - delay(500) - - CommandProcessor.getInstance().executeCommand(project, { - runWriteAction { - document.insertString(editor.caretModel.offset, "\n$text\n") - PsiDocumentManager.getInstance(project).commitDocument(document) - } - editor.moveCaret(editor.caretModel.offset + text.length + 1) - AutoPopupController.getInstance(project).scheduleAutoPopup(editor, CompletionType.BASIC, null) - }, "insertTextAndInvokeCompletion", "completionBenchmark") - - val result = try { - withTimeout(timeout) { collectResult(file, location) } - } catch (_: CancellationException) { - Result.ErrorResult(location) - } - - CommandProcessor.getInstance().executeCommand(project, { - runWriteAction { - document.deleteString(offset, offset + text.length + 2) - PsiDocumentManager.getInstance(project).commitDocument(document) - } - }, "revertToOriginal", "completionBenchmark") - - delay(100) - return result - } - - private suspend fun collectResult(file: KtFile, location: String): Result { - val results = benchmarkSink.channel.receive() - return Result.SuccessResult(file.getLineCount(), location, results.firstFlush, results.full) - } - - protected fun saveResults(allResults: List) { - val jfc = JFileChooser() - val result = jfc.showSaveDialog(null) - if (result == JFileChooser.APPROVE_OPTION) { - val file = jfc.selectedFile - file.writeText(buildString { - appendLine("n, file, lines, ff, full") - var i = 0 - allResults.forEach { - append(i++) - append(", ") - it.toCSV(this) - appendLine() - } - }) - } - AbstractCompletionBenchmarkAction.showPopup(project, KotlinBundle.message("title.done")) - } - - abstract suspend fun doBenchmark() -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/refactoringTesting/MoveRefactoringUtils.kt.192 b/idea/src/org/jetbrains/kotlin/idea/actions/internal/refactoringTesting/MoveRefactoringUtils.kt.192 deleted file mode 100644 index 48baca51dbc..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/refactoringTesting/MoveRefactoringUtils.kt.192 +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.actions.internal.refactoringTesting - -import com.intellij.ide.plugins.PluginManager -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.ServiceManager -import com.intellij.openapi.extensions.PluginId -import com.intellij.openapi.project.Project -import com.intellij.openapi.vfs.VfsUtil -import com.intellij.openapi.vfs.VirtualFile -import org.jetbrains.kotlin.gradle.getMethodOrNull - -internal fun lazyPub(initializer: () -> T) = lazy(LazyThreadSafetyMode.PUBLICATION, initializer) - -internal fun gitReset(project: Project, projectRoot: VirtualFile) { - - fun ClassLoader.loadClassOrThrow(name: String) = - loadClass(name) ?: error("$name not loaded") - - fun Class<*>.loadMethodOrThrow(name: String, vararg arguments: Class<*>) = - getMethodOrNull(name, *arguments) ?: error("${this.name}::$name not loaded") - - val loader = PluginManager.getPlugin(PluginId.getId("Git4Idea"))?.pluginClassLoader ?: error("Git plugin is not found") - - val gitCls = loader.loadClassOrThrow("git4idea.commands.Git") - val gitLineHandlerCls = loader.loadClassOrThrow("git4idea.commands.GitLineHandler") - val gitCommandCls = loader.loadClassOrThrow("git4idea.commands.GitCommand") - val gitCommandResultCls = loader.loadClassOrThrow("git4idea.commands.GitCommandResult") - val gitLineHandlerCtor = gitLineHandlerCls.getConstructor(Project::class.java, VirtualFile::class.java, gitCommandCls) ?: error( - "git4idea.commands.GitLineHandler::ctor not loaded" - ) - val runCommand = gitCls.loadMethodOrThrow("runCommand", gitLineHandlerCls) - val getExitCode = gitCommandResultCls.loadMethodOrThrow("getExitCode") - val gitLineHandlerAddParameters = gitLineHandlerCls.loadMethodOrThrow("addParameters", List::class.java) - - val gitCommandReset = gitCommandCls.getField("RESET")?.get(null) ?: error("git4idea.commands.GitCommand.RESET not loaded") - - val resetLineHandler = gitLineHandlerCtor.newInstance(project, projectRoot, gitCommandReset) - gitLineHandlerAddParameters.invoke(resetLineHandler, listOf("--hard", "HEAD")) - - val gitService = ServiceManager.getService(gitCls) - val runCommandResult = runCommand.invoke(gitService, resetLineHandler) - - val gitResetResultCode = getExitCode.invoke(runCommandResult) as Int - if (gitResetResultCode == 0) { - VfsUtil.markDirtyAndRefresh(false, true, false, projectRoot) - //GitRepositoryManager.getInstance(project).updateRepository(d.getGitRoot()) - } else { - error("Git reset failed") - } -} - -inline fun edtExecute(crossinline body: () -> Unit) { - ApplicationManager.getApplication().invokeAndWait { - body() - } -} - -inline fun readAction(crossinline body: () -> Unit) { - ApplicationManager.getApplication().runReadAction { - body() - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteUtil.kt.192 b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteUtil.kt.192 deleted file mode 100644 index 8749cfca711..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteUtil.kt.192 +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight - -import com.intellij.codeInsight.CodeInsightBundle -import com.intellij.codeInsight.CodeInsightSettings -import com.intellij.codeInsight.hint.HintManager -import com.intellij.codeInsight.hint.HintManagerImpl -import com.intellij.codeInsight.hint.HintUtil -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.ReadAction.nonBlocking -import com.intellij.openapi.command.WriteCommandAction -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.project.Project -import com.intellij.ui.LightweightHint -import com.intellij.util.ArrayUtil -import com.intellij.util.concurrency.AppExecutorUtil -import org.jetbrains.annotations.TestOnly -import org.jetbrains.concurrency.CancellablePromise -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.imports.KotlinImportOptimizer -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.resolve.ImportPath -import java.util.* -import javax.swing.event.HyperlinkEvent -import javax.swing.event.HyperlinkListener - -// FIX ME WHEN BUNCH 192 REMOVED -object ReviewAddedImports { - @get:TestOnly - var importsToBeReviewed: Collection = emptyList() - - @get:TestOnly - var importsToBeDeleted: Collection = emptyList() - - fun reviewAddedImports( - project: Project, - editor: Editor, - file: KtFile, - imported: TreeSet - ) { - if (CodeInsightSettings.getInstance().ADD_IMPORTS_ON_PASTE == CodeInsightSettings.YES && - !imported.isEmpty() - ) { - if (ApplicationManager.getApplication().isUnitTestMode) { - importsToBeReviewed = imported - removeImports(project, file, importsToBeDeleted) - return - } - // there is actual no such functionality in 192 - } - } - - private fun removeImports( - project: Project, - file: KtFile, - importsToRemove: Collection - ) { - if (importsToRemove.isEmpty()) return - - WriteCommandAction.runWriteCommandAction(project, KotlinBundle.message("revert.applied.imports"), null, Runnable { - val newImports = file.importDirectives.mapNotNull { - val importedFqName = it.importedFqName ?: return@mapNotNull null - if (importsToRemove.contains(importedFqName.asString())) return@mapNotNull null - ImportPath(importedFqName, it.isAllUnder, it.aliasName?.let { alias -> Name.identifier(alias) }) - } - KotlinImportOptimizer.replaceImports(file, newImports) - }) - } -} - -internal fun submitNonBlocking(project: Project, indicator: ProgressIndicator, block: () -> T): CancellablePromise = - nonBlocking { - return@nonBlocking block() - } - .withDocumentsCommitted(project) - .submit(AppExecutorUtil.getAppExecutorService()) \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/codevision/KotlinCodeVisionCompat.kt.192 b/idea/src/org/jetbrains/kotlin/idea/codeInsight/codevision/KotlinCodeVisionCompat.kt.192 deleted file mode 100644 index 2fdaead4773..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/codevision/KotlinCodeVisionCompat.kt.192 +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight.codevision - -import com.intellij.codeInsight.hints.ChangeListener -import com.intellij.codeInsight.hints.ImmediateConfigurable -import com.intellij.codeInsight.hints.config.InlayHintsConfigurable -import com.intellij.internal.statistic.eventLog.FeatureUsageData -import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger -import com.intellij.openapi.project.Project -import com.intellij.ui.components.JBCheckBox -import com.intellij.ui.layout.panel -import org.jetbrains.kotlin.idea.KotlinBundle -import javax.swing.JPanel - - -typealias CodeVisionInlayHintsConfigurable = InlayHintsConfigurable - -fun logUsageStatistics(project: Project?, groupId: String, eventId: String) { - project?.let { FUCounterUsageLogger.getInstance().logEvent(project, groupId, eventId) } -} - -fun logUsageStatistics(project: Project?, groupId: String, eventId: String, data: FeatureUsageData) { - project?.let { FUCounterUsageLogger.getInstance().logEvent(project, groupId, eventId, data) } -} - -fun createImmediateConfigurable(): ImmediateConfigurable { - return object : ImmediateConfigurable { - override fun createComponent(listener: ChangeListener): JPanel = panel {} - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/HintsCompat.kt.192 b/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/HintsCompat.kt.192 deleted file mode 100644 index 642e0043f42..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/hints/HintsCompat.kt.192 +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight.hints - -import com.intellij.codeInsight.hints.ChangeListener -import com.intellij.codeInsight.hints.ImmediateConfigurable -import com.intellij.codeInsight.hints.config.InlayHintsConfigurable -import com.intellij.ui.components.JBCheckBox -import com.intellij.ui.layout.panel -import org.jetbrains.kotlin.idea.KotlinBundle -import javax.swing.JComponent - - -typealias CompatibleInlayHintsConfigurable = InlayHintsConfigurable - -fun createLambdaHintsImmediateConfigurable(settings: KotlinLambdasHintsProvider.Settings): ImmediateConfigurable { - return object : ImmediateConfigurable { - - private val returnExprField = JBCheckBox(KotlinBundle.message("hints.settings.lambda.return"), settings.returnExpressions) - - private val receiversAndParamsField = JBCheckBox( - KotlinBundle.message("hints.settings.lambda.receivers.parameters"), - settings.implicitReceiversAndParams - ) - - override fun createComponent(listener: ChangeListener): JComponent { - returnExprField.isSelected = settings.returnExpressions - returnExprField.addActionListener { settings.returnExpressions = returnExprField.isSelected } - - receiversAndParamsField.isSelected = settings.implicitReceiversAndParams - receiversAndParamsField.addActionListener { settings.implicitReceiversAndParams = receiversAndParamsField.isSelected } - - return panel { - row { returnExprField(pushX) } - row { receiversAndParamsField(pushX) } - } - } - } -} - -fun createTypeHintsImmediateConfigurable(settings: KotlinReferencesTypeHintsProvider.Settings): ImmediateConfigurable { - return object : ImmediateConfigurable { - - private val propertyTypeField = JBCheckBox(KotlinBundle.message("hints.settings.types.property"), settings.propertyType) - private val variableTypeField = JBCheckBox(KotlinBundle.message("hints.settings.types.variable"), settings.localVariableType) - private val funReturnTypeField = JBCheckBox(KotlinBundle.message("hints.settings.types.return"), settings.functionReturnType) - private val paramTypeField = JBCheckBox(KotlinBundle.message("hints.settings.types.parameter"), settings.parameterType) - - override fun createComponent(listener: ChangeListener): JComponent { - propertyTypeField.isSelected = settings.propertyType - propertyTypeField.addActionListener { settings.propertyType = propertyTypeField.isSelected } - - variableTypeField.isSelected = settings.localVariableType - variableTypeField.addActionListener { settings.localVariableType = variableTypeField.isSelected } - - funReturnTypeField.isSelected = settings.functionReturnType - funReturnTypeField.addActionListener { settings.functionReturnType = funReturnTypeField.isSelected } - - paramTypeField.isSelected = settings.parameterType - paramTypeField.addActionListener { settings.parameterType = paramTypeField.isSelected } - - return panel { - row { propertyTypeField(pushX) } - row { variableTypeField(pushX) } - row { funReturnTypeField(pushX) } - row { paramTypeField(pushX) } - } - } - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java.192 b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java.192 deleted file mode 100644 index 20c905bef03..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java.192 +++ /dev/null @@ -1,752 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.compiler.configuration; - -import com.intellij.icons.AllIcons; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.fileChooser.FileChooserDescriptor; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.options.SearchableConfigurable; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.ComboBox; -import com.intellij.openapi.ui.TextComponentAccessor; -import com.intellij.openapi.ui.TextFieldWithBrowseButton; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.ListCellRendererWrapper; -import com.intellij.ui.RawCommandLineEditor; -import com.intellij.util.text.VersionComparatorUtil; -import com.intellij.util.ui.ThreeStateCheckBox; -import com.intellij.util.ui.UIUtil; -import kotlin.collections.ArraysKt; -import kotlin.collections.CollectionsKt; -import kotlin.jvm.functions.Function0; -import kotlin.jvm.functions.Function1; -import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments; -import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments; -import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments; -import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants; -import org.jetbrains.kotlin.config.*; -import org.jetbrains.kotlin.idea.KotlinBundle; -import org.jetbrains.kotlin.idea.PluginStartupComponent; -import org.jetbrains.kotlin.idea.facet.DescriptionListCellRenderer; -import org.jetbrains.kotlin.idea.facet.KotlinFacet; -import org.jetbrains.kotlin.idea.roots.RootUtilsKt; -import org.jetbrains.kotlin.idea.util.CidrUtil; -import org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt; -import org.jetbrains.kotlin.platform.IdePlatformKind; -import org.jetbrains.kotlin.platform.PlatformUtilKt; -import org.jetbrains.kotlin.platform.TargetPlatform; -import org.jetbrains.kotlin.platform.impl.JsIdePlatformUtil; -import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind; -import org.jetbrains.kotlin.platform.impl.JvmIdePlatformUtil; -import org.jetbrains.kotlin.platform.jvm.JdkPlatform; - -import javax.swing.*; -import java.util.*; - -public class KotlinCompilerConfigurableTab implements SearchableConfigurable { - private static final Map moduleKindDescriptions = new LinkedHashMap<>(); - private static final Map soruceMapSourceEmbeddingDescriptions = new LinkedHashMap<>(); - private static final List languageFeatureStates = Arrays.asList( - LanguageFeature.State.ENABLED, LanguageFeature.State.ENABLED_WITH_WARNING, LanguageFeature.State.ENABLED_WITH_ERROR - ); - private static final int MAX_WARNING_SIZE = 75; - - static { - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_PLAIN, KotlinBundle.message("configuration.description.plain.put.to.global.scope")); - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_AMD, KotlinBundle.message("configuration.description.amd")); - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_COMMONJS, KotlinBundle.message("configuration.description.commonjs")); - moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, KotlinBundle.message("configuration.description.umd.detect.amd.or.commonjs.if.available.fallback.to.plain")); - - soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, KotlinBundle.message("configuration.description.never")); - soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, KotlinBundle.message("configuration.description.always")); - soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, KotlinBundle.message("configuration.description.when.inlining.a.function.from.other.module.with.embedded.sources")); - } - - @Nullable - private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings; - private final Project project; - private final boolean isProjectSettings; - private CommonCompilerArguments commonCompilerArguments; - private K2JSCompilerArguments k2jsCompilerArguments; - private K2JVMCompilerArguments k2jvmCompilerArguments; - private CompilerSettings compilerSettings; - private JPanel contentPane; - private ThreeStateCheckBox reportWarningsCheckBox; - private RawCommandLineEditor additionalArgsOptionsField; - private JLabel additionalArgsLabel; - private ThreeStateCheckBox generateSourceMapsCheckBox; - private TextFieldWithBrowseButton outputPrefixFile; - private TextFieldWithBrowseButton outputPostfixFile; - private JLabel labelForOutputDirectory; - private TextFieldWithBrowseButton outputDirectory; - private ThreeStateCheckBox copyRuntimeFilesCheckBox; - private ThreeStateCheckBox keepAliveCheckBox; - private JCheckBox enableIncrementalCompilationForJvmCheckBox; - private JCheckBox enableIncrementalCompilationForJsCheckBox; - private JComboBox moduleKindComboBox; - private JTextField scriptTemplatesField; - private JTextField scriptTemplatesClasspathField; - private JLabel scriptTemplatesLabel; - private JLabel scriptTemplatesClasspathLabel; - private JPanel k2jvmPanel; - private JPanel k2jsPanel; - private JComboBox jvmVersionComboBox; - private JComboBox languageVersionComboBox; - private JComboBox coroutineSupportComboBox; - private JComboBox apiVersionComboBox; - private JPanel scriptPanel; - private JLabel labelForOutputPrefixFile; - private JLabel labelForOutputPostfixFile; - private JLabel warningLabel; - private JTextField sourceMapPrefix; - private JLabel labelForSourceMapPrefix; - private JComboBox sourceMapEmbedSources; - private JPanel coroutinesPanel; - private boolean isEnabled = true; - - public KotlinCompilerConfigurableTab( - Project project, - @NotNull CommonCompilerArguments commonCompilerArguments, - @NotNull K2JSCompilerArguments k2jsCompilerArguments, - @NotNull K2JVMCompilerArguments k2jvmCompilerArguments, CompilerSettings compilerSettings, - @Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings, - boolean isProjectSettings, - boolean isMultiEditor - ) { - this.project = project; - this.commonCompilerArguments = commonCompilerArguments; - this.k2jsCompilerArguments = k2jsCompilerArguments; - this.compilerSettings = compilerSettings; - this.compilerWorkspaceSettings = compilerWorkspaceSettings; - this.k2jvmCompilerArguments = k2jvmCompilerArguments; - this.isProjectSettings = isProjectSettings; - - warningLabel.setIcon(AllIcons.General.WarningDialog); - - if (isProjectSettings) { - languageVersionComboBox.addActionListener(e -> onLanguageLevelChanged(getSelectedLanguageVersionView())); - } - - additionalArgsOptionsField.attachLabel(additionalArgsLabel); - - fillLanguageAndAPIVersionList(); - fillCoroutineSupportList(); - - if (CidrUtil.isRunningInCidrIde()) { - keepAliveCheckBox.setVisible(false); - k2jvmPanel.setVisible(false); - k2jsPanel.setVisible(false); - } - else { - initializeNonCidrSettings(isMultiEditor); - } - - reportWarningsCheckBox.setThirdStateEnabled(isMultiEditor); - - if (isProjectSettings) { - List modulesOverridingProjectSettings = ArraysKt.mapNotNull( - ModuleManager.getInstance(project).getModules(), - module -> { - KotlinFacet facet = KotlinFacet.Companion.get(module); - if (facet == null) return null; - KotlinFacetSettings facetSettings = facet.getConfiguration().getSettings(); - if (facetSettings.getUseProjectSettings()) return null; - return module.getName(); - } - ); - CollectionsKt.sort(modulesOverridingProjectSettings); - if (!modulesOverridingProjectSettings.isEmpty()) { - warningLabel.setVisible(true); - warningLabel.setText(buildOverridingModulesWarning(modulesOverridingProjectSettings)); - } - } - } - - @SuppressWarnings("unused") - public KotlinCompilerConfigurableTab(Project project) { - this(project, - (CommonCompilerArguments) KotlinCommonCompilerArgumentsHolder.Companion.getInstance(project).getSettings().unfrozen(), - (K2JSCompilerArguments) Kotlin2JsCompilerArgumentsHolder.Companion.getInstance(project).getSettings().unfrozen(), - (K2JVMCompilerArguments) Kotlin2JvmCompilerArgumentsHolder.Companion.getInstance(project).getSettings().unfrozen(), - (CompilerSettings) KotlinCompilerSettings.Companion.getInstance(project).getSettings().unfrozen(), - KotlinCompilerWorkspaceSettings.getInstance(project), - true, - false); - } - - private void initializeNonCidrSettings(boolean isMultiEditor) { - setupFileChooser(labelForOutputPrefixFile, outputPrefixFile, - KotlinBundle.message("configuration.title.kotlin.compiler.js.option.output.prefix.browse.title"), - true); - setupFileChooser(labelForOutputPostfixFile, outputPostfixFile, - KotlinBundle.message("configuration.title.kotlin.compiler.js.option.output.postfix.browse.title"), - true); - setupFileChooser(labelForOutputDirectory, outputDirectory, - KotlinBundle.message("configuration.title.choose.output.directory"), - false); - - fillModuleKindList(); - fillSourceMapSourceEmbeddingList(); - fillJvmVersionList(); - - generateSourceMapsCheckBox.setThirdStateEnabled(isMultiEditor); - generateSourceMapsCheckBox.addActionListener(event -> sourceMapPrefix.setEnabled(generateSourceMapsCheckBox.isSelected())); - - copyRuntimeFilesCheckBox.setThirdStateEnabled(isMultiEditor); - keepAliveCheckBox.setThirdStateEnabled(isMultiEditor); - - if (compilerWorkspaceSettings == null) { - keepAliveCheckBox.setVisible(false); - k2jvmPanel.setVisible(false); - enableIncrementalCompilationForJsCheckBox.setVisible(false); - } - - updateOutputDirEnabled(); - } - - private static int calculateNameCountToShowInWarning(List allNames) { - int lengthSoFar = 0; - int size = allNames.size(); - for (int i = 0; i < size; i++) { - lengthSoFar = (i > 0 ? lengthSoFar + 2 : 0) + allNames.get(i).length(); - if (lengthSoFar > MAX_WARNING_SIZE) return i; - } - return size; - } - - @NotNull - private static String buildOverridingModulesWarning(List modulesOverridingProjectSettings) { - int nameCountToShow = calculateNameCountToShowInWarning(modulesOverridingProjectSettings); - int allNamesCount = modulesOverridingProjectSettings.size(); - if (nameCountToShow == 0) { - return KotlinBundle.message("configuration.warning.text.modules.override.project.settings", String.valueOf(allNamesCount)); - } - - StringBuilder builder = new StringBuilder(); - builder.append(""); - builder.append(KotlinBundle.message("configuration.warning.text.following.modules.override.project.settings")).append(" "); - CollectionsKt.joinTo( - modulesOverridingProjectSettings.subList(0, nameCountToShow), - builder, - ", ", - "", - "", - -1, - "", - new Function1() { - @Override - public CharSequence invoke(String s) { - return "" + s + ""; - } - } - ); - if (nameCountToShow < allNamesCount) { - builder.append(" ").append(KotlinBundle.message("configuration.text.and")).append(" ").append(allNamesCount - nameCountToShow).append(" ").append(KotlinBundle.message("configuration.text.other.s")); - } - return builder.toString(); - } - - @NotNull - private static String getModuleKindDescription(@Nullable String moduleKind) { - if (moduleKind == null) return ""; - String result = moduleKindDescriptions.get(moduleKind); - assert result != null : "Module kind " + moduleKind + " was not added to combobox, therefore it should not be here"; - return result; - } - - @NotNull - private static String getSourceMapSourceEmbeddingDescription(@Nullable String sourceMapSourceEmbeddingId) { - if (sourceMapSourceEmbeddingId == null) return ""; - String result = soruceMapSourceEmbeddingDescriptions.get(sourceMapSourceEmbeddingId); - assert result != null : "Source map source embedding mode " + sourceMapSourceEmbeddingId + - " was not added to combobox, therefore it should not be here"; - return result; - } - - @NotNull - private static String getModuleKindOrDefault(@Nullable String moduleKindId) { - if (moduleKindId == null) { - moduleKindId = K2JsArgumentConstants.MODULE_PLAIN; - } - return moduleKindId; - } - - @NotNull - private static String getSourceMapSourceEmbeddingOrDefault(@Nullable String sourceMapSourceEmbeddingId) { - if (sourceMapSourceEmbeddingId == null) { - sourceMapSourceEmbeddingId = K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING; - } - return sourceMapSourceEmbeddingId; - } - - private static String getJvmVersionOrDefault(@Nullable String jvmVersion) { - return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription(); - } - - private static void setupFileChooser( - @NotNull JLabel label, - @NotNull TextFieldWithBrowseButton fileChooser, - @NotNull String title, - boolean forFiles - ) { - label.setLabelFor(fileChooser); - - fileChooser.addBrowseFolderListener(title, null, null, - new FileChooserDescriptor(forFiles, !forFiles, false, false, false, false), - TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); - } - - private static boolean isModifiedWithNullize(@NotNull TextFieldWithBrowseButton chooser, @Nullable String currentValue) { - return !StringUtil.equals( - StringUtil.nullize(chooser.getText(), true), - StringUtil.nullize(currentValue, true)); - } - - private static boolean isModified(@NotNull TextFieldWithBrowseButton chooser, @NotNull String currentValue) { - return !StringUtil.equals(chooser.getText(), currentValue); - } - - private void updateOutputDirEnabled() { - if (isEnabled && copyRuntimeFilesCheckBox != null) { - outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected()); - labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected()); - } - } - - private boolean isLessOrEqual(LanguageVersion version, LanguageVersion upperBound) { - return VersionComparatorUtil.compare(version.getVersionString(), upperBound.getVersionString()) <= 0; - } - - public void onLanguageLevelChanged(@Nullable VersionView languageLevel) { - if (languageLevel == null) return; - restrictAPIVersions(languageLevel); - coroutinesPanel.setVisible(languageLevel.getVersion().compareTo(LanguageVersion.KOTLIN_1_3) < 0); - } - - @SuppressWarnings("unchecked") - private void restrictAPIVersions(VersionView upperBoundView) { - VersionView selectedAPIView = getSelectedAPIVersionView(); - LanguageVersion selectedAPIVersion = selectedAPIView.getVersion(); - LanguageVersion upperBound = upperBoundView.getVersion(); - List permittedAPIVersions = new ArrayList<>(LanguageVersion.values().length + 1); - if (isLessOrEqual(VersionView.LatestStable.INSTANCE.getVersion(), upperBound)) { - permittedAPIVersions.add(VersionView.LatestStable.INSTANCE); - } - ArraysKt.mapNotNullTo( - LanguageVersion.values(), - permittedAPIVersions, - version -> isLessOrEqual(version, upperBound) && !version.isUnsupported() ? new VersionView.Specific(version) : null - ); - apiVersionComboBox.setModel( - new DefaultComboBoxModel(permittedAPIVersions.toArray()) - ); - apiVersionComboBox.setSelectedItem( - VersionComparatorUtil.compare(selectedAPIVersion.getVersionString(), upperBound.getVersionString()) <= 0 - ? selectedAPIView - : upperBoundView - ); - } - - @SuppressWarnings("unchecked") - private void fillJvmVersionList() { - for (TargetPlatform jvm : JvmIdePlatformKind.INSTANCE.getPlatforms()) { - jvmVersionComboBox.addItem(PlatformUtilKt.subplatformsOfType(jvm, JdkPlatform.class).get(0).getTargetVersion().getDescription()); - } - } - - private void fillLanguageAndAPIVersionList() { - languageVersionComboBox.addItem(VersionView.LatestStable.INSTANCE); - apiVersionComboBox.addItem(VersionView.LatestStable.INSTANCE); - - for (LanguageVersion version : LanguageVersion.values()) { - if (version.isUnsupported() || !version.isStable() && !ApplicationManager.getApplication().isInternal()) { - continue; - } - - VersionView.Specific specificVersion = new VersionView.Specific(version); - languageVersionComboBox.addItem(specificVersion); - apiVersionComboBox.addItem(specificVersion); - } - languageVersionComboBox.setRenderer(new DescriptionListCellRenderer()); - apiVersionComboBox.setRenderer(new DescriptionListCellRenderer()); - } - - @SuppressWarnings("unchecked") - private void fillCoroutineSupportList() { - for (LanguageFeature.State coroutineSupport : languageFeatureStates) { - coroutineSupportComboBox.addItem(coroutineSupport); - } - coroutineSupportComboBox.setRenderer(new DescriptionListCellRenderer()); - } - - public void setTargetPlatform(@Nullable IdePlatformKind targetPlatform) { - k2jsPanel.setVisible(JsIdePlatformUtil.isJavaScript(targetPlatform)); - scriptPanel.setVisible(JvmIdePlatformUtil.isJvm(targetPlatform)); - } - - @SuppressWarnings("unchecked") - private void fillModuleKindList() { - for (String moduleKind : moduleKindDescriptions.keySet()) { - moduleKindComboBox.addItem(moduleKind); - } - moduleKindComboBox.setRenderer(new ListCellRendererWrapper() { - @Override - public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) { - setText(getModuleKindDescription(value)); - } - }); - } - - @SuppressWarnings("unchecked") - private void fillSourceMapSourceEmbeddingList() { - for (String moduleKind : soruceMapSourceEmbeddingDescriptions.keySet()) { - sourceMapEmbedSources.addItem(moduleKind); - } - sourceMapEmbedSources.setRenderer(new ListCellRendererWrapper() { - @Override - public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) { - setText(value != null ? getSourceMapSourceEmbeddingDescription(value) : ""); - } - }); - } - - @NotNull - @Override - public String getId() { - return "project.kotlinCompiler"; - } - - @Nullable - @Override - public Runnable enableSearch(String option) { - return null; - } - - @Nullable - @Override - public JComponent createComponent() { - return contentPane; - } - - @Override - public boolean isModified() { - return isModified(reportWarningsCheckBox, !commonCompilerArguments.getSuppressWarnings()) || - !getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) || - !getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) || - !getSelectedCoroutineState().equals(commonCompilerArguments.getCoroutinesState()) || - !additionalArgsOptionsField.getText().equals(compilerSettings.getAdditionalArguments()) || - isModified(scriptTemplatesField, compilerSettings.getScriptTemplates()) || - isModified(scriptTemplatesClasspathField, compilerSettings.getScriptTemplatesClasspath()) || - isModified(copyRuntimeFilesCheckBox, compilerSettings.getCopyJsLibraryFiles()) || - isModified(outputDirectory, compilerSettings.getOutputDirectoryForJsLibraryFiles()) || - - (compilerWorkspaceSettings != null && - (isModified(enableIncrementalCompilationForJvmCheckBox, compilerWorkspaceSettings.getPreciseIncrementalEnabled()) || - isModified(enableIncrementalCompilationForJsCheckBox, compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()) || - isModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) || - - isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) || - isModifiedWithNullize(outputPrefixFile, k2jsCompilerArguments.getOutputPrefix()) || - isModifiedWithNullize(outputPostfixFile, k2jsCompilerArguments.getOutputPostfix()) || - !getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())) || - isModified(sourceMapPrefix, StringUtil.notNullize(k2jsCompilerArguments.getSourceMapPrefix())) || - !getSelectedSourceMapSourceEmbedding().equals( - getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())) || - !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); - } - - @NotNull - private String getSelectedModuleKind() { - return getModuleKindOrDefault((String) moduleKindComboBox.getSelectedItem()); - } - - private String getSelectedSourceMapSourceEmbedding() { - return getSourceMapSourceEmbeddingOrDefault((String) sourceMapEmbedSources.getSelectedItem()); - } - - @NotNull - private String getSelectedJvmVersion() { - return getJvmVersionOrDefault((String) jvmVersionComboBox.getSelectedItem()); - } - - @NotNull - public VersionView getSelectedLanguageVersionView() { - Object item = languageVersionComboBox.getSelectedItem(); - return item != null ? (VersionView) item : VersionView.LatestStable.INSTANCE; - } - - @NotNull - private VersionView getSelectedAPIVersionView() { - Object item = apiVersionComboBox.getSelectedItem(); - return item != null ? (VersionView) item : VersionView.LatestStable.INSTANCE; - } - - @NotNull - private String getSelectedCoroutineState() { - if (getSelectedLanguageVersionView().getVersion().compareTo(LanguageVersion.KOTLIN_1_3) >= 0) { - return CommonCompilerArguments.DEFAULT; - } - - LanguageFeature.State state = (LanguageFeature.State) coroutineSupportComboBox.getSelectedItem(); - if (state == null) return CommonCompilerArguments.DEFAULT; - switch (state) { - case ENABLED: return CommonCompilerArguments.ENABLE; - case ENABLED_WITH_WARNING: return CommonCompilerArguments.WARN; - case ENABLED_WITH_ERROR: return CommonCompilerArguments.ERROR; - default: return CommonCompilerArguments.DEFAULT; - } - } - - public void applyTo( - CommonCompilerArguments commonCompilerArguments, - K2JVMCompilerArguments k2jvmCompilerArguments, - K2JSCompilerArguments k2jsCompilerArguments, - CompilerSettings compilerSettings - ) throws ConfigurationException { - if (isProjectSettings) { - boolean shouldInvalidateCaches = - !getSelectedLanguageVersionView().equals(KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)) || - !getSelectedAPIVersionView().equals(KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)) || - !getSelectedCoroutineState().equals(commonCompilerArguments.getCoroutinesState()) || - !additionalArgsOptionsField.getText().equals(compilerSettings.getAdditionalArguments()); - - if (shouldInvalidateCaches) { - ApplicationUtilsKt.runWriteAction( - new Function0() { - @Override - public Object invoke() { - RootUtilsKt.invalidateProjectRoots(project); - return null; - } - } - ); - } - } - - commonCompilerArguments.setSuppressWarnings(!reportWarningsCheckBox.isSelected()); - KotlinFacetSettingsKt.setLanguageVersionView(commonCompilerArguments, getSelectedLanguageVersionView()); - KotlinFacetSettingsKt.setApiVersionView(commonCompilerArguments, getSelectedAPIVersionView()); - - commonCompilerArguments.setCoroutinesState(getSelectedCoroutineState()); - - compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText()); - compilerSettings.setScriptTemplates(scriptTemplatesField.getText()); - compilerSettings.setScriptTemplatesClasspath(scriptTemplatesClasspathField.getText()); - compilerSettings.setCopyJsLibraryFiles(copyRuntimeFilesCheckBox.isSelected()); - compilerSettings.setOutputDirectoryForJsLibraryFiles(outputDirectory.getText()); - - if (compilerWorkspaceSettings != null) { - compilerWorkspaceSettings.setPreciseIncrementalEnabled(enableIncrementalCompilationForJvmCheckBox.isSelected()); - compilerWorkspaceSettings.setIncrementalCompilationForJsEnabled(enableIncrementalCompilationForJsCheckBox.isSelected()); - - boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon(); - compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected()); - if (keepAliveCheckBox.isSelected() != oldEnableDaemon) { - PluginStartupComponent.getInstance().resetAliveFlag(); - } - } - - k2jsCompilerArguments.setSourceMap(generateSourceMapsCheckBox.isSelected()); - k2jsCompilerArguments.setOutputPrefix(StringUtil.nullize(outputPrefixFile.getText(), true)); - k2jsCompilerArguments.setOutputPostfix(StringUtil.nullize(outputPostfixFile.getText(), true)); - k2jsCompilerArguments.setModuleKind(getSelectedModuleKind()); - - k2jsCompilerArguments.setSourceMapPrefix(sourceMapPrefix.getText()); - k2jsCompilerArguments.setSourceMapEmbedSources(generateSourceMapsCheckBox.isSelected() ? getSelectedSourceMapSourceEmbedding() : null); - - k2jvmCompilerArguments.setJvmTarget(getSelectedJvmVersion()); - - if (isProjectSettings) { - KotlinCommonCompilerArgumentsHolder.Companion.getInstance(project).setSettings(commonCompilerArguments); - Kotlin2JvmCompilerArgumentsHolder.Companion.getInstance(project).setSettings(k2jvmCompilerArguments); - Kotlin2JsCompilerArgumentsHolder.Companion.getInstance(project).setSettings(k2jsCompilerArguments); - KotlinCompilerSettings.Companion.getInstance(project).setSettings(compilerSettings); - } - - for (ClearBuildStateExtension extension : ClearBuildStateExtension.getExtensions()) { - extension.clearState(project); - } - } - - @Override - public void apply() throws ConfigurationException { - applyTo(commonCompilerArguments, k2jvmCompilerArguments, k2jsCompilerArguments, compilerSettings); - } - - @Override - public void reset() { - reportWarningsCheckBox.setSelected(!commonCompilerArguments.getSuppressWarnings()); - setSelectedItem(languageVersionComboBox, KotlinFacetSettingsKt.getLanguageVersionView(commonCompilerArguments)); - onLanguageLevelChanged((VersionView) languageVersionComboBox.getSelectedItem()); // getSelectedLanguageVersionView() replaces null - setSelectedItem(apiVersionComboBox, KotlinFacetSettingsKt.getApiVersionView(commonCompilerArguments)); - coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArguments(commonCompilerArguments)); - additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments()); - scriptTemplatesField.setText(compilerSettings.getScriptTemplates()); - scriptTemplatesClasspathField.setText(compilerSettings.getScriptTemplatesClasspath()); - copyRuntimeFilesCheckBox.setSelected(compilerSettings.getCopyJsLibraryFiles()); - outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles()); - - if (compilerWorkspaceSettings != null) { - enableIncrementalCompilationForJvmCheckBox.setSelected(compilerWorkspaceSettings.getPreciseIncrementalEnabled()); - enableIncrementalCompilationForJsCheckBox.setSelected(compilerWorkspaceSettings.getIncrementalCompilationForJsEnabled()); - keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon()); - } - - generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.getSourceMap()); - outputPrefixFile.setText(k2jsCompilerArguments.getOutputPrefix()); - outputPostfixFile.setText(k2jsCompilerArguments.getOutputPostfix()); - - moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())); - sourceMapPrefix.setText(k2jsCompilerArguments.getSourceMapPrefix()); - sourceMapPrefix.setEnabled(k2jsCompilerArguments.getSourceMap()); - sourceMapEmbedSources.setSelectedItem(getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())); - - jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); - } - - private static void setSelectedItem(JComboBox comboBox, VersionView versionView) { - // Imported projects might have outdated language/api versions - we display them as well (see createVersionValidator() for details) - int index = ((DefaultComboBoxModel) comboBox.getModel()).getIndexOf(versionView); - if (index == -1) - comboBox.addItem(versionView); - - comboBox.setSelectedItem(versionView); - } - - @Override - public void disposeUIResources() { - } - - @Nls - @Override - public String getDisplayName() { - return KotlinBundle.message("configuration.name.kotlin.compiler"); - } - - @Nullable - @Override - public String getHelpTopic() { - return "reference.compiler.kotlin"; - } - - public JPanel getContentPane() { - return contentPane; - } - - public ThreeStateCheckBox getReportWarningsCheckBox() { - return reportWarningsCheckBox; - } - - public RawCommandLineEditor getAdditionalArgsOptionsField() { - return additionalArgsOptionsField; - } - - public ThreeStateCheckBox getGenerateSourceMapsCheckBox() { - return generateSourceMapsCheckBox; - } - - public TextFieldWithBrowseButton getOutputPrefixFile() { - return outputPrefixFile; - } - - public TextFieldWithBrowseButton getOutputPostfixFile() { - return outputPostfixFile; - } - - public TextFieldWithBrowseButton getOutputDirectory() { - return outputDirectory; - } - - public ThreeStateCheckBox getCopyRuntimeFilesCheckBox() { - return copyRuntimeFilesCheckBox; - } - - public ThreeStateCheckBox getKeepAliveCheckBox() { - return keepAliveCheckBox; - } - - public JComboBox getModuleKindComboBox() { - return moduleKindComboBox; - } - - public JTextField getScriptTemplatesField() { - return scriptTemplatesField; - } - - public JTextField getScriptTemplatesClasspathField() { - return scriptTemplatesClasspathField; - } - - public JComboBox getLanguageVersionComboBox() { - return languageVersionComboBox; - } - - public JComboBox getApiVersionComboBox() { - return apiVersionComboBox; - } - - public JComboBox getCoroutineSupportComboBox() { - return coroutineSupportComboBox; - } - - public void setEnabled(boolean value) { - isEnabled = value; - UIUtil.setEnabled(getContentPane(), value, true); - } - - public CommonCompilerArguments getCommonCompilerArguments() { - return commonCompilerArguments; - } - - public void setCommonCompilerArguments(CommonCompilerArguments commonCompilerArguments) { - this.commonCompilerArguments = commonCompilerArguments; - } - - public K2JSCompilerArguments getK2jsCompilerArguments() { - return k2jsCompilerArguments; - } - - public void setK2jsCompilerArguments(K2JSCompilerArguments k2jsCompilerArguments) { - this.k2jsCompilerArguments = k2jsCompilerArguments; - } - - public K2JVMCompilerArguments getK2jvmCompilerArguments() { - return k2jvmCompilerArguments; - } - - public void setK2jvmCompilerArguments(K2JVMCompilerArguments k2jvmCompilerArguments) { - this.k2jvmCompilerArguments = k2jvmCompilerArguments; - } - - public CompilerSettings getCompilerSettings() { - return compilerSettings; - } - - public void setCompilerSettings(CompilerSettings compilerSettings) { - this.compilerSettings = compilerSettings; - } - - private void createUIComponents() { - // Explicit use of DefaultComboBoxModel guarantees that setSelectedItem() can make safe cast. - languageVersionComboBox = new ComboBox<>(new DefaultComboBoxModel<>()); - apiVersionComboBox = new ComboBox<>(new DefaultComboBoxModel<>()); - - // Workaround: ThreeStateCheckBox doesn't send suitable notification on state change - // TODO: replace with PropertyChangerListener after fix is available in IDEA - copyRuntimeFilesCheckBox = new ThreeStateCheckBox() { - @Override - public void setState(State state) { - super.setState(state); - updateOutputDirEnabled(); - } - }; - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinMigrationProjectComponent.kt.192 b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinMigrationProjectComponent.kt.192 deleted file mode 100644 index 61db43e6741..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinMigrationProjectComponent.kt.192 +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration - -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataImportListener -import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil -import com.intellij.openapi.module.Module -import com.intellij.openapi.module.ModuleManager -import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.ProjectRootManager -import com.intellij.openapi.roots.libraries.Library -import com.intellij.openapi.vcs.changes.ChangeListManager -import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx -import com.intellij.util.CommonProcessors -import com.intellij.util.text.VersionComparatorUtil -import org.jetbrains.annotations.TestOnly -import org.jetbrains.kotlin.config.ApiVersion -import org.jetbrains.kotlin.config.LanguageVersion -import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl -import org.jetbrains.kotlin.idea.configuration.ui.showMigrationNotification -import org.jetbrains.kotlin.idea.facet.KotlinFacet -import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID -import org.jetbrains.kotlin.idea.framework.MAVEN_SYSTEM_ID -import org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction -import org.jetbrains.kotlin.idea.migration.applicableMigrationTools -import org.jetbrains.kotlin.idea.project.languageVersionSettings -import org.jetbrains.kotlin.idea.util.application.runReadAction -import org.jetbrains.kotlin.idea.util.runReadActionInSmartMode -import org.jetbrains.kotlin.idea.versions.LibInfo -import java.io.File - -class KotlinMigrationProjectComponent(val project: Project) { - @Volatile - private var old: MigrationState? = null - - @Volatile - private var importFinishListener: ((MigrationTestState?) -> Unit)? = null - - init { - val connection = project.messageBus.connect(project) - connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener { - getInstanceIfNotDisposed(project)?.onImportFinished() - }) - } - - class MigrationTestState(val migrationInfo: MigrationInfo?, val hasApplicableTools: Boolean) - - @TestOnly - fun setImportFinishListener(newListener: ((MigrationTestState?) -> Unit)?) { - synchronized(this) { - if (newListener != null && importFinishListener != null) { - importFinishListener!!.invoke(null) - } - - importFinishListener = newListener - } - } - - private fun notifyFinish(migrationInfo: MigrationInfo?, hasApplicableTools: Boolean) { - importFinishListener?.invoke(MigrationTestState(migrationInfo, hasApplicableTools)) - } - - fun onImportAboutToStart() { - if (!CodeMigrationToggleAction.isEnabled(project) || !hasChangesInProjectFiles(project)) { - old = null - return - } - - old = MigrationState.build(project) - } - - fun onImportFinished() { - if (!CodeMigrationToggleAction.isEnabled(project) || old == null) { - notifyFinish(null, false) - return - } - - ApplicationManager.getApplication().executeOnPooledThread { - var migrationInfo: MigrationInfo? = null - var hasApplicableTools = false - - try { - val new = project.runReadActionInSmartMode { - MigrationState.build(project) - } - - val localOld = old.also { - old = null - } ?: return@executeOnPooledThread - - migrationInfo = prepareMigrationInfo(localOld, new) ?: return@executeOnPooledThread - - if (applicableMigrationTools(migrationInfo).isEmpty()) { - hasApplicableTools = false - return@executeOnPooledThread - } else { - hasApplicableTools = true - } - - if (ApplicationManager.getApplication().isUnitTestMode) { - return@executeOnPooledThread - } - - ApplicationManager.getApplication().invokeLater { - showMigrationNotification(project, migrationInfo) - } - } finally { - notifyFinish(migrationInfo, hasApplicableTools) - } - } - } - - companion object { - fun getInstance(project: Project): KotlinMigrationProjectComponent = - project.getComponent(KotlinMigrationProjectComponent::class.java) - ?: error("Can't find ${KotlinMigrationProjectComponent::class.qualifiedName} component") - - fun getInstanceIfNotDisposed(project: Project): KotlinMigrationProjectComponent? { - return runReadAction { - if (!project.isDisposed) getInstance(project) else null - } - } - - private fun prepareMigrationInfo(old: MigrationState?, new: MigrationState?): MigrationInfo? { - if (old == null || new == null) { - return null - } - - val oldLibraryVersion = old.stdlibInfo?.version - val newLibraryVersion = new.stdlibInfo?.version - - if (oldLibraryVersion == null || newLibraryVersion == null) { - return null - } - - if (VersionComparatorUtil.COMPARATOR.compare(newLibraryVersion, oldLibraryVersion) > 0 || - old.apiVersion < new.apiVersion || old.languageVersion < new.languageVersion - ) { - return MigrationInfo( - oldLibraryVersion, newLibraryVersion, - old.apiVersion, new.apiVersion, - old.languageVersion, new.languageVersion - ) - } - - return null - } - - private fun hasChangesInProjectFiles(project: Project): Boolean { - if (ProjectLevelVcsManagerEx.getInstance(project).allVcsRoots.isEmpty()) { - return true - } - - val checkedFiles = HashSet() - - project.basePath?.let { projectBasePath -> - checkedFiles.add(File(projectBasePath)) - } - - val changedFiles = ChangeListManager.getInstance(project).affectedPaths - for (changedFile in changedFiles) { - when (changedFile.extension) { - "gradle" -> return true - "properties" -> return true - "kts" -> return true - "iml" -> return true - "xml" -> { - if (changedFile.name == "pom.xml") return true - val parentDir = changedFile.parentFile - if (parentDir.isDirectory && parentDir.name == Project.DIRECTORY_STORE_FOLDER) { - return true - } - } - "kt", "java", "groovy" -> { - val dirs: Sequence = generateSequence(changedFile) { it.parentFile } - .drop(1) // Drop original file - .takeWhile { it.isDirectory } - - val isInBuildSrc = dirs - .takeWhile { checkedFiles.add(it) } - .any { it.name == BUILD_SRC_FOLDER_NAME } - - if (isInBuildSrc) { - return true - } - } - } - } - - return false - } - } -} - -private class MigrationState( - var stdlibInfo: LibInfo?, - var apiVersion: ApiVersion, - var languageVersion: LanguageVersion -) { - companion object { - fun build(project: Project): MigrationState { - val libraries = maxKotlinLibVersion(project) - val languageVersionSettings = collectMaxCompilerSettings(project) - return MigrationState(libraries, languageVersionSettings.apiVersion, languageVersionSettings.languageVersion) - } - } -} - -data class MigrationInfo( - val oldStdlibVersion: String, - val newStdlibVersion: String, - val oldApiVersion: ApiVersion, - val newApiVersion: ApiVersion, - val oldLanguageVersion: LanguageVersion, - val newLanguageVersion: LanguageVersion -) { - fun oldVersionsToMap(): Map = mapOf( - "old_stdlib_version" to oldStdlibVersion, - "old_api_version" to oldApiVersion.versionString, - "old_language_version" to oldLanguageVersion.versionString - ) - - companion object { - fun create( - oldStdlibVersion: String, - oldApiVersion: ApiVersion, - oldLanguageVersion: LanguageVersion, - newStdlibVersion: String = oldStdlibVersion, - newApiVersion: ApiVersion = oldApiVersion, - newLanguageVersion: LanguageVersion = oldLanguageVersion - ): MigrationInfo { - return MigrationInfo( - oldStdlibVersion, newStdlibVersion, - oldApiVersion, newApiVersion, - oldLanguageVersion, newLanguageVersion - ) - } - } -} - -fun MigrationInfo.isLanguageVersionUpdate(old: LanguageVersion, new: LanguageVersion): Boolean { - return oldLanguageVersion <= old && newLanguageVersion >= new -} - - -private const val BUILD_SRC_FOLDER_NAME = "buildSrc" -private const val KOTLIN_GROUP_ID = "org.jetbrains.kotlin" - -private fun maxKotlinLibVersion(project: Project): LibInfo? { - return runReadAction { - var maxStdlibInfo: LibInfo? = null - - val allLibProcessor = CommonProcessors.CollectUniquesProcessor() - ProjectRootManager.getInstance(project).orderEntries().forEachLibrary(allLibProcessor) - - for (library in allLibProcessor.results) { - if (!ExternalSystemApiUtil.isExternalSystemLibrary(library, GRADLE_SYSTEM_ID) && - !ExternalSystemApiUtil.isExternalSystemLibrary(library, MAVEN_SYSTEM_ID) - ) { - continue - } - - if (library.name?.contains(" $KOTLIN_GROUP_ID:kotlin-stdlib") != true) { - continue - } - - val libraryInfo = parseExternalLibraryName(library) ?: continue - - if (maxStdlibInfo == null || VersionComparatorUtil.COMPARATOR.compare(libraryInfo.version, maxStdlibInfo.version) > 0) { - maxStdlibInfo = LibInfo(KOTLIN_GROUP_ID, libraryInfo.artifactId, libraryInfo.version) - } - } - - maxStdlibInfo - } -} - -private fun collectMaxCompilerSettings(project: Project): LanguageVersionSettings { - return runReadAction { - var maxApiVersion: ApiVersion? = null - var maxLanguageVersion: LanguageVersion? = null - - for (module in ModuleManager.getInstance(project).modules) { - if (!module.isKotlinModule()) { - // Otherwise project compiler settings will give unreliable maximum for compiler settings - continue - } - - val languageVersionSettings = module.languageVersionSettings - - if (maxApiVersion == null || languageVersionSettings.apiVersion > maxApiVersion) { - maxApiVersion = languageVersionSettings.apiVersion - } - - if (maxLanguageVersion == null || languageVersionSettings.languageVersion > maxLanguageVersion) { - maxLanguageVersion = languageVersionSettings.languageVersion - } - } - - LanguageVersionSettingsImpl(maxLanguageVersion ?: LanguageVersion.LATEST_STABLE, maxApiVersion ?: ApiVersion.LATEST_STABLE) - } -} - -private fun Module.isKotlinModule(): Boolean { - if (isDisposed) return false - - if (KotlinFacet.get(this) != null) { - return true - } - - // This code works only for Maven and Gradle import, and it's expected that Kotlin facets are configured for - // all modules with external system. - return false -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinMigrationProjectService.kt.192 b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinMigrationProjectService.kt.192 deleted file mode 100644 index 19de5d23de4..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinMigrationProjectService.kt.192 +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration - -// FIX ME WHEN BUNCH 192 REMOVED -typealias KotlinMigrationProjectService = KotlinMigrationProjectComponent -typealias MigrationTestState = KotlinMigrationProjectComponent.MigrationTestState \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/MLCompletionForKotlin.kt.192 b/idea/src/org/jetbrains/kotlin/idea/configuration/MLCompletionForKotlin.kt.192 deleted file mode 100644 index d1d25c9b8bd..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/MLCompletionForKotlin.kt.192 +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration - -internal object MLCompletionForKotlin { - const val isAvailable: Boolean = false - - var isEnabled: Boolean - get() = false - set(value) { - throw UnsupportedOperationException() - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinSdkType.kt.192 b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinSdkType.kt.192 deleted file mode 100644 index 6797cda9755..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinSdkType.kt.192 +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.framework - -import com.intellij.openapi.Disposable -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.projectRoots.* -import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl -import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil -import com.intellij.util.Consumer -import org.jdom.Element -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.KotlinIcons -import org.jetbrains.kotlin.idea.util.application.runWriteAction -import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion -import org.jetbrains.kotlin.utils.PathUtil -import javax.swing.JComponent - -class KotlinSdkType : SdkType("KotlinSDK") { - companion object { - @JvmField - val INSTANCE = KotlinSdkType() - - val defaultHomePath: String - get() = PathUtil.kotlinPathsForIdeaPlugin.homePath.absolutePath - - @JvmOverloads - fun setUpIfNeeded(disposable: Disposable? = null, checkIfNeeded: () -> Boolean = { true }) { - val projectSdks: Array = ProjectJdkTable.getInstance().allJdks - if (projectSdks.any { it.sdkType is KotlinSdkType }) return - if (!checkIfNeeded()) return // do not create Kotlin SDK - - val newSdkName = SdkConfigurationUtil.createUniqueSdkName(INSTANCE, defaultHomePath, projectSdks.toList()) - val newJdk = ProjectJdkImpl(newSdkName, INSTANCE) - newJdk.homePath = defaultHomePath - INSTANCE.setupSdkPaths(newJdk) - - ApplicationManager.getApplication().invokeAndWait { - runWriteAction { - if (ProjectJdkTable.getInstance().allJdks.any { it.sdkType is KotlinSdkType }) return@runWriteAction - if (disposable != null) { - ProjectJdkTable.getInstance().addJdk(newJdk, disposable) - } else { - ProjectJdkTable.getInstance().addJdk(newJdk) - } - } - } - } - } - - override fun getPresentableName() = KotlinBundle.message("framework.name.kotlin.sdk") - - override fun getIcon() = KotlinIcons.SMALL_LOGO - - override fun isValidSdkHome(path: String?) = true - - override fun suggestSdkName(currentSdkName: String?, sdkHome: String?) = "Kotlin SDK" - - override fun suggestHomePath() = null - - override fun sdkHasValidPath(sdk: Sdk) = true - - override fun getVersionString(sdk: Sdk) = bundledRuntimeVersion() - - override fun supportsCustomCreateUI() = true - - override fun showCustomCreateUI(sdkModel: SdkModel, parentComponent: JComponent, selectedSdk: Sdk?, sdkCreatedCallback: Consumer) { - sdkCreatedCallback.consume(createSdkWithUniqueName(sdkModel.sdks.toList())) - } - - fun createSdkWithUniqueName(existingSdks: Collection): ProjectJdkImpl { - val sdkName = suggestSdkName(SdkConfigurationUtil.createUniqueSdkName(this, "", existingSdks), "") - return ProjectJdkImpl(sdkName, this).apply { - homePath = defaultHomePath - } - } - - override fun createAdditionalDataConfigurable(sdkModel: SdkModel, sdkModificator: SdkModificator) = null - - override fun saveAdditionalData(additionalData: SdkAdditionalData, additional: Element) { - - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCalleeTreeStructureUtils.kt.192 b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCalleeTreeStructureUtils.kt.192 deleted file mode 100644 index 3b6f9c8ee13..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCalleeTreeStructureUtils.kt.192 +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.hierarchy.calls - -import com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor -import com.intellij.psi.PsiMethod - -fun extractMemberFromDescriptor(nodeDescriptor: CallHierarchyNodeDescriptor): PsiMethod? { - return nodeDescriptor.enclosingElement as? PsiMethod -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/js/jsUtils.kt.192 b/idea/src/org/jetbrains/kotlin/idea/js/jsUtils.kt.192 deleted file mode 100644 index 0aa204f5466..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/js/jsUtils.kt.192 +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2010-2017 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.js - -import com.intellij.openapi.module.Module -import com.intellij.openapi.roots.CompilerModuleExtension -import org.jetbrains.jps.util.JpsPathUtil -import org.jetbrains.kotlin.idea.facet.KotlinFacet -import org.jetbrains.kotlin.idea.framework.isGradleModule -import org.jetbrains.kotlin.idea.project.platform -import org.jetbrains.kotlin.platform.js.isJs -import org.jetbrains.plugins.gradle.settings.GradleSystemRunningSettings - -val Module.jsTestOutputFilePath: String? - get() { - KotlinFacet.get(this)?.configuration?.settings?.testOutputPath?.let { return it } - - if (!shouldUseJpsOutput) return null - - val compilerExtension = CompilerModuleExtension.getInstance(this) - val outputDir = compilerExtension?.compilerOutputUrlForTests ?: return null - return JpsPathUtil.urlToPath("$outputDir/${name}_test.js") - } - -val Module.jsProductionOutputFilePath: String? - get() { - KotlinFacet.get(this)?.configuration?.settings?.productionOutputPath?.let { return it } - - if (!shouldUseJpsOutput) return null - - val compilerExtension = CompilerModuleExtension.getInstance(this) - val outputDir = compilerExtension?.compilerOutputUrl ?: return null - return JpsPathUtil.urlToPath("$outputDir/$name.js") - } - -fun Module.asJsModule(): Module? = takeIf { it.platform.isJs() } - -val Module.shouldUseJpsOutput: Boolean - get() = !(isGradleModule() && GradleSystemRunningSettings.getInstance().isUseGradleAwareMake) \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/migration/kotlinMigrationProfile.kt.192 b/idea/src/org/jetbrains/kotlin/idea/migration/kotlinMigrationProfile.kt.192 deleted file mode 100644 index 578fee7d4a5..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/migration/kotlinMigrationProfile.kt.192 +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.migration - -import com.intellij.codeInspection.InspectionEP -import com.intellij.codeInspection.InspectionProfileEntry -import com.intellij.codeInspection.ex.InspectionManagerEx -import com.intellij.codeInspection.ex.InspectionProfileImpl -import com.intellij.codeInspection.ex.InspectionToolWrapper -import com.intellij.codeInspection.ex.createSimple -import com.intellij.openapi.util.InvalidDataException -import com.intellij.openapi.util.WriteExternalException -import com.intellij.profile.codeInspection.InspectionProfileManager -import com.intellij.psi.PsiElement -import org.jdom.Element -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.configuration.MigrationInfo -import org.jetbrains.kotlin.idea.quickfix.migration.MigrationFix -import java.util.* - -fun createMigrationProfile( - managerEx: InspectionManagerEx, - psiElement: PsiElement?, - migrationInfo: MigrationInfo? = null -): InspectionProfileImpl { - val rootProfile = InspectionProfileManager.getInstance().currentProfile - - val migrationFixWrappers = applicableMigrationToolsImpl(migrationInfo) - - val allWrappers = LinkedHashSet>() - for (toolWrapper in migrationFixWrappers) { - allWrappers.add(toolWrapper) - rootProfile.collectDependentInspections(toolWrapper, allWrappers, managerEx.project) - } - - val model = createSimple(KotlinBundle.message("inspection.migration.profile.name"), managerEx.project, migrationFixWrappers) - try { - val element = Element("toCopy") - for (wrapper in migrationFixWrappers) { - wrapper.tool.writeSettings(element) - val tw = (if (psiElement == null) - model.getInspectionTool(wrapper.shortName, managerEx.project) - else - model.getInspectionTool(wrapper.shortName, psiElement))!! - - tw.tool.readSettings(element) - } - } catch (ignored: WriteExternalException) { - } catch (ignored: InvalidDataException) { - } - - return model -} - -fun applicableMigrationTools(migrationInfo: MigrationInfo) = applicableMigrationToolsImpl(migrationInfo) - -private fun applicableMigrationToolsImpl(migrationInfo: MigrationInfo?): List> { - val rootProfile = InspectionProfileManager.getInstance().currentProfile - - return rootProfile.allTools.asSequence() - .map { it.tool } - .filter { toolWrapper: InspectionToolWrapper<*, *> -> - val tool = toolWrapper.tool - tool is MigrationFix && (migrationInfo == null || tool.isApplicable(migrationInfo)) - } - .toList() -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 deleted file mode 100644 index b5549c02a30..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt.192 +++ /dev/null @@ -1,512 +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.refactoring.changeSignature.ui - -import com.intellij.openapi.editor.colors.EditorColorsManager -import com.intellij.openapi.editor.colors.EditorFontType -import com.intellij.openapi.editor.event.DocumentEvent -import com.intellij.openapi.editor.event.DocumentListener -import com.intellij.openapi.options.ConfigurationException -import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.Messages -import com.intellij.openapi.ui.VerticalFlowLayout -import com.intellij.openapi.util.text.StringUtil -import com.intellij.psi.PsiCodeFragment -import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.PsiElement -import com.intellij.refactoring.BaseRefactoringProcessor -import com.intellij.refactoring.RefactoringBundle -import com.intellij.refactoring.changeSignature.ChangeSignatureDialogBase -import com.intellij.refactoring.changeSignature.MethodDescriptor -import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase -import com.intellij.refactoring.ui.ComboBoxVisibilityPanel -import com.intellij.ui.DottedBorder -import com.intellij.ui.EditorTextField -import com.intellij.ui.components.JBLabel -import com.intellij.ui.treeStructure.Tree -import com.intellij.util.Consumer -import com.intellij.util.IJSwingUtilities -import com.intellij.util.ui.UIUtil -import com.intellij.util.ui.table.JBTableRow -import com.intellij.util.ui.table.JBTableRowEditor -import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.descriptors.Visibility -import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.refactoring.changeSignature.* -import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinMethodDescriptor.Kind -import org.jetbrains.kotlin.idea.refactoring.validateElement -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.isIdentifier -import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.types.isError -import java.awt.BorderLayout -import java.awt.Font -import java.awt.Toolkit -import java.awt.event.ItemEvent -import java.util.* -import javax.swing.* - -class KotlinChangeSignatureDialog( - project: Project, - methodDescriptor: KotlinMethodDescriptor, - context: PsiElement, - private val commandName: String? -) : ChangeSignatureDialogBase< - KotlinParameterInfo, - PsiElement, - Visibility, - KotlinMethodDescriptor, - ParameterTableModelItemBase, - KotlinCallableParameterTableModel>(project, methodDescriptor, false, context) { - override fun getFileType(): KotlinFileType = KotlinFileType.INSTANCE - - override fun createParametersInfoModel(descriptor: KotlinMethodDescriptor) = - createParametersInfoModel(descriptor, myDefaultValueContext) - - override fun createReturnTypeCodeFragment() = createReturnTypeCodeFragment(myProject, myMethod) - - private val parametersTableModel: KotlinCallableParameterTableModel get() = super.myParametersTableModel - - override fun getRowPresentation( - item: ParameterTableModelItemBase, - selected: Boolean, - focused: Boolean - ): JComponent? { - val panel = JPanel(BorderLayout()) - - val valOrVar = if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) { - when (item.parameter.valOrVar) { - KotlinValVar.None -> " " - KotlinValVar.Val -> "val " - KotlinValVar.Var -> "var " - } - } else { - "" - } - - val parameterName = getPresentationName(item) - val typeText = item.typeCodeFragment.text - val defaultValue = item.defaultValueCodeFragment.text - val separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length + 1) - val text = "$valOrVar$parameterName:$separator$typeText" + if (StringUtil.isNotEmpty(defaultValue)) { - KotlinBundle.message("text.default.value", defaultValue) - } else { - "" - } - - val field = object : EditorTextField(" $text", project, fileType) { - override fun shouldHaveBorder() = false - } - - val plainFont = EditorColorsManager.getInstance().globalScheme.getFont(EditorFontType.PLAIN) - field.font = Font(plainFont.fontName, plainFont.style, 12) - - if (selected && focused) { - panel.background = UIUtil.getTableSelectionBackground() - field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground()) - } else { - panel.background = UIUtil.getTableBackground() - if (selected && !focused) { - panel.border = DottedBorder(UIUtil.getTableForeground()) - } - } - panel.add(field, BorderLayout.WEST) - - return panel - } - - private fun getPresentationName(item: ParameterTableModelItemBase): String { - val parameter = item.parameter - return if (parameter == parametersTableModel.receiver) "" else parameter.name - } - - private fun getColumnTextMaxLength(nameFunction: Function1, String?>) = - parametersTableModel.items.asSequence().map { nameFunction(it)?.length ?: 0 }.max() ?: 0 - - private fun getParamNamesMaxLength() = getColumnTextMaxLength { getPresentationName(it) } - - private fun getTypesMaxLength() = getColumnTextMaxLength { it.typeCodeFragment?.text } - - private fun getDefaultValuesMaxLength() = getColumnTextMaxLength { it.defaultValueCodeFragment?.text } - - override fun isListTableViewSupported() = true - - override fun isEmptyRow(row: ParameterTableModelItemBase): Boolean { - if (row.parameter.name.isNotEmpty()) return false - if (row.parameter.typeText.isNotEmpty()) return false - return true - } - - override fun createCallerChooser(title: String, treeToReuse: Tree?, callback: Consumer>) = - KotlinCallerChooser(myMethod.method, myProject, title, treeToReuse, callback) - - // Forbid receiver propagation - override fun mayPropagateParameters() = - parameters.any { it.isNewParameter && it != parametersTableModel.receiver } - - override fun getTableEditor(table: JTable, item: ParameterTableModelItemBase): JBTableRowEditor? { - return object : JBTableRowEditor() { - private val components = ArrayList() - private val nameEditor = EditorTextField(item.parameter.name, project, fileType) - - private fun updateNameEditor() { - nameEditor.isEnabled = item.parameter != parametersTableModel.receiver - } - - private fun isDefaultColumnEnabled() = - item.parameter.isNewParameter && item.parameter != myMethod.receiver - - override fun prepareEditor(table: JTable, row: Int) { - layout = BoxLayout(this, BoxLayout.X_AXIS) - var column = 0 - - for (columnInfo in parametersTableModel.columnInfos) { - val panel = JPanel(VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false)) - val editor: EditorTextField? - val component: JComponent - val columnFinal = column - - if (KotlinCallableParameterTableModel.isTypeColumn(columnInfo)) { - val document = PsiDocumentManager.getInstance(project).getDocument(item.typeCodeFragment) - editor = EditorTextField(document, project, fileType) - component = editor - } else if (KotlinCallableParameterTableModel.isNameColumn(columnInfo)) { - editor = nameEditor - component = editor - updateNameEditor() - } else if (KotlinCallableParameterTableModel.isDefaultValueColumn(columnInfo) && isDefaultColumnEnabled()) { - val document = PsiDocumentManager.getInstance(project).getDocument(item.defaultValueCodeFragment) - editor = EditorTextField(document, project, fileType) - component = editor - } else if (KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo)) { - val comboBox = JComboBox(KotlinValVar.values()) - comboBox.selectedItem = item.parameter.valOrVar - comboBox.addItemListener { - parametersTableModel.setValueAtWithoutUpdate(it.item, row, columnFinal) - updateSignature() - } - component = comboBox - editor = null - } else if (KotlinFunctionParameterTableModel.isReceiverColumn(columnInfo)) { - val checkBox = JCheckBox() - checkBox.isSelected = parametersTableModel.receiver == item.parameter - checkBox.addItemListener { - val newReceiver = if (it.stateChange == ItemEvent.SELECTED) item.parameter else null - (parametersTableModel as KotlinFunctionParameterTableModel).receiver = newReceiver - updateSignature() - updateNameEditor() - } - component = checkBox - editor = null - } else - continue - - val label = JBLabel(columnInfo.name, UIUtil.ComponentStyle.SMALL) - panel.add(label) - - if (editor != null) { - editor.addDocumentListener( - object : DocumentListener { - override fun documentChanged(e: DocumentEvent) { - fireDocumentChanged(e, columnFinal) - } - } - ) - editor.setPreferredWidth(table.width / parametersTableModel.columnCount) - } - - components.add(component) - panel.add(component) - add(panel) - IJSwingUtilities.adjustComponentsOnMac(label, component) - column++ - } - } - - override fun getValue(): JBTableRow { - return JBTableRow { column -> - val columnInfo = parametersTableModel.columnInfos[column] - - when { - KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo) -> - (components[column] as @Suppress("NO_TYPE_ARGUMENTS_ON_RHS") JComboBox).selectedItem - KotlinCallableParameterTableModel.isTypeColumn(columnInfo) -> - item.typeCodeFragment - KotlinCallableParameterTableModel.isNameColumn(columnInfo) -> - (components[column] as EditorTextField).text - KotlinCallableParameterTableModel.isDefaultValueColumn(columnInfo) -> - item.defaultValueCodeFragment - else -> - null - } - } - } - - private fun getColumnWidth(letters: Int): Int { - var font = EditorColorsManager.getInstance().globalScheme.getFont(EditorFontType.PLAIN) - font = Font(font.fontName, font.style, 12) - return letters * Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth("W") - } - - private fun getEditorIndex(x: Int): Int { - @Suppress("NAME_SHADOWING") var x = x - - val columnLetters = if (isDefaultColumnEnabled()) - intArrayOf(4, getParamNamesMaxLength(), getTypesMaxLength(), getDefaultValuesMaxLength()) - else - intArrayOf(4, getParamNamesMaxLength(), getTypesMaxLength()) - - var columnIndex = 0 - for (i in (if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) 0 else 1) until columnLetters.size) { - val width = getColumnWidth(columnLetters[i]) - - if (x <= width) - return columnIndex - - columnIndex++ - x -= width - } - - return columnIndex - 1 - } - - override fun getPreferredFocusedComponent(): JComponent { - val me = mouseEvent - val index = when { - me != null -> getEditorIndex(me.point.getX().toInt()) - myMethod.kind === Kind.PRIMARY_CONSTRUCTOR -> 1 - else -> 0 - } - val component = components[index] - return if (component is EditorTextField) component.focusTarget else component - } - - override fun getFocusableComponents(): Array { - return Array(components.size) { - val component = components[it] - (component as? EditorTextField)?.focusTarget ?: component - } - } - } - } - - override fun calculateSignature(): String { - val changeInfo = evaluateChangeInfo( - parametersTableModel, - myReturnTypeCodeFragment, - getMethodDescriptor(), - visibility, - methodName, - myDefaultValueContext, - true - ) - return changeInfo.getNewSignature(getMethodDescriptor().originalPrimaryCallable) - } - - override fun createVisibilityControl() = ComboBoxVisibilityPanel( - arrayOf(Visibilities.INTERNAL, Visibilities.PRIVATE, Visibilities.PROTECTED, Visibilities.PUBLIC) - ) - - override fun updateSignatureAlarmFired() { - super.updateSignatureAlarmFired() - validateButtons() - } - - override fun validateAndCommitData(): String? { - if (myMethod.canChangeReturnType() == MethodDescriptor.ReadWriteOption.ReadWrite && - myReturnTypeCodeFragment.getTypeInfo(isCovariant = true, forPreview = false).type == null - ) { - if (showOkCancelDialog( - myProject, - KotlinBundle.message("message.text.return.type.cannot.be.resolved", - myReturnTypeCodeFragment?.text.toString() - ), - RefactoringBundle.message("changeSignature.refactoring.name"), - Messages.getWarningIcon() - ) != Messages.OK - ) { - return EXIT_SILENTLY - } - } - - for (item in parametersTableModel.items) { - if (item.typeCodeFragment.getTypeInfo(isCovariant = true, forPreview = false).type == null) { - val paramText = if (item.parameter != parametersTableModel.receiver) - KotlinBundle.message("text.parameter.0", item.parameter.name) - else - KotlinBundle.message("text.receiver") - if (showOkCancelDialog( - myProject, - KotlinBundle.message("message.type.for.cannot.be.resolved", - item.typeCodeFragment.text, - paramText - ), - RefactoringBundle.message("changeSignature.refactoring.name"), - Messages.getWarningIcon() - ) != Messages.OK - ) { - return EXIT_SILENTLY - } - } - } - return null - } - - override fun canRun() { - if (myNamePanel.isVisible && myMethod.canChangeName() && !methodName.isIdentifier()) { - throw ConfigurationException(KotlinBundle.message("function.name.is.invalid")) - } - - if (myMethod.canChangeReturnType() === MethodDescriptor.ReadWriteOption.ReadWrite) { - (myReturnTypeCodeFragment as? KtTypeCodeFragment) - ?.validateElement(KotlinBundle.message("return.type.is.invalid")) - } - - for (item in parametersTableModel.items) { - val parameterName = item.parameter.name - - if (item.parameter != parametersTableModel.receiver && !parameterName.isIdentifier()) { - throw ConfigurationException(KotlinBundle.message("parameter.name.is.invalid", parameterName)) - } - - (item.typeCodeFragment as? KtTypeCodeFragment) - ?.validateElement(KotlinBundle.message("parameter.type.is.invalid", item.typeCodeFragment.text)) - } - } - - override fun createRefactoringProcessor(): BaseRefactoringProcessor { - val changeInfo = evaluateChangeInfo( - parametersTableModel, - myReturnTypeCodeFragment, - getMethodDescriptor(), - visibility, - methodName, - myDefaultValueContext, - false - ) - changeInfo.primaryPropagationTargets = myMethodsToPropagateParameters ?: emptyList() - return KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: title) - } - - private fun getMethodDescriptor(): KotlinMethodDescriptor = myMethod - - override fun getSelectedIdx(): Int { - return myMethod.parameters.withIndex().firstOrNull { it.value.isNewParameter }?.index - ?: super.getSelectedIdx() - } - - companion object { - private fun createParametersInfoModel( - descriptor: KotlinMethodDescriptor, - defaultValueContext: PsiElement - ): KotlinCallableParameterTableModel { - val typeContext = getTypeCodeFragmentContext(descriptor.baseDeclaration) - return when (descriptor.kind) { - Kind.FUNCTION -> KotlinFunctionParameterTableModel(descriptor, typeContext, defaultValueContext) - Kind.PRIMARY_CONSTRUCTOR -> KotlinPrimaryConstructorParameterTableModel(descriptor, typeContext, defaultValueContext) - Kind.SECONDARY_CONSTRUCTOR -> KotlinSecondaryConstructorParameterTableModel(descriptor, typeContext, defaultValueContext) - } - } - - fun getTypeCodeFragmentContext(startFrom: PsiElement): KtElement { - return startFrom.parentsWithSelf.mapNotNull { - when { - it is KtNamedFunction -> it.bodyExpression ?: it.valueParameterList - it is KtPropertyAccessor -> it.bodyExpression - it is KtDeclaration && KtPsiUtil.isLocal(it) -> null - it is KtConstructor<*> -> it - it is KtClassOrObject -> it - it is KtFile -> it - else -> null - } - }.first() - } - - private fun createReturnTypeCodeFragment(project: Project, method: KotlinMethodDescriptor) = - KtPsiFactory(project).createTypeCodeFragment(method.returnTypeInfo.render(), getTypeCodeFragmentContext(method.baseDeclaration)) - - fun createRefactoringProcessorForSilentChangeSignature( - project: Project, - commandName: String, - method: KotlinMethodDescriptor, - defaultValueContext: PsiElement - ): BaseRefactoringProcessor { - val parameterTableModel = createParametersInfoModel(method, defaultValueContext) - parameterTableModel.setParameterInfos(method.parameters) - val changeInfo = evaluateChangeInfo( - parameterTableModel, - createReturnTypeCodeFragment(project, method), - method, - method.visibility, - method.name, - defaultValueContext, - false - ) - return KotlinChangeSignatureProcessor(project, changeInfo, commandName) - } - - fun PsiCodeFragment?.getTypeInfo(isCovariant: Boolean, forPreview: Boolean): KotlinTypeInfo { - if (this !is KtTypeCodeFragment) return KotlinTypeInfo(isCovariant) - - val typeRef = getContentElement() - val type = typeRef?.analyze(BodyResolveMode.PARTIAL)?.get(BindingContext.TYPE, typeRef) - return when { - type != null && !type.isError -> KotlinTypeInfo(isCovariant, type, if (forPreview) typeRef.text else null) - typeRef != null -> KotlinTypeInfo(isCovariant, null, typeRef.text) - else -> KotlinTypeInfo(isCovariant) - } - } - - private fun evaluateChangeInfo( - parametersModel: KotlinCallableParameterTableModel, - returnTypeCodeFragment: PsiCodeFragment?, - methodDescriptor: KotlinMethodDescriptor, - visibility: Visibility?, - methodName: String, - defaultValueContext: PsiElement, - forPreview: Boolean - ): KotlinChangeInfo { - val parameters = parametersModel.items.map { parameter -> - val parameterInfo = parameter.parameter - - parameterInfo.currentTypeInfo = parameter.typeCodeFragment.getTypeInfo(false, forPreview) - - val codeFragment = parameter.defaultValueCodeFragment as KtExpressionCodeFragment - val oldDefaultValue = parameterInfo.defaultValueForCall - if (codeFragment.text != (if (oldDefaultValue != null) oldDefaultValue.text else "")) { - parameterInfo.defaultValueForCall = codeFragment.getContentElement() - } - - parameterInfo - } - - return KotlinChangeInfo( - methodDescriptor.original, - methodName, - returnTypeCodeFragment.getTypeInfo(true, forPreview), - visibility ?: Visibilities.DEFAULT_VISIBILITY, - parameters, - parametersModel.receiver, - defaultValueContext - ) - } - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsPassFactory.kt.192 b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsPassFactory.kt.192 deleted file mode 100644 index 8a12a75343c..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsPassFactory.kt.192 +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.refactoring.cutPaste - -import com.intellij.codeHighlighting.Pass -import com.intellij.codeHighlighting.TextEditorHighlightingPass -import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory -import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar -import com.intellij.codeInsight.daemon.impl.HighlightInfo -import com.intellij.codeInsight.daemon.impl.HighlightInfoType -import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil -import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction -import com.intellij.openapi.components.ProjectComponent -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.progress.ProgressIndicator -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiFile -import com.intellij.psi.util.PsiModificationTracker -import org.jetbrains.kotlin.idea.core.util.range - -class MoveDeclarationsPassFactory(highlightingPassRegistrar: TextEditorHighlightingPassRegistrar) : ProjectComponent, - TextEditorHighlightingPassFactory { - - init { - highlightingPassRegistrar.registerTextEditorHighlightingPass( - this, - TextEditorHighlightingPassRegistrar.Anchor.BEFORE, - Pass.POPUP_HINTS, - true, - true - ) - } - - override fun createHighlightingPass(file: PsiFile, editor: Editor): TextEditorHighlightingPass? { - return MyPass(file.project, file, editor) - } - - private class MyPass( - private val project: Project, - private val file: PsiFile, - private val editor: Editor - ) : TextEditorHighlightingPass(project, editor.document, true) { - - override fun doCollectInformation(progress: ProgressIndicator) {} - - override fun doApplyInformationToEditor() { - val info = buildHighlightingInfo() - UpdateHighlightersUtil.setHighlightersToEditor(project, myDocument!!, 0, file.textLength, listOfNotNull(info), colorsScheme, id) - } - - private fun buildHighlightingInfo(): HighlightInfo? { - val cookie = editor.getUserData(MoveDeclarationsEditorCookie.KEY) ?: return null - - if (cookie.modificationCount != PsiModificationTracker.SERVICE.getInstance(project).modificationCount) return null - - val processor = MoveDeclarationsProcessor.build(editor, cookie) - - if (processor == null) { - editor.putUserData(MoveDeclarationsEditorCookie.KEY, null) - return null - } - - val info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION) - .range(cookie.bounds.range!!) - .createUnconditionally() - QuickFixAction.registerQuickFixAction(info, MoveDeclarationsIntentionAction(processor, cookie.bounds, cookie.modificationCount)) - - return info - } - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 deleted file mode 100644 index a3e1cd1b2e9..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt.192 +++ /dev/null @@ -1,1051 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.refactoring - -import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils -import com.intellij.codeInsight.unwrap.RangeSplitter -import com.intellij.codeInsight.unwrap.UnwrapHandler -import com.intellij.ide.IdeBundle -import com.intellij.ide.util.PsiElementListCellRenderer -import com.intellij.lang.injection.InjectedLanguageManager -import com.intellij.lang.java.JavaLanguage -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.TransactionGuard -import com.intellij.openapi.command.CommandAdapter -import com.intellij.openapi.command.CommandEvent -import com.intellij.openapi.command.CommandProcessor -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.colors.EditorColors -import com.intellij.openapi.editor.colors.EditorColorsManager -import com.intellij.openapi.editor.markup.HighlighterTargetArea -import com.intellij.openapi.editor.markup.RangeHighlighter -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.openapi.options.ConfigurationException -import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.DialogWrapper -import com.intellij.openapi.ui.Messages -import com.intellij.openapi.ui.popup.* -import com.intellij.openapi.util.Pass -import com.intellij.openapi.util.TextRange -import com.intellij.openapi.util.text.StringUtil -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.* -import com.intellij.psi.impl.file.PsiPackageBase -import com.intellij.psi.impl.light.LightElement -import com.intellij.psi.presentation.java.SymbolPresentationUtil -import com.intellij.psi.util.PsiTreeUtil -import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException -import com.intellij.refactoring.changeSignature.ChangeSignatureUtil -import com.intellij.refactoring.listeners.RefactoringEventData -import com.intellij.refactoring.listeners.RefactoringEventListener -import com.intellij.refactoring.rename.PsiElementRenameHandler -import com.intellij.refactoring.ui.ConflictsDialog -import com.intellij.refactoring.util.ConflictsUtil -import com.intellij.refactoring.util.RefactoringUIUtil -import com.intellij.ui.components.JBList -import com.intellij.usageView.UsageViewTypeLocation -import com.intellij.util.VisibilityUtil -import com.intellij.util.containers.MultiMap -import org.jetbrains.annotations.Nls -import org.jetbrains.kotlin.asJava.LightClassUtil -import org.jetbrains.kotlin.asJava.elements.KtLightMethod -import org.jetbrains.kotlin.asJava.getAccessorLightMethods -import org.jetbrains.kotlin.asJava.namedUnwrappedElement -import org.jetbrains.kotlin.asJava.toLightClass -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor -import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.idea.KotlinLanguage -import org.jetbrains.kotlin.idea.analysis.analyzeAsReplacement -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall -import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny -import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor -import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMemberDescriptor -import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde -import org.jetbrains.kotlin.idea.core.* -import org.jetbrains.kotlin.idea.core.util.showYesNoCancelDialog -import org.jetbrains.kotlin.idea.project.languageVersionSettings -import org.jetbrains.kotlin.idea.refactoring.changeSignature.KotlinValVar -import org.jetbrains.kotlin.idea.refactoring.changeSignature.toValVar -import org.jetbrains.kotlin.idea.refactoring.memberInfo.KtPsiClassWrapper -import org.jetbrains.kotlin.idea.refactoring.rename.canonicalRender -import org.jetbrains.kotlin.idea.roots.isOutsideKotlinAwareSourceRoot -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import org.jetbrains.kotlin.idea.util.ProjectRootsUtil -import org.jetbrains.kotlin.idea.util.actualsForExpected -import org.jetbrains.kotlin.idea.util.liftToExpected -import org.jetbrains.kotlin.idea.util.string.collapseSpaces -import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.FqNameUnsafe -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.* -import org.jetbrains.kotlin.renderer.DescriptorRenderer -import org.jetbrains.kotlin.resolve.* -import org.jetbrains.kotlin.resolve.calls.callUtil.getCallWithAssert -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver -import org.jetbrains.kotlin.resolve.source.getPsi -import java.lang.annotation.Retention -import java.util.* -import javax.swing.Icon -import kotlin.math.min - -import org.jetbrains.kotlin.idea.core.util.getLineCount as newGetLineCount -import org.jetbrains.kotlin.idea.core.util.toPsiDirectory as newToPsiDirectory -import org.jetbrains.kotlin.idea.core.util.toPsiFile as newToPsiFile - -const val CHECK_SUPER_METHODS_YES_NO_DIALOG = "CHECK_SUPER_METHODS_YES_NO_DIALOG" - -@JvmOverloads -fun getOrCreateKotlinFile( - fileName: String, - targetDir: PsiDirectory, - packageName: String? = targetDir.getFqNameWithImplicitPrefix()?.asString() -): KtFile? = - (targetDir.findFile(fileName) ?: createKotlinFile(fileName, targetDir, packageName)) as? KtFile - -fun createKotlinFile( - fileName: String, - targetDir: PsiDirectory, - packageName: String? = targetDir.getFqNameWithImplicitPrefix()?.asString() -): KtFile { - targetDir.checkCreateFile(fileName) - val packageFqName = packageName?.let(::FqName) ?: FqName.ROOT - val file = PsiFileFactory.getInstance(targetDir.project).createFileFromText( - fileName, KotlinFileType.INSTANCE, if (!packageFqName.isRoot) "package ${packageFqName.quoteSegmentsIfNeeded()} \n\n" else "" - ) - - return targetDir.add(file) as KtFile -} - -fun PsiElement.getUsageContext(): PsiElement { - return when (this) { - is KtElement -> PsiTreeUtil.getParentOfType( - this, - KtPropertyAccessor::class.java, - KtProperty::class.java, - KtNamedFunction::class.java, - KtConstructor::class.java, - KtClassOrObject::class.java - ) ?: containingFile - else -> ConflictsUtil.getContainer(this) - } -} - -fun PsiElement.isInKotlinAwareSourceRoot(): Boolean = - !isOutsideKotlinAwareSourceRoot(containingFile) - -fun KtFile.createTempCopy(text: String? = null): KtFile { - val tmpFile = KtPsiFactory(this).createAnalyzableFile(name, text ?: this.text ?: "", this) - tmpFile.originalFile = this - return tmpFile -} - -fun PsiElement.getAllExtractionContainers(strict: Boolean = true): List { - val containers = ArrayList() - - var objectOrNonInnerNestedClassFound = false - val parents = if (strict) parents else parentsWithSelf - for (element in parents) { - val isValidContainer = when (element) { - is KtFile -> true - is KtClassBody -> !objectOrNonInnerNestedClassFound || element.parent is KtObjectDeclaration - is KtBlockExpression -> !objectOrNonInnerNestedClassFound - else -> false - } - if (!isValidContainer) continue - - containers.add(element as KtElement) - - if (!objectOrNonInnerNestedClassFound) { - val bodyParent = (element as? KtClassBody)?.parent - objectOrNonInnerNestedClassFound = - (bodyParent is KtObjectDeclaration && !bodyParent.isObjectLiteral()) - || (bodyParent is KtClass && !bodyParent.isInner()) - } - } - - return containers -} - -fun PsiElement.getExtractionContainers(strict: Boolean = true, includeAll: Boolean = false): List { - fun getEnclosingDeclaration(element: PsiElement, strict: Boolean): PsiElement? { - return (if (strict) element.parents else element.parentsWithSelf) - .filter { - (it is KtDeclarationWithBody && it !is KtFunctionLiteral && !(it is KtNamedFunction && it.name == null)) - || it is KtAnonymousInitializer - || it is KtClassBody - || it is KtFile - } - .firstOrNull() - } - - if (includeAll) return getAllExtractionContainers(strict) - - val enclosingDeclaration = getEnclosingDeclaration(this, strict)?.let { - if (it is KtDeclarationWithBody || it is KtAnonymousInitializer) getEnclosingDeclaration(it, true) else it - } - - return when (enclosingDeclaration) { - is KtFile -> Collections.singletonList(enclosingDeclaration) - is KtClassBody -> getAllExtractionContainers(strict).filterIsInstance() - else -> { - val targetContainer = when (enclosingDeclaration) { - is KtDeclarationWithBody -> enclosingDeclaration.bodyExpression - is KtAnonymousInitializer -> enclosingDeclaration.body - else -> null - } - if (targetContainer is KtBlockExpression) Collections.singletonList(targetContainer) else Collections.emptyList() - } - } -} - -fun Project.checkConflictsInteractively( - conflicts: MultiMap, - onShowConflicts: () -> Unit = {}, - onAccept: () -> Unit -) { - if (!conflicts.isEmpty) { - if (ApplicationManager.getApplication()!!.isUnitTestMode) throw ConflictsInTestsException(conflicts.values()) - - val dialog = ConflictsDialog(this, conflicts) { onAccept() } - dialog.show() - if (!dialog.isOK) { - if (dialog.isShowConflicts) { - onShowConflicts() - } - return - } - } - - onAccept() -} - -fun reportDeclarationConflict( - conflicts: MultiMap, - declaration: PsiElement, - message: (renderedDeclaration: String) -> String -) { - conflicts.putValue(declaration, message(RefactoringUIUtil.getDescription(declaration, true).capitalize())) -} - -fun getPsiElementPopup( - editor: Editor, - elements: List, - renderer: PsiElementListCellRenderer, - title: String?, - highlightSelection: Boolean, - toPsi: (T) -> E, - processor: (T) -> Boolean -): JBPopup { - val highlighter = if (highlightSelection) SelectionAwareScopeHighlighter(editor) else null - - val list = JBList(elements.map(toPsi)) - list.cellRenderer = renderer - list.addListSelectionListener { - highlighter?.dropHighlight() - val index = list.selectedIndex - if (index >= 0) { - highlighter?.highlight(list.model!!.getElementAt(index) as PsiElement) - } - } - - return with(PopupChooserBuilder(list)) { - title?.let { setTitle(it) } - renderer.installSpeedSearch(this, true) - setItemChoosenCallback { - val index = list.selectedIndex - if (index >= 0) { - processor(elements[index]) - } - } - addListener(object : JBPopupAdapter() { - override fun onClosed(event: LightweightWindowEvent) { - highlighter?.dropHighlight() - } - }) - - createPopup() - } -} - -class SelectionAwareScopeHighlighter(val editor: Editor) { - private val highlighters = ArrayList() - - private fun addHighlighter(r: TextRange, attr: TextAttributes) { - highlighters.add( - editor.markupModel.addRangeHighlighter( - r.startOffset, - r.endOffset, - UnwrapHandler.HIGHLIGHTER_LEVEL, - attr, - HighlighterTargetArea.EXACT_RANGE - ) - ) - } - - fun highlight(wholeAffected: PsiElement) { - dropHighlight() - - val affectedRange = wholeAffected.textRange ?: return - - val attributes = EditorColorsManager.getInstance().globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)!! - val selectedRange = with(editor.selectionModel) { TextRange(selectionStart, selectionEnd) } - val textLength = editor.document.textLength - for (r in RangeSplitter.split(affectedRange, Collections.singletonList(selectedRange))) { - if (r.endOffset <= textLength) addHighlighter(r, attributes) - } - } - - fun dropHighlight() { - highlighters.forEach { it.dispose() } - highlighters.clear() - } -} - -@Deprecated( - "Use org.jetbrains.kotlin.idea.core.util.getLineStartOffset() instead", - ReplaceWith("this.getLineStartOffset(line)", "org.jetbrains.kotlin.idea.core.util.getLineStartOffset"), - DeprecationLevel.ERROR -) -fun PsiFile.getLineStartOffset(line: Int): Int? { - val doc = viewProvider.document ?: PsiDocumentManager.getInstance(project).getDocument(this) - if (doc != null && line >= 0 && line < doc.lineCount) { - val startOffset = doc.getLineStartOffset(line) - val element = findElementAt(startOffset) ?: return startOffset - - if (element is PsiWhiteSpace || element is PsiComment) { - return PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace::class.java, PsiComment::class.java)?.startOffset ?: startOffset - } - return startOffset - } - - return null -} - -@Deprecated( - "Use org.jetbrains.kotlin.idea.core.util.getLineEndOffset() instead", - ReplaceWith("this.getLineEndOffset(line)", "org.jetbrains.kotlin.idea.core.util.getLineEndOffset"), - DeprecationLevel.ERROR -) -fun PsiFile.getLineEndOffset(line: Int): Int? { - val document = viewProvider.document ?: PsiDocumentManager.getInstance(project).getDocument(this) - return document?.getLineEndOffset(line) -} - -fun PsiElement.getLineNumber(start: Boolean = true): Int { - val document = containingFile.viewProvider.document ?: PsiDocumentManager.getInstance(project).getDocument(containingFile) - val index = if (start) this.startOffset else this.endOffset - if (index > document?.textLength ?: 0) return 0 - return document?.getLineNumber(index) ?: 0 -} - -class SeparateFileWrapper(manager: PsiManager) : LightElement(manager, KotlinLanguage.INSTANCE) { - override fun toString() = "" -} - -fun chooseContainerElement( - containers: List, - editor: Editor, - title: String, - highlightSelection: Boolean, - toPsi: (T) -> PsiElement, - onSelect: (T) -> Unit -) { - val popup = getPsiElementPopup( - editor, - containers, - object : PsiElementListCellRenderer() { - private fun PsiElement.renderName(): String = when { - this is KtPropertyAccessor -> property.renderName() + if (isGetter) ".get" else ".set" - this is KtObjectDeclaration && isCompanion() -> { - val name = getStrictParentOfType()?.renderName() ?: "" - "Companion object of $name" - } - else -> (this as? PsiNamedElement)?.name ?: "" - } - - private fun PsiElement.renderDeclaration(): String? { - if (this is KtFunctionLiteral || isFunctionalExpression()) return renderText() - - val descriptor = when (this) { - is KtFile -> name - is KtElement -> analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this] - is PsiMember -> getJavaMemberDescriptor() - else -> null - } ?: return null - val name = renderName() - val params = (descriptor as? FunctionDescriptor)?.valueParameters?.joinToString( - ", ", - "(", - ")" - ) { DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it.type) } ?: "" - return "$name$params" - } - - private fun PsiElement.renderText(): String = when (this) { - is SeparateFileWrapper -> KotlinBundle.message("refactoring.extract.to.separate.file.text") - is PsiPackageBase -> qualifiedName - else -> { - val text = text ?: "" - StringUtil.shortenTextWithEllipsis(text.collapseSpaces(), 53, 0) - } - } - - private fun PsiElement.getRepresentativeElement(): PsiElement = when (this) { - is KtBlockExpression -> (parent as? KtDeclarationWithBody) ?: this - is KtClassBody -> parent as KtClassOrObject - else -> this - } - - override fun getElementText(element: PsiElement): String? { - val representativeElement = element.getRepresentativeElement() - return representativeElement.renderDeclaration() ?: representativeElement.renderText() - } - - override fun getContainerText(element: PsiElement, name: String?): String? = null - - override fun getIconFlags(): Int = 0 - - override fun getIcon(element: PsiElement): Icon? = - super.getIcon(element.getRepresentativeElement()) - }, - title, - highlightSelection, - toPsi, - { - onSelect(it) - true - } - ) - ApplicationManager.getApplication().invokeLater { - popup.showInBestPositionFor(editor) - } -} - -fun chooseContainerElementIfNecessary( - containers: List, - editor: Editor, - title: String, - highlightSelection: Boolean, - toPsi: (T) -> PsiElement, - onSelect: (T) -> Unit -) { - when { - containers.isEmpty() -> return - containers.size == 1 || ApplicationManager.getApplication()!!.isUnitTestMode -> onSelect(containers.first()) - else -> chooseContainerElement(containers, editor, title, highlightSelection, toPsi, onSelect) - } -} - -fun PsiElement.isTrueJavaMethod(): Boolean = this is PsiMethod && this !is KtLightMethod - -fun PsiElement.canRefactor(): Boolean = when { - !isValid -> false - this is PsiPackage -> directories.any { it.canRefactor() } - this is KtElement || this is PsiMember && language == JavaLanguage.INSTANCE || this is PsiDirectory -> ProjectRootsUtil.isInProjectSource( - this, - includeScriptsOutsideSourceRoots = true - ) - else -> false -} - -private fun copyModifierListItems(from: PsiModifierList, to: PsiModifierList, withPsiModifiers: Boolean = true) { - if (withPsiModifiers) { - for (modifier in PsiModifier.MODIFIERS) { - if (from.hasExplicitModifier(modifier)) { - to.setModifierProperty(modifier, true) - } - } - } - for (annotation in from.annotations) { - val annotationName = annotation.qualifiedName ?: continue - - if (Retention::class.java.name != annotationName) { - to.addAnnotation(annotationName) - } - } -} - -private fun copyTypeParameters( - from: T, - to: T, - inserter: (T, PsiTypeParameterList) -> Unit -) where T : PsiTypeParameterListOwner, T : PsiNameIdentifierOwner { - val factory = PsiElementFactory.SERVICE.getInstance((from as PsiElement).project) - val templateTypeParams = from.typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY - if (templateTypeParams.isNotEmpty()) { - inserter(to, factory.createTypeParameterList()) - val targetTypeParamList = to.typeParameterList - val newTypeParams = templateTypeParams.map { - factory.createTypeParameter(it.name, it.extendsList.referencedTypes) - } - ChangeSignatureUtil.synchronizeList( - targetTypeParamList, - newTypeParams, - { it!!.typeParameters.toList() }, - BooleanArray(newTypeParams.size) - ) - } -} - -fun createJavaMethod(function: KtFunction, targetClass: PsiClass): PsiMethod { - val template = LightClassUtil.getLightClassMethod(function) - ?: throw AssertionError("Can't generate light method: ${function.getElementTextWithContext()}") - return createJavaMethod(template, targetClass) -} - -fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMethod { - val factory = PsiElementFactory.SERVICE.getInstance(template.project) - val methodToAdd = if (template.isConstructor) { - factory.createConstructor(template.name) - } else { - factory.createMethod(template.name, template.returnType) - } - val method = targetClass.add(methodToAdd) as PsiMethod - - copyModifierListItems(template.modifierList, method.modifierList) - if (targetClass.isInterface) { - method.modifierList.setModifierProperty(PsiModifier.FINAL, false) - } - - copyTypeParameters(template, method) { psiMethod, typeParameterList -> - psiMethod.addAfter(typeParameterList, psiMethod.modifierList) - } - - val targetParamList = method.parameterList - val newParams = template.parameterList.parameters.map { - val param = factory.createParameter(it.name!!, it.type) - copyModifierListItems(it.modifierList!!, param.modifierList!!) - param - } - ChangeSignatureUtil.synchronizeList( - targetParamList, - newParams, - { it.parameters.toList() }, - BooleanArray(newParams.size) - ) - - if (template.modifierList.hasModifierProperty(PsiModifier.ABSTRACT) || targetClass.isInterface) { - method.body!!.delete() - } else if (!template.isConstructor) { - CreateFromUsageUtils.setupMethodBody(method) - } - - return method -} - -fun createJavaField(property: KtNamedDeclaration, targetClass: PsiClass): PsiField { - val accessorLightMethods = property.getAccessorLightMethods() - val template = accessorLightMethods.getter - ?: throw AssertionError("Can't generate light method: ${property.getElementTextWithContext()}") - - val factory = PsiElementFactory.SERVICE.getInstance(template.project) - val field = targetClass.add(factory.createField(property.name!!, template.returnType!!)) as PsiField - - with(field.modifierList!!) { - val templateModifiers = template.modifierList - setModifierProperty(VisibilityUtil.getVisibilityModifier(templateModifiers), true) - if ((property as KtValVarKeywordOwner).valOrVarKeyword.toValVar() != KotlinValVar.Var || targetClass.isInterface) { - setModifierProperty(PsiModifier.FINAL, true) - } - copyModifierListItems(templateModifiers, this, false) - } - - return field -} - -fun createJavaClass(klass: KtClass, targetClass: PsiClass?, forcePlainClass: Boolean = false): PsiClass { - val kind = if (forcePlainClass) ClassKind.CLASS else (klass.unsafeResolveToDescriptor() as ClassDescriptor).kind - - val factory = PsiElementFactory.SERVICE.getInstance(klass.project) - val className = klass.name!! - val javaClassToAdd = when (kind) { - ClassKind.CLASS -> factory.createClass(className) - ClassKind.INTERFACE -> factory.createInterface(className) - ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(className) - ClassKind.ENUM_CLASS -> factory.createEnum(className) - else -> throw AssertionError("Unexpected class kind: ${klass.getElementTextWithContext()}") - } - val javaClass = (targetClass?.add(javaClassToAdd) ?: javaClassToAdd) as PsiClass - - val template = klass.toLightClass() ?: throw AssertionError("Can't generate light class: ${klass.getElementTextWithContext()}") - - copyModifierListItems(template.modifierList!!, javaClass.modifierList!!) - if (template.isInterface) { - javaClass.modifierList!!.setModifierProperty(PsiModifier.ABSTRACT, false) - } - - copyTypeParameters(template, javaClass) { clazz, typeParameterList -> - clazz.addAfter(typeParameterList, clazz.nameIdentifier) - } - - // Turning interface to class - if (!javaClass.isInterface && template.isInterface) { - val implementsList = factory.createReferenceListWithRole( - template.extendsList?.referenceElements ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY, - PsiReferenceList.Role.IMPLEMENTS_LIST - ) - implementsList?.let { javaClass.implementsList?.replace(it) } - } else { - val extendsList = factory.createReferenceListWithRole( - template.extendsList?.referenceElements ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY, - PsiReferenceList.Role.EXTENDS_LIST - ) - extendsList?.let { javaClass.extendsList?.replace(it) } - - val implementsList = factory.createReferenceListWithRole( - template.implementsList?.referenceElements ?: PsiJavaCodeReferenceElement.EMPTY_ARRAY, - PsiReferenceList.Role.IMPLEMENTS_LIST - ) - implementsList?.let { javaClass.implementsList?.replace(it) } - } - - for (method in template.methods) { - val hasParams = method.parameterList.parametersCount > 0 - val needSuperCall = !template.isEnum && - (template.superClass?.constructors ?: PsiMethod.EMPTY_ARRAY).all { - it.parameterList.parametersCount > 0 - } - if (method.isConstructor && !(hasParams || needSuperCall)) continue - with(createJavaMethod(method, javaClass)) { - if (isConstructor && needSuperCall) { - body!!.add(factory.createStatementFromText("super();", this)) - } - } - } - - return javaClass -} - -internal fun broadcastRefactoringExit(project: Project, refactoringId: String) { - project.messageBus.syncPublisher(KotlinRefactoringEventListener.EVENT_TOPIC).onRefactoringExit(refactoringId) -} - -// IMPORTANT: Target refactoring must support KotlinRefactoringEventListener -internal abstract class CompositeRefactoringRunner( - val project: Project, - val refactoringId: String -) { - protected abstract fun runRefactoring() - - protected open fun onRefactoringDone() {} - protected open fun onExit() {} - - fun run() { - val connection = project.messageBus.connect() - connection.subscribe( - RefactoringEventListener.REFACTORING_EVENT_TOPIC, - object : RefactoringEventListener { - override fun undoRefactoring(refactoringId: String) { - - } - - override fun refactoringStarted(refactoringId: String, beforeData: RefactoringEventData?) { - - } - - override fun conflictsDetected(refactoringId: String, conflictsData: RefactoringEventData) { - - } - - override fun refactoringDone(refactoringId: String, afterData: RefactoringEventData?) { - if (refactoringId == this@CompositeRefactoringRunner.refactoringId) { - onRefactoringDone() - } - } - } - ) - connection.subscribe( - KotlinRefactoringEventListener.EVENT_TOPIC, - object : KotlinRefactoringEventListener { - override fun onRefactoringExit(refactoringId: String) { - if (refactoringId == this@CompositeRefactoringRunner.refactoringId) { - try { - onExit() - } finally { - connection.disconnect() - } - } - } - } - ) - runRefactoring() - } -} - -@Throws(ConfigurationException::class) -fun KtElement?.validateElement(errorMessage: String) { - if (this == null) throw ConfigurationException(errorMessage) - - try { - AnalyzingUtils.checkForSyntacticErrors(this) - } catch (e: Exception) { - throw ConfigurationException(errorMessage) - } -} - -fun invokeOnceOnCommandFinish(action: () -> Unit) { - val commandProcessor = CommandProcessor.getInstance() - val listener = object : CommandAdapter() { - override fun beforeCommandFinished(event: CommandEvent) { - action() - commandProcessor.removeCommandListener(this) - } - } - commandProcessor.addCommandListener(listener) -} - -fun FqNameUnsafe.hasIdentifiersOnly(): Boolean = pathSegments().all { it.asString().quoteIfNeeded().isIdentifier() } - -fun FqName.hasIdentifiersOnly(): Boolean = pathSegments().all { it.asString().quoteIfNeeded().isIdentifier() } - -fun PsiNamedElement.isInterfaceClass(): Boolean = when (this) { - is KtClass -> isInterface() - is PsiClass -> isInterface - is KtPsiClassWrapper -> psiClass.isInterface - else -> false -} - -fun KtNamedDeclaration.isAbstract(): Boolean = when { - hasModifier(KtTokens.ABSTRACT_KEYWORD) -> true - containingClassOrObject?.isInterfaceClass() != true -> false - this is KtProperty -> initializer == null && delegate == null && accessors.isEmpty() - this is KtNamedFunction -> !hasBody() - else -> false -} - -fun KtNamedDeclaration.isConstructorDeclaredProperty() = this is KtParameter && ownerFunction is KtPrimaryConstructor && hasValOrVar() - -fun replaceListPsiAndKeepDelimiters( - originalList: ListType, - newList: ListType, - @Suppress("UNCHECKED_CAST") listReplacer: ListType.(ListType) -> ListType = { replace(it) as ListType }, - itemsFun: ListType.() -> List -): ListType { - originalList.children.takeWhile { it is PsiErrorElement }.forEach { it.delete() } - - val oldParameters = originalList.itemsFun().toMutableList() - val newParameters = newList.itemsFun() - val oldCount = oldParameters.size - val newCount = newParameters.size - - val commonCount = min(oldCount, newCount) - for (i in 0 until commonCount) { - oldParameters[i] = oldParameters[i].replace(newParameters[i]) as KtElement - } - - if (commonCount == 0) return originalList.listReplacer(newList) - - val lastOriginalParameter = oldParameters.last() - - if (oldCount > commonCount) { - originalList.deleteChildRange(oldParameters[commonCount - 1].nextSibling, lastOriginalParameter) - } else if (newCount > commonCount) { - val psiBeforeLastParameter = lastOriginalParameter.prevSibling - val withMultiline = - (psiBeforeLastParameter is PsiWhiteSpace || psiBeforeLastParameter is PsiComment) && psiBeforeLastParameter.textContains('\n') - val extraSpace = if (withMultiline) KtPsiFactory(originalList).createNewLine() else null - originalList.addRangeAfter(newParameters[commonCount - 1].nextSibling, newParameters.last(), lastOriginalParameter) - if (extraSpace != null) { - val addedItems = originalList.itemsFun().subList(commonCount, newCount) - for (addedItem in addedItems) { - val elementBefore = addedItem.prevSibling - if ((elementBefore !is PsiWhiteSpace && elementBefore !is PsiComment) || !elementBefore.textContains('\n')) { - addedItem.parent.addBefore(extraSpace, addedItem) - } - } - } - } - - return originalList -} - -fun Pass(body: (T) -> Unit) = object : Pass() { - override fun pass(t: T) = body(t) -} - -fun KtExpression.removeTemplateEntryBracesIfPossible(): KtExpression { - val parent = parent as? KtBlockStringTemplateEntry ?: return this - val newEntry = if (parent.canDropBraces()) parent.dropBraces() else parent - return newEntry.expression!! -} - -fun dropOverrideKeywordIfNecessary(element: KtNamedDeclaration) { - val callableDescriptor = element.resolveToDescriptorIfAny() as? CallableDescriptor ?: return - if (callableDescriptor.overriddenDescriptors.isEmpty()) { - element.removeModifier(KtTokens.OVERRIDE_KEYWORD) - } -} - -fun dropOperatorKeywordIfNecessary(element: KtNamedDeclaration) { - val callableDescriptor = element.resolveToDescriptorIfAny() as? CallableDescriptor ?: return - val diagnosticHolder = BindingTraceContext() - OperatorModifierChecker.check(element, callableDescriptor, diagnosticHolder, element.languageVersionSettings) - if (diagnosticHolder.bindingContext.diagnostics.any { it.factory == Errors.INAPPLICABLE_OPERATOR_MODIFIER }) { - element.removeModifier(KtTokens.OPERATOR_KEYWORD) - } -} - -fun getQualifiedTypeArgumentList(initializer: KtExpression): KtTypeArgumentList? { - val call = initializer.resolveToCall() ?: return null - val typeArgumentMap = call.typeArguments - val typeArguments = call.candidateDescriptor.typeParameters.mapNotNull { typeArgumentMap[it] } - val renderedList = typeArguments.joinToString(prefix = "<", postfix = ">") { - IdeDescriptorRenderers.SOURCE_CODE_NOT_NULL_TYPE_APPROXIMATION.renderType(it) - } - return KtPsiFactory(initializer).createTypeArguments(renderedList) -} - -fun addTypeArgumentsIfNeeded(expression: KtExpression, typeArgumentList: KtTypeArgumentList) { - val context = expression.analyze(BodyResolveMode.PARTIAL_WITH_DIAGNOSTICS) - val call = expression.getCallWithAssert(context) - val callElement = call.callElement as? KtCallExpression ?: return - if (call.typeArgumentList != null) return - val callee = call.calleeExpression ?: return - if (context.diagnostics.forElement(callee).all { - it.factory != Errors.TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER && - it.factory != Errors.NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER - } - ) { - return - } - - callElement.addAfter(typeArgumentList, callElement.calleeExpression) - ShortenReferences.DEFAULT.process(callElement.typeArgumentList!!) -} - -internal fun DeclarationDescriptor.getThisLabelName(): String { - if (!name.isSpecial) return name.asString() - if (this is AnonymousFunctionDescriptor) { - val function = source.getPsi() as? KtFunction - val argument = function?.parent as? KtValueArgument - ?: (function?.parent as? KtLambdaExpression)?.parent as? KtValueArgument - val callElement = argument?.getStrictParentOfType() - val callee = callElement?.calleeExpression as? KtSimpleNameExpression - if (callee != null) return callee.text - } - return "" -} - -internal fun DeclarationDescriptor.explicateAsTextForReceiver(): String { - val labelName = getThisLabelName() - return if (labelName.isEmpty()) "this" else "this@$labelName" -} - -internal fun ImplicitReceiver.explicateAsText(): String { - return declarationDescriptor.explicateAsTextForReceiver() -} - -val PsiFile.isInjectedFragment: Boolean - get() = InjectedLanguageManager.getInstance(project).isInjectedFragment(this) - -val PsiElement.isInsideInjectedFragment: Boolean - get() = containingFile.isInjectedFragment - -fun checkSuperMethods( - declaration: KtDeclaration, - ignore: Collection?, - @Nls actionString: String -): List { - fun getClassDescriptions(overriddenElementsToDescriptor: Map): List { - return overriddenElementsToDescriptor.entries.map { entry -> - val (element, descriptor) = entry - val description = when (element) { - is KtNamedFunction, is KtProperty, is KtParameter -> formatClassDescriptor(descriptor.containingDeclaration) - is PsiMethod -> { - val psiClass = element.containingClass ?: error("Invalid element: ${element.getText()}") - formatPsiClass(psiClass, markAsJava = true, inCode = false) - } - else -> error("Unexpected element: ${element.getElementTextWithContext()}") - } - " $description\n" - } - } - - fun askUserForMethodsToSearch( - declarationDescriptor: CallableDescriptor, - overriddenElementsToDescriptor: Map - ): List { - val superClassDescriptions = getClassDescriptions(overriddenElementsToDescriptor) - - val message = KotlinBundle.message( - "override.declaration.x.overrides.y.in.class.list", - DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.render(declarationDescriptor), - "\n${superClassDescriptions.joinToString(separator = "")}", - actionString - ) - - val exitCode = showYesNoCancelDialog( - CHECK_SUPER_METHODS_YES_NO_DIALOG, - declaration.project, message, IdeBundle.message("title.warning"), Messages.getQuestionIcon(), Messages.YES - ) - return when (exitCode) { - Messages.YES -> overriddenElementsToDescriptor.keys.toList() - Messages.NO -> listOf(declaration) - else -> emptyList() - } - } - - - val declarationDescriptor = declaration.unsafeResolveToDescriptor() as CallableDescriptor - - if (declarationDescriptor is LocalVariableDescriptor) return listOf(declaration) - - val project = declaration.project - val overriddenElementsToDescriptor = HashMap() - for (overriddenDescriptor in DescriptorUtils.getAllOverriddenDescriptors(declarationDescriptor)) { - val overriddenDeclaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, overriddenDescriptor) ?: continue - if (overriddenDeclaration is KtNamedFunction || overriddenDeclaration is KtProperty || overriddenDeclaration is PsiMethod || overriddenDeclaration is KtParameter) { - overriddenElementsToDescriptor[overriddenDeclaration] = overriddenDescriptor - } - } - if (ignore != null) { - overriddenElementsToDescriptor.keys.removeAll(ignore) - } - - if (overriddenElementsToDescriptor.isEmpty()) return listOf(declaration) - - return askUserForMethodsToSearch(declarationDescriptor, overriddenElementsToDescriptor) -} - -fun checkSuperMethodsWithPopup( - declaration: KtNamedDeclaration, - deepestSuperMethods: List, - actionString: String, - editor: Editor, - action: (List) -> Unit -) { - if (deepestSuperMethods.isEmpty()) return action(listOf(declaration)) - - val superMethod = deepestSuperMethods.first() - - val (superClass, isAbstract) = when (superMethod) { - is PsiMember -> superMethod.containingClass to superMethod.hasModifierProperty(PsiModifier.ABSTRACT) - is KtNamedDeclaration -> superMethod.containingClassOrObject to superMethod.isAbstract() - else -> null - } ?: return action(listOf(declaration)) - if (superClass == null) return action(listOf(declaration)) - - if (ApplicationManager.getApplication().isUnitTestMode) return action(deepestSuperMethods) - - val kind = when (declaration) { - is KtNamedFunction -> "function" - is KtProperty, is KtParameter -> "property" - else -> return - } - - val unwrappedSupers = deepestSuperMethods.mapNotNull { it.namedUnwrappedElement } - val hasJavaMethods = unwrappedSupers.any { it is PsiMethod } - val hasKtMembers = unwrappedSupers.any { it is KtNamedDeclaration } - val superKind = when { - hasJavaMethods && hasKtMembers -> "member" - hasJavaMethods -> "method" - else -> kind - } - - val renameBase = actionString + " base $superKind" + (if (deepestSuperMethods.size > 1) "s" else "") - val renameCurrent = "$actionString only current $kind" - val title = buildString { - append(declaration.name) - append(if (isAbstract) " implements " else " overrides ") - append(ElementDescriptionUtil.getElementDescription(superMethod, UsageViewTypeLocation.INSTANCE)) - append(" of ") - append(SymbolPresentationUtil.getSymbolPresentableText(superClass)) - } - - JBPopupFactory.getInstance() - .createPopupChooserBuilder(listOf(renameBase, renameCurrent)) - .setTitle(title) - .setMovable(false) - .setResizable(false) - .setRequestFocus(true) - .setItemChosenCallback { selected -> - if (selected == renameBase) { - val ableToRename = declaration.project.let { project -> - deepestSuperMethods.all { PsiElementRenameHandler.canRename(project, editor, it) } - } - if (ableToRename) action(deepestSuperMethods + declaration) - } else action(listOf(declaration)) - } - .createPopup() - .showInBestPositionFor(editor) -} - -fun KtNamedDeclaration.isCompanionMemberOf(klass: KtClassOrObject): Boolean { - val containingObject = containingClassOrObject as? KtObjectDeclaration ?: return false - return containingObject.isCompanion() && containingObject.containingClassOrObject == klass -} - -internal fun KtDeclaration.withExpectedActuals(): List { - val expect = liftToExpected() ?: return listOf(this) - val actuals = expect.actualsForExpected() - return listOf(expect) + actuals -} - -internal fun KtDeclaration.resolveToExpectedDescriptorIfPossible(): DeclarationDescriptor { - val descriptor = unsafeResolveToDescriptor() - return descriptor.liftToExpected() ?: descriptor -} - -fun DialogWrapper.showWithTransaction() { - TransactionGuard.submitTransaction(disposable, Runnable { show() }) -} - -fun PsiMethod.checkDeclarationConflict(name: String, conflicts: MultiMap, callables: Collection) { - containingClass - ?.findMethodsByName(name, true) - // as is necessary here: see KT-10386 - ?.firstOrNull { it.parameterList.parametersCount == 0 && !callables.contains(it.namedUnwrappedElement as PsiElement?) } - ?.let { reportDeclarationConflict(conflicts, it) { s -> "$s already exists" } } -} - -fun T.replaceWithCopyWithResolveCheck( - resolveStrategy: (T, BindingContext) -> DeclarationDescriptor?, - context: BindingContext = analyze(), - preHook: T.() -> Unit = {}, - postHook: T.() -> T? = { this } -): T? { - val originDescriptor = resolveStrategy(this, context) ?: return null - @Suppress("UNCHECKED_CAST") val elementCopy = copy() as T - elementCopy.preHook() - val newContext = elementCopy.analyzeAsReplacement(this, context) - val newDescriptor = resolveStrategy(elementCopy, newContext) ?: return null - - return if (originDescriptor.canonicalRender() == newDescriptor.canonicalRender()) elementCopy.postHook() else null -} - -@Deprecated( - "Use org.jetbrains.kotlin.idea.core.util.getLineCount() instead", - ReplaceWith("this.getLineCount()", "org.jetbrains.kotlin.idea.core.util.getLineCount"), - DeprecationLevel.ERROR -) -fun PsiElement.getLineCount(): Int { - return newGetLineCount() -} - -@Deprecated( - "Use org.jetbrains.kotlin.idea.core.util.toPsiDirectory() instead", - ReplaceWith("this.toPsiDirectory()", "org.jetbrains.kotlin.idea.core.util.toPsiDirectory"), - DeprecationLevel.ERROR -) -fun VirtualFile.toPsiDirectory(project: Project): PsiDirectory? { - return newToPsiDirectory(project) -} - -@Deprecated( - "Use org.jetbrains.kotlin.idea.core.util.toPsiFile() instead", - ReplaceWith("this.toPsiFile()", "org.jetbrains.kotlin.idea.core.util.toPsiFile"), - DeprecationLevel.ERROR -) -fun VirtualFile.toPsiFile(project: Project): PsiFile? { - return newToPsiFile(project) -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/roots/projectRootUtils.kt.192 b/idea/src/org/jetbrains/kotlin/idea/roots/projectRootUtils.kt.192 deleted file mode 100644 index 00e481bf956..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/roots/projectRootUtils.kt.192 +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.roots - -import com.intellij.openapi.externalSystem.model.DataNode -import com.intellij.openapi.module.Module -import com.intellij.openapi.module.ModuleManager -import com.intellij.openapi.project.Project -import com.intellij.openapi.project.rootManager -import com.intellij.openapi.roots.ModifiableRootModel -import com.intellij.openapi.roots.ModuleRootManager -import com.intellij.openapi.roots.ProjectRootManager -import com.intellij.openapi.roots.SourceFolder -import com.intellij.openapi.vfs.NonPhysicalFileSystem -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiCodeFragment -import com.intellij.psi.PsiFile -import com.intellij.util.containers.ContainerUtil -import org.jetbrains.jps.model.JpsElement -import org.jetbrains.jps.model.ex.JpsElementBase -import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes -import org.jetbrains.jps.model.java.JavaResourceRootType -import org.jetbrains.jps.model.java.JavaSourceRootProperties -import org.jetbrains.jps.model.java.JavaSourceRootType -import org.jetbrains.jps.model.module.JpsModuleSourceRoot -import org.jetbrains.jps.model.module.JpsModuleSourceRootType -import org.jetbrains.kotlin.config.* -import org.jetbrains.kotlin.idea.framework.KotlinSdkType -import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData -import java.util.* - -private fun JpsModuleSourceRoot.getOrCreateProperties() = - getProperties(rootType)?.also { (it as? JpsElementBase<*>)?.setParent(null) } ?: rootType.createDefaultProperties() - -fun JpsModuleSourceRoot.getMigratedSourceRootTypeWithProperties(): Pair, JpsElement>? { - val currentRootType = rootType - - @Suppress("UNCHECKED_CAST") - val newSourceRootType: JpsModuleSourceRootType = when (currentRootType) { - JavaSourceRootType.SOURCE -> SourceKotlinRootType as JpsModuleSourceRootType - JavaSourceRootType.TEST_SOURCE -> TestSourceKotlinRootType - JavaResourceRootType.RESOURCE -> ResourceKotlinRootType - JavaResourceRootType.TEST_RESOURCE -> TestResourceKotlinRootType - else -> return null - } as JpsModuleSourceRootType - return newSourceRootType to getOrCreateProperties() -} - -fun migrateNonJvmSourceFolders(modifiableRootModel: ModifiableRootModel) { - for (contentEntry in modifiableRootModel.contentEntries) { - for (sourceFolder in contentEntry.sourceFolders) { - val (newSourceRootType, properties) = sourceFolder.jpsElement.getMigratedSourceRootTypeWithProperties() ?: continue - val url = sourceFolder.url - contentEntry.removeSourceFolder(sourceFolder) - contentEntry.addSourceFolder(url, newSourceRootType, properties) - } - } - KotlinSdkType.setUpIfNeeded() -} - -fun populateNonJvmSourceRootTypes(sourceSetNode: DataNode, module: Module) = Unit - -fun getKotlinAwareDestinationSourceRoots(project: Project): List { - return ModuleManager.getInstance(project).modules.flatMap { it.collectKotlinAwareDestinationSourceRoots() } -} - -private val KOTLIN_AWARE_SOURCE_ROOT_TYPES: Set> = - JavaModuleSourceRootTypes.SOURCES + ALL_KOTLIN_SOURCE_ROOT_TYPES - -private fun Module.collectKotlinAwareDestinationSourceRoots(): List { - return rootManager - .contentEntries - .asSequence() - .flatMap { it.getSourceFolders(KOTLIN_AWARE_SOURCE_ROOT_TYPES).asSequence() } - .filterNot { isForGeneratedSources(it) } - .mapNotNull { it.file } - .toList() -} - -fun isOutsideSourceRootSet(psiFile: PsiFile?, sourceRootTypes: Set>): Boolean { - if (psiFile == null || psiFile is PsiCodeFragment) return false - val file = psiFile.virtualFile ?: return false - if (file.fileSystem is NonPhysicalFileSystem) return false - val projectFileIndex = ProjectRootManager.getInstance(psiFile.project).fileIndex - return !projectFileIndex.isUnderSourceRootOfType(file, sourceRootTypes) && !projectFileIndex.isInLibrary(file) -} - -fun isOutsideKotlinAwareSourceRoot(psiFile: PsiFile?) = isOutsideSourceRootSet(psiFile, KOTLIN_AWARE_SOURCE_ROOT_TYPES) - -/** - * @return list of all java source roots in the project which can be suggested as a target directory for a class created by user - */ -fun getSuitableDestinationSourceRoots(project: Project): List { - val roots = ArrayList() - for (module in ModuleManager.getInstance(project).modules) { - collectSuitableDestinationSourceRoots(module, roots) - } - return roots -} - -fun collectSuitableDestinationSourceRoots(module: Module, result: MutableList) { - for (entry in ModuleRootManager.getInstance(module).contentEntries) { - for (sourceFolder in entry.getSourceFolders(KOTLIN_AWARE_SOURCE_ROOT_TYPES)) { - if (!isForGeneratedSources(sourceFolder)) { - ContainerUtil.addIfNotNull(result, sourceFolder.file) - } - } - } -} - -fun isForGeneratedSources(sourceFolder: SourceFolder): Boolean { - val properties = sourceFolder.jpsElement.getProperties(KOTLIN_AWARE_SOURCE_ROOT_TYPES) - val javaResourceProperties = sourceFolder.jpsElement.getProperties(JavaModuleSourceRootTypes.RESOURCES) - val kotlinResourceProperties = sourceFolder.jpsElement.getProperties(ALL_KOTLIN_RESOURCE_ROOT_TYPES) - return properties != null && properties.isForGeneratedSources - || (javaResourceProperties != null && javaResourceProperties.isForGeneratedSources) - || (kotlinResourceProperties != null && kotlinResourceProperties.isForGeneratedSources) -} diff --git a/idea/src/org/jetbrains/kotlin/idea/util/ProgressIndicatorUtils.kt.192 b/idea/src/org/jetbrains/kotlin/idea/util/ProgressIndicatorUtils.kt.192 deleted file mode 100644 index 0af220d261a..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/util/ProgressIndicatorUtils.kt.192 +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.util - -import com.intellij.openapi.Disposable -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.progress.ProcessCanceledException -import com.intellij.openapi.progress.ProgressManager -import com.intellij.openapi.progress.util.BackgroundTaskUtil -import com.intellij.openapi.project.DumbService -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.Computable -import com.intellij.openapi.util.ThrowableComputable -import org.jetbrains.annotations.Nls -import org.jetbrains.kotlin.idea.util.application.runReadAction -import java.util.concurrent.Future -import java.util.concurrent.TimeUnit -import java.util.concurrent.TimeoutException - -object ProgressIndicatorUtils { - private val LOG = Logger.getInstance(ProgressIndicatorUtils::class.java) - - @JvmStatic - fun underModalProgress( - project: Project, - @Nls progressTitle: String, - computable: () -> T - ): T { - val dumbService = DumbService.getInstance(project) - val useAlternativeResolve = dumbService.isAlternativeResolveEnabled - val inReadAction = - ThrowableComputable { runReadAction { return@runReadAction computable() } } - val prioritizedRunnable = - ThrowableComputable { ProgressManager.getInstance().computePrioritized(inReadAction) } - val process = - if (useAlternativeResolve) ThrowableComputable { dumbService.computeWithAlternativeResolveEnabled(prioritizedRunnable) } else prioritizedRunnable - return ProgressManager.getInstance().runProcessWithProgressSynchronously(process, progressTitle, true, project) - } - - fun runUnderDisposeAwareIndicator( - parent: Disposable, - computable: () -> T - ): T = BackgroundTaskUtil.runUnderDisposeAwareIndicator(parent, Computable { computable() }) - - @JvmStatic - fun awaitWithCheckCanceled(future: Future): T { - while (true) { - ProgressManager.checkCanceled() - try { - return future.get(50, TimeUnit.MILLISECONDS) - } catch (e: TimeoutException) { - // ignore - } catch (e: Exception) { - LOG.warn(e) - throw ProcessCanceledException(e) - } - } - } -} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt.192 b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt.192 deleted file mode 100644 index a1a64d7a054..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinUpdatePluginComponent.kt.192 +++ /dev/null @@ -1,70 +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.versions - -import com.intellij.ide.util.PropertiesComponent -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.BaseComponent -import com.intellij.openapi.vfs.JarFileSystem -import com.intellij.openapi.vfs.LocalFileSystem -import com.intellij.openapi.vfs.VfsUtilCore -import com.intellij.openapi.vfs.VirtualFileVisitor -import com.intellij.openapi.vfs.newvfs.NewVirtualFile -import org.jetbrains.kotlin.idea.KotlinPluginUtil -import java.io.File - -private val INSTALLED_KOTLIN_VERSION = "installed.kotlin.plugin.version" - -/** - * Component forces update for built-in libraries in plugin directory. They are ignored because of - * com.intellij.util.indexing.FileBasedIndex.isUnderConfigOrSystem() - */ -// FIX ME WHEN BUNCH 192 REMOVED -class KotlinUpdatePluginComponent : BaseComponent { - override fun initComponent() { - if (ApplicationManager.getApplication()?.isUnitTestMode == true) { - return - } - - val installedKotlinVersion = PropertiesComponent.getInstance()?.getValue(INSTALLED_KOTLIN_VERSION) - - if (installedKotlinVersion == null || KotlinPluginUtil.getPluginVersion() != installedKotlinVersion) { - // Force refresh jar handlers - for (libraryJarDescriptor in LibraryJarDescriptor.values()) { - requestFullJarUpdate(libraryJarDescriptor.getPathInPlugin()) - } - - PropertiesComponent.getInstance()?.setValue(INSTALLED_KOTLIN_VERSION, KotlinPluginUtil.getPluginVersion()) - } - } - - override fun getComponentName(): String { - return "ReindexBundledRuntimeComponent" - } - - override fun disposeComponent() { - } - - private fun requestFullJarUpdate(jarFilePath: File) { - val localVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jarFilePath) ?: return - - // Build and update JarHandler - val jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(localVirtualFile) ?: return - VfsUtilCore.visitChildrenRecursively(jarFile, object : VirtualFileVisitor() {}) - ((jarFile as NewVirtualFile)).markDirtyRecursively() - } -} diff --git a/idea/testData/decompiler/navigation/userJavaCode/ClassAndConstuctors.java.libsrc.fail.192 b/idea/testData/decompiler/navigation/userJavaCode/ClassAndConstuctors.java.libsrc.fail.192 deleted file mode 100644 index cd8c8240431..00000000000 --- a/idea/testData/decompiler/navigation/userJavaCode/ClassAndConstuctors.java.libsrc.fail.192 +++ /dev/null @@ -1,5 +0,0 @@ -Actual data differs from file content: ClassAndConstuctors.source.expected expected:< [SomeClassWithConstructors.class -public final class <1><2><3><4>SomeClassWithConstructors public constructor(arg: kotlin.String)] { -> but was:< [classAndConstructors.kt -class <1><2><3><4>SomeClassWithConstructors(private val arg: String) ] { -> \ No newline at end of file diff --git a/idea/testData/decompiler/navigation/userJavaCode/OverloadedFun.java.libsrc.fail.192 b/idea/testData/decompiler/navigation/userJavaCode/OverloadedFun.java.libsrc.fail.192 deleted file mode 100644 index 07fe0e9c91b..00000000000 --- a/idea/testData/decompiler/navigation/userJavaCode/OverloadedFun.java.libsrc.fail.192 +++ /dev/null @@ -1,10 +0,0 @@ -Actual data differs from file content: OverloadedFun.source.expected expected:<...d from a class file -[// Implementation of methods is not available - -package testData.libraries - -@kotlin.jvm.JvmOverloads public fun kotlin.String.<2><4><6>overloadedFun(vararg specs: kotlin.String, allowExisting: kotlin.Boolean /* = compiled code */, x: kotlin.Int, y: kotlin.Int /* = compiled code */, z: T): kotlin.String { /* compiled code */ }] -> but was:<...d from a class file -[ overloadedFun.kt -fun String.<2><4><6>overloadedFun(vararg specs: String, allowExisting: Boolean = false, x: Int, y: Int = 2, z: T): String {] -> \ No newline at end of file diff --git a/idea/testData/decompiler/navigation/userJavaCode/RenamedElements.java.libsrc.fail.192 b/idea/testData/decompiler/navigation/userJavaCode/RenamedElements.java.libsrc.fail.192 deleted file mode 100644 index 4c177094b04..00000000000 --- a/idea/testData/decompiler/navigation/userJavaCode/RenamedElements.java.libsrc.fail.192 +++ /dev/null @@ -1,12 +0,0 @@ -Actual data differs from file content: RenamedElements.source.expected expected:<[RenamedElementsKt.class -<1>// IntelliJ API Decompiler stub source generated from a class file -// Implementation of methods is not available - -package testData.libraries - -@kotlin.jvm.JvmName public fun <2>funToRename(x: kotlin.Int): kotlin.Unit { /* compiled code */ }] -> but was:<[ RenamedElementsKt.class -<1>// IntelliJ API Decompiler stub source generated from a class file - renamedElements.kt -fun <2>funToRename(x: Int) {] -> \ No newline at end of file diff --git a/idea/testData/decompiler/navigation/usercode/TypeAlias.kt.libsrc.fail.192 b/idea/testData/decompiler/navigation/usercode/TypeAlias.kt.libsrc.fail.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/testData/decompiler/navigation/usercode/TypeAlias.kt.libsrcjs.fail.192 b/idea/testData/decompiler/navigation/usercode/TypeAlias.kt.libsrcjs.fail.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.0.kt.fail.192 b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.0.kt.fail.192 deleted file mode 100644 index 80a0350d0f4..00000000000 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibraryNestedClassSecondaryConstructorUsages.0.kt.fail.192 +++ /dev/null @@ -1,9 +0,0 @@ -Actual data differs from file content: LibraryNestedClassSecondaryConstructorUsages.results.txt expected:<...3 class Y(): A.T() -[[LibraryNestedClassSecondaryConstructorUsages.1.java] New instance creation 14 A.T a = new A.T(); -[LibraryNestedClassSecondaryConstructorUsages.1.java] Unclassified usage 10 super(); -[LibraryNestedClassSecondaryConstructorUsages.1.java] Unclassified usage 6 public J() { -[library.kt] New instance creation 64 val tt = A.T() -[library.kt] Supertype 40 class VV(): A.T() -]> but was:<...3 class Y(): A.T() -[[library.kt] New instance creation 64 val tt = A.T() -[library.kt] Supertype 40 class VV(): A.T()]> \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.0.kt.fail.192 b/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.0.kt.fail.192 deleted file mode 100644 index 80394f51d40..00000000000 --- a/idea/testData/findUsages/libraryUsages/kotlinLibrary/LibrarySecondaryConstructorUsages.0.kt.fail.192 +++ /dev/null @@ -1,6 +0,0 @@ -Actual data differs from file content: LibrarySecondaryConstructorUsages.results.txt expected:<... 13 class Y(): A() -[[LibrarySecondaryConstructorUsages.1.java] New instance creation 14 A a = new A(); -[LibrarySecondaryConstructorUsages.1.java] Unclassified usage 10 super(); -[LibrarySecondaryConstructorUsages.1.java] Unclassified usage 6 public J() { -[]library.kt] New inst...> but was:<... 13 class Y(): A() -[[]library.kt] New inst...> \ No newline at end of file diff --git a/idea/testData/gradle/configurator/configureKotlinDevVersion/build.gradle.after.192 b/idea/testData/gradle/configurator/configureKotlinDevVersion/build.gradle.after.192 deleted file mode 100644 index e796ed80335..00000000000 --- a/idea/testData/gradle/configurator/configureKotlinDevVersion/build.gradle.after.192 +++ /dev/null @@ -1,24 +0,0 @@ -plugins { - id 'org.jetbrains.kotlin.jvm' version '1.2.60-dev-286' -} -group 'testgroup' -version '1.0-SNAPSHOT' -repositories { - maven { - url 'https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.2.60-dev-286,branch:(default:any)/artifacts/content/maven' - } - mavenCentral() -} -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" -} -compileKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} -compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} diff --git a/idea/testData/hierarchy/calls/callers/kotlinClass/KotlinClass_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinClass/KotlinClass_verification.xml.192 deleted file mode 100644 index 4bb58ee5816..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinClass/KotlinClass_verification.xml.192 +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callers/kotlinFunction/KotlinFunction_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinFunction/KotlinFunction_verification.xml.192 deleted file mode 100644 index a217f227f31..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinFunction/KotlinFunction_verification.xml.192 +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callers/kotlinNestedClass/KotlinNestedClass_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinNestedClass/KotlinNestedClass_verification.xml.192 deleted file mode 100644 index 2fd5633ea81..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinNestedClass/KotlinNestedClass_verification.xml.192 +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callers/kotlinNestedInnerClass/KotlinNestedInnerClass_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinNestedInnerClass/KotlinNestedInnerClass_verification.xml.192 deleted file mode 100644 index 2fd5633ea81..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinNestedInnerClass/KotlinNestedInnerClass_verification.xml.192 +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callers/kotlinPackageFunction/KotlinPackageFunction_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinPackageFunction/KotlinPackageFunction_verification.xml.192 deleted file mode 100644 index bc5d565ec44..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinPackageFunction/KotlinPackageFunction_verification.xml.192 +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callers/kotlinPackageProperty/KotlinPackageProperty_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinPackageProperty/KotlinPackageProperty_verification.xml.192 deleted file mode 100644 index cc5f0550703..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinPackageProperty/KotlinPackageProperty_verification.xml.192 +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callers/kotlinProperty/KotlinProperty_verification.xml.192 b/idea/testData/hierarchy/calls/callers/kotlinProperty/KotlinProperty_verification.xml.192 deleted file mode 100644 index 5c043b80d32..00000000000 --- a/idea/testData/hierarchy/calls/callers/kotlinProperty/KotlinProperty_verification.xml.192 +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/idea/testData/hierarchy/calls/callersJava/javaMethod/JavaMethod_verification.xml.192 b/idea/testData/hierarchy/calls/callersJava/javaMethod/JavaMethod_verification.xml.192 deleted file mode 100644 index bc89a4b1c3c..00000000000 --- a/idea/testData/hierarchy/calls/callersJava/javaMethod/JavaMethod_verification.xml.192 +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/idea/testData/resolve/referenceInLib/inLibrarySource.kt.fail.192 b/idea/testData/resolve/referenceInLib/inLibrarySource.kt.fail.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/testData/resolve/referenceInLib/toFunParameter.kt.fail.192 b/idea/testData/resolve/referenceInLib/toFunParameter.kt.fail.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/testData/resolve/referenceInLib/toLocalFun.kt.fail.192 b/idea/testData/resolve/referenceInLib/toLocalFun.kt.fail.192 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt.192 b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt.192 deleted file mode 100644 index 103160cf86d..00000000000 --- a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt.192 +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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 - -import com.intellij.openapi.util.io.FileUtil -import com.intellij.testFramework.LightProjectDescriptor -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.descriptors.PackageViewDescriptor -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -import org.jetbrains.kotlin.psi.KtExpression -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoAfter -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue -import org.jetbrains.kotlin.resolve.calls.smartcasts.IdentifierInfo -import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitReceiver -import org.jetbrains.kotlin.test.KotlinTestUtils -import java.io.File - -abstract class AbstractDataFlowValueRenderingTest : KotlinLightCodeInsightFixtureTestCase() { - - private fun IdentifierInfo.render(): String? = when (this) { - is IdentifierInfo.Expression -> expression.text - is IdentifierInfo.Receiver -> (value as? ImplicitReceiver)?.declarationDescriptor?.name?.let { "this@$it" } - is IdentifierInfo.Variable -> variable.name.asString() - is IdentifierInfo.PackageOrClass -> (descriptor as? PackageViewDescriptor)?.let { it.fqName.asString() } - is IdentifierInfo.Qualified -> receiverInfo.render() + "." + selectorInfo.render() - else -> null - } - - private fun DataFlowValue.render() = - // If it is not a stable identifier, there's no point in rendering it - if (!isStable) null - else identifierInfo.render() - - override fun getTestDataPath(): String = PluginTestCaseBase.getTestDataPathBase() + "/dataFlowValueRendering/" - - override fun getProjectDescriptor(): LightProjectDescriptor { - return LightCodeInsightFixtureTestCase.JAVA_LATEST - } - - fun doTest(fileName: String) { - val fixture = myFixture - fixture.configureByFile(fileName) - - val jetFile = fixture.file as KtFile - val element = jetFile.findElementAt(fixture.caretOffset)!! - val expression = element.getStrictParentOfType()!! - val info = expression.analyze().getDataFlowInfoAfter(expression) - - val allValues = (info.completeTypeInfo.keySet() + info.completeNullabilityInfo.keySet()).toSet() - val actual = allValues.mapNotNull { it.render() }.sorted().joinToString("\n") - - KotlinTestUtils.assertEqualsToFile(File(FileUtil.getNameWithoutExtension(fileName) + ".txt"), actual) - } -} diff --git a/idea/tests/org/jetbrains/kotlin/copyright/AbstractUpdateKotlinCopyrightTest.kt.192 b/idea/tests/org/jetbrains/kotlin/copyright/AbstractUpdateKotlinCopyrightTest.kt.192 deleted file mode 100644 index 374549a00a0..00000000000 --- a/idea/tests/org/jetbrains/kotlin/copyright/AbstractUpdateKotlinCopyrightTest.kt.192 +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.copyright - -import junit.framework.AssertionFailedError -import org.jetbrains.kotlin.idea.copyright.UpdateKotlinCopyright -import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -import org.jetbrains.kotlin.test.InTextDirectivesUtils -import org.junit.Assert -import java.io.File - -abstract class AbstractUpdateKotlinCopyrightTest : KotlinLightCodeInsightFixtureTestCase() { - fun doTest(path: String) { - myFixture.configureByFile(path) - - val fileText = myFixture.file.text.trim() - val expectedNumberOfComments = InTextDirectivesUtils.getPrefixedInt(fileText, "// COMMENTS: ") ?: run { - if (fileText.isNotEmpty()) { - throw AssertionFailedError("Every test should assert number of comments with `COMMENTS` directive") - } else { - 0 - } - } - - val comments = UpdateKotlinCopyright.getExistentComments(myFixture.file) - for (comment in comments) { - val commentText = comment.text - when { - commentText.contains("PRESENT") -> { - } - commentText.contains("ABSENT") -> { - throw AssertionFailedError("Unexpected comment found: `$commentText`") - } - else -> { - throw AssertionFailedError("A comment with bad directive found: `$commentText`") - } - } - } - - Assert.assertEquals( - "Wrong number of comments found:\n${comments.joinToString(separator = "\n") { it.text }}\n", - expectedNumberOfComments, comments.size - ) - } - - override fun getTestDataPath() = File(PluginTestCaseBase.getTestDataPathBase(), "/copyright").path + File.separator -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/codevision/AbstractKotlinCodeVisionProviderTest.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/codevision/AbstractKotlinCodeVisionProviderTest.kt.192 deleted file mode 100644 index d8405d1dfe3..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/codevision/AbstractKotlinCodeVisionProviderTest.kt.192 +++ /dev/null @@ -1 +0,0 @@ -package org.jetbrains.kotlin.idea.codeInsight.codevision \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/codevision/KotlinCodeVisionProviderTestGenerated.java.192 b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/codevision/KotlinCodeVisionProviderTestGenerated.java.192 deleted file mode 100644 index 971778b8289..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/codevision/KotlinCodeVisionProviderTestGenerated.java.192 +++ /dev/null @@ -1 +0,0 @@ -package org.jetbrains.kotlin.idea.codeInsight.codevision; \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinLambdasHintsProviderTest.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinLambdasHintsProviderTest.kt.192 deleted file mode 100644 index bd95a065cae..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinLambdasHintsProviderTest.kt.192 +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight.hints \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinReferenceTypeHintsProviderTest.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinReferenceTypeHintsProviderTest.kt.192 deleted file mode 100644 index bd95a065cae..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/AbstractKotlinReferenceTypeHintsProviderTest.kt.192 +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight.hints \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferenceTypeHintsProviderTestGenerated.java.192 b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferenceTypeHintsProviderTestGenerated.java.192 deleted file mode 100644 index 9c764ffd2c2..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/hints/KotlinReferenceTypeHintsProviderTestGenerated.java.192 +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.codeInsight.hints; \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 deleted file mode 100644 index b26b5abe2c3..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea - -import com.intellij.ide.hierarchy.HierarchyTreeStructure -import com.intellij.openapi.Disposable -import com.intellij.openapi.extensions.ExtensionPointName -import com.intellij.openapi.util.Computable -import com.intellij.testFramework.PlatformTestUtil -import com.intellij.testFramework.codeInsight.hierarchy.HierarchyViewTestFixture - -// FIX ME WHEN BUNCH 192 REMOVED -@Suppress("UNUSED_PARAMETER") -fun doHierarchyTestCompat( - hierarchyFixture: HierarchyViewTestFixture, - treeStructureComputable: Computable, - expectedStructure: String, -) { - hierarchyFixture.doHierarchyTest(treeStructureComputable.compute(), expectedStructure) -} - -fun maskExtensions( - pointName: ExtensionPointName, - newExtensions: List, - parentDisposable: Disposable -) { - PlatformTestUtil.maskExtensions(pointName, newExtensions, parentDisposable) -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureProjectByChangingFileTest.java.192 b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureProjectByChangingFileTest.java.192 deleted file mode 100644 index d4007bb7ca8..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureProjectByChangingFileTest.java.192 +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleType; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.openapi.vfs.CharsetToolkit; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiJavaModule; -import com.intellij.psi.search.FilenameIndex; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.testFramework.LightProjectDescriptor; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.idea.core.script.ScriptUtilsKt; -import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightTestCase; -import org.jetbrains.kotlin.test.InTextDirectivesUtils; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.plugins.groovy.GroovyFileType; - -import java.io.File; -import java.io.IOException; -import java.util.Objects; - -@SuppressWarnings("deprecation") -public abstract class AbstractConfigureProjectByChangingFileTest - extends KotlinLightCodeInsightTestCase { - private static final String DEFAULT_VERSION = "default_version"; - - private PsiFile moduleInfoFile; - - @Override - protected void setUp() throws Exception { - super.setUp(); - ApplicationManager.getApplication().runWriteAction( - () -> FileTypeManager.getInstance().associateExtension(GroovyFileType.GROOVY_FILE_TYPE, "gradle") - ); - } - - @Override - protected void tearDown() throws Exception { - moduleInfoFile = null; - super.tearDown(); - } - - protected void doTest(@NotNull String beforeFile, @NotNull String afterFile, @NotNull C configurator) throws Exception { - configureByFile(beforeFile); - - prepareModuleInfoFile(beforeFile); - - String versionFromFile = InTextDirectivesUtils.findStringWithPrefixes(getFile().getText(), "// VERSION:"); - String version = versionFromFile != null ? versionFromFile : DEFAULT_VERSION; - - NotificationMessageCollector collector = NotificationMessageCollectorKt.createConfigureKotlinNotificationCollector(getProject()); - - runConfigurator(getModule(), getFile(), configurator, version, collector); - - collector.showNotification(); - - KotlinTestUtils.assertEqualsToFile(new File(afterFile), getFile().getText().replace(version, "$VERSION$")); - - checkModuleInfoFile(beforeFile); - } - - private void prepareModuleInfoFile(@NotNull String beforeFile) throws IOException { - File file = new File(beforeFile); - String parent = file.getParent(); - File moduleInfo = new File(parent, PsiJavaModule.MODULE_INFO_FILE); - moduleInfoFile = null; - if (moduleInfo.exists()) { - String fileText = FileUtilRt.loadFile(moduleInfo, CharsetToolkit.UTF8, true); - createAndSaveFile(PsiJavaModule.MODULE_INFO_FILE, fileText); - - PsiFile[] moduleInfoFiles = - FilenameIndex.getFilesByName(getProject(), PsiJavaModule.MODULE_INFO_FILE, GlobalSearchScope.allScope(getProject())); - assertTrue(PsiJavaModule.MODULE_INFO_FILE + " should be present in index", moduleInfoFiles.length == 1); - moduleInfoFile = moduleInfoFiles[0]; - } - } - - private void checkModuleInfoFile(@NotNull String beforeFile) { - File file = new File(beforeFile); - String parent = file.getParent(); - - if (moduleInfoFile != null) { - String afterFileName = PsiJavaModule.MODULE_INFO_FILE.replace(".java", "_after.java"); - commitAllDocuments(); - KotlinTestUtils.assertEqualsToFile(new File(parent, afterFileName), moduleInfoFile.getText()); - } - } - - protected abstract void runConfigurator( - Module module, @NotNull PsiFile file, - @NotNull C configurator, - @NotNull String version, - @NotNull NotificationMessageCollector collector - ); - - @NotNull - @Override - protected String getTestDataPath() { - return ""; - } - - @NotNull - @Override - protected LightProjectDescriptor getProjectDescriptor() { - return new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK()); - } - - private static class SimpleLightProjectDescriptor extends LightProjectDescriptor { - @NotNull private final ModuleType myModuleType; - @Nullable private final Sdk mySdk; - - SimpleLightProjectDescriptor(@NotNull ModuleType moduleType, @Nullable Sdk sdk) { - myModuleType = moduleType; - mySdk = sdk; - } - - @NotNull - @Override - public ModuleType getModuleType() { - return myModuleType; - } - - @Nullable - @Override - public Sdk getSdk() { - return mySdk; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SimpleLightProjectDescriptor that = (SimpleLightProjectDescriptor)o; - - if (!myModuleType.equals(that.myModuleType)) return false; - return areJdksEqual(that.getSdk()); - } - - @Override - public int hashCode() { - return myModuleType.hashCode(); - } - - private boolean areJdksEqual(Sdk newSdk) { - if (mySdk == null || newSdk == null) return mySdk == newSdk; - - if (!Objects.equals(mySdk.getVersionString(), newSdk.getVersionString())) { - return false; - } - - String[] myUrls = mySdk.getRootProvider().getUrls(OrderRootType.CLASSES); - String[] newUrls = newSdk.getRootProvider().getUrls(OrderRootType.CLASSES); - return ContainerUtil.newHashSet(myUrls).equals(ContainerUtil.newHashSet(newUrls)); - } - } -} diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/compat.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/configuration/compat.kt.192 deleted file mode 100644 index 1937528b34b..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/compat.kt.192 +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.configuration - -import com.intellij.openapi.project.Project -import com.intellij.openapi.project.ex.ProjectManagerEx -import java.nio.file.Path - -// FIX ME WHEN BUNCH 192 REMOVED -internal fun loadProjectCompat(projectFile: Path): Project { - return (ProjectManagerEx.getInstanceEx()).loadProject(projectFile.toFile().path)!! -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/AbstractParameterInfoTest.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/AbstractParameterInfoTest.kt.192 deleted file mode 100644 index a1bf7a4767d..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/AbstractParameterInfoTest.kt.192 +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.parameterInfo - -import com.intellij.codeInsight.hint.ShowParameterInfoContext -import com.intellij.codeInsight.hint.ShowParameterInfoHandler -import com.intellij.openapi.util.io.FileUtil -import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiWhiteSpace -import com.intellij.testFramework.LightProjectDescriptor -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import com.intellij.util.PathUtil -import org.jetbrains.kotlin.idea.KotlinLanguage -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources -import org.jetbrains.kotlin.idea.test.SdkAndMockLibraryProjectDescriptor -import org.jetbrains.kotlin.idea.test.withCustomCompilerOptions -import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.psiUtil.allChildren -import org.jetbrains.kotlin.test.InTextDirectivesUtils -import org.jetbrains.kotlin.test.KotlinTestUtils -import org.junit.Assert -import java.io.File - -abstract class AbstractParameterInfoTest : LightCodeInsightFixtureTestCase() { - override fun getProjectDescriptor(): LightProjectDescriptor { - val root = KotlinTestUtils.getTestsRoot(this::class.java) - if (root.contains("Lib")) { - return SdkAndMockLibraryProjectDescriptor("$root/sharedLib", true, true, false, false) - } - - return ProjectDescriptorWithStdlibSources.INSTANCE - } - - override fun setUp() { - super.setUp() - myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/parameterInfo" - } - - protected fun doTest(fileName: String) { - val prefix = FileUtil.getNameWithoutExtension(PathUtil.getFileName(fileName)) - val mainFile = File(FileUtil.toSystemDependentName(fileName)) - mainFile.parentFile - .listFiles { _, name -> name.startsWith("$prefix.") && name != mainFile.name } - .forEach { myFixture.configureByFile(FileUtil.toSystemIndependentName(it.path)) } - - myFixture.configureByFile(fileName) - - val file = myFixture.file as KtFile - - withCustomCompilerOptions(file.text, project, myFixture.module) { - val lastChild = file.allChildren.filter { it !is PsiWhiteSpace }.last() - val expectedResultText = when (lastChild.node.elementType) { - KtTokens.BLOCK_COMMENT -> lastChild.text.substring(2, lastChild.text.length - 2).trim() - KtTokens.EOL_COMMENT -> lastChild.text.substring(2).trim() - else -> error("Unexpected last file child") - } - - val context = ShowParameterInfoContext(editor, project, file, editor.caretModel.offset, -1, true) - - val handlers = ShowParameterInfoHandler.getHandlers(project, KotlinLanguage.INSTANCE)!! - val handler = handlers.firstOrNull { it.findElementForParameterInfo(context) != null } - ?: error("Could not find parameter info handler") - - val mockCreateParameterInfoContext = MockCreateParameterInfoContext(file, myFixture) - val parameterOwner = handler.findElementForParameterInfo(mockCreateParameterInfoContext) as PsiElement - - val textToType = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TYPE:") - if (textToType != null) { - myFixture.type(textToType) - PsiDocumentManager.getInstance(project).commitAllDocuments() - } - - //to update current parameter index - val updateContext = MockUpdateParameterInfoContext(file, myFixture, mockCreateParameterInfoContext) - val elementForUpdating = handler.findElementForUpdatingParameterInfo(updateContext) - if (elementForUpdating != null) { - handler.updateParameterInfo(elementForUpdating, updateContext) - } - - val parameterInfoUIContext = MockParameterInfoUIContext(parameterOwner, updateContext.currentParameter) - - mockCreateParameterInfoContext.itemsToShow?.forEach { - handler.updateUI(it, parameterInfoUIContext) - } - - Assert.assertEquals(expectedResultText, parameterInfoUIContext.resultText) - } - } -} diff --git a/idea/tests/org/jetbrains/kotlin/idea/script/extensionsUtil.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/script/extensionsUtil.kt.192 deleted file mode 100644 index 6959dea0ab0..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/script/extensionsUtil.kt.192 +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.idea.script - -import com.intellij.openapi.Disposable -import com.intellij.openapi.extensions.ExtensionPointName -import com.intellij.openapi.extensions.Extensions -import com.intellij.openapi.project.Project -import com.intellij.testFramework.PlatformTestUtil - -fun addExtensionPointInTest( - pointName: ExtensionPointName, - project: Project, - provider: T, - testRootDisposable: Disposable -) { - PlatformTestUtil.registerExtension( - Extensions.getArea(project), - pointName, - provider, - testRootDisposable - ) -} diff --git a/idea/tests/org/jetbrains/kotlin/test/util/ProjectStructureUtils.kt.192 b/idea/tests/org/jetbrains/kotlin/test/util/ProjectStructureUtils.kt.192 deleted file mode 100644 index d5cc0225953..00000000000 --- a/idea/tests/org/jetbrains/kotlin/test/util/ProjectStructureUtils.kt.192 +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.test.util - -import com.intellij.openapi.module.Module -import com.intellij.openapi.roots.DependencyScope -import com.intellij.openapi.roots.ModuleRootModificationUtil -import com.intellij.openapi.roots.OrderRootType -import com.intellij.openapi.roots.impl.libraries.LibraryEx -import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable -import com.intellij.openapi.roots.libraries.Library -import com.intellij.openapi.roots.libraries.PersistentLibraryKind -import com.intellij.openapi.vfs.JarFileSystem -import com.intellij.openapi.vfs.LocalFileSystem -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.PlatformTestCase -import org.jetbrains.kotlin.test.testFramework.runWriteAction -import java.io.File - -fun PlatformTestCase.projectLibrary( - libraryName: String = "TestLibrary", - classesRoot: VirtualFile? = null, - sourcesRoot: VirtualFile? = null, - kind: PersistentLibraryKind<*>? = null -): LibraryEx { - return runWriteAction { - val modifiableModel = ProjectLibraryTable.getInstance(project).modifiableModel - val library = try { - modifiableModel.createLibrary(libraryName, kind) as LibraryEx - } finally { - modifiableModel.commit() - } - with(library.modifiableModel) { - classesRoot?.let { addRoot(it, OrderRootType.CLASSES) } - sourcesRoot?.let { addRoot(it, OrderRootType.SOURCES) } - commit() - } - library - } -} - -val File.jarRoot: VirtualFile - get() { - val virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(this) ?: error("Cannot find file $this") - return JarFileSystem.getInstance().getRootByLocal(virtualFile) ?: error("Can't find root by file $virtualFile") - } - -fun Module.addDependency( - library: Library, - dependencyScope: DependencyScope = DependencyScope.COMPILE, - exported: Boolean = false -) = ModuleRootModificationUtil.addDependency(this, library, dependencyScope, exported) diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/AbstractJavaToKotlinConverterForWebDemoTest.kt.192 b/j2k/tests/org/jetbrains/kotlin/j2k/AbstractJavaToKotlinConverterForWebDemoTest.kt.192 deleted file mode 100644 index fb7dde64b25..00000000000 --- a/j2k/tests/org/jetbrains/kotlin/j2k/AbstractJavaToKotlinConverterForWebDemoTest.kt.192 +++ /dev/null @@ -1,136 +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.j2k - -import com.intellij.codeInsight.ContainerProvider -import com.intellij.codeInsight.NullableNotNullManager -import com.intellij.codeInsight.NullableNotNullManagerImpl -import com.intellij.codeInsight.runner.JavaMainMethodProvider -import com.intellij.core.CoreApplicationEnvironment -import com.intellij.core.JavaCoreApplicationEnvironment -import com.intellij.core.JavaCoreProjectEnvironment -import com.intellij.lang.MetaLanguage -import com.intellij.lang.jvm.facade.JvmElementProvider -import com.intellij.openapi.extensions.Extensions -import com.intellij.openapi.extensions.ExtensionsArea -import com.intellij.openapi.fileTypes.FileTypeExtensionPoint -import com.intellij.openapi.util.Disposer -import com.intellij.openapi.util.io.FileUtil -import com.intellij.psi.* -import com.intellij.psi.augment.PsiAugmentProvider -import com.intellij.psi.augment.TypeAnnotationModifier -import com.intellij.psi.compiled.ClassFileDecompilers -import com.intellij.psi.impl.JavaClassSupersImpl -import com.intellij.psi.impl.PsiTreeChangePreprocessor -import com.intellij.psi.meta.MetaDataContributor -import com.intellij.psi.stubs.BinaryFileStubBuilders -import com.intellij.psi.util.JavaClassSupers -import junit.framework.TestCase -import org.jetbrains.kotlin.utils.PathUtil -import java.io.File -import java.net.URLClassLoader - -abstract class AbstractJavaToKotlinConverterForWebDemoTest : TestCase() { - val DISPOSABLE = Disposer.newDisposable() - - fun doTest(javaPath: String) { - try { - val fileContents = FileUtil.loadFile(File(javaPath), true) - val javaCoreEnvironment: JavaCoreProjectEnvironment = setUpJavaCoreEnvironment() - translateToKotlin(fileContents, javaCoreEnvironment.project) - } - finally { - Disposer.dispose(DISPOSABLE) - } - } - - fun setUpJavaCoreEnvironment(): JavaCoreProjectEnvironment { - Extensions.cleanRootArea(DISPOSABLE) - val area = Extensions.getRootArea() - - registerExtensionPoints(area) - - val applicationEnvironment = JavaCoreApplicationEnvironment(DISPOSABLE) - val javaCoreEnvironment = object : JavaCoreProjectEnvironment(DISPOSABLE, applicationEnvironment) { - override fun preregisterServices() { - val projectArea = Extensions.getArea(project) - CoreApplicationEnvironment.registerExtensionPoint(projectArea, PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor::class.java) - CoreApplicationEnvironment.registerExtensionPoint(projectArea, PsiElementFinder.EP_NAME, PsiElementFinder::class.java) - CoreApplicationEnvironment.registerExtensionPoint(projectArea, JvmElementProvider.EP_NAME, JvmElementProvider::class.java) - } - } - - javaCoreEnvironment.project.registerService(NullableNotNullManager::class.java, object : NullableNotNullManagerImpl(javaCoreEnvironment.project) { - override fun isNullable(owner: PsiModifierListOwner, checkBases: Boolean) = !isNotNull(owner, checkBases) - override fun isNotNull(owner: PsiModifierListOwner, checkBases: Boolean) = true - override fun hasHardcodedContracts(element: PsiElement): Boolean = false - override fun getNullables() = emptyList() - override fun setNullables(vararg p0: String) = Unit - override fun getNotNulls() = emptyList() - override fun setNotNulls(vararg p0: String) = Unit - override fun getDefaultNullable() = "" - override fun setDefaultNullable(defaultNullable: String) = Unit - override fun getDefaultNotNull() = "" - override fun setDefaultNotNull(p0: String) = Unit - override fun setInstrumentedNotNulls(p0: List) = Unit - override fun getInstrumentedNotNulls() = emptyList() - }) - - applicationEnvironment.application.registerService(JavaClassSupers::class.java, JavaClassSupersImpl::class.java) - - for (root in PathUtil.getJdkClassesRootsFromCurrentJre()) { - javaCoreEnvironment.addJarToClassPath(root) - } - val annotations: File? = findAnnotations() - if (annotations != null && annotations.exists()) { - javaCoreEnvironment.addJarToClassPath(annotations) - } - return javaCoreEnvironment - } - - private fun registerExtensionPoints(area: ExtensionsArea) { - CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint::class.java) - CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider::class.java) - - CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor::class.java) - CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider::class.java) - CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider::class.java) - - CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider::class.java) - CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler::class.java) - - CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier::class.java) - CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage::class.java) - CoreApplicationEnvironment.registerExtensionPoint(area, JavaModuleSystem.EP_NAME, JavaModuleSystem::class.java) - } - - fun findAnnotations(): File? { - var classLoader = JavaToKotlinTranslator::class.java.classLoader - while (classLoader != null) { - val loader = classLoader - if (loader is URLClassLoader) { - for (url in loader.urLs) { - if ("file" == url.protocol && url.file!!.endsWith("/annotations.jar")) { - return File(url.file!!) - } - } - } - classLoader = classLoader.parent - } - return null - } -} diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.192 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.192 deleted file mode 100644 index 6aa88d78956..00000000000 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/KotlinAbstractUElement.kt.192 +++ /dev/null @@ -1,262 +0,0 @@ -/* - * 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. - * 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.uast.kotlin - -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiMethod -import org.jetbrains.kotlin.asJava.LightClassUtil -import org.jetbrains.kotlin.asJava.elements.KtLightElement -import org.jetbrains.kotlin.asJava.elements.KtLightMethod -import org.jetbrains.kotlin.asJava.toLightGetter -import org.jetbrains.kotlin.asJava.toLightSetter -import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject -import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter -import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -import org.jetbrains.kotlin.utils.addToStdlib.safeAs -import org.jetbrains.uast.* -import org.jetbrains.uast.kotlin.expressions.KotlinLocalFunctionULambdaExpression -import org.jetbrains.uast.kotlin.expressions.KotlinUElvisExpression -import org.jetbrains.uast.kotlin.internal.KotlinUElementWithComments -import org.jetbrains.uast.kotlin.psi.UastKotlinPsiParameter -import org.jetbrains.uast.kotlin.psi.UastKotlinPsiVariable - -abstract class KotlinAbstractUElement(private val givenParent: UElement?) : KotlinUElementWithComments { - - final override val uastParent: UElement? by lz { - givenParent ?: convertParent() - } - - protected open fun convertParent(): UElement? { - @Suppress("DEPRECATION") - val psi = psi //TODO: `psi` is deprecated but it seems that it couldn't be simply replaced for this case - var parent = psi?.parent ?: sourcePsi?.parent ?: psi?.containingFile - - if (psi is PsiMethod && psi !is KtLightMethod) { // handling of synthetic things not represented in lightclasses directly - when (parent) { - is KtClassBody -> { - val grandParent = parent.parent - doConvertParent(this, grandParent)?.let { return it } - parent = grandParent - } - is KtFile -> { - parent.toUElementOfType()?.let { return it } // mutlifile facade class - } - } - - } - - if (psi is KtLightElement<*, *> && sourcePsi.safeAs()?.isLocal == true) { - val originParent = psi.kotlinOrigin?.parent - parent = when (originParent) { - null -> parent - is KtClassBody -> originParent.parent - else -> originParent - } - } - - if (psi is KtAnnotationEntry) { - val parentUnwrapped = KotlinConverter.unwrapElements(parent) ?: return null - val target = psi.useSiteTarget?.getAnnotationUseSiteTarget() - when (target) { - AnnotationUseSiteTarget.PROPERTY_GETTER -> - parent = (parentUnwrapped as? KtProperty)?.getter - ?: (parentUnwrapped as? KtParameter)?.toLightGetter() - ?: parent - - AnnotationUseSiteTarget.PROPERTY_SETTER -> - parent = (parentUnwrapped as? KtProperty)?.setter - ?: (parentUnwrapped as? KtParameter)?.toLightSetter() - ?: parent - AnnotationUseSiteTarget.FIELD -> - parent = (parentUnwrapped as? KtProperty) - ?: (parentUnwrapped as? KtParameter) - ?.takeIf { it.isPropertyParameter() } - ?.let(LightClassUtil::getLightClassBackingField) - ?: parent - AnnotationUseSiteTarget.SETTER_PARAMETER -> - parent = (parentUnwrapped as? KtParameter) - ?.toLightSetter()?.parameterList?.parameters?.firstOrNull() ?: parent - } - } - if ((psi is UastKotlinPsiVariable || psi is UastKotlinPsiParameter) && parent != null) { - parent = parent.parent - } - - if (KotlinConverter.forceUInjectionHost) { - if (parent is KtBlockStringTemplateEntry) { - parent = parent.parent - } - } else - while (parent is KtStringTemplateEntryWithExpression || parent is KtStringTemplateExpression && parent.entries.size == 1) { - parent = parent.parent - } - - if (parent is KtWhenConditionWithExpression) { - parent = parent.parent - } - - if (parent is KtImportList) { - parent = parent.parent - } - - if (psi is KtFunctionLiteral && parent is KtLambdaExpression) { - parent = parent.parent - } - - if (parent is KtLambdaArgument) { - parent = parent.parent - } - - if (psi is KtSuperTypeCallEntry) { - parent = parent?.parent - } - - if (parent is KtPropertyDelegate) { - parent = parent.parent - } - - val result = doConvertParent(this, parent) - if (result == this) { - throw IllegalStateException("Loop in parent structure when converting a $psi of type ${psi?.javaClass} with parent $parent of type ${parent?.javaClass} text: [${parent?.text}], result = $result") - } - - return result - } - - override fun equals(other: Any?): Boolean { - if (other !is UElement) { - return false - } - - return this.psi == other.psi - } - - override fun hashCode() = psi?.hashCode() ?: 0 -} - -fun doConvertParent(element: UElement, parent: PsiElement?): UElement? { - val parentUnwrapped = KotlinConverter.unwrapElements(parent) ?: return null - if (parent is KtValueArgument && parentUnwrapped is KtAnnotationEntry) { - return (KotlinUastLanguagePlugin().convertElementWithParent(parentUnwrapped, null) as? KotlinUAnnotation) - ?.findAttributeValueExpression(parent) - } - - if (parent is KtParameter) { - val annotationClass = findAnnotationClassFromConstructorParameter(parent) - if (annotationClass != null) { - return annotationClass.methods.find { it.name == parent.name } - } - } - - if (parent is KtClassInitializer) { - val containingClass = parent.containingClassOrObject - if (containingClass != null) { - val containingUClass = KotlinUastLanguagePlugin().convertElementWithParent(containingClass, null) as? KotlinUClass - containingUClass?.methods?.filterIsInstance()?.firstOrNull { it.isPrimary }?.let { - return it.uastBody - } - } - } - - val result = KotlinUastLanguagePlugin().convertElementWithParent(parentUnwrapped, null) - - if (result is KotlinUBlockExpression && element is UClass) { - return KotlinUDeclarationsExpression(result).apply { - declarations = listOf(element) - } - } - - if (result is UEnumConstant && element is UDeclaration) { - return result.initializingClass - } - - if (result is UCallExpression && result.uastParent is UEnumConstant) { - return result.uastParent - } - - if (result is USwitchClauseExpressionWithBody && !isInConditionBranch(element, result)) { - return result.body - } - - if (result is KotlinUDestructuringDeclarationExpression && - when (parent) { - is KtDestructuringDeclaration -> parent.initializer?.let { it == element.psi } == true - is KtDeclarationModifierList -> parent == element.sourcePsi?.parent - else -> false - } - ) { - return result.tempVarAssignment - } - - if (result is KotlinUElvisExpression && parentUnwrapped is KtBinaryExpression) { - val branch: Sequence = element.psi?.parentsWithSelf.orEmpty().takeWhile { it != parentUnwrapped } - if (branch.contains(parentUnwrapped.left)) - return result.lhsDeclaration - if (branch.contains(parentUnwrapped.right)) - return result.rhsIfExpression - } - - if ((result is UMethod || result is KotlinLocalFunctionULambdaExpression) - && result !is KotlinConstructorUMethod // no sense to wrap super calls with `return` - && element is UExpression - && element !is UBlockExpression - && element !is UTypeReferenceExpression // when element is a type in extension methods - ) { - return KotlinUBlockExpression.KotlinLazyUBlockExpression(result, { block -> - listOf(KotlinUImplicitReturnExpression(block).apply { returnExpression = element }) - }).expressions.single() - } - - if (result is KotlinULambdaExpression.Body && element is UExpression && result.implicitReturn?.returnExpression == element) { - return result.implicitReturn!! - } - - return result -} - -private fun isInConditionBranch(element: UElement, result: USwitchClauseExpressionWithBody) = - element.psi?.parentsWithSelf?.takeWhile { it !== result.psi }?.any { it is KtWhenCondition } ?: false - - -private fun findAnnotationClassFromConstructorParameter(parameter: KtParameter): UClass? { - val primaryConstructor = parameter.getStrictParentOfType() ?: return null - val containingClass = primaryConstructor.getContainingClassOrObject() - if (containingClass.isAnnotation()) { - return KotlinUastLanguagePlugin().convertElementWithParent(containingClass, null) as? UClass - } - return null -} - -abstract class KotlinAbstractUExpression(givenParent: UElement?) : - KotlinAbstractUElement(givenParent), - UExpression { - - override val javaPsi: PsiElement? = null - - override val psi - get() = sourcePsi - - override val annotations: List - get() { - val annotatedExpression = sourcePsi?.parent as? KtAnnotatedExpression ?: return emptyList() - return annotatedExpression.annotationEntries.map { KotlinUAnnotation(it, this) } - } -} - diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.192 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.192 deleted file mode 100644 index c088e99a6c1..00000000000 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUSwitchExpression.kt.192 +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - * 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.uast.kotlin - -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.psi.KtBlockExpression -import org.jetbrains.kotlin.psi.KtWhenEntry -import org.jetbrains.kotlin.psi.KtWhenExpression -import org.jetbrains.uast.* -import org.jetbrains.uast.kotlin.declarations.KotlinUIdentifier -import org.jetbrains.uast.kotlin.kinds.KotlinSpecialExpressionKinds - -class KotlinUSwitchExpression( - override val sourcePsi: KtWhenExpression, - givenParent: UElement? -) : KotlinAbstractUExpression(givenParent), USwitchExpression, KotlinUElementWithType { - override val expression by lz { KotlinConverter.convertOrNull(sourcePsi.subjectExpression, this) } - - override val body: UExpressionList by lz { - object : KotlinUExpressionList(sourcePsi, KotlinSpecialExpressionKinds.WHEN, this@KotlinUSwitchExpression) { - override fun asRenderString() = expressions.joinToString("\n") { it.asRenderString().withMargin } - }.apply { - expressions = this@KotlinUSwitchExpression.sourcePsi.entries.map { KotlinUSwitchEntry(it, this) } - } - } - - override fun asRenderString() = buildString { - val expr = expression?.let { "(" + it.asRenderString() + ") " } ?: "" - appendln("switch $expr {") - appendln(body.asRenderString()) - appendln("}") - } - - override val switchIdentifier: UIdentifier - get() = KotlinUIdentifier(null, this) -} - -class KotlinUSwitchEntry( - override val sourcePsi: KtWhenEntry, - givenParent: UElement? -) : KotlinAbstractUExpression(givenParent), USwitchClauseExpressionWithBody { - override val caseValues by lz { - sourcePsi.conditions.map { KotlinConverter.convertWhenCondition(it, this, DEFAULT_EXPRESSION_TYPES_LIST) ?: UastEmptyExpression(null) } - } - - override val body: UExpressionList by lz { - object : KotlinUExpressionList(sourcePsi, KotlinSpecialExpressionKinds.WHEN_ENTRY, this@KotlinUSwitchEntry) { - override fun asRenderString() = buildString { - appendln("{") - expressions.forEach { appendln(it.asRenderString().withMargin) } - appendln("}") - } - }.apply { - val exprPsi = this@KotlinUSwitchEntry.sourcePsi.expression - val userExpressions = when (exprPsi) { - is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) } - else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this)) - } - expressions = userExpressions + object : UBreakExpression { - override val javaPsi: PsiElement? = null - override val sourcePsi: PsiElement? = null - override val psi: PsiElement? - get() = null - override val label: String? - get() = null - override val uastParent: UElement? - get() = this@KotlinUSwitchEntry - override val annotations: List - get() = emptyList() - } - } - } - - override fun convertParent(): UElement? { - val result = KotlinConverter.unwrapElements(sourcePsi.parent)?.let { parentUnwrapped -> - KotlinUastLanguagePlugin().convertElementWithParent(parentUnwrapped, null) - } - return (result as? KotlinUSwitchExpression)?.body ?: result - } -} \ No newline at end of file diff --git a/plugins/uast-kotlin/testData/AnnotatedExpressions.log.txt.192 b/plugins/uast-kotlin/testData/AnnotatedExpressions.log.txt.192 deleted file mode 100644 index c300fb5b5ea..00000000000 --- a/plugins/uast-kotlin/testData/AnnotatedExpressions.log.txt.192 +++ /dev/null @@ -1,74 +0,0 @@ -UFile (package = ) - UClass (name = AnnotatedExpressionsKt) - UMethod (name = foo) - UBlockExpression - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UAnnotation (fqName = kotlin.Suppress) - UIdentifier (Identifier (foo)) - USimpleNameReferenceExpression (identifier = foo, resolvesTo = null) - UDeclarationsExpression - ULocalVariable (name = a) - UAnnotation (fqName = kotlin.Suppress) - ULiteralExpression (value = 1) - UDeclarationsExpression - ULocalVariable (name = b) - UAnnotation (fqName = kotlin.Suppress) - ULiteralExpression (value = 2) - UBinaryExpression (operator = =) - UAnnotation (fqName = kotlin.Suppress) - USimpleNameReferenceExpression (identifier = b) - USimpleNameReferenceExpression (identifier = a) - UIfExpression - UAnnotation (fqName = kotlin.Suppress) - UBinaryExpression (operator = >) - USimpleNameReferenceExpression (identifier = a) - ULiteralExpression (value = 2) - USimpleNameReferenceExpression (identifier = a) - USimpleNameReferenceExpression (identifier = b) - UDeclarationsExpression - ULocalVariable (name = c) - UExpressionList (elvis) - UDeclarationsExpression - ULocalVariable (name = varae507364) - USimpleNameReferenceExpression (identifier = a) - UAnnotation (fqName = kotlin.Suppress) - UIfExpression - UBinaryExpression (operator = !=) - USimpleNameReferenceExpression (identifier = varae507364) - ULiteralExpression (value = null) - USimpleNameReferenceExpression (identifier = varae507364) - USimpleNameReferenceExpression (identifier = b) - UMethod (name = annotatedSwitch) - UParameter (name = str) - UAnnotation (fqName = org.jetbrains.annotations.NotNull) - UBlockExpression - UReturnExpression - USwitchExpression - UExpressionList (when) - USwitchClauseExpressionWithBody - UQualifiedReferenceExpression - UAnnotation (fqName = kotlin.Suppress) - UNamedExpression (name = names) - ULiteralExpression (value = "DEPRECATION") - USimpleNameReferenceExpression (identifier = str) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (isBlank)) - USimpleNameReferenceExpression (identifier = isBlank, resolvesTo = null) - UExpressionList (when_entry) - ULiteralExpression (value = null) - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - UBinaryExpression (operator = !=) - UQualifiedReferenceExpression - USimpleNameReferenceExpression (identifier = str) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (isNotEmpty)) - USimpleNameReferenceExpression (identifier = isNotEmpty, resolvesTo = null) - ULiteralExpression (value = null) - UExpressionList (when_entry) - ULiteralExpression (value = null) - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - UExpressionList (when_entry) - ULiteralExpression (value = 1) - UBreakExpression (label = null) diff --git a/plugins/uast-kotlin/testData/AnnotatedExpressions.render.txt.192 b/plugins/uast-kotlin/testData/AnnotatedExpressions.render.txt.192 deleted file mode 100644 index fbce5252cea..00000000000 --- a/plugins/uast-kotlin/testData/AnnotatedExpressions.render.txt.192 +++ /dev/null @@ -1,33 +0,0 @@ -public final class AnnotatedExpressionsKt { - public static final fun foo() : void { - foo() - @kotlin.Suppress var a: int = 1 - @kotlin.Suppress var b: int = 2 - b = a - if (a > 2) a else b - var c: int = elvis { - var varae507364: int = a - if (varae507364 != null) varae507364 else b - } - } - public static final fun annotatedSwitch(@org.jetbrains.annotations.NotNull str: java.lang.String) : java.lang.Integer { - return switch { - str.isBlank() -> { - null - break - } - - str.isNotEmpty() != null -> { - null - break - } - - -> { - 1 - break - } - - } - - } -} diff --git a/plugins/uast-kotlin/testData/WhenAndDestructing.log.txt.192 b/plugins/uast-kotlin/testData/WhenAndDestructing.log.txt.192 deleted file mode 100644 index 4b01e9ae238..00000000000 --- a/plugins/uast-kotlin/testData/WhenAndDestructing.log.txt.192 +++ /dev/null @@ -1,49 +0,0 @@ -UFile (package = ) - UClass (name = WhenAndDestructingKt) - UMethod (name = getElementsAdditionalResolve) - UParameter (name = string) - UAnnotation (fqName = org.jetbrains.annotations.NotNull) - UBlockExpression - UDeclarationsExpression - ULocalVariable (name = arr) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 2)) - UIdentifier (Identifier (listOf)) - USimpleNameReferenceExpression (identifier = listOf, resolvesTo = null) - ULiteralExpression (value = "1") - ULiteralExpression (value = "2") - USwitchExpression - USimpleNameReferenceExpression (identifier = string) - UExpressionList (when) - USwitchClauseExpressionWithBody - ULiteralExpression (value = "aaaa") - UExpressionList (when_entry) - UReturnExpression - ULiteralExpression (value = "bindingContext") - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - ULiteralExpression (value = "empty-switch") - UExpressionList (when_entry) - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - UExpressionList (when_entry) - UDeclarationsExpression - ULocalVariable (name = var837f2350) - UAnnotation (fqName = null) - USimpleNameReferenceExpression (identifier = arr) - ULocalVariable (name = bindingContext) - UAnnotation (fqName = null) - UQualifiedReferenceExpression - USimpleNameReferenceExpression (identifier = var837f2350) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (component1)) - USimpleNameReferenceExpression (identifier = , resolvesTo = null) - ULocalVariable (name = statementFilter) - UAnnotation (fqName = null) - UQualifiedReferenceExpression - USimpleNameReferenceExpression (identifier = var837f2350) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (component2)) - USimpleNameReferenceExpression (identifier = , resolvesTo = null) - UReturnExpression - USimpleNameReferenceExpression (identifier = bindingContext) - UBreakExpression (label = null) diff --git a/plugins/uast-kotlin/testData/WhenAndDestructing.render.txt.192 b/plugins/uast-kotlin/testData/WhenAndDestructing.render.txt.192 deleted file mode 100644 index 8e8f98c034d..00000000000 --- a/plugins/uast-kotlin/testData/WhenAndDestructing.render.txt.192 +++ /dev/null @@ -1,25 +0,0 @@ -public final class WhenAndDestructingKt { - public static final fun getElementsAdditionalResolve(@org.jetbrains.annotations.NotNull string: java.lang.String) : java.lang.String { - var arr: java.util.List = listOf("1", "2") - switch (string) { - "aaaa" -> { - return "bindingContext" - break - } - - "empty-switch" -> { - break - } - - -> { - @null var var837f2350: = arr - @null var bindingContext: java.lang.String = var837f2350.() - @null var statementFilter: java.lang.String = var837f2350.() - return bindingContext - break - } - - } - - } -} diff --git a/plugins/uast-kotlin/testData/WhenIs.log.txt.192 b/plugins/uast-kotlin/testData/WhenIs.log.txt.192 deleted file mode 100644 index 0941dd1c738..00000000000 --- a/plugins/uast-kotlin/testData/WhenIs.log.txt.192 +++ /dev/null @@ -1,24 +0,0 @@ -UFile (package = ) - UClass (name = WhenIsKt) - UMethod (name = foo) - UParameter (name = bar) - UAnnotation (fqName = org.jetbrains.annotations.NotNull) - UBlockExpression - UReturnExpression - USwitchExpression - USimpleNameReferenceExpression (identifier = bar) - UExpressionList (when) - USwitchClauseExpressionWithBody - UBinaryExpressionWithType - USimpleNameReferenceExpression (identifier = it) - UTypeReferenceExpression (name = java.lang.String) - UExpressionList (when_entry) - USimpleNameReferenceExpression (identifier = bar) - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - UBinaryExpressionWithType - USimpleNameReferenceExpression (identifier = it) - UTypeReferenceExpression (name = java.lang.String) - UExpressionList (when_entry) - ULiteralExpression (value = "") - UBreakExpression (label = null) diff --git a/plugins/uast-kotlin/testData/WhenIs.render.txt.192 b/plugins/uast-kotlin/testData/WhenIs.render.txt.192 deleted file mode 100644 index 85830653f7e..00000000000 --- a/plugins/uast-kotlin/testData/WhenIs.render.txt.192 +++ /dev/null @@ -1,17 +0,0 @@ -public final class WhenIsKt { - public static final fun foo(@org.jetbrains.annotations.NotNull bar: java.lang.Object) : java.lang.String { - return switch (bar) { - it is java.lang.String -> { - bar - break - } - - it !is java.lang.String -> { - "" - break - } - - } - - } -} diff --git a/plugins/uast-kotlin/testData/WhenStringLiteral.log.txt.192 b/plugins/uast-kotlin/testData/WhenStringLiteral.log.txt.192 deleted file mode 100644 index e689d23089e..00000000000 --- a/plugins/uast-kotlin/testData/WhenStringLiteral.log.txt.192 +++ /dev/null @@ -1,33 +0,0 @@ -UFile (package = ) - UClass (name = WhenStringLiteralKt) - UField (name = a) - UAnnotation (fqName = org.jetbrains.annotations.Nullable) - UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) - UIdentifier (Identifier (readLine)) - USimpleNameReferenceExpression (identifier = readLine, resolvesTo = null) - UField (name = b) - UAnnotation (fqName = org.jetbrains.annotations.NotNull) - USwitchExpression - USimpleNameReferenceExpression (identifier = a) - UExpressionList (when) - USwitchClauseExpressionWithBody - ULiteralExpression (value = "abc") - UExpressionList (when_entry) - ULiteralExpression (value = 1) - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - ULiteralExpression (value = "def") - ULiteralExpression (value = "ghi") - UExpressionList (when_entry) - ULiteralExpression (value = 2) - UBreakExpression (label = null) - USwitchClauseExpressionWithBody - UExpressionList (when_entry) - ULiteralExpression (value = 3) - UBreakExpression (label = null) - UMethod (name = getA) - UMethod (name = getB) - UMethod (name = ) - UBlockExpression - ULiteralExpression (value = "abc1") - ULiteralExpression (value = "def1") diff --git a/plugins/uast-kotlin/testData/WhenStringLiteral.render.txt.192 b/plugins/uast-kotlin/testData/WhenStringLiteral.render.txt.192 deleted file mode 100644 index 07cf0439387..00000000000 --- a/plugins/uast-kotlin/testData/WhenStringLiteral.render.txt.192 +++ /dev/null @@ -1,27 +0,0 @@ -public final class WhenStringLiteralKt { - @org.jetbrains.annotations.Nullable private static final var a: java.lang.String = readLine() - @org.jetbrains.annotations.NotNull private static final var b: int = switch (a) { - "abc" -> { - 1 - break - } - - "def", "ghi" -> { - 2 - break - } - - -> { - 3 - break - } - - } - - public static final fun getA() : java.lang.String = UastEmptyExpression - public static final fun getB() : int = UastEmptyExpression - public static final fun () : void { - "abc1" - "def1" - } -} diff --git a/plugins/uast-kotlin/tests/KotlinUastReferencesTest.kt.192 b/plugins/uast-kotlin/tests/KotlinUastReferencesTest.kt.192 deleted file mode 100644 index d81f5e60237..00000000000 --- a/plugins/uast-kotlin/tests/KotlinUastReferencesTest.kt.192 +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * 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.uast.test.kotlin - -import com.intellij.openapi.Disposable -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.extensions.Extensions -import com.intellij.openapi.util.Disposer -import com.intellij.patterns.uast.injectionHostUExpression -import com.intellij.psi.* -import com.intellij.psi.impl.source.resolve.reference.PsiReferenceContributorEP -import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry -import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl -import com.intellij.psi.util.PropertyUtil -import com.intellij.testFramework.LightProjectDescriptor -import com.intellij.testFramework.registerServiceInstance -import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor -import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.evaluateString -import org.jetbrains.uast.toUElementOfType -import org.junit.Test -import org.junit.runner.RunWith -import kotlin.test.fail - -@RunWith(JUnit3WithIdeaConfigurationRunner::class) -class KotlinUastReferencesTest : KotlinLightCodeInsightFixtureTestCase() { - - override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE - - - @Test - fun `test original getter is visible when reference is under renaming`() { - - registerReferenceProviders(testRootDisposable) { - registerUastReferenceProvider(injectionHostUExpression(), uastInjectionHostReferenceProvider { _, psiLanguageInjectionHost -> - arrayOf(GetterReference("KotlinBean", psiLanguageInjectionHost)) - }) - } - - myFixture.configureByText( - "KotlinBean.kt", """ - data class KotlinBean(val myField: String) - - val reference = "myField" - - """.trimIndent() - ) - - myFixture.renameElementAtCaret("myRenamedField") - - myFixture.checkResult( - """ - data class KotlinBean(val myRenamedField: String) - - val reference = "myRenamedField" - - """.trimIndent() - ) - - } - -} - -private class GetterReference( - val className: String, - psiElement: PsiElement -) : PsiReferenceBase(psiElement) { - override fun resolve(): PsiMethod? { - val psiClass = JavaPsiFacade.getInstance(element.project).findClass(className, element.resolveScope) ?: return null - val name = element.toUElementOfType()?.evaluateString() ?: return null - return PropertyUtil.getGetters(psiClass, name).firstOrNull() - } - - override fun handleElementRename(newElementName: String): PsiElement { - val resolve = resolve() - ?: fail("can't resolve during rename, looks like someone renamed or removed the source element before updating references") - - val newName = - if (PropertyUtil.getPropertyName(resolve) != null) - PropertyUtil.getPropertyName(newElementName) ?: newElementName - else newElementName - - return super.handleElementRename(newName) - } - - override fun getVariants(): Array = emptyArray() -} - - -fun registerReferenceProviders(disposable: Disposable, registerContributors: PsiReferenceRegistrar.() -> Unit) { - registerReferenceContributor(object : PsiReferenceContributor() { - override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) = registrar.registerContributors() - }, disposable) -} - -fun registerReferenceContributor(contributor: PsiReferenceContributor, disposable: Disposable) { - val referenceContributorEp = Extensions.getArea(null).getExtensionPoint(PsiReferenceContributor.EP_NAME.name) - - val contributorEp = object : PsiReferenceContributorEP() { - override fun getInstance(): PsiReferenceContributor = contributor - } - - referenceContributorEp.registerExtension(contributorEp) - - val application = ApplicationManager.getApplication() - - //we need a fresh ReferenceProvidersRegistry after updating ReferenceContributors - val oldReferenceProviderRegistry = - application.picoContainer.getComponentInstance(ReferenceProvidersRegistry::class.java) as ReferenceProvidersRegistry - application.registerServiceInstance(ReferenceProvidersRegistry::class.java, ReferenceProvidersRegistryImpl()) - - Disposer.register(disposable, Disposable { - referenceContributorEp.unregisterExtension(contributorEp) - application.registerServiceInstance(ReferenceProvidersRegistry::class.java, oldReferenceProviderRegistry) - }) - -} - - - - diff --git a/tests/mute-platform.csv.192 b/tests/mute-platform.csv.192 deleted file mode 100644 index c7f3c1b86e0..00000000000 --- a/tests/mute-platform.csv.192 +++ /dev/null @@ -1,36 +0,0 @@ -Test key, Issue, State (optional: MUTE or FAIL), Status (optional: FLAKY) -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Common.StaticMembers.testJavaStaticMethodsFromImports, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.BoldOrGrayed.testNonPredictableSmartCast1, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.BoldOrGrayed.testNonPredictableSmartCast2, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.BoldOrGrayed.testSyntheticJavaProperties1, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.BoldOrGrayed.testSyntheticJavaProperties2, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.SyntheticExtensions.testNullableReceiver, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.SyntheticExtensions.testSafeCall, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.SyntheticExtensions.testSmartCast, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.SyntheticExtensions.testSmartCast2, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.JvmBasicCompletionTestGenerated.Java.SyntheticExtensions.testSyntheticExtensions1, KT-32919,, -org.jetbrains.kotlin.idea.completion.test.weighers.BasicCompletionWeigherTestGenerated.testPreferFromJdk, KT-35709 Class from JDK is not prioritized,, -org.jetbrains.kotlin.idea.quickfix.QuickFixMultiFileTestGenerated.AutoImports.testAmbiguousNamePreferFromJdk, KT-35709 Class from JDK is not prioritized,, -org.jetbrains.kotlin.findUsages.KotlinFindUsagesWithLibraryTestGenerated.KotlinLibrary.testLibrarySecondaryConstructorUsages, KT-34542, FAIL, -org.jetbrains.kotlin.findUsages.KotlinFindUsagesWithLibraryTestGenerated.KotlinLibrary.testLibraryNestedClassSecondaryConstructorUsages, KT-34542, FAIL, -org.jetbrains.kotlin.idea.decompiler.navigation.NavigateJavaToLibrarySourceTestGenerated.testClassAndConstuctors, KT-34542, FAIL, -org.jetbrains.kotlin.idea.decompiler.navigation.NavigateJavaToLibrarySourceTestGenerated.testOverloadedFun, KT-34542, FAIL, -org.jetbrains.kotlin.idea.decompiler.navigation.NavigateJavaToLibrarySourceTestGenerated.testRenamedElements, KT-34542, FAIL, -org.jetbrains.kotlin.gradle.HierarchicalMultiplatformProjectImportingTest.testImportIntermediateModules, KMM-304,, -"org.jetbrains.kotlin.gradle.HierarchicalMultiplatformProjectImportingTest.testJvmWithJavaOnHMPP[8: Gradle-6.5.1, KotlinGradlePlugin-master]", KMM-304,, -org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testProjectDependency, KMM-304,, -org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testNestedDependencies, KMM-304,, -"org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testAndroidDependencyOnMPP[4: Gradle-5.6.4, KotlinGradlePlugin-latest stable]", KMM-304,, -"org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testAndroidDependencyOnMPP[7: Gradle-6.5.1, KotlinGradlePlugin-latest stable]", KMM-304,, -"org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testAndroidDependencyOnMPP[8: Gradle-6.5.1, KotlinGradlePlugin-master]", KMM-304,, -"org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testDependencyOnRoot", KT-40551,, -"org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testJavaTransitiveOnMPP", KT-40551,, -"org.jetbrains.kotlin.gradle.NewMultiplatformProjectImportingTest.testImportBeforeBuild", KT-40551,, -"org.jetbrains.kotlin.gradle.MultiplatformProjectImportingTest.testJsTestOutputFileInProjectWithAndroid[7: Gradle-6.5.1, KotlinGradlePlugin-latest stable]", NoSuchMethodError,, -"org.jetbrains.kotlin.gradle.MultiplatformProjectImportingTest.testJsTestOutputFileInProjectWithAndroid[8: Gradle-6.5.1, KotlinGradlePlugin-master]", NoSuchMethodError,, -"org.jetbrains.kotlin.gradle.MultiplatformProjectImportingTest.simpleAndroidAppWithCommonModule[7: Gradle-6.5.1, KotlinGradlePlugin-latest stable]", NoSuchMethodError,, -"org.jetbrains.kotlin.gradle.MultiplatformProjectImportingTest.simpleAndroidAppWithCommonModule[8: Gradle-6.5.1, KotlinGradlePlugin-master]", NoSuchMethodError,, -"org.jetbrains.kotlin.gradle.MultiplatformProjectImportingTest.testTransitiveImplementWithAndroid[7: Gradle-6.5.1, KotlinGradlePlugin-latest stable]", NoSuchMethodError,, -"org.jetbrains.kotlin.gradle.MultiplatformProjectImportingTest.testTransitiveImplementWithAndroid[8: Gradle-6.5.1, KotlinGradlePlugin-master]", NoSuchMethodError,, -org.jetbrains.kotlin.idea.codeInsight.gradle.GradleFacetImportTest.testJDKImport, Old story with Idea core,, -"org.jetbrains.kotlin.ide.konan.gradle.GradleNativeLibrariesInIDENamingTest.testLibrariesNaming[0: with Gradle-4.10.2]", Old IDE with new plugin problem,, \ No newline at end of file