Rewrite ApplicationUtils.java to Kotlin
This commit is contained in:
+2
-2
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils
|
||||
import com.intellij.util.containers.SLRUCache
|
||||
import com.intellij.psi.util.PsiModificationTracker
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import org.jetbrains.jet.plugin.util.ApplicationUtils
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerForJvm
|
||||
import org.jetbrains.jet.context.SimpleGlobalContext
|
||||
@@ -65,6 +64,7 @@ import org.jetbrains.jet.lang.types.TypeUtils
|
||||
import org.jetbrains.jet.lang.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.plugin.util.application.warnTimeConsuming
|
||||
|
||||
public trait CacheExtension<T> {
|
||||
public val platform: TargetPlatform
|
||||
@@ -172,7 +172,7 @@ private class PerFileAnalysisCache(val file: JetFile, val resolveSession: Resolv
|
||||
return AnalyzeExhaust.EMPTY
|
||||
}
|
||||
|
||||
ApplicationUtils.warnTimeConsuming(LOG)
|
||||
warnTimeConsuming(LOG)
|
||||
|
||||
try {
|
||||
return KotlinResolveDataProvider.analyze(project, resolveSession, analyzableElement)
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.util;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
|
||||
public final class ApplicationUtils {
|
||||
private ApplicationUtils() {
|
||||
}
|
||||
|
||||
public static void warnTimeConsuming(Logger logger) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application.isUnitTestMode() || application.isHeadlessEnvironment() || ShutDownTracker.isShutdownHookRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!application.isDispatchThread()) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.warn("This operation is time consuming and must not be called on EDT.");
|
||||
|
||||
//noinspection CallToPrintStackTrace
|
||||
new Throwable().printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-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.jet.plugin.util.application
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.util.ShutDownTracker
|
||||
|
||||
public fun warnTimeConsuming(logger: Logger) {
|
||||
val application = ApplicationManager.getApplication()!!
|
||||
if (application.isUnitTestMode() || application.isHeadlessEnvironment() || ShutDownTracker.isShutdownHookRunning()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!application.isDispatchThread()) {
|
||||
return
|
||||
}
|
||||
|
||||
logger.warn("This operation is time consuming and must not be called on EDT.")
|
||||
Throwable().printStackTrace()
|
||||
}
|
||||
Reference in New Issue
Block a user