Skip to content

Commit f093f8b

Browse files
authored
fix issue #305 Debugger slow when watching variables (#203)
* fix issue #305 Debugger slow when watching variables * Use the source containers from source lookup provider.
1 parent 94f8ce5 commit f093f8b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/eval/JdtEvaluationProvider.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.commons.lang3.reflect.FieldUtils;
2929
import org.eclipse.core.resources.IWorkspaceRoot;
3030
import org.eclipse.core.resources.ResourcesPlugin;
31-
import org.eclipse.core.runtime.CoreException;
3231
import org.eclipse.debug.core.DebugException;
3332
import org.eclipse.debug.core.ILaunch;
3433
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -37,7 +36,7 @@
3736
import org.eclipse.debug.core.model.ISourceLocator;
3837
import org.eclipse.debug.core.model.IStackFrame;
3938
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
40-
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
39+
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
4140
import org.eclipse.jdt.core.IJavaProject;
4241
import org.eclipse.jdt.debug.core.IJavaStackFrame;
4342
import org.eclipse.jdt.debug.eval.ICompiledExpression;
@@ -52,6 +51,8 @@
5251
import com.microsoft.java.debug.core.adapter.Constants;
5352
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
5453
import com.microsoft.java.debug.core.adapter.IEvaluationProvider;
54+
import com.microsoft.java.debug.core.adapter.ISourceLookUpProvider;
55+
import com.microsoft.java.debug.plugin.internal.JdtSourceLookUpProvider;
5556
import com.microsoft.java.debug.plugin.internal.JdtUtils;
5657
import com.sun.jdi.StackFrame;
5758
import com.sun.jdi.ThreadReference;
@@ -319,7 +320,8 @@ private void ensureDebugTarget(VirtualMachine vm, ThreadReference thread, int de
319320
}
320321

321322
if (launch == null) {
322-
launch = createILaunchMock(project);
323+
ISourceLookUpProvider sourceProvider = context.getProvider(ISourceLookUpProvider.class);
324+
launch = createILaunchMock(project, ((JdtSourceLookUpProvider) sourceProvider).getSourceContainers());
323325
}
324326

325327
debugTarget = new JDIDebugTarget(launch, vm, "", false, false, null, false) {
@@ -331,7 +333,7 @@ protected synchronized void initialize() {
331333
}
332334
}
333335

334-
private static ILaunch createILaunchMock(IJavaProject project) {
336+
private static ILaunch createILaunchMock(IJavaProject project, ISourceContainer[] containers) {
335337
return new ILaunch() {
336338
private AbstractSourceLookupDirector locator;
337339

@@ -405,9 +407,8 @@ public ISourceLocator getSourceLocator() {
405407
locator = new JavaSourceLookupDirector();
406408

407409
try {
408-
locator.setSourceContainers(
409-
new ProjectSourceContainer(project.getProject(), true).getSourceContainers());
410-
} catch (CoreException e) {
410+
locator.setSourceContainers(containers);
411+
} catch (Exception e) {
411412
logger.severe(String.format("Cannot initialize JavaSourceLookupDirector: %s", e.toString()));
412413
}
413414
locator.initializeParticipants();

0 commit comments

Comments
 (0)