diff --git a/java/java-impl/src/com/intellij/psi/RefResolveServiceImpl.java b/java/java-impl/src/com/intellij/psi/RefResolveServiceImpl.java index 3655942f97b7..8b4e3062a9f4 100644 --- a/java/java-impl/src/com/intellij/psi/RefResolveServiceImpl.java +++ b/java/java-impl/src/com/intellij/psi/RefResolveServiceImpl.java @@ -16,6 +16,7 @@ package com.intellij.psi; import com.intellij.concurrency.JobLauncher; +import com.intellij.ide.PowerSaveMode; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationAdapter; import com.intellij.openapi.application.ApplicationManager; @@ -27,7 +28,9 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; +import com.intellij.openapi.progress.util.ProgressIndicatorBase; import com.intellij.openapi.progress.util.ProgressIndicatorUtils; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.IndexNotReadyException; @@ -87,7 +90,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable private final ApplicationEx myApplication; private volatile boolean myDisposed; private volatile boolean upToDate; - private volatile boolean enabled = true; + private final AtomicInteger enableVetoes = new AtomicInteger(); // number of disable() calls. To enable the service, there should be at least corresponding number of enable() calls. private final FileWriter log; private final ProjectFileIndex myProjectFileIndex; @@ -205,6 +208,17 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable enable(); } }); + messageBus.connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() { + @Override + public void powerSaveStateChanged() { + if (PowerSaveMode.isEnabled()) { + enable(); + } + else { + disable(); + } + } + }); myApplication.addApplicationListener(new ApplicationAdapter() { @Override public void beforeWriteActionStart(Object action) { @@ -375,7 +389,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable synchronized (filesToResolve) { isEmpty = filesToResolve.isEmpty(); } - if (!enabled || isEmpty) { + if (enableVetoes.get() > 0 || isEmpty) { try { waitForQueue(); } @@ -389,18 +403,25 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - new Task.Backgroundable(myProject, "Resolving files...", true) { + final Set files = countFilesToResolve(); + Task.Backgroundable backgroundable = new Task.Backgroundable(myProject, "Resolving files...", true) { @Override public void run(@NotNull final ProgressIndicator indicator) { if (ApplicationManager.getApplication().isDisposed()) return; try { - processBatch(indicator); + processBatch(indicator, files); } finally { batchProcessedLatch.countDown(); } } - }.queue(); + }; + if (files.size() > 1) { + backgroundable.queue(); //show progress + } + else { + ProgressManager.getInstance().runProcessWithProgressAsynchronously(backgroundable, new MyProgress()); + } } }, myProject.getDisposed()); @@ -419,27 +440,10 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable } } - private void processBatch(@NotNull final ProgressIndicator indicator) { - Set set; - int queuedSize; - synchronized (filesToResolve) { - queuedSize = filesToResolve.size(); - set = new THashSet(queuedSize); - // someone might have cleared this bit to mark file as processed - for (VirtualFile file : filesToResolve) { - if (fileIsInQueue.clear(getAbsId(file))) { - set.add(file); - } - } - filesToResolve.clear(); - } - final ConcurrentIntObjectMap fileToForwardIds = new StripedLockIntObjectConcurrentHashMap(); - Set files = countAndMarkUnresolved(set, false); - if (files.isEmpty()) return; + private void processBatch(@NotNull final ProgressIndicator indicator, @NotNull Set files) { final int size = files.size(); + final ConcurrentIntObjectMap fileToForwardIds = new StripedLockIntObjectConcurrentHashMap(); final Set toProcess = Collections.synchronizedSet(files); - log("Started to resolve "+ size + " files (was queued "+queuedSize+")"); - indicator.setIndeterminate(false); ProgressIndicatorUtils.forceWriteActionPriority(indicator, (Disposable)indicator); long start = System.currentTimeMillis(); @@ -483,6 +487,26 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable } } + private Set countFilesToResolve() { + Set set; + int queuedSize; + synchronized (filesToResolve) { + queuedSize = filesToResolve.size(); + set = new THashSet(queuedSize); + // someone might have cleared this bit to mark file as processed + for (VirtualFile file : filesToResolve) { + if (fileIsInQueue.clear(getAbsId(file))) { + set.add(file); + } + } + filesToResolve.clear(); + } + Set files = countAndMarkUnresolved(set, false); + if (files.isEmpty()) return null; + log("Started to resolve "+ files.size() + " files (was queued "+queuedSize+")"); + return files; + } + private static int getAbsId(@NotNull VirtualFile file) { return Math.abs(((VirtualFileWithId)file).getId()); } @@ -528,12 +552,17 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable } private void enable() { - enabled = true; + // decrement but only if it's positive + int vetoes; + do { + vetoes = enableVetoes.get(); + if (vetoes == 0) break; + } while(!enableVetoes.compareAndSet(vetoes, vetoes-1)); wakeUp(); } private void disable() { - enabled = false; + enableVetoes.incrementAndGet(); wakeUp(); } @@ -644,7 +673,8 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable psiFile.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceElement(PsiJavaCodeReferenceElement reference) { - resolveReference(reference, indicator, resolved); + indicator.checkCanceled(); + resolveReference(reference, resolved); super.visitReferenceElement(reference); } @@ -655,7 +685,8 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable @Override public void visitXmlElement(XmlElement element) { for (PsiReference reference : element.getReferences()) { - resolveReference(reference, indicator, resolved); + indicator.checkCanceled(); + resolveReference(reference, resolved); } super.visitXmlElement(element); } @@ -675,8 +706,7 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable return forward; } - private void resolveReference(@NotNull PsiReference reference, @NotNull ProgressIndicator indicator, @NotNull Set resolved) { - indicator.checkCanceled(); + private void resolveReference(@NotNull PsiReference reference, @NotNull Set resolved) { PsiElement element = reference.resolve(); if (element != null) { resolved.add(element); @@ -770,4 +800,10 @@ public class RefResolveServiceImpl extends RefResolveService implements Runnable } return queued; } + + private static class MyProgress extends ProgressIndicatorBase implements Disposable{ + @Override + public void dispose() { + } + } } diff --git a/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java b/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java index 8ad915c5ed95..5aed647ddec2 100644 --- a/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java +++ b/java/java-indexing-api/src/com/intellij/psi/search/searches/FunctionalExpressionSearch.java @@ -15,7 +15,9 @@ */ package com.intellij.psi.search.searches; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiFunctionalExpression; import com.intellij.psi.PsiMethod; @@ -36,7 +38,7 @@ public class FunctionalExpressionSearch extends ExtensibleQueryFactory search(final PsiClass aClass, SearchScope scope) { + public static Query search(@NotNull final PsiClass aClass, @NotNull SearchScope scope) { return INSTANCE.createUniqueResultsQuery(new SearchParameters(aClass, scope)); } - public static Query search(final PsiMethod psiMethod) { + public static Query search(@NotNull final PsiMethod psiMethod) { return search(psiMethod, GlobalSearchScope.allScope(psiMethod.getProject())); } - public static Query search(final PsiMethod psiMethod, SearchScope scope) { - if (!psiMethod.hasModifierProperty(PsiModifier.STATIC) && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) { - return INSTANCE.createUniqueResultsQuery(new SearchParameters(psiMethod.getContainingClass(), scope)); - } + public static Query search(@NotNull final PsiMethod psiMethod, @NotNull final SearchScope scope) { + return ApplicationManager.getApplication().runReadAction(new Computable>() { + @Override + public Query compute() { + if (!psiMethod.hasModifierProperty(PsiModifier.STATIC) && !psiMethod.hasModifierProperty(PsiModifier.DEFAULT)) { + return INSTANCE.createUniqueResultsQuery(new SearchParameters(psiMethod.getContainingClass(), scope)); + } - return EmptyQuery.getEmptyQuery(); + return EmptyQuery.getEmptyQuery(); + } + }); } - public static Query search(final PsiClass aClass) { + public static Query search(@NotNull final PsiClass aClass) { return search(aClass, GlobalSearchScope.allScope(aClass.getProject())); } } diff --git a/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java b/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java index d5603b2a28ae..4225270ed4b4 100644 --- a/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java +++ b/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -42,6 +42,7 @@ public class EmptyProgressIndicator implements ProgressIndicator { @Override public void cancel() { myIsCanceled = true; + ProgressIndicatorProvider.canceled(); } @Override diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java index afe440b8588f..89ff2fcd48a1 100644 --- a/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java +++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressIndicatorProvider.java @@ -54,4 +54,8 @@ public abstract class ProgressIndicatorProvider { ourInstance.doCheckCanceled(); } } + + public static void canceled() { + ourNeedToCheckCancel = true; + } } diff --git a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java index 4b4ace28cd37..3f0601ba951b 100644 --- a/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java +++ b/platform/core-api/src/com/intellij/openapi/progress/ProgressManager.java @@ -184,7 +184,7 @@ public abstract class ProgressManager extends ProgressIndicatorProvider { throws ProcessCanceledException { ProgressIndicator oldIndicator = null; - boolean set = progress != null && progress != (oldIndicator = myThreadIndicator.get()); + boolean set = progress != null && progress != (oldIndicator = getProgressIndicator()); if (set) { myThreadIndicator.set(progress); } diff --git a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java index d548fd2412b2..132dd5b30ee4 100644 --- a/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java +++ b/platform/core-impl/src/com/intellij/openapi/progress/util/AbstractProgressIndicatorBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * 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. @@ -21,6 +21,7 @@ import com.intellij.openapi.application.impl.ModalityStateEx; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressIndicatorProvider; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.util.containers.ConcurrentHashSet; import com.intellij.util.containers.DoubleArrayList; @@ -89,6 +90,7 @@ public class AbstractProgressIndicatorBase extends UserDataHolderBase implements @Override public void cancel() { myCanceled = true; + ProgressIndicatorProvider.canceled(); } @Override diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java index b441952f7a43..996a04317b7d 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/ui/VcsPushDialog.java @@ -20,6 +20,7 @@ import com.intellij.dvcs.push.VcsPushOptionsPanel; import com.intellij.dvcs.repo.Repository; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.OptionAction; import com.intellij.openapi.ui.ValidationInfo; import net.miginfocom.swing.MigLayout; @@ -32,8 +33,11 @@ import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.List; +import static com.intellij.openapi.ui.Messages.CANCEL; + public class VcsPushDialog extends DialogWrapper { + @NotNull private final Project myProject; private final PushLog myListPanel; private final PushController myController; private final Action[] myExecutorActions = {new DvcsPushAction("&Force Push", true)}; @@ -43,6 +47,7 @@ public class VcsPushDialog extends DialogWrapper { public VcsPushDialog(@NotNull Project project, @NotNull List selectedRepositories) { super(project); + myProject = project; myController = new PushController(project, this, selectedRepositories); myListPanel = myController.getPushPanelInfo(); myAdditionalOptionsFromVcsPanel = new JPanel(new MigLayout("ins 0 0, flowx")); @@ -127,6 +132,12 @@ public class VcsPushDialog extends DialogWrapper { @Override public void actionPerformed(ActionEvent e) { + if (myForce) { + int answer = Messages.showOkCancelDialog(myProject, "Would you like to force push in all selected repositories?", + "Force Push Confirmation Dialog", + "&Force Push", "&Cancel", Messages.getWarningIcon()); + if (answer == CANCEL) return; + } myController.push(myForce); close(OK_EXIT_CODE); } diff --git a/platform/indexing-api/src/com/intellij/psi/search/searches/ReferencesSearch.java b/platform/indexing-api/src/com/intellij/psi/search/searches/ReferencesSearch.java index aafb85d529bc..4271680aea1b 100644 --- a/platform/indexing-api/src/com/intellij/psi/search/searches/ReferencesSearch.java +++ b/platform/indexing-api/src/com/intellij/psi/search/searches/ReferencesSearch.java @@ -15,7 +15,10 @@ */ package com.intellij.psi.search.searches; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Computable; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.search.*; @@ -112,7 +115,13 @@ public class ReferencesSearch extends ExtensibleQueryFactory(result, new SearchRequestQuery(element.getProject(), requests))); + return uniqueResults(new MergeQuery(result, new SearchRequestQuery( + ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Project compute() { + return element.getProject(); + } + }), requests))); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index fd91b710ecd0..0ca85ae6e676 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -426,6 +426,7 @@ public class DocumentationManager extends DockablePopupManager timeout) { - throw new RuntimeException("timeout"); - } - attempts++; - } - } - } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java index f83dcfe4788f..93921cd6c1dc 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java @@ -431,8 +431,14 @@ public abstract class BaseRefactoringProcessor implements Runnable { final Runnable prepareHelpersRunnable = new Runnable() { @Override public void run() { - for (RefactoringHelper helper : Extensions.getExtensions(RefactoringHelper.EP_NAME)) { - preparedData.put(helper, helper.prepareOperation(writableUsageInfos)); + for (final RefactoringHelper helper : Extensions.getExtensions(RefactoringHelper.EP_NAME)) { + Object operation = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Object compute() { + return helper.prepareOperation(writableUsageInfos); + } + }); + preparedData.put(helper, operation); } } }; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java index a34d30dc5401..dd20f5a7d3e7 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -25,6 +25,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFrame; @@ -184,9 +185,14 @@ public class RenameProcessor extends BaseRefactoringProcessor { final Runnable runnable = new Runnable() { @Override public void run() { - for (Map.Entry entry : renames.entrySet()) { + for (final Map.Entry entry : renames.entrySet()) { final UsageInfo[] usages = - RenameUtil.findUsages(entry.getKey(), entry.getValue(), mySearchInComments, mySearchTextOccurrences, myAllRenames); + ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public UsageInfo[] compute() { + return RenameUtil.findUsages(entry.getKey(), entry.getValue(), mySearchInComments, mySearchTextOccurrences, myAllRenames); + } + }); Collections.addAll(variableUsages, usages); } } @@ -223,9 +229,14 @@ public class RenameProcessor extends BaseRefactoringProcessor { final Runnable runnable = new Runnable() { @Override public void run() { - for (final AutomaticRenamer renamer : myRenamers) { - renamer.findUsages(variableUsages, mySearchInComments, mySearchTextOccurrences, mySkippedUsages, myAllRenames); - } + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + for (final AutomaticRenamer renamer : myRenamers) { + renamer.findUsages(variableUsages, mySearchInComments, mySearchTextOccurrences, mySkippedUsages, myAllRenames); + } + } + }); } }; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 6fa0ed27d8c8..0f9011308533 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -245,7 +245,12 @@ public class VariableInplaceRenamer extends InplaceRefactoring { final Runnable runnable = new Runnable() { @Override public void run() { - renamer.findUsages(usages, false, false); + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + renamer.findUsages(usages, false, false); + } + }); } }; diff --git a/platform/platform-api/src/com/intellij/mock/MockProgressIndicator.java b/platform/platform-api/src/com/intellij/mock/MockProgressIndicator.java index f69cf9b0b963..bc2fd80a5efa 100644 --- a/platform/platform-api/src/com/intellij/mock/MockProgressIndicator.java +++ b/platform/platform-api/src/com/intellij/mock/MockProgressIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -15,97 +15,11 @@ */ package com.intellij.mock; -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.progress.ProgressIndicator; -import org.jetbrains.annotations.NotNull; +import com.intellij.openapi.progress.EmptyProgressIndicator; +import org.jetbrains.annotations.TestOnly; -public class MockProgressIndicator implements ProgressIndicator { - private boolean myIsRunning = false; - private boolean myIsCanceled = false; - - public void start() { - myIsRunning = true; - myIsCanceled = false; - } - - public void stop() { - myIsRunning = false; - } - - public boolean isRunning() { - return myIsRunning; - } - - public void cancel() { - myIsCanceled = true; - } - - public boolean isCanceled() { - return myIsCanceled; - } - - public void setText(String text) { - } - - public String getText() { - return ""; - } - - public void setText2(String text) { - } - - public String getText2() { - return ""; - } - - public double getFraction() { - return 1; - } - - public void setFraction(double fraction) { - } - - public void pushState() { - } - - public void popState() { - } - - public void startNonCancelableSection() { - } - - public void finishNonCancelableSection() { - } - - public boolean isModal() { - return false; - } - - @NotNull - public ModalityState getModalityState() { - return ModalityState.NON_MODAL; - } - - public void setModalityProgress(ProgressIndicator modalityProgress) { - } - - public boolean isIndeterminate() { - return false; - } - - public void setIndeterminate(boolean indeterminate) { - } - - public void checkCanceled() { - } - - @Override - public boolean isPopupWasShown() { - return false; - } - - @Override - public boolean isShowing() { - return false; +public class MockProgressIndicator extends EmptyProgressIndicator { + @TestOnly + public MockProgressIndicator() { } } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index 8f19594a801a..23491c2bdd6a 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -360,7 +360,12 @@ public class IdeEventQueue extends EventQueue { @Override public void dispatchEvent(AWTEvent e) { if (!appIsLoaded()) { - super.dispatchEvent(e); + try { + super.dispatchEvent(e); + } + catch (Throwable t) { + processException(t); + } return; } @@ -379,9 +384,7 @@ public class IdeEventQueue extends EventQueue { _dispatchEvent(e, false); } catch (Throwable t) { - if (!myToolkitBugsProcessor.process(t)) { - PluginManager.processException(t); - } + processException(t); } finally { myIsInInputEvent = wasInputEvent; @@ -397,6 +400,12 @@ public class IdeEventQueue extends EventQueue { } } + private void processException(Throwable t) { + if (!myToolkitBugsProcessor.process(t)) { + PluginManager.processException(t); + } + } + private static void fixNonEnglishKeyboardLayouts(AWTEvent e) { if (!Registry.is("ide.non.english.keyboard.layout.fix")) return; if (e instanceof KeyEvent) { @@ -739,9 +748,7 @@ public class IdeEventQueue extends EventQueue { super.dispatchEvent(e); } catch (Throwable t) { - if (!myToolkitBugsProcessor.process(t)) { - PluginManager.processException(t); - } + processException(t); } finally { myDispatchingFocusEvent = false; diff --git a/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java b/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java index 3e644468f282..709c3b458112 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/BaseNavigateToSourceAction.java @@ -17,7 +17,6 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.pom.Navigatable; import com.intellij.pom.NavigatableWithText; import com.intellij.pom.PomTargetPsiElement; @@ -56,7 +55,7 @@ public abstract class BaseNavigateToSourceAction extends AnAction implements Dum event.getPresentation().setVisible(target == null || myFocusEditor); String navigateActionText = myFocusEditor && target instanceof NavigatableWithText? ((NavigatableWithText)target).getNavigateActionText(true) : null; - event.getPresentation().setText(StringUtil.notNullize(navigateActionText, getTemplatePresentation().getText())); + event.getPresentation().setText(navigateActionText == null ? getTemplatePresentation().getText() : navigateActionText); } @Nullable diff --git a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java index 786a5825e783..b1b0db1fd0d7 100644 --- a/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/customize/CustomizeFeaturedPluginsStepPanel.java @@ -107,11 +107,11 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt JPanel progressPanel = new JPanel(new VerticalFlowLayout(true, false)); progressPanel.add(progressBar); final LinkLabel cancelLink = new LinkLabel("Cancel", AllIcons.Actions.Cancel); - JPanel linkWrapper = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel linkWrapper = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); linkWrapper.add(cancelLink); progressPanel.add(linkWrapper); - JPanel buttonPanel = new JPanel(new VerticalFlowLayout()); + JPanel buttonPanel = new JPanel(new VerticalFlowLayout(0, 0)); buttonPanel.add(installButton); buttonWrapper.add(buttonPanel, "button"); @@ -238,7 +238,7 @@ public class CustomizeFeaturedPluginsStepPanel extends AbstractCustomizeWizardSt protected Color getColor() { return ColorUtil.withAlpha(JBColor.foreground(), .2); } - }, BorderFactory.createEmptyBorder(GAP, GAP, 0, GAP))); + }, BorderFactory.createEmptyBorder(0, GAP / 2, 0, GAP / 2))); cursor++; } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java index a1ea238835cd..57329fb8fe9d 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java @@ -15,6 +15,7 @@ */ package com.intellij.ide.plugins; +import com.intellij.diagnostic.PluginException; import com.intellij.ide.ClassUtilCore; import com.intellij.ide.IdeBundle; import com.intellij.idea.IdeaApplication; @@ -100,31 +101,44 @@ public class PluginManager extends PluginManagerCore { public static void processException(Throwable t) { if (!IdeaApplication.isLoaded()) { - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") StartupAbortedException se = findCause(t); + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") StartupAbortedException se = findCause(t, StartupAbortedException.class); if (se == null) se = new StartupAbortedException(t); + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") PluginException pe = findCause(t, PluginException.class); + PluginId pluginId = pe != null ? pe.getPluginId() : null; - if (se.logError()) { + if (Logger.isInitialized() && !(t instanceof ProcessCanceledException)) { try { - if (Logger.isInitialized() && !(t instanceof ProcessCanceledException)) { - getLogger().error(t); - } + getLogger().error(t); } catch (Throwable ignore) { } - - Main.showMessage("Start Failed", t); } - System.exit(se.exitCode()); + if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) { + disablePlugin(pluginId.getIdString()); + + StringWriter message = new StringWriter(); + message.append("Plugin '").append(pluginId.getIdString()).append("' failed to initialize and will be disabled. "); + message.append(" Please restart ").append(ApplicationNamesInfo.getInstance().getFullProductName()).append('.'); + message.append("\n\n"); + pe.getCause().printStackTrace(new PrintWriter(message)); + + Main.showMessage("Plugin Error", message.toString(), false); + System.exit(Main.PLUGIN_ERROR); + } + else { + Main.showMessage("Start Failed", t); + System.exit(se.exitCode()); + } } else if (!(t instanceof ProcessCanceledException)) { getLogger().error(t); } } - private static StartupAbortedException findCause(Throwable t) { + private static T findCause(Throwable t, Class clazz) { while (t != null) { - if (t instanceof StartupAbortedException) { - return (StartupAbortedException)t; + if (clazz.isInstance(t)) { + return clazz.cast(t); } t = t.getCause(); } @@ -229,18 +243,7 @@ public class PluginManager extends PluginManagerCore { } if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) { - getLogger().warn(t); - - disablePlugin(pluginId.getIdString()); - - StringWriter message = new StringWriter(); - message.append("Plugin '").append(pluginId.getIdString()).append("' failed to initialize and will be disabled. "); - message.append(" Please restart ").append(ApplicationNamesInfo.getInstance().getFullProductName()).append('.'); - message.append("\n\n"); - t.printStackTrace(new PrintWriter(message)); - Main.showMessage("Plugin Error", message.toString(), false); - - throw new StartupAbortedException(t).exitCode(Main.PLUGIN_ERROR).logError(false); + throw new StartupAbortedException(new PluginException(t, pluginId)); } else { throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'", t); @@ -249,7 +252,6 @@ public class PluginManager extends PluginManagerCore { private static class StartupAbortedException extends RuntimeException { private int exitCode = Main.STARTUP_EXCEPTION; - private boolean logError = true; public StartupAbortedException(Throwable cause) { super(cause); @@ -267,14 +269,5 @@ public class PluginManager extends PluginManagerCore { this.exitCode = exitCode; return this; } - - public boolean logError() { - return logError; - } - - public StartupAbortedException logError(boolean logError) { - this.logError = logError; - return this; - } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 81d1f1190702..21d527b1fff5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -743,12 +743,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi myGutterComponent.repaint(0, y, myGutterComponent.getWidth(), myGutterComponent.getHeight() - y); } // make sure carets won't appear at invalid positions (e.g. on Tab width change) - getCaretModel().runForEachCaret(new CaretAction() { - @Override - public void perform(Caret caret) { - caret.moveToOffset(caret.getOffset()); - } - }); + for (Caret caret : getCaretModel().getAllCarets()) { + caret.moveToOffset(caret.getOffset()); + } } private void initTabPainter() { diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java index 6a37bb2fb69e..3d478f2b7084 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/impl/ProgressManagerImpl.java @@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class ProgressManagerImpl extends ProgressManager implements Disposable { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.progress.impl.ProgressManagerImpl"); + public static final int CHECK_CANCELED_DELAY_MILLIS = 10; private final AtomicInteger myCurrentUnsafeProgressCount = new AtomicInteger(0); private final AtomicInteger myCurrentModalProgressCount = new AtomicInteger(0); @@ -64,7 +65,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable { public void run() { ourNeedToCheckCancel = true; } - }, 0, 10, TimeUnit.MILLISECONDS); + }, 0, CHECK_CANCELED_DELAY_MILLIS, TimeUnit.MILLISECONDS); } } @@ -83,7 +84,7 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable { ourLockedCheckCounter++; if (ourLockedCheckCounter > 10) { ourLockedCheckCounter = 0; - ourNeedToCheckCancel = true; + canceled(); } } else { @@ -94,10 +95,6 @@ public class ProgressManagerImpl extends ProgressManager implements Disposable { } } - public static void canceled() { - ourNeedToCheckCancel = true; - } - private static class NonCancelableIndicator extends EmptyProgressIndicator implements NonCancelableSection { private final ProgressIndicator myOld; diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorBase.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorBase.java index 2d9a7b3a88e6..b4821f52fddb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorBase.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/ProgressIndicatorBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * 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. @@ -19,7 +19,6 @@ import com.intellij.openapi.application.impl.LaterInvocator; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.TaskInfo; -import com.intellij.openapi.progress.impl.ProgressManagerImpl; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.WeakList; @@ -151,9 +150,6 @@ public class ProgressIndicatorBase extends AbstractProgressIndicatorBase impleme @Override public void cancel() { super.cancel(); - - ProgressManagerImpl.canceled(); - delegateRunningChange(CANCEL_ACTION); } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index 2f95c21cb558..c01edf79e925 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -21,6 +21,7 @@ import com.intellij.conversion.ConversionService; import com.intellij.ide.AppLifecycleListener; import com.intellij.ide.RecentProjectsManagerBase; import com.intellij.ide.impl.ProjectUtil; +import com.intellij.ide.plugins.PluginManager; import com.intellij.ide.startup.impl.StartupManagerImpl; import com.intellij.notification.NotificationsManager; import com.intellij.openapi.Disposable; @@ -354,7 +355,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt myDefaultProjectRootElement = null; } catch (Throwable t) { - LOG.error(t); + PluginManager.processException(t); } } }); diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 6ff354015918..c82ee6df346b 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -208,22 +208,28 @@ public class JDOMUtil { } @NotNull - public static String legalizeText(@NotNull final String str) { - StringBuilder result = new StringBuilder(str.length()); - for (int i = 0, len = str.length(); i < len; i ++) { - result.append(str.charAt(i)); - legalizeChar(result, result.length() - 1); - } - return result.toString(); + public static String legalizeText(@NotNull String str) { + return legalizeChars(str).toString(); } - public static void legalizeChar(@NotNull StringBuilder sb, int pos) { - char each = sb.charAt(pos); + @NotNull + public static CharSequence legalizeChars(@NotNull CharSequence str) { + StringBuilder result = new StringBuilder(str.length()); + for (int i = 0, len = str.length(); i < len; i ++) { + appendLegalized(result, str.charAt(i)); + } + return result; + } + + public static void appendLegalized(@NotNull StringBuilder sb, char each) { if (each == '<' || each == '>') { - sb.replace(pos, pos + 1, each == '<' ? "<" : ">"); + sb.append(each == '<' ? "<" : ">"); } else if (!Verifier.isXMLCharacter(each)) { - sb.replace(pos, pos + 1, "0x").insert(pos + 2, StringUtil.toUpperCase(Long.toHexString(each))); + sb.append("0x").append(StringUtil.toUpperCase(Long.toHexString(each))); + } + else { + sb.append(each); } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogRefresherImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogRefresherImpl.java index 12996f91c116..c7ab5e324b3d 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogRefresherImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/VcsLogRefresherImpl.java @@ -15,12 +15,14 @@ */ package com.intellij.vcs.log.data; +import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.progress.impl.ProgressManagerImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; @@ -272,22 +274,23 @@ public class VcsLogRefresherImpl implements VcsLogRefresher { Map> currentRefs = myCurrentDataPack.getRefsModel().getAllRefsByRoot(); try { if (permanentGraph != null) { - loadLogAndRefs(roots, currentRefs, myRecentCommitCount); - List> compoundLog = compound(ContainerUtil.map(myLoadedInfos.values(), - new Function>>() { - @Override - public List> fun( - LogAndRefs refs) { - return refs.log; - } - })); - Map> allNewRefs = getAllNewRefs(myLoadedInfos, currentRefs); - List> joinedFullLog = join(compoundLog, permanentGraph.getAllCommits(), currentRefs, allNewRefs); - if (joinedFullLog != null) { - return DataPack.build(joinedFullLog, new RefsModel(allNewRefs, myHashMap.asIndexGetter()), - myHashMap.asIndexGetter(), myHashMap.asHashGetter(), myProviders, true); + int commitCount = myRecentCommitCount; + for (int attempt = 0; attempt <= 1; attempt++) { + loadLogAndRefs(roots, currentRefs, commitCount); + List> compoundLog = compoundLoadedLogs(myLoadedInfos.values()); + Map> allNewRefs = getAllNewRefs(myLoadedInfos, currentRefs); + List> joinedFullLog = join(compoundLog, permanentGraph.getAllCommits(), currentRefs, allNewRefs); + if (joinedFullLog == null) { + commitCount *= 5; + } + else { + return DataPack.build(joinedFullLog, new RefsModel(allNewRefs, myHashMap.asIndexGetter()), + myHashMap.asIndexGetter(), myHashMap.asHashGetter(), myProviders, true); + } } - // couldn't join => need to reload everything; this shouldn't happen often, the error is logged in join(). + // couldn't join => need to reload everything; if 5000 commits is still not enough, it's worth reporting: + LOG.error("Couldn't join " + commitCount + " recent commits to the log (" + permanentGraph.getAllCommits().size() + " commits)", + new Attachment("recent_commits", toLogString(myLoadedInfos))); } Pair, Map>> fullLogAndRefs = loadFullLog(); @@ -302,6 +305,38 @@ public class VcsLogRefresherImpl implements VcsLogRefresher { } } + private String toLogString(Map infos) { + StringBuilder sb = new StringBuilder(); + for (Map.Entry entry : infos.entrySet()) { + sb.append(entry.getKey().getName()); + sb.append(" LOG:\n"); + sb.append(StringUtil.join(entry.getValue().log, new Function, String>() { + @Override + public String fun(GraphCommit commit) { + return commit.getId() + "<-" + StringUtil.join(commit.getParents(), ","); + } + }, "\n")); + sb.append("\nREFS:\n"); + sb.append(StringUtil.join(entry.getValue().refs, new Function() { + @Override + public String fun(VcsRef ref) { + return ref.getName() + "(" + myHashMap.getCommitIndex(ref.getCommitHash()) + ")"; + } + }, ",")); + } + return sb.toString(); + } + + @NotNull + private List> compoundLoadedLogs(@NotNull Collection logsAndRefs) { + return compound(ContainerUtil.map(logsAndRefs, new Function>>() { + @Override + public List> fun(LogAndRefs refs) { + return refs.log; + } + })); + } + @NotNull private Map> getAllNewRefs(@NotNull Map newInfo, @NotNull Map> previousRefs) { @@ -374,7 +409,7 @@ public class VcsLogRefresherImpl implements VcsLogRefresher { return commits; } catch (VcsLogRefreshNotEnoughDataException e) { - LOG.error(e); // collecting information : how often this situation happens, do we need to try to load more or can safely reload all + LOG.info(e); } catch (IllegalStateException e) { LOG.error(e); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogSettingsImpl.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogSettingsImpl.java index 88b2b449ac69..016f08451a95 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogSettingsImpl.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogSettingsImpl.java @@ -45,9 +45,4 @@ public class VcsLogSettingsImpl implements VcsLogSettings, PersistentStateCompon public void setShowBranchesPanel(boolean show) { myState.SHOW_BRANCHES_PANEL = show; } - - public void setRecentCommitsBlockSize(int commitCount) { - myState.RECENT_COMMITS_COUNT = commitCount; - } - } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java index ec5c50db6e9d..390e61b8b53b 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEditorLinePainter.java @@ -15,8 +15,10 @@ */ package com.intellij.xdebugger.impl.evaluate; +import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorLinePainter; import com.intellij.openapi.editor.LineExtensionInfo; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; @@ -39,63 +41,72 @@ import java.util.List; * @author Konstantin Bulenkov */ public class XDebuggerEditorLinePainter extends EditorLinePainter { - public static final Key> CACHE = Key.create("debug.frame"); + public static final Key> CACHE = Key.create("debug.inline.variables.cache"); @Override public Collection getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) { if (!Registry.is("ide.debugger.inline")) { return null; } - Map, Set> map = project.getUserData(XVariablesView.DEBUG_VARIABLES); + final Map, Set> map = project.getUserData(XVariablesView.DEBUG_VARIABLES); + final Map timestamps = project.getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS); + final Document doc = FileDocumentManager.getInstance().getDocument(file); + + if (map == null || timestamps == null || doc == null) { + return null; + } + Map oldValues = project.getUserData(CACHE); if (oldValues == null) { oldValues = new HashMap(); project.putUserData(CACHE, oldValues); } - if (map != null) { - Set values = map.get(Pair.create(file, lineNumber)); - if (values != null && !values.isEmpty()) { - ArrayList result = new ArrayList(); - for (XValueNodeImpl value : values) { - SimpleColoredText text = new SimpleColoredText(); - XValueTextRendererImpl renderer = new XValueTextRendererImpl(text); - final XValuePresentation presentation = value.getValuePresentation(); - if (presentation == null) continue; - try { - if (presentation instanceof XValueCompactPresentation) { - ((XValueCompactPresentation)presentation).renderValue(renderer, value); - } else { - presentation.renderValue(renderer); - } - } catch (Exception e) { - continue; - } - final Color color = getForeground(); - final String name = value.getName(); - result.add(new LineExtensionInfo(" " + name + ": ", color, null, null, Font.PLAIN)); - - Variable var = new Variable(name, lineNumber); - VariableValue variableValue = oldValues.get(var); - if (variableValue == null) { - variableValue = new VariableValue(text.toString(), null, value.hashCode()); - oldValues.put(var, variableValue); - } - if (variableValue.valueNodeHashCode != value.hashCode()) { - variableValue.old = variableValue.actual; - variableValue.actual = text.toString(); - variableValue.valueNodeHashCode = value.hashCode(); - } - - if (!variableValue.isChanged()) { - for (String s : text.getTexts()) { - result.add(new LineExtensionInfo(s, color, null, null, Font.PLAIN)); - } + final Long timestamp = timestamps.get(file); + if (timestamp == null || timestamp < doc.getModificationStamp()) { + return null; + } + Set values = map.get(Pair.create(file, lineNumber)); + if (values != null && !values.isEmpty()) { + ArrayList result = new ArrayList(); + for (XValueNodeImpl value : values) { + SimpleColoredText text = new SimpleColoredText(); + XValueTextRendererImpl renderer = new XValueTextRendererImpl(text); + final XValuePresentation presentation = value.getValuePresentation(); + if (presentation == null) continue; + try { + if (presentation instanceof XValueCompactPresentation) { + ((XValueCompactPresentation)presentation).renderValue(renderer, value); } else { - variableValue.produceChangedParts(result); + presentation.renderValue(renderer); } + } catch (Exception e) { + continue; + } + final Color color = getForeground(); + final String name = value.getName(); + result.add(new LineExtensionInfo(" " + name + ": ", color, null, null, Font.PLAIN)); + + Variable var = new Variable(name, lineNumber); + VariableValue variableValue = oldValues.get(var); + if (variableValue == null) { + variableValue = new VariableValue(text.toString(), null, value.hashCode()); + oldValues.put(var, variableValue); + } + if (variableValue.valueNodeHashCode != value.hashCode()) { + variableValue.old = variableValue.actual; + variableValue.actual = text.toString(); + variableValue.valueNodeHashCode = value.hashCode(); + } + + if (!variableValue.isChanged()) { + for (String s : text.getTexts()) { + result.add(new LineExtensionInfo(s, color, null, null, Font.PLAIN)); + } + } else { + variableValue.produceChangedParts(result); } - return result; } + return result; } return null; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java index df43b1147419..ea53645b57e5 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesView.java @@ -36,7 +36,8 @@ import static com.intellij.xdebugger.impl.ui.tree.nodes.MessageTreeNode.createIn * @author nik */ public class XVariablesView extends XVariablesViewBase { - public static final Key, Set>> DEBUG_VARIABLES = Key.create("debug.frame"); + public static final Key, Set>> DEBUG_VARIABLES = Key.create("debug.variables"); + public static final Key> DEBUG_VARIABLES_TIMESTAMPS = Key.create("debug.variables.timestamps"); public XVariablesView(@NotNull XDebugSessionImpl session) { super(session.getProject(), session.getDebugProcess().getEditorsProvider(), session.getValueMarkers()); @@ -69,6 +70,7 @@ public class XVariablesView extends XVariablesViewBase { protected void clear() { XDebuggerTree tree = getTree(); tree.getProject().putUserData(DEBUG_VARIABLES, null); + tree.getProject().putUserData(DEBUG_VARIABLES_TIMESTAMPS, null); tree.setSourcePosition(null); XDebuggerTreeNode node; diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java index ace9938318df..ab4483cd75d9 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java @@ -56,6 +56,7 @@ public abstract class XVariablesViewBase extends XDebugView { tree.setSourcePosition(stackFrame.getSourcePosition()); tree.setRoot(new XStackFrameNode(tree, stackFrame), false); tree.getProject().putUserData(XVariablesView.DEBUG_VARIABLES, new HashMap, Set>()); + tree.getProject().putUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS, new HashMap()); Object newEqualityObject = stackFrame.getEqualityObject(); if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java index aa3445b4b421..3f06418ac8ac 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java @@ -71,7 +71,7 @@ public class XDebuggerMultilineEditor extends XDebuggerEditorBase { @Override public XExpression getExpression() { - return XExpressionImpl.fromText(myEditorTextField.getText(), EvaluationMode.CODE_FRAGMENT); + return getEditorsProvider().createExpression(getProject(), myEditorTextField.getDocument(), myExpression.getLanguage(), EvaluationMode.CODE_FRAGMENT); } @Override diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java index 1f3d4c77e84f..4b10c1a28b09 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java @@ -16,6 +16,8 @@ package com.intellij.xdebugger.impl.ui.tree.nodes; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; @@ -120,26 +122,7 @@ public class XValueNodeImpl extends XValueContainerNode implements XValu myValuePresentation = valuePresentation; myRawValue = XValuePresentationUtil.computeValueText(valuePresentation); if (Registry.is("ide.debugger.inline")) { - try { - getValueContainer().computeSourcePosition(new XNavigatable() { - @Override - public void setSourcePosition(@Nullable XSourcePosition sourcePosition) { - Map, Set> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES); - if (map == null || sourcePosition == null) return; - VirtualFile file = sourcePosition.getFile(); - int line = sourcePosition.getLine(); - Pair key = Pair.create(file, line); - Set presentations = map.get(key); - if (presentations == null) { - presentations = new LinkedHashSet(); - map.put(key, presentations); - } - presentations.add(XValueNodeImpl.this); - } - }); - } - catch (Exception ignore) { - } + updateInlineDebuggerData(); } updateText(); setLeaf(!hasChildren); @@ -147,6 +130,33 @@ public class XValueNodeImpl extends XValueContainerNode implements XValu myTree.nodeLoaded(this, myName); } + public void updateInlineDebuggerData() { + try { + getValueContainer().computeSourcePosition(new XNavigatable() { + @Override + public void setSourcePosition(@Nullable XSourcePosition sourcePosition) { + final Map, Set> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES); + final Map timestamps = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS); + if (map == null || timestamps == null || sourcePosition == null) return; + VirtualFile file = sourcePosition.getFile(); + final Document doc = FileDocumentManager.getInstance().getDocument(file); + if (doc == null) return; + int line = sourcePosition.getLine(); + Pair key = Pair.create(file, line); + Set presentations = map.get(key); + if (presentations == null) { + presentations = new LinkedHashSet(); + map.put(key, presentations); + timestamps.put(file, doc.getModificationStamp()); + } + presentations.add(XValueNodeImpl.this); + } + }); + } + catch (Exception ignore) { + } + } + @Override public void setFullValueEvaluator(@NotNull final XFullValueEvaluator fullValueEvaluator) { AppUIUtil.invokeOnEdt(new Runnable() { diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/StaticInheritanceFix.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/StaticInheritanceFix.java index 1289bbdbe694..c24de84ba1ea 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/StaticInheritanceFix.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/StaticInheritanceFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * 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. @@ -30,6 +30,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.psi.*; import com.intellij.psi.impl.DebugUtil; +import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; @@ -91,7 +92,13 @@ class StaticInheritanceFix extends InspectionGadgetsFix { @Override public void run(@NotNull ProgressIndicator indicator) { for (final PsiField field : allFields) { - final Query search = ReferencesSearch.search(field, implementingClass.getUseScope(), false); + SearchScope scope = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public SearchScope compute() { + return implementingClass.getUseScope(); + } + }); + final Query search = ReferencesSearch.search(field, scope, false); for (PsiReference reference : search) { if (!(reference instanceof PsiReferenceExpression)) { continue; diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java index 0f3a1846b4e2..4e9ab75451fe 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxControllerFieldSearcher.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.javaFX.fxml.refs; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -43,7 +44,12 @@ public class JavaFxControllerFieldSearcher implements QueryExecutor() { + @Override + public PsiClass compute() { + return field.getContainingClass(); + } + }); if (containingClass != null) { final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable() { @Override @@ -52,45 +58,45 @@ public class JavaFxControllerFieldSearcher implements QueryExecutor fxmlWithController = - JavaFxControllerClassIndex.findFxmlWithController(containingClass.getProject(), qualifiedName); - final String fieldName = field.getName(); - for (final PsiFile file : fxmlWithController) { - final VirtualFile virtualFile = file.getViewProvider().getVirtualFile(); - final SearchScope searchScope = ApplicationManager.getApplication().runReadAction(new Computable() { - @Override - public SearchScope compute() { - return queryParameters.getEffectiveSearchScope(); - } - }); - if (searchScope instanceof LocalSearchScope) { - if (!((LocalSearchScope)searchScope).isInScope(virtualFile)) continue; - } else if (searchScope instanceof GlobalSearchScope) { - if (!((GlobalSearchScope)searchScope).contains(virtualFile)) continue; + Project project = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Project compute() { + return containingClass.getProject(); } - final Runnable runnable = new Runnable() { + }); + final List fxmlWithController = + JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName); + for (final PsiFile file : fxmlWithController) { + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { - file.accept(new XmlRecursiveElementVisitor() { - @Override - public void visitXmlAttributeValue(final XmlAttributeValue value) { - final PsiReference reference = value.getReference(); - if (reference != null) { - final PsiElement resolve = reference.resolve(); - if (resolve instanceof XmlAttributeValue) { - final PsiElement parent = resolve.getParent(); - if (parent instanceof XmlAttribute) { - final XmlAttribute attribute = (XmlAttribute)parent; - if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) { - consumer.process(reference); + final String fieldName = field.getName(); + final VirtualFile virtualFile = file.getViewProvider().getVirtualFile(); + final SearchScope searchScope = queryParameters.getEffectiveSearchScope(); + boolean contains = searchScope instanceof LocalSearchScope ? ((LocalSearchScope)searchScope).isInScope(virtualFile) : + ((GlobalSearchScope)searchScope).contains(virtualFile); + if (contains) { + file.accept(new XmlRecursiveElementVisitor() { + @Override + public void visitXmlAttributeValue(final XmlAttributeValue value) { + final PsiReference reference = value.getReference(); + if (reference != null) { + final PsiElement resolve = reference.resolve(); + if (resolve instanceof XmlAttributeValue) { + final PsiElement parent = resolve.getParent(); + if (parent instanceof XmlAttribute) { + final XmlAttribute attribute = (XmlAttribute)parent; + if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) { + consumer.process(reference); + } } } } } - } - }); + }); + } } - }; - ApplicationManager.getApplication().runReadAction(runnable); + }); } } } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRepositoryPoolTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRepositoryPoolTest.java index e2475e020950..ecad58e2b20d 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRepositoryPoolTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRepositoryPoolTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -107,13 +107,7 @@ public class SvnCachingRepositoryPoolTest extends FileBasedTest { } } }; - final EmptyProgressIndicator indicator = new EmptyProgressIndicator() { - @Override - public void cancel() { - super.cancel(); - ProgressManagerImpl.canceled(); - } - }; + final EmptyProgressIndicator indicator = new EmptyProgressIndicator(); Thread thread = new Thread(new Runnable() { @Override public void run() { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java index d698a076b891..a9996ba276d0 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/actions/GenerateMainAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -21,7 +21,6 @@ import com.intellij.codeInsight.generation.PsiGenerationInfo; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; @@ -146,7 +145,7 @@ public class GenerateMainAction extends AnAction { PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); if (psiClass == null) return false; if (PsiMethodUtil.findMainMethod(psiClass) != null) return false; - if (FormClassIndex.findFormsBoundToClass(psiClass).isEmpty()) return false; + if (FormClassIndex.findFormsBoundToClass(project, psiClass).isEmpty()) return false; return true; } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java index 48816354893d..60f12b2489b6 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/BoundIconRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -124,7 +124,7 @@ public class BoundIconRenderer extends GutterIconRenderer { aClass = (PsiClass) myElement; } if (aClass != null && aClass.getQualifiedName() != null) { - formFiles = FormClassIndex.findFormsBoundToClass(aClass); + formFiles = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass); } return formFiles; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java index 0733ad85c781..05c1bcb1b912 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassAnnotator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -47,7 +47,7 @@ public class FormClassAnnotator implements Annotator { } else if (psiElement instanceof PsiClass) { PsiClass aClass = (PsiClass) psiElement; - final List formsBoundToClass = FormClassIndex.findFormsBoundToClass(aClass); + final List formsBoundToClass = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass); if (formsBoundToClass.size() > 0) { Annotation boundClassAnnotation = holder.createInfoAnnotation(aClass.getNameIdentifier(), null); boundClassAnnotation.setGutterIconRenderer(new BoundIconRenderer(aClass)); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java index 0bf86d73618b..000b63716ef4 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormClassIndex.java @@ -127,15 +127,15 @@ public class FormClassIndex extends ScalarIndexExtension { }); } - public static List findFormsBoundToClass(@NotNull PsiClass psiClass) { + public static List findFormsBoundToClass(Project project, @NotNull PsiClass psiClass) { String qName = FormReferencesSearcher.getQualifiedName(psiClass); if (qName == null) return Collections.emptyList(); - return findFormsBoundToClass(psiClass.getProject(), qName); + return findFormsBoundToClass(project, qName); } - public static List findFormsBoundToClass(PsiClass psiClass, GlobalSearchScope scope) { + public static List findFormsBoundToClass(Project project, PsiClass psiClass, GlobalSearchScope scope) { String qName = FormReferencesSearcher.getQualifiedName(psiClass); if (qName == null) return Collections.emptyList(); - return findFormsBoundToClass(psiClass.getProject(), qName, scope); + return findFormsBoundToClass(project, qName, scope); } } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java index c0ef7a143a41..173ae3a3a7c1 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferenceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -83,7 +83,7 @@ public class FormReferenceProvider extends PsiReferenceProvider { public static PsiReference getFormReference(PsiField field) { final PsiClass containingClass = field.getContainingClass(); if (containingClass != null && containingClass.getQualifiedName() != null) { - final List forms = FormClassIndex.findFormsBoundToClass(containingClass); + final List forms = FormClassIndex.findFormsBoundToClass(containingClass.getProject(), containingClass); for (PsiFile formFile : forms) { final PsiReference[] refs = formFile.getReferences(); for (final PsiReference ref : refs) { diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java index 179f47d57a47..6a1576d798e5 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormReferencesSearcher.java @@ -1,3 +1,18 @@ +/* + * 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 com.intellij.uiDesigner.binding; import com.intellij.lang.properties.IProperty; @@ -45,31 +60,33 @@ public class FormReferencesSearcher implements QueryExecutor processor, - final PsiClass aClass, - GlobalSearchScope scope, final LocalSearchScope filterScope) { - PsiManagerImpl manager = (PsiManagerImpl)aClass.getManager(); + PsiManager psiManager, final PsiClass aClass, + GlobalSearchScope scope, final LocalSearchScope filterScope) { + PsiManagerImpl manager = (PsiManagerImpl)psiManager; String className = getQualifiedName(aClass); return className == null || processReferencesInUIFormsInner(className, aClass, processor, scope, manager, filterScope); } @@ -112,9 +129,9 @@ public class FormReferencesSearcher implements QueryExecutor processor, - final PsiEnumConstant enumConstant, + PsiManager psiManager, final PsiEnumConstant enumConstant, GlobalSearchScope scope, final LocalSearchScope filterScope) { - PsiManagerImpl manager = (PsiManagerImpl)enumConstant.getManager(); + PsiManagerImpl manager = (PsiManagerImpl)psiManager; String className = ApplicationManager.getApplication().runReadAction(new Computable() { @Override public String compute() { @@ -152,15 +169,15 @@ public class FormReferencesSearcher implements QueryExecutor processor, - PsiField field, + PsiManager psiManager,PsiField field, GlobalSearchScope scope1, LocalSearchScope filterScope) { - GlobalSearchScope scope = GlobalSearchScope.projectScope(field.getProject()).intersectWith(scope1); - PsiManagerImpl manager = (PsiManagerImpl)field.getManager(); + PsiManagerImpl manager = (PsiManagerImpl)psiManager; + GlobalSearchScope scope = GlobalSearchScope.projectScope(manager.getProject()).intersectWith(scope1); + final AccessToken token = ReadAction.start(); PsiClass containingClass = field.getContainingClass(); if (containingClass == null) return true; String fieldName; - final AccessToken token = ReadAction.start(); try { fieldName = field.getName(); } @@ -170,7 +187,7 @@ public class FormReferencesSearcher implements QueryExecutor files = FormClassIndex.findFormsBoundToClass(containingClass, scope); + final List files = FormClassIndex.findFormsBoundToClass(psiManager.getProject(), containingClass, scope); for (PsiFile file : files) { ProgressManager.checkCanceled(); @@ -227,13 +244,13 @@ public class FormReferencesSearcher implements QueryExecutor processor, - final Property property, - final GlobalSearchScope globalSearchScope, - final LocalSearchScope filterScope) { + PsiManager psiManager, final Property property, + final GlobalSearchScope globalSearchScope, + final LocalSearchScope filterScope) { + final Project project = psiManager.getProject(); - final Project project = property.getProject(); final GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope); - final PsiManagerImpl manager = (PsiManagerImpl)property.getManager(); + final PsiManagerImpl manager = (PsiManagerImpl)psiManager; String name = ApplicationManager.getApplication().runReadAction(new Computable() { @Override public String compute() { @@ -274,11 +291,13 @@ public class FormReferencesSearcher implements QueryExecutor processor, final PropertiesFile propFile, final GlobalSearchScope globalSearchScope, - final LocalSearchScope filterScope) { - final Project project = propFile.getProject(); + private static boolean processReferencesInUIForms(final Processor processor, + PsiManager psiManager, final PropertiesFile propFile, + final GlobalSearchScope globalSearchScope, + final LocalSearchScope filterScope) { + final Project project = psiManager.getProject(); GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope); - PsiManagerImpl manager = (PsiManagerImpl)propFile.getContainingFile().getManager(); + PsiManagerImpl manager = (PsiManagerImpl)psiManager; final String baseName = propFile.getResourceBundle().getBaseName(); manager.startBatchFilesProcessingMode(); diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java index dbe28385666d..8de344a03f16 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormRelatedFilesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -42,7 +42,7 @@ public class FormRelatedFilesProvider extends GotoRelatedProvider { PsiClass psiClass = PsiTreeUtil.getParentOfType(context, PsiClass.class, false); if (psiClass != null) { while (psiClass != null) { - List forms = FormClassIndex.findFormsBoundToClass(psiClass); + List forms = FormClassIndex.findFormsBoundToClass(psiClass.getProject(), psiClass); if (!forms.isEmpty()) { return GotoRelatedItem.createItems(forms, "UI Forms"); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java index cafbb8d2bf73..796aced2a67d 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -39,7 +39,7 @@ public class FormsRenamer extends AutomaticRenamer { public FormsRenamer(PsiClass aClass, String newClassName) { if (aClass.getQualifiedName() != null) { - List forms = FormClassIndex.findFormsBoundToClass(aClass); + List forms = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass); myElements.addAll(forms); suggestAllNames(aClass.getName(), newClassName); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java index 7f719850834e..5ffca466a954 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/binding/FormsRenamerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -29,7 +29,7 @@ import java.util.List; public class FormsRenamerFactory implements AutomaticRenamerFactory { public boolean isApplicable(final PsiElement element) { if (!(element instanceof PsiClass)) return false; - List forms = FormClassIndex.findFormsBoundToClass((PsiClass) element); + List forms = FormClassIndex.findFormsBoundToClass(element.getProject(), (PsiClass)element); return forms.size() > 0; } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java b/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java index 473593be180e..1b3b00365d8f 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/projectView/Form.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * 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. @@ -34,7 +34,7 @@ public class Form implements Navigatable { public Form(PsiClass classToBind) { myClassToBind = classToBind; - myFormFiles = FormClassIndex.findFormsBoundToClass(classToBind); + myFormFiles = FormClassIndex.findFormsBoundToClass(classToBind.getProject(), classToBind); } public Form(PsiClass classToBind, Collection formFiles) { diff --git a/python/edu/build/paths.nsi b/python/edu/build/paths.nsi index 5a49ea65d0aa..d85492988c41 100644 --- a/python/edu/build/paths.nsi +++ b/python/edu/build/paths.nsi @@ -1,5 +1,5 @@ ; Installer images -!define IMAGES_LOCATION ${COMMUNITY_DIR}\python\build\edu\resources +!define IMAGES_LOCATION ${COMMUNITY_DIR}\python\edu\build\resources ;!define LICENSE_FILE ${BASE_DIR}\python\license\PyCharm_Preview_License !define PRODUCT_PROPERTIES_FILE ${BASE_DIR}\out\pycharmEDU\layout\bin\idea.properties !define PRODUCT_VM_OPTIONS_NAME pycharm.exe.vmoptions diff --git a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java index 04f5d67d3694..cd2625b33117 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlElementType.java @@ -55,7 +55,7 @@ public interface XmlElementType extends XmlTokenType { //todo: move to html IElementType HTML_DOCUMENT = new IXmlElementType("HTML_DOCUMENT"); IElementType HTML_TAG = new IXmlElementType("HTML_TAG"); - IFileElementType HTML_FILE = new IFileElementType(HTMLLanguage.INSTANCE); + IFileElementType HTML_FILE = new IStubFileElementType(HTMLLanguage.INSTANCE); IElementType HTML_EMBEDDED_CONTENT = new EmbeddedHtmlContentElementType(); IElementType XML_TEXT = new XmlTextElementType();