Skip to content

Commit 593163f

Browse files
committed
1 parent 011465f commit 593163f

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/InitializeRequestHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public CompletableFuture<Messages.Response> handle(Requests.Command command, Req
5353
caps.supportsCompletionsRequest = true;
5454
caps.supportsRestartFrame = true;
5555
caps.supportsLogPoints = true;
56+
caps.supportsEvaluateForHovers = true;
5657
Types.ExceptionBreakpointFilter[] exceptionFilters = {
5758
Types.ExceptionBreakpointFilter.UNCAUGHT_EXCEPTION_FILTER,
5859
Types.ExceptionBreakpointFilter.CAUGHT_EXCEPTION_FILTER,

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/ScopesRequestHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public CompletableFuture<Response> handle(Command command, Arguments arguments,
4747
ThreadReference thread = stackFrameReference.getThread();
4848
VariableProxy localScope = new VariableProxy(thread, "Local", stackFrameReference);
4949
int localScopeId = context.getRecyclableIdPool().addObject(thread.uniqueID(), localScope);
50-
scopes.add(new Types.Scope(localScope.getScope(), localScopeId, false));
50+
scopes.add(new Types.Scope(localScope.getScope(), localScopeId, context.isAttached()));
5151

5252
response.body = new Responses.ScopesResponseBody(scopes);
5353
return CompletableFuture.completedFuture(response);

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveClasspathsHandler.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313

1414
import java.util.ArrayList;
1515
import java.util.List;
16+
import java.util.Objects;
1617
import java.util.logging.Level;
1718
import java.util.logging.Logger;
1819
import java.util.stream.Collectors;
1920

2021
import org.eclipse.core.runtime.CoreException;
2122
import org.eclipse.core.runtime.IStatus;
2223
import org.eclipse.core.runtime.Status;
24+
import org.eclipse.jdt.core.IClasspathAttribute;
25+
import org.eclipse.jdt.core.IClasspathEntry;
2326
import org.eclipse.jdt.core.IJavaElement;
2427
import org.eclipse.jdt.core.IJavaProject;
2528
import org.eclipse.jdt.core.search.IJavaSearchConstants;
@@ -29,6 +32,7 @@
2932
import org.eclipse.jdt.core.search.SearchParticipant;
3033
import org.eclipse.jdt.core.search.SearchPattern;
3134
import org.eclipse.jdt.core.search.SearchRequestor;
35+
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
3236
import org.eclipse.jdt.launching.JavaRuntime;
3337

3438
import com.microsoft.java.debug.core.Configuration;
@@ -162,12 +166,45 @@ private static String[][] computeClassPath(IJavaProject javaProject) throws Core
162166
}
163167
String[][] result = new String[2][];
164168
if (JavaRuntime.isModularProject(javaProject)) {
165-
result[0] = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
169+
result[0] = computeDefaultRuntimeClassPath(javaProject);
166170
result[1] = new String[0];
167171
} else {
168172
result[0] = new String[0];
169-
result[1] = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
173+
result[1] = computeDefaultRuntimeClassPath(javaProject);
170174
}
171175
return result;
172176
}
177+
178+
private static String[] computeDefaultRuntimeClassPath(IJavaProject jproject) throws CoreException {
179+
IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(jproject);
180+
List<String> resolved = new ArrayList<>(unresolved.length);
181+
for (int i = 0; i < unresolved.length; i++) {
182+
IRuntimeClasspathEntry entry = unresolved[i];
183+
if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
184+
IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspathEntry(entry, jproject);
185+
for (int j = 0; j < entries.length; j++) {
186+
if (entries[j].getClasspathEntry().getPath().equals(jproject.getOutputLocation())) {
187+
continue;
188+
}
189+
if (isTest(entries[j].getClasspathEntry())) {
190+
continue;
191+
}
192+
String location = entries[j].getLocation();
193+
if (location != null) {
194+
resolved.add(location);
195+
}
196+
}
197+
}
198+
}
199+
return resolved.toArray(new String[resolved.size()]);
200+
}
201+
202+
private static boolean isTest(final IClasspathEntry classpathEntry) {
203+
for (final IClasspathAttribute classpathAttribute : classpathEntry.getExtraAttributes()) {
204+
if (Objects.equals(classpathAttribute.getName(), "test")) {
205+
return Objects.equals(classpathAttribute.getValue(), "true");
206+
}
207+
}
208+
return false;
209+
}
173210
}

0 commit comments

Comments
 (0)