use of one.util.streamex.StreamEx in project intellij-community by JetBrains.
the class MethodBreakpoint method createRequestForPreparedClassEmulated.
static void createRequestForPreparedClassEmulated(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType classType, boolean base) {
if (!base && !shouldCreateRequest(breakpoint, breakpoint.getXBreakpoint(), debugProcess, true)) {
return;
}
try {
Method lambdaMethod = MethodBytecodeUtil.getLambdaMethod(classType, debugProcess.getVirtualMachineProxy());
StreamEx<Method> methods = lambdaMethod != null ? StreamEx.of(lambdaMethod) : breakpoint.matchingMethods(StreamEx.of(classType.methods()).filter(m -> base || !m.isAbstract()), debugProcess);
boolean found = false;
for (Method method : methods) {
found = true;
if (base && method.isNative()) {
breakpoint.disableEmulation();
return;
}
Method target = MethodBytecodeUtil.getBridgeTargetMethod(method, debugProcess.getVirtualMachineProxy());
if (target != null && !DebuggerUtilsEx.allLineLocations(target).isEmpty()) {
method = target;
}
List<Location> allLineLocations = DebuggerUtilsEx.allLineLocations(method);
if (!allLineLocations.isEmpty()) {
if (breakpoint.isWatchEntry()) {
createLocationBreakpointRequest(breakpoint, ContainerUtil.getFirstItem(allLineLocations), debugProcess);
}
if (breakpoint.isWatchExit()) {
MethodBytecodeUtil.visit(method, new MethodVisitor(Opcodes.API_VERSION) {
int myLastLine = 0;
@Override
public void visitLineNumber(int line, Label start) {
myLastLine = line;
}
@Override
public void visitInsn(int opcode) {
switch(opcode) {
case Opcodes.RETURN:
case Opcodes.IRETURN:
case Opcodes.FRETURN:
case Opcodes.ARETURN:
case Opcodes.LRETURN:
case Opcodes.DRETURN:
//case Opcodes.ATHROW:
allLineLocations.stream().filter(l -> l.lineNumber() == myLastLine).findFirst().ifPresent(location -> createLocationBreakpointRequest(breakpoint, location, debugProcess));
}
}
}, true);
}
}
}
if (base && found) {
// desired class found - now also track all new classes
createRequestForSubClasses(breakpoint, debugProcess, classType);
}
} catch (Exception e) {
LOG.debug(e);
}
}
use of one.util.streamex.StreamEx in project intellij-community by JetBrains.
the class DescriptionCheckerUtil method allDescriptionDirs.
/**
* Unlike getDescriptionsDirs this includes dirs in dependent modules and even project dirs ordered by
* search scopes (first dirs in current module, then dirs in module dependencies, then dirs in
* dependent modules, finally other project dirs).
*
* @param module module to search description directories for
* @param descriptionType type of description directory to search
* @return lazily populated stream of candidate directories
*/
public static StreamEx<PsiDirectory> allDescriptionDirs(Module module, DescriptionType descriptionType) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(module.getProject());
final PsiPackage psiPackage = javaPsiFacade.findPackage(descriptionType.getDescriptionFolder());
if (psiPackage == null)
return StreamEx.empty();
return searchScopes(module).flatMap(scope -> StreamEx.of(psiPackage.getDirectories(scope))).distinct();
}
Aggregations