Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.microsoft.java.debug.plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<command id="vscode.java.checkProjectSettings"/>
<command id="vscode.java.resolveElementAtSelection"/>
<command id="vscode.java.resolveBuildFiles"/>
<command id="vscode.java.isOnClasspath"/>
</delegateCommandHandler>
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.ls.core.internal.IDelegateCommandHandler;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.jdt.ls.core.internal.ProjectUtils;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;

import com.microsoft.java.debug.core.DebugException;
import com.microsoft.java.debug.core.UsageDataStore;
import com.microsoft.java.debug.core.protocol.JsonUtils;
import com.microsoft.java.debug.core.protocol.Requests.LaunchArguments;
Expand All @@ -39,6 +42,7 @@ public class JavaDebugDelegateCommandHandler implements IDelegateCommandHandler
public static final String CHECK_PROJECT_SETTINGS = "vscode.java.checkProjectSettings";
public static final String RESOLVE_ELEMENT_AT_SELECTION = "vscode.java.resolveElementAtSelection";
public static final String RESOLVE_BUILD_FILES = "vscode.java.resolveBuildFiles";
public static final String IS_ON_CLASSPATH = "vscode.java.isOnClasspath";

@Override
public Object executeCommand(String commandId, List<Object> arguments, IProgressMonitor progress) throws Exception {
Expand Down Expand Up @@ -72,6 +76,8 @@ public Object executeCommand(String commandId, List<Object> arguments, IProgress
return ResolveElementHandler.resolveElementAtSelection(arguments, progress);
case RESOLVE_BUILD_FILES:
return getBuildFiles();
case IS_ON_CLASSPATH:
return isOnClasspath(arguments);
default:
break;
}
Expand All @@ -97,4 +103,19 @@ private List<String> getBuildFiles() {

return result;
}

private boolean isOnClasspath(List<Object> arguments) throws DebugException {
if (arguments.size() < 1) {
throw new DebugException("No file uri is specified.");
}

String uri = (String) arguments.get(0);
final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(uri);
if (unit == null || unit.getResource() == null || !unit.getResource().exists()) {
throw new DebugException("The compilation unit " + uri + " doesn't exist.");
}

IJavaProject javaProject = unit.getJavaProject();
return javaProject == null || javaProject.isOnClasspath(unit);
}
}