From 69a82ef3c317b551670edd30566a1e23757bad4e Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Wed, 24 Jul 2019 15:26:12 +0300 Subject: [PATCH] avoid type.allLineLocations as it causes fetching of all methods line tables GitOrigin-RevId: 39ba07ba8566aae47a7bcc511bf7d4feea76f117 --- .../engine/DefaultSourcePositionProvider.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/DefaultSourcePositionProvider.java b/java/debugger/impl/src/com/intellij/debugger/engine/DefaultSourcePositionProvider.java index e373b7014d61..33bc497b8f60 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/DefaultSourcePositionProvider.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/DefaultSourcePositionProvider.java @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.debugger.engine; import com.intellij.debugger.SourcePosition; @@ -21,10 +19,7 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.containers.ContainerUtil; -import com.sun.jdi.AbsentInformationException; -import com.sun.jdi.ClassNotPreparedException; -import com.sun.jdi.Location; -import com.sun.jdi.ReferenceType; +import com.sun.jdi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -101,10 +96,15 @@ public class DefaultSourcePositionProvider extends SourcePositionProvider { DebugProcessImpl debugProcess = context.getDebugProcess(); if (debugProcess != null) { try { - List locations = type.allLineLocations(); - if (!locations.isEmpty()) { - // important: use the last location to be sure the position will be within the anonymous class - aClass = JVMNameUtil.getClassAt(debugProcess.getPositionManager().getSourcePosition(ContainerUtil.getLastItem(locations))); + // important: use the last location to be sure the position will be within the anonymous class + // and do not use type.allLineLocations as it fetches line tables for all methods + List methods = type.methods(); + for (int i = methods.size() - 1; i >= 0; i--) { + List locations = methods.get(i).allLineLocations(); + if (!locations.isEmpty()) { + aClass = JVMNameUtil.getClassAt(debugProcess.getPositionManager().getSourcePosition(ContainerUtil.getLastItem(locations))); + break; + } } } catch (AbsentInformationException | ClassNotPreparedException ignored) {