diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/confidence/UnfocusedPossibleFunctionParameter.java b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/confidence/UnfocusedPossibleFunctionParameter.java deleted file mode 100644 index 146ea4487e7..00000000000 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/confidence/UnfocusedPossibleFunctionParameter.java +++ /dev/null @@ -1,73 +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.confidence; - -import com.intellij.codeInsight.completion.CompletionConfidence; -import com.intellij.codeInsight.completion.CompletionParameters; -import com.intellij.psi.PsiElement; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.ThreeState; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.psi.*; - -public class UnfocusedPossibleFunctionParameter extends CompletionConfidence { - @NotNull - @Override - public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) { - // 1. Do not automatically insert completion for first reference expression in block inside - // function literal if it has no parameters yet. - - // 2. The same but for the case when first expression is additionally surrounded with brackets - - PsiElement position = parameters.getPosition(); - KtLambdaExpression functionLiteral = PsiTreeUtil.getParentOfType( - position, KtLambdaExpression.class); - - if (functionLiteral != null) { - PsiElement expectedReference = position.getParent(); - if (expectedReference instanceof KtSimpleNameExpression) { - if (PsiTreeUtil.findChildOfType(functionLiteral, KtParameterList.class) == null) { - { - // 1. - PsiElement expectedBlock = expectedReference.getParent(); - if (expectedBlock instanceof KtBlockExpression) { - if (expectedReference.getPrevSibling() == null) { - return ThreeState.NO; - } - } - } - - { - // 2. - PsiElement expectedParenthesized = expectedReference.getParent(); - if (expectedParenthesized instanceof KtParenthesizedExpression) { - PsiElement expectedBlock = expectedParenthesized.getParent(); - if (expectedBlock instanceof KtBlockExpression) { - if (expectedParenthesized.getPrevSibling() == null) { - return ThreeState.NO; - } - } - } - } - } - } - } - - return ThreeState.UNSURE; - } -} - diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt index 67a1b275788..9187c7c5199 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.configuration @@ -22,10 +11,7 @@ import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleUtilCore import com.intellij.openapi.project.Project import com.intellij.openapi.project.ProjectBundle -import com.intellij.openapi.roots.ModuleRootAdapter -import com.intellij.openapi.roots.ModuleRootEvent -import com.intellij.openapi.roots.ModuleRootManager -import com.intellij.openapi.roots.ModuleRootModificationUtil +import com.intellij.openapi.roots.* import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.ui.popup.ListPopup @@ -54,7 +40,7 @@ class KotlinSetupEnvironmentNotificationProvider( notifications: EditorNotifications) : EditorNotifications.Provider() { init { - myProject.messageBus.connect(myProject).subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootAdapter() { + myProject.messageBus.connect(myProject).subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener { override fun rootsChanged(event: ModuleRootEvent?) { notifications.updateAllNotifications() } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt index b65cdbd5348..2da0e9f679a 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerSettings.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.debugger @@ -19,7 +8,6 @@ package org.jetbrains.kotlin.idea.debugger import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage -import com.intellij.openapi.components.StoragePathMacros import com.intellij.openapi.options.Configurable import com.intellij.openapi.options.SimpleConfigurable import com.intellij.openapi.util.Getter @@ -29,7 +17,7 @@ import com.intellij.xdebugger.settings.DebuggerSettingsCategory import com.intellij.xdebugger.settings.XDebuggerSettings import org.jetbrains.kotlin.idea.debugger.stepping.KotlinSteppingConfigurableUi -@State(name = "KotlinDebuggerSettings", storages = arrayOf(Storage(file = StoragePathMacros.APP_CONFIG + "/kotlin_debug.xml"))) +@State(name = "KotlinDebuggerSettings", storages = arrayOf(Storage("kotlin_debug.xml"))) class KotlinDebuggerSettings : XDebuggerSettings("kotlin_debugger"), Getter { var DEBUG_RENDER_DELEGATED_PROPERTIES: Boolean = true var DEBUG_DISABLE_KOTLIN_INTERNAL_CLASSES: Boolean = true diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/surroundWith/KotlinRuntimeTypeCastSurrounder.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/surroundWith/KotlinRuntimeTypeCastSurrounder.kt index 1ebeb56d210..5e3da7efb45 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/surroundWith/KotlinRuntimeTypeCastSurrounder.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/surroundWith/KotlinRuntimeTypeCastSurrounder.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.debugger.surroundWith @@ -26,6 +15,7 @@ import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.ScrollType import com.intellij.openapi.progress.ProgressIndicator +import com.intellij.openapi.progress.util.ProgressWindow import com.intellij.openapi.progress.util.ProgressWindowWithNotification import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange @@ -59,7 +49,7 @@ class KotlinRuntimeTypeCastSurrounder: KotlinExpressionSurrounder() { val debuggerContext = DebuggerManagerEx.getInstanceEx(project).context val debuggerSession = debuggerContext.debuggerSession if (debuggerSession != null) { - val progressWindow = ProgressWindowWithNotification(true, expression.project) + val progressWindow = ProgressWindow(true, expression.project) val worker = SurroundWithCastWorker(editor, expression, debuggerContext, progressWindow) progressWindow.title = DebuggerBundle.message("title.evaluating") debuggerContext.debugProcess?.managerThread?.startProgress(worker, progressWindow) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt index a4f8f9eeef9..5392c9f8d21 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt @@ -1,29 +1,20 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.versions -import com.intellij.openapi.components.* +import com.intellij.openapi.components.PersistentStateComponent +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.components.State import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.intellij.util.xmlb.XmlSerializerUtil import org.jetbrains.kotlin.idea.configuration.ModuleSourceRootGroup import org.jetbrains.kotlin.idea.configuration.toModuleGroup -@State(name = "SuppressABINotification", storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE))) +@State(name = "SuppressABINotification") class SuppressNotificationState : PersistentStateComponent { var isSuppressed: Boolean = false var modulesWithSuppressedNotConfigured = sortedSetOf() diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt index 7bf214d0e93..b8d3a7416ac 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.versions @@ -29,8 +18,8 @@ import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.IndexNotReadyException import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.ModuleRootAdapter import com.intellij.openapi.roots.ModuleRootEvent +import com.intellij.openapi.roots.ModuleRootListener import com.intellij.openapi.roots.libraries.Library import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.ui.popup.PopupStep @@ -63,7 +52,7 @@ class UnsupportedAbiVersionNotificationPanelProvider(private val project: Projec init { val connection = project.messageBus.connect() - connection.subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootAdapter() { + connection.subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener { override fun rootsChanged(event: ModuleRootEvent?) { updateNotifications() } diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt index dff7f946253..63d0c18ab0b 100644 --- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt +++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt @@ -1,23 +1,11 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.liveTemplates import com.intellij.codeInsight.lookup.LookupManager -import com.intellij.codeInsight.template.TemplateManager import com.intellij.codeInsight.template.impl.TemplateManagerImpl import com.intellij.codeInsight.template.impl.TemplateState import com.intellij.ide.DataManager @@ -37,12 +25,7 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() { override fun setUp() { super.setUp() myFixture.testDataPath = File(TEST_DATA_BASE_PATH).path + File.separator - (TemplateManager.getInstance(project) as TemplateManagerImpl).setTemplateTesting(true) - } - - override fun tearDown() { - (TemplateManager.getInstance(project) as TemplateManagerImpl).setTemplateTesting(false) - super.tearDown() + TemplateManagerImpl.setTemplateTesting(myModule.project, testRootDisposable) } fun testSout() { @@ -310,7 +293,10 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() { private fun doAction(actionId: String) { val actionManager = EditorActionManager.getInstance() val actionHandler = actionManager.getActionHandler(actionId) - actionHandler.execute(myFixture.editor, DataManager.getInstance().getDataContext(myFixture.editor.component)) + actionHandler.execute( + myFixture.editor, myFixture.editor.caretModel.currentCaret, + DataManager.getInstance().getDataContext(myFixture.editor.component) + ) } private fun assertStringItems(@NonNls vararg items: String) { diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 20711bf3b8a..ba2cba2422b 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -457,8 +457,6 @@ implementationClass="org.jetbrains.kotlin.idea.completion.KDocCompletionContributor"/> - diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt index 7c9ae387dfc..e9f39ff24c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea @@ -23,17 +12,13 @@ import com.intellij.notification.NotificationDisplayType import com.intellij.notification.NotificationGroup import com.intellij.notification.NotificationType import com.intellij.openapi.Disposable -import com.intellij.openapi.application.ApplicationInfo -import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.PathManager +import com.intellij.openapi.application.* import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.diagnostic.Logger 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.UpdateChecker import com.intellij.openapi.updateSettings.impl.UpdateSettings import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.util.SystemInfo @@ -176,7 +161,7 @@ class KotlinPluginUpdater(val propertiesComponent: PropertiesComponent) : Dispos val buildNumber = ApplicationInfo.getInstance().apiVersion val currentVersion = KotlinPluginUtil.getPluginVersion() val os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8) - val uid = UpdateChecker.getInstallationUID(propertiesComponent) + val uid = PermanentInstallationID.get() val url = "https://plugins.jetbrains.com/plugins/list?pluginId=6954&build=$buildNumber&pluginVersion=$currentVersion&os=$os&uuid=$uid" val responseDoc = HttpRequests.request(url).connect { JDOMUtil.load(it.inputStream) diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java index c45a7a489a0..1a3e3771e49 100644 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java +++ b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.compiler.configuration; @@ -300,7 +289,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co fileChooser.addBrowseFolderListener(title, null, null, new FileChooserDescriptor(forFiles, !forFiles, false, false, false, false), - TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false); + TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); } private static boolean isModified(@NotNull TextFieldWithBrowseButton chooser, @Nullable String currentValue) { diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEditorOptionsConfigurable.java b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEditorOptionsConfigurable.java index 88a2cf220a7..e706849340b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEditorOptionsConfigurable.java +++ b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEditorOptionsConfigurable.java @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.editor; @@ -25,8 +14,13 @@ import javax.swing.*; public class KotlinEditorOptionsConfigurable extends BeanConfigurable implements UnnamedConfigurable { public KotlinEditorOptionsConfigurable() { super(KotlinEditorOptions.getInstance()); - checkBox("enableJavaToKotlinConversion", "Convert pasted Java code to Kotlin"); - checkBox("donTShowConversionDialog", "Don't show Java to Kotlin conversion dialog on paste"); + KotlinEditorOptions instance = KotlinEditorOptions.getInstance(); + checkBox("Convert pasted Java code to Kotlin", + instance::isEnableJavaToKotlinConversion, + instance::setEnableJavaToKotlinConversion); + checkBox("Don't show Java to Kotlin conversion dialog on paste", + instance::isDonTShowConversionDialog, + instance::setDonTShowConversionDialog); } @Override diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt index 9ef9477eae6..7824bdc6bd3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/KotlinEnterHandler.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.editor @@ -32,8 +21,14 @@ import com.intellij.psi.tree.TokenSet import com.intellij.util.IncorrectOperationException import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.psi.KtDotQualifiedExpression +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtFunctionLiteral +import org.jetbrains.kotlin.psi.KtStringTemplateExpression +import org.jetbrains.kotlin.psi.psiUtil.endOffset +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import org.jetbrains.kotlin.psi.psiUtil.isSingleQuoted +import org.jetbrains.kotlin.psi.psiUtil.startOffset class KotlinEnterHandler: EnterHandlerDelegateAdapter() { companion object { @@ -74,7 +69,7 @@ class KotlinEnterHandler: EnterHandlerDelegateAdapter() { val isBeforeRBrace = elementAfter == null || elementAfter.node!!.elementType == KtTokens.RBRACE if (isAfterLBraceOrArrow && isBeforeRBrace && (elementBefore!!.parent is KtFunctionLiteral)) { - originalHandler?.execute(editor, dataContext) + originalHandler?.execute(editor, editor.caretModel.currentCaret, dataContext) PsiDocumentManager.getInstance(file.getProject()).commitDocument(document) try { diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt index 6fa3172973b..5f7951d4159 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuspendCallLineMarkerProvider.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.highlighter @@ -40,7 +29,7 @@ class KotlinSuspendCallLineMarkerProvider : LineMarkerProvider { callElement, callElement.textRange, KotlinIcons.SUSPEND_CALL, - Pass.UPDATE_OVERRIDDEN_MARKERS, + Pass.LINE_MARKERS, { message }, null, GutterIconRenderer.Alignment.RIGHT diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 43c30561572..723d39a7406 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.intentions @@ -90,7 +79,7 @@ class UsePropertyAccessSyntaxInspection : IntentionBasedInspection { - val profile = InspectionProjectProfileManager.getInstance(project).inspectionProfile + val profile = InspectionProjectProfileManager.getInstance(project).currentProfile val tool = profile.getUnwrappedTool(USE_PROPERTY_ACCESS_INSPECTION, element) return (tool?.fqNameList ?: default.map(::FqNameUnsafe)).toSet() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java index 3a71300735a..2a1b222797c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable; @@ -303,7 +292,7 @@ public class KotlinInplaceVariableIntroducer ex TemplateManagerImpl.getTemplateState(InjectedLanguageUtil.getTopLevelEditor(myEditor)); if (templateState != null) { myEditor.putUserData(INTRODUCE_RESTART, true); - templateState.cancelTemplate(); + templateState.gotoEnd(true); } } }.execute(); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt index bfd4b42571f..d196e7a713b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/ui/KotlinAwareMoveFilesOrDirectoriesDialog.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui @@ -176,27 +165,25 @@ class KotlinAwareMoveFilesOrDirectoriesDialog( } project.executeCommand(RefactoringBundle.message("move.title"), null) { - DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL) { - runWriteAction { - val directoryName = targetDirectoryField.childComponent.text.replace(File.separatorChar, '/') - try { - targetDirectory = DirectoryUtil.mkdirs(PsiManager.getInstance(project), directoryName) - } - catch (e: IncorrectOperationException) { - // ignore - } + runWriteAction { + val directoryName = targetDirectoryField.childComponent.text.replace(File.separatorChar, '/') + try { + targetDirectory = DirectoryUtil.mkdirs(PsiManager.getInstance(project), directoryName) } - - if (targetDirectory == null) { - CommonRefactoringUtil.showErrorMessage(title, - RefactoringBundle.message("cannot.create.directory"), - helpID, - project) - return@allowStartingDumbModeInside + catch (e: IncorrectOperationException) { + // ignore } - - callback(this@KotlinAwareMoveFilesOrDirectoriesDialog) } + + if (targetDirectory == null) { + CommonRefactoringUtil.showErrorMessage(title, + RefactoringBundle.message("cannot.create.directory"), + helpID, + project) + return@executeCommand + } + + callback(this@KotlinAwareMoveFilesOrDirectoriesDialog) } } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt index 906ff099f13..6cc586b3dd6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspectionTest.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.inspections @@ -39,7 +28,7 @@ class KotlinCleanupInspectionTest(): KotlinLightCodeInsightFixtureTestCase() { val managerEx = InspectionManager.getInstance(project) val globalContext = managerEx.createNewGlobalContext(false) as GlobalInspectionContextBase val analysisScope = AnalysisScope(myFixture.file) - val profile = InspectionProjectProfileManager.getInstance(project).inspectionProfile + val profile = InspectionProjectProfileManager.getInstance(project).currentProfile globalContext.codeCleanup(analysisScope, profile, "Cleanup", null, true) myFixture.checkResultByFile(result) diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/AbstractJoinLinesTest.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/AbstractJoinLinesTest.java index 9c2c9baa303..20db4f52a94 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/AbstractJoinLinesTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/AbstractJoinLinesTest.java @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.intentions.declarations; @@ -30,7 +19,8 @@ import java.io.File; public abstract class AbstractJoinLinesTest extends LightCodeInsightTestCase { public void doTest(@NotNull String path) throws Exception { configureByFile(path); - new JoinLinesHandler(null).execute(getEditor(), getCurrentEditorDataContext()); + new JoinLinesHandler(null).execute(getEditor(), getEditor().getCaretModel().getCurrentCaret(), + getCurrentEditorDataContext()); String afterFilePath = path + ".after"; try { checkResultByFile(afterFilePath); diff --git a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KdocRenameTest.java b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KdocRenameTest.java index 469cab6d7bd..1561b053195 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KdocRenameTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KdocRenameTest.java @@ -1,22 +1,11 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.kdoc; -import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.codeInsight.TargetElementUtil; import com.intellij.ide.startup.impl.StartupManagerImpl; import com.intellij.openapi.startup.StartupManager; import com.intellij.psi.PsiElement; @@ -52,9 +41,9 @@ public class KdocRenameTest extends LightCodeInsightTestCase { private void doTest(String newName) throws Exception { configureByFile(getTestName(false) + ".kt"); - PsiElement element = TargetElementUtilBase + PsiElement element = TargetElementUtil .findTargetElement(myEditor, - TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED); + TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED); assertNotNull(element); new RenameProcessor(getProject(), element, newName, true, true).run(); checkResultByFile(getTestName(false) + ".kt.after"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/MockParameterInfoUIContext.java b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/MockParameterInfoUIContext.java index 2fdfcc6bcc1..0fe69d29d45 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/MockParameterInfoUIContext.java +++ b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/MockParameterInfoUIContext.java @@ -1,22 +1,10 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.parameterInfo; -import com.intellij.codeInsight.hint.HintUtil; import com.intellij.lang.parameterInfo.ParameterInfoUIContext; import com.intellij.psi.PsiElement; @@ -54,7 +42,7 @@ public class MockParameterInfoUIContext implements ParameterInfoUIContext { String resultText = "Text: (" + highlightedText + "), " + "Disabled: " + isDisabled + ", " + "Strikeout: " + strikeout + ", " + - "Green: " + background.equals(KotlinParameterInfoWithCallHandlerBase.GREEN_BACKGROUND); + "Green: " + KotlinParameterInfoWithCallHandlerBase.GREEN_BACKGROUND.equals(background); result.add(resultText); // return value not used, just return something @@ -82,7 +70,7 @@ public class MockParameterInfoUIContext implements ParameterInfoUIContext { @Override public Color getDefaultParameterColor() { - return HintUtil.INFORMATION_COLOR; + return null; } public String getResultText() { diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt index c734a0ad632..ec946399811 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/InplaceRenameTest.kt @@ -1,35 +1,25 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.refactoring -import com.intellij.codeInsight.TargetElementUtilBase +import com.intellij.codeInsight.TargetElementUtil +import com.intellij.codeInsight.template.TemplateManager +import com.intellij.codeInsight.template.impl.TemplateManagerImpl +import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.actionSystem.impl.SimpleDataContext +import com.intellij.openapi.command.WriteCommandAction +import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler import com.intellij.testFramework.LightPlatformCodeInsightTestCase import com.intellij.testFramework.fixtures.CodeInsightTestUtil -import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler -import kotlin.test.* -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase -import com.intellij.openapi.actionSystem.impl.SimpleDataContext -import com.intellij.openapi.actionSystem.CommonDataKeys import org.jetbrains.kotlin.idea.refactoring.rename.RenameKotlinImplicitLambdaParameter -import com.intellij.codeInsight.template.impl.TemplateManagerImpl -import com.intellij.codeInsight.template.TemplateManager -import com.intellij.openapi.command.WriteCommandAction import org.jetbrains.kotlin.idea.refactoring.rename.findElementForRename +import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.psi.KtNameReferenceExpression +import kotlin.test.assertFalse +import kotlin.test.assertTrue class InplaceRenameTest : LightPlatformCodeInsightTestCase() { override fun isRunInWriteAction(): Boolean = false @@ -143,9 +133,9 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() { private fun doTestInplaceRename(newName: String?) { configureByFile(getTestName(false) + ".kt") - val element = TargetElementUtilBase.findTargetElement( + val element = TargetElementUtil.findTargetElement( LightPlatformCodeInsightTestCase.myEditor, - TargetElementUtilBase.ELEMENT_NAME_ACCEPTED or TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED + TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED ) assertNotNull(element) diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/SimpleNameReferenceRenameTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/SimpleNameReferenceRenameTest.java index a3cda742cef..e0f800f1b6d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/SimpleNameReferenceRenameTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/SimpleNameReferenceRenameTest.java @@ -1,22 +1,11 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.refactoring.rename; -import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.codeInsight.TargetElementUtil; import com.intellij.psi.PsiElement; import com.intellij.refactoring.rename.RenameProcessor; import com.intellij.testFramework.LightCodeInsightTestCase; @@ -61,9 +50,9 @@ public class SimpleNameReferenceRenameTest extends LightCodeInsightTestCase { private void doTest(String newName) throws Exception { configureByFile(getTestName(true) + ".kt"); - PsiElement element = TargetElementUtilBase + PsiElement element = TargetElementUtil .findTargetElement(myEditor, - TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED); + TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED); assertNotNull(element); new RenameProcessor(getProject(), element, newName, true, true).run(); checkResultByFile(getTestName(true) + ".kt.after"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/safeDelete/AbstractSafeDeleteTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/safeDelete/AbstractSafeDeleteTest.java index c650db1a0b8..5fa2a13f4fa 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/safeDelete/AbstractSafeDeleteTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/safeDelete/AbstractSafeDeleteTest.java @@ -1,22 +1,11 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.refactoring.safeDelete; -import com.intellij.codeInsight.TargetElementUtilBase; +import com.intellij.codeInsight.TargetElementUtil; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiClass; @@ -130,8 +119,8 @@ public abstract class AbstractSafeDeleteTest extends KotlinLightCodeInsightFixtu PsiElement elementAtCaret = null; for (Editor editor : editors) { - elementAtCaret = TargetElementUtilBase.findTargetElement( - editor, TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtilBase.ELEMENT_NAME_ACCEPTED + elementAtCaret = TargetElementUtil.findTargetElement( + editor, TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil.ELEMENT_NAME_ACCEPTED ); if (elementAtCaret != null) break; } diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt index 107423f6e24..b1ff3cbf3cc 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.stubs @@ -123,8 +112,7 @@ fun Module.createFacet( useProjectSettings: Boolean = true, implementedModuleName: String? = null ) { - val accessToken = WriteAction.start() - try { + WriteAction.run { val modelsProvider = IdeModifiableModelsProviderImpl(project) with (getOrCreateFacet(modelsProvider, useProjectSettings).configuration.settings) { initializeIfNeeded( @@ -138,7 +126,4 @@ fun Module.createFacet( } modelsProvider.commit() } - finally { - accessToken.finish() - } }