mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -75,7 +75,6 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
|
||||
protected final Project myProject;
|
||||
|
||||
@NonNls private static final String LOG_MESSAGE_OPTION_NAME = "LOG_MESSAGE";
|
||||
public static final Breakpoint[] EMPTY_ARRAY = new Breakpoint[0];
|
||||
protected boolean myCachedVerifiedState = false;
|
||||
|
||||
protected Breakpoint(@NotNull Project project, XBreakpoint<P> xBreakpoint) {
|
||||
@@ -209,33 +208,29 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processLocatableEvent(final SuspendContextCommandImpl action, final LocatableEvent event) throws EventProcessingException {
|
||||
final SuspendContextImpl context = action.getSuspendContext();
|
||||
if(!isValid()) {
|
||||
public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event) throws EventProcessingException {
|
||||
SuspendContextImpl context = action.getSuspendContext();
|
||||
if (!isValid()) {
|
||||
context.getDebugProcess().getRequestsManager().deleteRequest(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String[] title = {DebuggerBundle.message("title.error.evaluating.breakpoint.condition") };
|
||||
String title = DebuggerBundle.message("title.error.evaluating.breakpoint.condition");
|
||||
|
||||
try {
|
||||
final StackFrameProxyImpl frameProxy = context.getThread().frame(0);
|
||||
StackFrameProxyImpl frameProxy = context.getThread().frame(0);
|
||||
if (frameProxy == null) {
|
||||
// might be if the thread has been collected
|
||||
return false;
|
||||
}
|
||||
|
||||
final EvaluationContextImpl evaluationContext = new EvaluationContextImpl(
|
||||
action.getSuspendContext(),
|
||||
frameProxy,
|
||||
getThisObject(context, event)
|
||||
);
|
||||
EvaluationContextImpl evaluationContext = new EvaluationContextImpl(context, frameProxy, getThisObject(context, event));
|
||||
|
||||
if(!evaluateCondition(evaluationContext, event)) {
|
||||
if (!evaluateCondition(evaluationContext, event)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
title[0] = DebuggerBundle.message("title.error.evaluating.breakpoint.action");
|
||||
title = DebuggerBundle.message("title.error.evaluating.breakpoint.action");
|
||||
runAction(evaluationContext, event);
|
||||
}
|
||||
catch (final EvaluateException ex) {
|
||||
@@ -244,42 +239,37 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new EventProcessingException(title[0], ex.getMessage(), ex);
|
||||
throw new EventProcessingException(title, ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void runAction(final EvaluationContextImpl context, LocatableEvent event) {
|
||||
final DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
private void runAction(EvaluationContextImpl context, LocatableEvent event) {
|
||||
DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
if (isLogEnabled() || isLogExpressionEnabled()) {
|
||||
final StringBuilder buf = StringBuilderSpinAllocator.alloc();
|
||||
StringBuilder buf = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
if (myXBreakpoint.isLogMessage()) {
|
||||
buf.append(getEventMessage(event));
|
||||
buf.append("\n");
|
||||
buf.append(getEventMessage(event)).append("\n");
|
||||
}
|
||||
if (isLogExpressionEnabled()) {
|
||||
if (!debugProcess.isAttached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final TextWithImports expressionToEvaluate = getLogMessage();
|
||||
try {
|
||||
SourcePosition position = ContextUtil.getSourcePosition(context);
|
||||
PsiElement element = ContextUtil.getContextElement(context, position);
|
||||
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, () ->
|
||||
createExpressionEvaluator(myProject, element, position, expressionToEvaluate, this::createLogMessageCodeFragment));
|
||||
createExpressionEvaluator(myProject, element, position, getLogMessage(), this::createLogMessageCodeFragment));
|
||||
Value eval = evaluator.evaluate(context);
|
||||
buf.append(eval instanceof VoidValue ? "void" : DebuggerUtils.getValueAsString(context, eval));
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
buf.append(DebuggerBundle.message("error.unable.to.evaluate.expression"));
|
||||
buf.append(" \"");
|
||||
buf.append(expressionToEvaluate);
|
||||
buf.append("\"");
|
||||
buf.append(" : ");
|
||||
buf.append(e.getMessage());
|
||||
buf.append(DebuggerBundle.message("error.unable.to.evaluate.expression"))
|
||||
.append(" \"").append(getLogMessage()).append("\"")
|
||||
.append(" : ").append(e.getMessage());
|
||||
}
|
||||
buf.append("\n");
|
||||
}
|
||||
@@ -304,7 +294,7 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
|
||||
}
|
||||
|
||||
public boolean evaluateCondition(final EvaluationContextImpl context, LocatableEvent event) throws EvaluateException {
|
||||
final DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
if (isCountFilterEnabled()) {
|
||||
debugProcess.getVirtualMachineProxy().suspend();
|
||||
debugProcess.getRequestsManager().deleteRequest(this);
|
||||
@@ -504,8 +494,7 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
|
||||
}
|
||||
|
||||
protected boolean isLogExpressionEnabled() {
|
||||
XExpression expression = myXBreakpoint.getLogExpressionObject();
|
||||
if (XDebuggerUtilImpl.isEmptyExpression(expression)) {
|
||||
if (XDebuggerUtilImpl.isEmptyExpression(myXBreakpoint.getLogExpressionObject())) {
|
||||
return false;
|
||||
}
|
||||
return !getLogMessage().isEmpty();
|
||||
|
||||
+7
-8
@@ -310,14 +310,13 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
final Project project = getProject();
|
||||
DebuggerInvocationUtil.swingInvokeLater(project, () -> {
|
||||
DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
|
||||
if (!isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(project).getContext();
|
||||
final DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
|
||||
DebugProcessImpl debugProcess = context.getDebugProcess();
|
||||
if (debugProcess == null || !debugProcess.isAttached()) {
|
||||
updateCaches(null);
|
||||
updateGutter();
|
||||
@@ -327,11 +326,11 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
|
||||
@Override
|
||||
protected void action() throws Exception {
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
if (!project.isDisposed()) {
|
||||
if (!myProject.isDisposed()) {
|
||||
updateCaches(debugProcess);
|
||||
}
|
||||
});
|
||||
DebuggerInvocationUtil.swingInvokeLater(project, BreakpointWithHighlighter.this::updateGutter);
|
||||
DebuggerInvocationUtil.swingInvokeLater(myProject, BreakpointWithHighlighter.this::updateGutter);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -386,9 +385,9 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
|
||||
|
||||
@Nullable
|
||||
public Document getDocument() {
|
||||
final PsiFile file = getPsiFile();
|
||||
PsiFile file = getPsiFile();
|
||||
if (file != null) {
|
||||
return PsiDocumentManager.getInstance(getProject()).getDocument(file);
|
||||
return PsiDocumentManager.getInstance(myProject).getDocument(file);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -110,25 +110,22 @@ public class FieldBreakpoint extends BreakpointWithHighlighter<JavaFieldBreakpoi
|
||||
public PsiField getPsiField() {
|
||||
final SourcePosition sourcePosition = getSourcePosition();
|
||||
try {
|
||||
final PsiField field = ApplicationManager.getApplication().runReadAction(new Computable<PsiField>() {
|
||||
@Override
|
||||
public PsiField compute() {
|
||||
final PsiClass psiClass = getPsiClassAt(sourcePosition);
|
||||
return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
|
||||
}
|
||||
PsiField field = ApplicationManager.getApplication().runReadAction((Computable<PsiField>)() -> {
|
||||
PsiClass psiClass = getPsiClassAt(sourcePosition);
|
||||
return psiClass != null ? psiClass.findFieldByName(getFieldName(), true) : null;
|
||||
});
|
||||
if (field != null) {
|
||||
return field;
|
||||
}
|
||||
} catch (IndexNotReadyException ignored) {}
|
||||
return PositionUtil.getPsiElementAt(getProject(), PsiField.class, sourcePosition);
|
||||
return PositionUtil.getPsiElementAt(myProject, PsiField.class, sourcePosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reload(PsiFile psiFile) {
|
||||
super.reload(psiFile);
|
||||
PsiField field = PositionUtil.getPsiElementAt(getProject(), PsiField.class, getSourcePosition());
|
||||
if(field != null) {
|
||||
PsiField field = PositionUtil.getPsiElementAt(myProject, PsiField.class, getSourcePosition());
|
||||
if (field != null) {
|
||||
setFieldName(field.getName());
|
||||
PsiClass psiClass = field.getContainingClass();
|
||||
if (psiClass != null) {
|
||||
|
||||
@@ -239,12 +239,11 @@ public class LineBreakpoint<P extends JavaBreakpointProperties> extends Breakpoi
|
||||
if (LOG.isDebugEnabled()) {
|
||||
final GlobalSearchScope scope = debugProcess.getSearchScope();
|
||||
final boolean contains = scope.contains(breakpointFile);
|
||||
final Project project = getProject();
|
||||
List<VirtualFile> files = ContainerUtil.map(
|
||||
JavaFullClassNameIndex.getInstance().get(className.hashCode(), project, scope),
|
||||
JavaFullClassNameIndex.getInstance().get(className.hashCode(), myProject, scope),
|
||||
aClass -> aClass.getContainingFile().getVirtualFile());
|
||||
List<VirtualFile> allFiles = ContainerUtil.map(
|
||||
JavaFullClassNameIndex.getInstance().get(className.hashCode(), project, new EverythingGlobalScope(project)),
|
||||
JavaFullClassNameIndex.getInstance().get(className.hashCode(), myProject, new EverythingGlobalScope(myProject)),
|
||||
aClass -> aClass.getContainingFile().getVirtualFile());
|
||||
final VirtualFile contentRoot = fileIndex.getContentRootForFile(breakpointFile);
|
||||
final Module module = fileIndex.getModuleForFile(breakpointFile);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -133,7 +133,7 @@ public class RunToCursorBreakpoint extends LineBreakpoint<JavaLineBreakpointProp
|
||||
VirtualFile file = position.getFile().getVirtualFile();
|
||||
int line = position.getLine();
|
||||
for (XLineBreakpointType<?> type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) {
|
||||
if (type instanceof JavaLineBreakpointType && type.canPutAt(file, line, getProject())) {
|
||||
if (type instanceof JavaLineBreakpointType && type.canPutAt(file, line, myProject)) {
|
||||
return ((JavaLineBreakpointType)type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user