mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make read action visible in stacktrace
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.concurrency.AtomicFieldUpdater;
|
||||
import com.intellij.util.containers.FList;
|
||||
@@ -154,30 +156,36 @@ public class DebugReflectionUtil {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
BackLink backLink = this;
|
||||
String result = "";
|
||||
while (backLink != null) {
|
||||
String valueStr;
|
||||
AccessToken token = ReadAction.start();
|
||||
try {
|
||||
valueStr = backLink.value instanceof FList
|
||||
? "FList (size="+((FList)backLink.value).size()+")" :
|
||||
backLink.value instanceof Collection ? "Collection (size="+((Collection)backLink.value).size()+")" :
|
||||
String.valueOf(backLink.value);
|
||||
valueStr = StringUtil.first(StringUtil.convertLineSeparators(valueStr, "\\n"), 200, true);
|
||||
return
|
||||
ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
String result = "";
|
||||
BackLink backLink = BackLink.this;
|
||||
while (backLink != null) {
|
||||
String valueStr;
|
||||
AccessToken token = ReadAction.start();
|
||||
try {
|
||||
valueStr = backLink.value instanceof FList
|
||||
? "FList (size=" + ((FList)backLink.value).size() + ")" :
|
||||
backLink.value instanceof Collection ? "Collection (size=" + ((Collection)backLink.value).size() + ")" :
|
||||
String.valueOf(backLink.value);
|
||||
valueStr = StringUtil.first(StringUtil.convertLineSeparators(valueStr, "\\n"), 200, true);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
valueStr = "(" + e.getMessage() + " while computing .toString())";
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
Field field = backLink.field;
|
||||
String fieldName = field == null ? "?" : field.getDeclaringClass().getName() + "." + field.getName();
|
||||
result += "via '" + fieldName + "'; Value: '" + valueStr + "' of " + backLink.value.getClass() + "\n";
|
||||
backLink = backLink.backLink;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
valueStr = "(" + e.getMessage() + " while computing .toString())";
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
Field field = backLink.field;
|
||||
String fieldName = field == null ? "?" : field.getDeclaringClass().getName()+"."+field.getName();
|
||||
result += "via '" + fieldName + "'; Value: '" + valueStr + "' of " + backLink.value.getClass() + "\n";
|
||||
backLink = backLink.backLink;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,7 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
@@ -403,27 +401,27 @@ public class FindInProjectUtil {
|
||||
public static String buildStringToFindForIndicesFromRegExp(@NotNull String stringToFind, @NotNull Project project) {
|
||||
if (!Registry.is("idea.regexp.search.uses.indices")) return "";
|
||||
|
||||
final AccessToken accessToken = ReadAction.start();
|
||||
try {
|
||||
final List<PsiElement> topLevelRegExpChars = getTopLevelRegExpChars("a", project);
|
||||
if (topLevelRegExpChars.size() != 1) return "";
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
final List<PsiElement> topLevelRegExpChars = getTopLevelRegExpChars("a", project);
|
||||
if (topLevelRegExpChars.size() != 1) return "";
|
||||
|
||||
// leave only top level regExpChars
|
||||
return StringUtil.join(getTopLevelRegExpChars(stringToFind, project), new Function<PsiElement, String>() {
|
||||
final Class regExpCharPsiClass = topLevelRegExpChars.get(0).getClass();
|
||||
// leave only top level regExpChars
|
||||
return StringUtil.join(getTopLevelRegExpChars(stringToFind, project), new Function<PsiElement, String>() {
|
||||
final Class regExpCharPsiClass = topLevelRegExpChars.get(0).getClass();
|
||||
|
||||
@Override
|
||||
public String fun(PsiElement element) {
|
||||
if(regExpCharPsiClass.isInstance(element)) {
|
||||
String text = element.getText();
|
||||
if (!text.startsWith("\\")) return text;
|
||||
@Override
|
||||
public String fun(PsiElement element) {
|
||||
if (regExpCharPsiClass.isInstance(element)) {
|
||||
String text = element.getText();
|
||||
if (!text.startsWith("\\")) return text;
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
}, "");
|
||||
} finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
}, "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class StringUsageTarget implements ConfigurableUsageTarget, ItemPresentation, TypeSafeDataProvider {
|
||||
|
||||
@@ -31,8 +31,7 @@ import com.intellij.navigation.AnonymousElementProvider;
|
||||
import com.intellij.navigation.ChooseByNameRegistry;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
@@ -93,39 +92,38 @@ public class GotoClassAction extends GotoActionBase implements DumbAware {
|
||||
|
||||
@Override
|
||||
public void elementChosen(ChooseByNamePopup popup, Object element) {
|
||||
AccessToken token = ReadAction.start();
|
||||
try {
|
||||
if (element instanceof PsiElement && ((PsiElement)element).isValid()) {
|
||||
PsiElement psiElement = getElement(((PsiElement)element), popup);
|
||||
psiElement = psiElement.getNavigationElement();
|
||||
VirtualFile file = PsiUtilCore.getVirtualFile(psiElement);
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (element instanceof PsiElement && ((PsiElement)element).isValid()) {
|
||||
PsiElement psiElement = getElement(((PsiElement)element), popup);
|
||||
psiElement = psiElement.getNavigationElement();
|
||||
VirtualFile file = PsiUtilCore.getVirtualFile(psiElement);
|
||||
|
||||
if (file != null && popup.getLinePosition() != -1) {
|
||||
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file, popup.getLinePosition(), popup.getColumnPosition());
|
||||
Navigatable n = descriptor.setUseCurrentWindow(popup.isOpenInCurrentWindowRequested());
|
||||
if (n.canNavigate()) {
|
||||
n.navigate(true);
|
||||
return;
|
||||
if (file != null && popup.getLinePosition() != -1) {
|
||||
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file, popup.getLinePosition(), popup.getColumnPosition());
|
||||
Navigatable n = descriptor.setUseCurrentWindow(popup.isOpenInCurrentWindowRequested());
|
||||
if (n.canNavigate()) {
|
||||
n.navigate(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (file != null && popup.getMemberPattern() != null) {
|
||||
NavigationUtil.activateFileWithPsiElement(psiElement, !popup.isOpenInCurrentWindowRequested());
|
||||
Navigatable member = findMember(popup.getMemberPattern(), psiElement, file);
|
||||
if (member != null) {
|
||||
member.navigate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file != null && popup.getMemberPattern() != null) {
|
||||
NavigationUtil.activateFileWithPsiElement(psiElement, !popup.isOpenInCurrentWindowRequested());
|
||||
Navigatable member = findMember(popup.getMemberPattern(), psiElement, file);
|
||||
if (member != null) {
|
||||
member.navigate(true);
|
||||
}
|
||||
}
|
||||
|
||||
NavigationUtil.activateFileWithPsiElement(psiElement, !popup.isOpenInCurrentWindowRequested());
|
||||
else {
|
||||
EditSourceUtil.navigate(((NavigationItem)element), true, popup.isOpenInCurrentWindowRequested());
|
||||
}
|
||||
}
|
||||
else {
|
||||
EditSourceUtil.navigate(((NavigationItem)element), true, popup.isOpenInCurrentWindowRequested());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, IdeBundle.message("go.to.class.toolwindow.title"), true);
|
||||
}
|
||||
|
||||
+2
-8
@@ -16,9 +16,7 @@
|
||||
package com.intellij.xdebugger.impl.breakpoints;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -401,8 +399,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
myDefaultBreakpoints.clear();
|
||||
myBreakpointsDefaults.clear();
|
||||
|
||||
AccessToken token = ReadAction.start();
|
||||
try {
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
for (BreakpointState breakpointState : state.getDefaultBreakpoints()) {
|
||||
loadBreakpoint(breakpointState, true);
|
||||
}
|
||||
@@ -430,10 +427,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
|
||||
}
|
||||
|
||||
myDependentBreakpointManager.loadState();
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
});
|
||||
myLineBreakpointManager.updateBreakpointsUI();
|
||||
myTime = state.getTime();
|
||||
myDefaultGroup = state.getDefaultGroup();
|
||||
|
||||
Reference in New Issue
Block a user