Don't irritate user and in interrupt execution of methods with assertTimeConsuming(). Warning is used instead.

This commit is contained in:
Nikolay Krasko
2012-08-27 14:06:23 +04:00
parent dfecf24b80
commit 3fd96fb049
2 changed files with 46 additions and 3 deletions
@@ -19,7 +19,6 @@ package org.jetbrains.jet.plugin.project;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
@@ -54,6 +53,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.plugin.util.ApplicationUtils;
import java.util.Arrays;
import java.util.Collection;
@@ -101,7 +101,7 @@ public final class AnalyzerFacadeWithCache {
@Override
public Result<AnalyzeExhaust> compute() {
try {
ApplicationManagerEx.getApplicationEx().assertTimeConsuming();
ApplicationUtils.warnTimeConsuming(LOG);
// Collect context for headers first
AnalyzeExhaust analyzeExhaustHeaders = analyzeHeadersWithCacheOnFile(file, declarationProvider);
@@ -194,7 +194,7 @@ public final class AnalyzerFacadeWithCache {
CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<ResolveSession>() {
@Override
public Result<ResolveSession> compute() {
ApplicationManagerEx.getApplicationEx().assertTimeConsuming();
ApplicationUtils.warnTimeConsuming(LOG);
ModuleDescriptor javaModule = new ModuleDescriptor(Name.special("<java module>"));
@@ -0,0 +1,43 @@
/*
* Copyright 2010-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.
*/
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;
/**
* @author Nikolay Krasko
*/
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");
}
}