Merge remote-tracking branch 'origin/master'

This commit is contained in:
Liana Bakradze
2014-08-21 17:32:13 +04:00
45 changed files with 477 additions and 413 deletions
@@ -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<VirtualFile> 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<VirtualFile> set;
int queuedSize;
synchronized (filesToResolve) {
queuedSize = filesToResolve.size();
set = new THashSet<VirtualFile>(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<int[]> fileToForwardIds = new StripedLockIntObjectConcurrentHashMap<int[]>();
Set<VirtualFile> files = countAndMarkUnresolved(set, false);
if (files.isEmpty()) return;
private void processBatch(@NotNull final ProgressIndicator indicator, @NotNull Set<VirtualFile> files) {
final int size = files.size();
final ConcurrentIntObjectMap<int[]> fileToForwardIds = new StripedLockIntObjectConcurrentHashMap<int[]>();
final Set<VirtualFile> 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<VirtualFile> countFilesToResolve() {
Set<VirtualFile> set;
int queuedSize;
synchronized (filesToResolve) {
queuedSize = filesToResolve.size();
set = new THashSet<VirtualFile>(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<VirtualFile> 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<PsiElement> resolved) {
indicator.checkCanceled();
private void resolveReference(@NotNull PsiReference reference, @NotNull Set<PsiElement> 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() {
}
}
}
@@ -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<PsiFuncti
private final PsiClass myElementToSearch;
private final SearchScope myScope;
public SearchParameters(PsiClass aClass, SearchScope scope) {
public SearchParameters(@NotNull PsiClass aClass, @NotNull SearchScope scope) {
myElementToSearch = aClass;
myScope = scope;
}
@@ -52,23 +54,28 @@ public class FunctionalExpressionSearch extends ExtensibleQueryFactory<PsiFuncti
}
}
public static Query<PsiFunctionalExpression> search(final PsiClass aClass, SearchScope scope) {
public static Query<PsiFunctionalExpression> search(@NotNull final PsiClass aClass, @NotNull SearchScope scope) {
return INSTANCE.createUniqueResultsQuery(new SearchParameters(aClass, scope));
}
public static Query<PsiFunctionalExpression> search(final PsiMethod psiMethod) {
public static Query<PsiFunctionalExpression> search(@NotNull final PsiMethod psiMethod) {
return search(psiMethod, GlobalSearchScope.allScope(psiMethod.getProject()));
}
public static Query<PsiFunctionalExpression> 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<PsiFunctionalExpression> search(@NotNull final PsiMethod psiMethod, @NotNull final SearchScope scope) {
return ApplicationManager.getApplication().runReadAction(new Computable<Query<PsiFunctionalExpression>>() {
@Override
public Query<PsiFunctionalExpression> 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<PsiFunctionalExpression> search(final PsiClass aClass) {
public static Query<PsiFunctionalExpression> search(@NotNull final PsiClass aClass) {
return search(aClass, GlobalSearchScope.allScope(aClass.getProject()));
}
}
@@ -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
@@ -54,4 +54,8 @@ public abstract class ProgressIndicatorProvider {
ourInstance.doCheckCanceled();
}
}
public static void canceled() {
ourNeedToCheckCancel = true;
}
}
@@ -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);
}
@@ -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
@@ -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<? extends Repository> 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 <b>force push</b> in all selected repositories?",
"Force Push Confirmation Dialog",
"&Force Push", "&Cancel", Messages.getWarningIcon());
if (answer == CANCEL) return;
}
myController.push(myForce);
close(OK_EXIT_CODE);
}
@@ -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<PsiReference, Refer
final PsiElement element = parameters.getElementToSearch();
return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(element.getProject(), requests)));
return uniqueResults(new MergeQuery<PsiReference>(result, new SearchRequestQuery(
ApplicationManager.getApplication().runReadAction(new Computable<Project>() {
@Override
public Project compute() {
return element.getProject();
}
}), requests)));
}
@NotNull
@@ -426,6 +426,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
@Override
public boolean process(JBPopup popup) {
createToolWindow(element, originalElement);
myToolWindow.setAutoHide(false);
popup.cancel();
return false;
}
@@ -554,22 +554,4 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
boolean isEnabled() {
return myEnabled;
}
@TestOnly
public void waitUntilAllCommitted(long timeout) throws InterruptedException {
if (!myEnabled) {
throw new IllegalStateException("DocumentCommitThread is disabled");
}
int attempts = 0;
int delay = 100;
synchronized (documentsToCommit) {
while(!documentsToCommit.isEmpty() || currentTask != null) {
documentsToCommit.wait(delay);
if (delay * attempts > timeout) {
throw new RuntimeException("timeout");
}
attempts++;
}
}
}
}
@@ -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<Object>() {
@Override
public Object compute() {
return helper.prepareOperation(writableUsageInfos);
}
});
preparedData.put(helper, operation);
}
}
};
@@ -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<PsiElement, String> entry : renames.entrySet()) {
for (final Map.Entry<PsiElement, String> entry : renames.entrySet()) {
final UsageInfo[] usages =
RenameUtil.findUsages(entry.getKey(), entry.getValue(), mySearchInComments, mySearchTextOccurrences, myAllRenames);
ApplicationManager.getApplication().runReadAction(new Computable<UsageInfo[]>() {
@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);
}
}
});
}
};
@@ -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);
}
});
}
};
@@ -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() {
}
}
@@ -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;
@@ -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
@@ -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++;
}
@@ -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 extends Throwable> T findCause(Throwable t, Class<T> 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;
}
}
}
@@ -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() {
@@ -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;
@@ -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);
}
@@ -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);
}
}
});
@@ -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 == '<' ? "&lt;" : "&gt;");
sb.append(each == '<' ? "&lt;" : "&gt;");
}
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);
}
}
@@ -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<VirtualFile, Collection<VcsRef>> currentRefs = myCurrentDataPack.getRefsModel().getAllRefsByRoot();
try {
if (permanentGraph != null) {
loadLogAndRefs(roots, currentRefs, myRecentCommitCount);
List<? extends GraphCommit<Integer>> compoundLog = compound(ContainerUtil.map(myLoadedInfos.values(),
new Function<LogAndRefs, List<? extends GraphCommit<Integer>>>() {
@Override
public List<? extends GraphCommit<Integer>> fun(
LogAndRefs refs) {
return refs.log;
}
}));
Map<VirtualFile, Collection<VcsRef>> allNewRefs = getAllNewRefs(myLoadedInfos, currentRefs);
List<GraphCommit<Integer>> 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<? extends GraphCommit<Integer>> compoundLog = compoundLoadedLogs(myLoadedInfos.values());
Map<VirtualFile, Collection<VcsRef>> allNewRefs = getAllNewRefs(myLoadedInfos, currentRefs);
List<GraphCommit<Integer>> 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<PermanentGraph<Integer>, Map<VirtualFile, Collection<VcsRef>>> fullLogAndRefs = loadFullLog();
@@ -302,6 +305,38 @@ public class VcsLogRefresherImpl implements VcsLogRefresher {
}
}
private String toLogString(Map<VirtualFile, LogAndRefs> infos) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<VirtualFile, LogAndRefs> entry : infos.entrySet()) {
sb.append(entry.getKey().getName());
sb.append(" LOG:\n");
sb.append(StringUtil.join(entry.getValue().log, new Function<GraphCommit<Integer>, String>() {
@Override
public String fun(GraphCommit<Integer> commit) {
return commit.getId() + "<-" + StringUtil.join(commit.getParents(), ",");
}
}, "\n"));
sb.append("\nREFS:\n");
sb.append(StringUtil.join(entry.getValue().refs, new Function<VcsRef, String>() {
@Override
public String fun(VcsRef ref) {
return ref.getName() + "(" + myHashMap.getCommitIndex(ref.getCommitHash()) + ")";
}
}, ","));
}
return sb.toString();
}
@NotNull
private List<? extends GraphCommit<Integer>> compoundLoadedLogs(@NotNull Collection<LogAndRefs> logsAndRefs) {
return compound(ContainerUtil.map(logsAndRefs, new Function<LogAndRefs, List<? extends GraphCommit<Integer>>>() {
@Override
public List<? extends GraphCommit<Integer>> fun(LogAndRefs refs) {
return refs.log;
}
}));
}
@NotNull
private Map<VirtualFile, Collection<VcsRef>> getAllNewRefs(@NotNull Map<VirtualFile, LogAndRefs> newInfo,
@NotNull Map<VirtualFile, Collection<VcsRef>> 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);
@@ -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;
}
}
@@ -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<Map<Variable, VariableValue>> CACHE = Key.create("debug.frame");
public static final Key<Map<Variable, VariableValue>> CACHE = Key.create("debug.inline.variables.cache");
@Override
public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) {
if (!Registry.is("ide.debugger.inline")) {
return null;
}
Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = project.getUserData(XVariablesView.DEBUG_VARIABLES);
final Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = project.getUserData(XVariablesView.DEBUG_VARIABLES);
final Map<VirtualFile, Long> timestamps = project.getUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS);
final Document doc = FileDocumentManager.getInstance().getDocument(file);
if (map == null || timestamps == null || doc == null) {
return null;
}
Map<Variable, VariableValue> oldValues = project.getUserData(CACHE);
if (oldValues == null) {
oldValues = new HashMap<Variable, VariableValue>();
project.putUserData(CACHE, oldValues);
}
if (map != null) {
Set<XValueNodeImpl> values = map.get(Pair.create(file, lineNumber));
if (values != null && !values.isEmpty()) {
ArrayList<LineExtensionInfo> result = new ArrayList<LineExtensionInfo>();
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<XValueNodeImpl> values = map.get(Pair.create(file, lineNumber));
if (values != null && !values.isEmpty()) {
ArrayList<LineExtensionInfo> result = new ArrayList<LineExtensionInfo>();
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;
@@ -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<Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>>> DEBUG_VARIABLES = Key.create("debug.frame");
public static final Key<Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>>> DEBUG_VARIABLES = Key.create("debug.variables");
public static final Key<Map<VirtualFile, Long>> 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;
@@ -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<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>>());
tree.getProject().putUserData(XVariablesView.DEBUG_VARIABLES_TIMESTAMPS, new HashMap<VirtualFile, Long>());
Object newEqualityObject = stackFrame.getEqualityObject();
if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject)
&& myTreeState != null) {
@@ -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
@@ -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<XValue> 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<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
if (map == null || sourcePosition == null) return;
VirtualFile file = sourcePosition.getFile();
int line = sourcePosition.getLine();
Pair<VirtualFile, Integer> key = Pair.create(file, line);
Set<XValueNodeImpl> presentations = map.get(key);
if (presentations == null) {
presentations = new LinkedHashSet<XValueNodeImpl>();
map.put(key, presentations);
}
presentations.add(XValueNodeImpl.this);
}
});
}
catch (Exception ignore) {
}
updateInlineDebuggerData();
}
updateText();
setLeaf(!hasChildren);
@@ -147,6 +130,33 @@ public class XValueNodeImpl extends XValueContainerNode<XValue> implements XValu
myTree.nodeLoaded(this, myName);
}
public void updateInlineDebuggerData() {
try {
getValueContainer().computeSourcePosition(new XNavigatable() {
@Override
public void setSourcePosition(@Nullable XSourcePosition sourcePosition) {
final Map<Pair<VirtualFile, Integer>, Set<XValueNodeImpl>> map = myTree.getProject().getUserData(XVariablesView.DEBUG_VARIABLES);
final Map<VirtualFile, Long> 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<VirtualFile, Integer> key = Pair.create(file, line);
Set<XValueNodeImpl> presentations = map.get(key);
if (presentations == null) {
presentations = new LinkedHashSet<XValueNodeImpl>();
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() {
@@ -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<PsiReference> search = ReferencesSearch.search(field, implementingClass.getUseScope(), false);
SearchScope scope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
public SearchScope compute() {
return implementingClass.getUseScope();
}
});
final Query<PsiReference> search = ReferencesSearch.search(field, scope, false);
for (PsiReference reference : search) {
if (!(reference instanceof PsiReferenceExpression)) {
continue;
@@ -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<PsiReference
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (elementToSearch instanceof PsiField) {
final PsiField field = (PsiField)elementToSearch;
final PsiClass containingClass = field.getContainingClass();
final PsiClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
@Override
public PsiClass compute() {
return field.getContainingClass();
}
});
if (containingClass != null) {
final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
@@ -52,45 +58,45 @@ public class JavaFxControllerFieldSearcher implements QueryExecutor<PsiReference
}
});
if (qualifiedName != null) {
final List<PsiFile> 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<SearchScope>() {
@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<Project>() {
@Override
public Project compute() {
return containingClass.getProject();
}
final Runnable runnable = new Runnable() {
});
final List<PsiFile> 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);
});
}
}
}
@@ -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() {
@@ -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;
}
}
@@ -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;
}
@@ -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<PsiFile> formsBoundToClass = FormClassIndex.findFormsBoundToClass(aClass);
final List<PsiFile> formsBoundToClass = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass);
if (formsBoundToClass.size() > 0) {
Annotation boundClassAnnotation = holder.createInfoAnnotation(aClass.getNameIdentifier(), null);
boundClassAnnotation.setGutterIconRenderer(new BoundIconRenderer(aClass));
@@ -127,15 +127,15 @@ public class FormClassIndex extends ScalarIndexExtension<String> {
});
}
public static List<PsiFile> findFormsBoundToClass(@NotNull PsiClass psiClass) {
public static List<PsiFile> 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<PsiFile> findFormsBoundToClass(PsiClass psiClass, GlobalSearchScope scope) {
public static List<PsiFile> 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);
}
}
@@ -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<PsiFile> forms = FormClassIndex.findFormsBoundToClass(containingClass);
final List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(containingClass.getProject(), containingClass);
for (PsiFile formFile : forms) {
final PsiReference[] refs = formFile.getReferences();
for (final PsiReference ref : refs) {
@@ -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<PsiReference, Refer
if (psiFile == null) return true;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null) return true;
Module module = ProjectRootManager.getInstance(refElement.getProject()).getFileIndex().getModuleForFile(virtualFile);
Project project = psiFile.getProject();
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
if (module == null) return true;
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesScope(module);
final LocalSearchScope filterScope = p.getScope() instanceof LocalSearchScope
? (LocalSearchScope) p.getScope()
: null;
PsiManager psiManager = PsiManager.getInstance(project);
if (refElement instanceof PsiPackage) {
//no need to do anything
//if (!UIFormUtil.processReferencesInUIForms(consumer, (PsiPackage)refElement, scope)) return false;
}
else if (refElement instanceof PsiClass) {
if (!processReferencesInUIForms(consumer, (PsiClass)refElement, scope, filterScope)) return false;
if (!processReferencesInUIForms(consumer, psiManager,(PsiClass)refElement, scope, filterScope)) return false;
}
else if (refElement instanceof PsiEnumConstant) {
if (!processReferencesInUIForms(consumer, (PsiEnumConstant)refElement, scope, filterScope)) return false;
if (!processReferencesInUIForms(consumer, psiManager, (PsiEnumConstant)refElement, scope, filterScope)) return false;
}
else if (refElement instanceof PsiField) {
if (!processReferencesInUIForms(consumer, (PsiField)refElement, scope, filterScope)) return false;
if (!processReferencesInUIForms(consumer, psiManager, (PsiField)refElement, scope, filterScope)) return false;
}
else if (refElement instanceof IProperty) {
if (!processReferencesInUIForms(consumer, (Property)refElement, scope, filterScope)) return false;
if (!processReferencesInUIForms(consumer, psiManager, (Property)refElement, scope, filterScope)) return false;
}
else if (refElement instanceof PropertiesFile) {
if (!processReferencesInUIForms(consumer, (PropertiesFile)refElement, scope, filterScope)) return false;
if (!processReferencesInUIForms(consumer, psiManager, (PropertiesFile)refElement, scope, filterScope)) return false;
}
return true;
@@ -95,9 +112,9 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
}
private static boolean processReferencesInUIForms(Processor<PsiReference> 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<PsiReference, Refer
}
private static boolean processReferencesInUIForms(Processor<PsiReference> 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<String>() {
@Override
public String compute() {
@@ -152,15 +169,15 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
}
private static boolean processReferencesInUIForms(Processor<PsiReference> 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<PsiReference, Refer
manager.startBatchFilesProcessingMode();
try {
final List<PsiFile> files = FormClassIndex.findFormsBoundToClass(containingClass, scope);
final List<PsiFile> files = FormClassIndex.findFormsBoundToClass(psiManager.getProject(), containingClass, scope);
for (PsiFile file : files) {
ProgressManager.checkCanceled();
@@ -227,13 +244,13 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
}
private static boolean processReferencesInUIForms(final Processor<PsiReference> 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<String>() {
@Override
public String compute() {
@@ -274,11 +291,13 @@ public class FormReferencesSearcher implements QueryExecutor<PsiReference, Refer
return true;
}
private static boolean processReferencesInUIForms(final Processor<PsiReference> processor, final PropertiesFile propFile, final GlobalSearchScope globalSearchScope,
final LocalSearchScope filterScope) {
final Project project = propFile.getProject();
private static boolean processReferencesInUIForms(final Processor<PsiReference> 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();
@@ -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<PsiFile> forms = FormClassIndex.findFormsBoundToClass(psiClass);
List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(psiClass.getProject(), psiClass);
if (!forms.isEmpty()) {
return GotoRelatedItem.createItems(forms, "UI Forms");
}
@@ -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<PsiFile> forms = FormClassIndex.findFormsBoundToClass(aClass);
List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(aClass.getProject(), aClass);
myElements.addAll(forms);
suggestAllNames(aClass.getName(), newClassName);
}
@@ -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<PsiFile> forms = FormClassIndex.findFormsBoundToClass((PsiClass) element);
List<PsiFile> forms = FormClassIndex.findFormsBoundToClass(element.getProject(), (PsiClass)element);
return forms.size() > 0;
}
@@ -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<PsiFile> formFiles) {
+1 -1
View File
@@ -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
@@ -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();