diff --git a/java/idea-ui/src/com/intellij/jarRepository/ExternalAnnotationsRepositoryResolver.kt b/java/idea-ui/src/com/intellij/jarRepository/ExternalAnnotationsRepositoryResolver.kt index 3cec7d9e7178..598b1bf97b94 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/ExternalAnnotationsRepositoryResolver.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/ExternalAnnotationsRepositoryResolver.kt @@ -1,10 +1,10 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.jarRepository import com.intellij.codeInsight.ExternalAnnotationsArtifactsResolver import com.intellij.codeInsight.externalAnnotation.location.AnnotationsLocation import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project @@ -50,7 +50,7 @@ class ExternalAnnotationsRepositoryResolver : ExternalAnnotationsArtifactsResolv as MutableList? } - invokeAndWaitIfNeed { + invokeAndWaitIfNeeded { updateLibrary(roots, mavenLibDescriptor, library) } @@ -73,7 +73,7 @@ class ExternalAnnotationsRepositoryResolver : ExternalAnnotationsArtifactsResolv .loadDependenciesSync(project, descriptor, setOf(ArtifactKind.ANNOTATIONS), repos, null) ?: return library - invokeAndWaitIfNeed { updateLibrary(roots, descriptor, library) } + invokeAndWaitIfNeeded { updateLibrary(roots, descriptor, library) } return library } diff --git a/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt b/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt index 8032064be5b2..e6896be0ce7a 100644 --- a/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt +++ b/platform/platform-impl/src/com/intellij/credentialStore/credentialPromt.kt @@ -1,11 +1,11 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. @file:JvmName("CredentialPromptDialog") package com.intellij.credentialStore import com.intellij.CommonBundle import com.intellij.ide.passwordSafe.PasswordSafe import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.project.Project import com.intellij.ui.AppIcon import com.intellij.ui.components.CheckBox @@ -57,7 +57,7 @@ fun askCredentials(project: Project?, } } - return invokeAndWaitIfNeed(ModalityState.any()) { + return invokeAndWaitIfNeeded(ModalityState.any()) { val passwordField = JPasswordField() val rememberCheckBox = RememberCheckBoxState.createCheckBox(toolTip = "The password will be stored between application sessions.") @@ -69,7 +69,7 @@ fun askCredentials(project: Project?, AppIcon.getInstance().requestAttention(project, true) if (!dialog(dialogTitle, project = project, panel = panel, focusedComponent = passwordField, errorText = error).showAndGet()) { - return@invokeAndWaitIfNeed null + return@invokeAndWaitIfNeeded null } RememberCheckBoxState.update(rememberCheckBox) @@ -81,7 +81,7 @@ fun askCredentials(project: Project?, } // for memory only store isRemember is true, because false doesn't matter - return@invokeAndWaitIfNeed CredentialRequestResult(credentials, isRemember = rememberCheckBox.isSelected) + return@invokeAndWaitIfNeeded CredentialRequestResult(credentials, isRemember = rememberCheckBox.isSelected) } } diff --git a/platform/projectModel-api/src/com/intellij/openapi/application/actions.kt b/platform/projectModel-api/src/com/intellij/openapi/application/actions.kt index bbfbe349daf9..ce59cb95c45d 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/application/actions.kt +++ b/platform/projectModel-api/src/com/intellij/openapi/application/actions.kt @@ -23,9 +23,9 @@ inline fun runReadAction(crossinline runnable: () -> T): T { } /** - * @exclude Internal use only + * @suppress Internal use only */ -fun invokeAndWaitIfNeed(modalityState: ModalityState? = null, runnable: () -> T): T { +fun invokeAndWaitIfNeeded(modalityState: ModalityState? = null, runnable: () -> T): T { val app = ApplicationManager.getApplication() if (app == null) { if (SwingUtilities.isEventDispatchThread()) { @@ -49,6 +49,11 @@ fun invokeAndWaitIfNeed(modalityState: ModalityState? = null, runnable: () - } } +@Deprecated(replaceWith = ReplaceWith("invokeAndWaitIfNeeded()"), message = "Use invokeAndWaitIfNeeded()") +fun invokeAndWaitIfNeed(modalityState: ModalityState? = null, runnable: () -> T): T { + return invokeAndWaitIfNeeded(modalityState, runnable) +} + @PublishedApi internal inline fun computeDelegated(executor: (setter: (T) -> Unit) -> Unit): T { var resultRef: T? = null diff --git a/plugins/git4idea/src/git4idea/GitProtectedBranches.kt b/plugins/git4idea/src/git4idea/GitProtectedBranches.kt index 025291a7bdcb..a6ed557c8eca 100644 --- a/plugins/git4idea/src/git4idea/GitProtectedBranches.kt +++ b/plugins/git4idea/src/git4idea/GitProtectedBranches.kt @@ -1,7 +1,7 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package git4idea -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.vcs.log.Hash import com.intellij.vcs.log.impl.VcsProjectLog import git4idea.branch.GitBranchUtil @@ -35,7 +35,7 @@ fun findProtectedRemoteBranchContainingCommit(repository: GitRepository, hash: H val root = repository.root val branchesGetter = VcsProjectLog.getInstance(repository.project).dataManager?.containingBranchesGetter val branches = if (branchesGetter != null) { - invokeAndWaitIfNeed { branchesGetter.getContainingBranchesQuickly(root, hash) } ?: + invokeAndWaitIfNeeded { branchesGetter.getContainingBranchesQuickly(root, hash) } ?: branchesGetter.getContainingBranchesSynchronously(root, hash) } else { diff --git a/plugins/git4idea/tests/git4idea/tests/GitPartialCommitTest.kt b/plugins/git4idea/tests/git4idea/tests/GitPartialCommitTest.kt index 563bdecd4dec..d45ac862356b 100644 --- a/plugins/git4idea/tests/git4idea/tests/GitPartialCommitTest.kt +++ b/plugins/git4idea/tests/git4idea/tests/GitPartialCommitTest.kt @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package git4idea.tests -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.application.runReadAction import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.editor.Document @@ -198,7 +198,7 @@ class GitPartialCommitTest : GitSingleRepoTest() { private fun assertChanges(changes: ChangesBuilder.() -> Unit): List { return changeListManager.assertChanges(changes) } - + private fun assertCommittedContent(fileName: String, expectedContent: String, useFilters: Boolean = false) { val actualContent = repo.gitAsBytes("cat-file" + (if (useFilters) " --filters" else " -p") + @@ -207,7 +207,7 @@ class GitPartialCommitTest : GitSingleRepoTest() { } private fun withTrackedDocument(fileName: String, newContent: String, task: (Document, PartialLocalLineStatusTracker) -> Unit) { - invokeAndWaitIfNeed { + invokeAndWaitIfNeeded { val lstm = LineStatusTrackerManager.getInstance(project) as LineStatusTrackerManager val file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(child(fileName))!! diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.kt b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.kt index 8727700427c1..6f60261f8b62 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.kt @@ -1,19 +1,5 @@ -// 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 file. -/* - * Copyright 2000-2012 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-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + package org.jetbrains.plugins.github import com.intellij.CommonBundle @@ -22,7 +8,7 @@ import com.intellij.ide.BrowserUtil import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.DataProvider -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.components.service import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.progress.ProgressIndicator @@ -265,7 +251,7 @@ class GithubShareAction : DumbAwareAction("Share Project on GitHub", "Easily sha allFiles.addAll(trackedFiles) allFiles.addAll(untrackedFiles) - val dialog = invokeAndWaitIfNeed(indicator.modalityState) { + val dialog = invokeAndWaitIfNeeded(indicator.modalityState) { GithubUntrackedFilesDialog(project, allFiles).apply { if (!trackedFiles.isEmpty()) { selectedFiles = trackedFiles diff --git a/plugins/github/src/org/jetbrains/plugins/github/authentication/ui/GithubLoginDialog.kt b/plugins/github/src/org/jetbrains/plugins/github/authentication/ui/GithubLoginDialog.kt index 1f1888e321c9..de00a8883be4 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/authentication/ui/GithubLoginDialog.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/authentication/ui/GithubLoginDialog.kt @@ -1,11 +1,11 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.authentication.ui import com.intellij.icons.AllIcons import com.intellij.ide.BrowserUtil import com.intellij.openapi.Disposable import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.components.service import com.intellij.openapi.progress.EmptyProgressIndicator import com.intellij.openapi.progress.ProgressIndicator @@ -260,7 +260,7 @@ class GithubLoginDialog @JvmOverloads constructor(private val executorFactory: G override fun createExecutor(): GithubApiRequestExecutor.WithBasicAuth { val modalityState = ModalityState.stateForComponent(passwordField) return executorFactory.create(loginTextField.text, passwordField.password, Supplier { - invokeAndWaitIfNeed(modalityState) { + invokeAndWaitIfNeeded(modalityState) { Messages.showInputDialog(passwordField, "Authentication Code", "Github Two-Factor Authentication", diff --git a/plugins/github/src/org/jetbrains/plugins/github/extensions/InteractiveGithubHttpAuthDataProvider.kt b/plugins/github/src/org/jetbrains/plugins/github/extensions/InteractiveGithubHttpAuthDataProvider.kt index a8217a578ea8..044e2984c23c 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/extensions/InteractiveGithubHttpAuthDataProvider.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/extensions/InteractiveGithubHttpAuthDataProvider.kt @@ -1,8 +1,8 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.extensions import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.project.Project import com.intellij.util.AuthData import git4idea.DialogManager @@ -31,7 +31,7 @@ internal class InteractiveGithubHttpAuthDataProvider(private val project: Projec DialogManager.show(dialog) if (!dialog.isOK) return null val account = dialog.account - val token = invokeAndWaitIfNeed(parentComponent?.let(ModalityState::stateForComponent) ?: ModalityState.any()) { + val token = invokeAndWaitIfNeeded(parentComponent?.let(ModalityState::stateForComponent) ?: ModalityState.any()) { authenticationManager.getTokenForAccount(account) ?: authenticationManager.requestNewToken(account, project, parentComponent) } ?: return null if (dialog.setDefault) authenticationManager.setDefaultAccount(project, account) diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/service/GithubPullRequestsStateServiceImpl.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/service/GithubPullRequestsStateServiceImpl.kt index 51cfdf72ec9e..f54d94e9801f 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/service/GithubPullRequestsStateServiceImpl.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/service/GithubPullRequestsStateServiceImpl.kt @@ -1,8 +1,8 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.pullrequest.data.service import com.intellij.openapi.Disposable -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager @@ -101,7 +101,7 @@ class GithubPullRequestsStateServiceImpl internal constructor(private val projec indicator.checkCanceled() indicator.text2 = "Acquiring commit message" - val commitMessage = invokeAndWaitIfNeed { + val commitMessage = invokeAndWaitIfNeeded { val dialog = GithubMergeCommitMessageDialog(project, "Merge Pull Request", "Merge pull request #${pullRequest}", @@ -182,7 +182,7 @@ class GithubPullRequestsStateServiceImpl internal constructor(private val projec indicator.text2 = "Acquiring commit message" val body = "* " + StringUtil.join(commits, { it.subject }, "\n\n* ") - val commitMessage = invokeAndWaitIfNeed { + val commitMessage = invokeAndWaitIfNeeded { val dialog = GithubMergeCommitMessageDialog(project, "Merge Pull Request", "Merge pull request #${pullRequest}", diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.kt b/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.kt index df46fe5a334a..bbba01434988 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.kt @@ -1,9 +1,9 @@ -// 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 file. +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.github.util import com.intellij.concurrency.JobScheduler import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.invokeAndWaitIfNeed +import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.progress.ProgressIndicator @@ -120,7 +120,7 @@ object GithubUtil { val authManager = GithubAuthenticationManager.getInstance() var account = authManager.getSingleOrDefaultAccount(project) if (account == null) { - account = invokeAndWaitIfNeed(ModalityState.any()) { authManager.requestNewAccount(project) } + account = invokeAndWaitIfNeeded(ModalityState.any()) { authManager.requestNewAccount(project) } } if (account == null) throw ProcessCanceledException()