mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extracted safe allLineLocations to utils
This commit is contained in:
@@ -115,14 +115,9 @@ public class JumpToObjectAction extends DebuggerAction{
|
||||
if (cls != null) {
|
||||
Method method = ContainerUtil.getFirstItem(cls.methodsByName(name));
|
||||
if (method != null) {
|
||||
try {
|
||||
Location loc = ContainerUtil.getFirstItem(method.allLineLocations());
|
||||
if (loc != null) {
|
||||
locationRef.set(loc);
|
||||
}
|
||||
}
|
||||
catch (AbsentInformationException e) {
|
||||
LOG.debug(e);
|
||||
Location loc = ContainerUtil.getFirstItem(DebuggerUtilsEx.allLineLocations(method));
|
||||
if (loc != null) {
|
||||
locationRef.set(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,6 +591,16 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
|
||||
return new SigReader(s).getSignature();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<Location> allLineLocations(Method method) {
|
||||
try {
|
||||
return method.allLineLocations();
|
||||
}
|
||||
catch (AbsentInformationException ignored) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public static Value createValue(VirtualMachineProxyImpl vm, String expectedType, double value) {
|
||||
if (PsiType.DOUBLE.getPresentableText().equals(expectedType)) {
|
||||
return vm.mirrorOf(value);
|
||||
|
||||
@@ -91,13 +91,11 @@ public class SourceCodeChecker {
|
||||
catch (EvaluateException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
catch (AbsentInformationException ignore) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static ThreeState check(Location location, SourcePosition position, Project project) throws AbsentInformationException {
|
||||
private static ThreeState check(Location location, SourcePosition position, Project project) {
|
||||
Method method = location.method();
|
||||
// for now skip constructors, bridges, lambdas etc.
|
||||
if (method.isConstructor() ||
|
||||
@@ -108,7 +106,7 @@ public class SourceCodeChecker {
|
||||
LambdaMethodFilter.isLambdaName(method.name())) {
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
List<Location> locations = method.allLineLocations();
|
||||
List<Location> locations = DebuggerUtilsEx.allLineLocations(method);
|
||||
if (ContainerUtil.isEmpty(locations)) {
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.debugger.jdi;
|
||||
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.ThrowableConsumer;
|
||||
import com.sun.jdi.*;
|
||||
@@ -26,7 +27,6 @@ import org.jetbrains.org.objectweb.asm.Type;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -180,7 +180,7 @@ public class MethodBytecodeUtil {
|
||||
dos.writeInt(bytecodes.length); // code_length
|
||||
dos.write(bytecodes); // code
|
||||
dos.writeShort(0); // exception_table_length
|
||||
List<Location> locations = getMethodLocations(method);
|
||||
List<Location> locations = DebuggerUtilsEx.allLineLocations(method);
|
||||
if (!locations.isEmpty()) {
|
||||
dos.writeShort(1); // attributes_count
|
||||
dos.writeShort(cw.newUTF8("LineNumberTable"));
|
||||
@@ -197,16 +197,6 @@ public class MethodBytecodeUtil {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<Location> getMethodLocations(Method method) {
|
||||
try {
|
||||
return method.allLineLocations();
|
||||
}
|
||||
catch (AbsentInformationException ignored) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private static final Type OBJECT_TYPE = Type.getObjectType("java/lang/Object");
|
||||
|
||||
public static Type getVarInstructionType(int opcode) {
|
||||
|
||||
@@ -155,7 +155,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
try {
|
||||
for (Method method : classType.methods()) {
|
||||
if (getMethodName().equals(method.name()) && mySignature.getName(debugProcess).equals(method.signature())) {
|
||||
List<Location> allLineLocations = method.allLineLocations();
|
||||
List<Location> allLineLocations = DebuggerUtilsEx.allLineLocations(method);
|
||||
if (!allLineLocations.isEmpty()) {
|
||||
if (isWatchEntry()) {
|
||||
createLocationBreakpointRequest(ContainerUtil.getFirstItem(allLineLocations), debugProcess);
|
||||
|
||||
Reference in New Issue
Block a user