mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-149798 Extensible Attach to Local Process action: liststask.exe is now in platform
This commit is contained in:
@@ -33,12 +33,6 @@ import java.util.List;
|
||||
class ProcessListWin32 implements IProcessList {
|
||||
private static final Logger LOG = Logger.getInstance(ProcessListWin32.class);
|
||||
|
||||
private String myHelpersRoot;
|
||||
|
||||
public ProcessListWin32(String helpersRoot) {
|
||||
myHelpersRoot = helpersRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessInfo[] getProcessList() {
|
||||
try {
|
||||
@@ -56,7 +50,7 @@ class ProcessListWin32 implements IProcessList {
|
||||
}
|
||||
catch (Exception e) {
|
||||
//Use fallback
|
||||
return new ProcessListWin32Internal(myHelpersRoot).getProcessList();
|
||||
return new ProcessListWin32Internal().getProcessList();
|
||||
}
|
||||
try {
|
||||
return parseListTasks(p.getInputStream());
|
||||
|
||||
+26
-15
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.execution.process;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
|
||||
import java.io.*;
|
||||
@@ -26,25 +28,34 @@ import java.util.List;
|
||||
* Use through ProcessUtils.
|
||||
*/
|
||||
class ProcessListWin32Internal implements IProcessList {
|
||||
private String myHelpersRoot;
|
||||
|
||||
public ProcessListWin32Internal(String helpersRoot) {
|
||||
myHelpersRoot = helpersRoot;
|
||||
}
|
||||
private static final Logger LOG = Logger.getInstance(ProcessListWin32Internal.class);
|
||||
|
||||
@Override
|
||||
public ProcessInfo[] getProcessList() {
|
||||
String[] dirs = {
|
||||
PathManager.getBinPath(),
|
||||
PathManager.getHomePath() + "/community/bin/win",
|
||||
PathManager.getBinPath() + "/win"};
|
||||
|
||||
File listtasks = null;
|
||||
|
||||
for (String each : dirs) {
|
||||
listtasks = new File(each, "listtasks.exe");
|
||||
}
|
||||
|
||||
if (!listtasks.exists()) {
|
||||
LOG.error("listtasks.exe not found in bin folders");
|
||||
return ProcessInfo.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
try {
|
||||
File file = new File(myHelpersRoot, "process/listtasks.exe");
|
||||
if (file.exists()) {
|
||||
String[] command = {file.getCanonicalPath()};
|
||||
Process p = ProcessUtils.createProcess(command, null, null);
|
||||
try {
|
||||
return parseListTasks(p.getInputStream());
|
||||
}
|
||||
finally {
|
||||
p.destroy();
|
||||
}
|
||||
String[] command = {listtasks.getCanonicalPath()};
|
||||
Process p = ProcessUtils.createProcess(command, null, null);
|
||||
try {
|
||||
return parseListTasks(p.getInputStream());
|
||||
}
|
||||
finally {
|
||||
p.destroy();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
|
||||
@@ -63,14 +63,14 @@ public class ProcessUtils {
|
||||
|
||||
|
||||
@NotNull
|
||||
public static ProcessInfo[] getProcessList(@NotNull String helpersRoot) {
|
||||
return getProcessListImpl(helpersRoot).getProcessList();
|
||||
public static ProcessInfo[] getProcessList() {
|
||||
return getProcessListImpl().getProcessList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static IProcessList getProcessListImpl(@NotNull String helpersRoot) {
|
||||
private static IProcessList getProcessListImpl() {
|
||||
if (SystemInfo.isWindows) {
|
||||
return new ProcessListWin32(helpersRoot);
|
||||
return new ProcessListWin32();
|
||||
}
|
||||
if (SystemInfo.isLinux) {
|
||||
return new ProcessListLinux();
|
||||
|
||||
@@ -9,6 +9,7 @@ debugger.hotswap.display.name=HotSwap
|
||||
xdebugger.default.content.title=Debug
|
||||
xdebugger.debugger.tab.title=Debugger
|
||||
|
||||
xdebugger.attach.toLocal.popup.title=Attach
|
||||
xdebugger.attach.toLocal.action=Attach to Local Process...
|
||||
xdebugger.attach.toLocal.action.description=Attach to a locally running process with an available debugger
|
||||
|
||||
|
||||
+20
-17
@@ -62,31 +62,34 @@ public class AttachToLocalProcessAction extends AnAction {
|
||||
// todo show message
|
||||
}
|
||||
|
||||
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<AttachItem>("Attach", items) {
|
||||
@Override
|
||||
public boolean isSpeedSearchEnabled() {
|
||||
return true;
|
||||
}
|
||||
BaseListPopupStep<AttachItem> step =
|
||||
new BaseListPopupStep<AttachItem>(XDebuggerBundle.message("xdebugger.attach.toLocal.popup.title"), items) {
|
||||
@Override
|
||||
public boolean isSpeedSearchEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTextFor(AttachItem value) {
|
||||
return value.info.getPid() + " " + value.info.getExecutableName();
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTextFor(AttachItem value) {
|
||||
return value.info.getPid() + " " + value.info.getExecutableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PopupStep onChosen(AttachItem selectedValue, boolean finalChoice) {
|
||||
startDebugSession(project, selectedValue.debuggers.get(0), selectedValue.info);
|
||||
return super.onChosen(selectedValue, finalChoice);
|
||||
}
|
||||
}).showCenteredInCurrentWindow(project);
|
||||
@Override
|
||||
public PopupStep onChosen(AttachItem selectedValue, boolean finalChoice) {
|
||||
startDebugSession(project, selectedValue.debuggers.get(0), selectedValue.info);
|
||||
return super.onChosen(selectedValue, finalChoice);
|
||||
}
|
||||
};
|
||||
|
||||
JBPopupFactory.getInstance().createListPopup(step).showCenteredInCurrentWindow(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<AttachItem> collectAttachItems(@NotNull Project project) {
|
||||
List<AttachItem> result = new ArrayList<AttachItem>();
|
||||
|
||||
for (ProcessInfo eachInfo : ProcessUtils.getProcessList("")) {
|
||||
for (ProcessInfo eachInfo : ProcessUtils.getProcessList()) {
|
||||
List<XLocalAttachDebugger> availableDebuggers = new ArrayList<XLocalAttachDebugger>();
|
||||
for (XLocalAttachDebuggerProvider eachProvider : Extensions.getExtensions(XLocalAttachDebuggerProvider.EP)) {
|
||||
availableDebuggers.addAll(eachProvider.getAvailableDebuggers(project, eachInfo));
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.SelectFromListDialog;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -86,7 +85,7 @@ public class PyAttachToProcessAction extends AnAction {
|
||||
}
|
||||
|
||||
private static ProcessInfo[] pythonProcessesList() {
|
||||
ProcessInfo[] list = ProcessUtils.getProcessList(PythonHelpersLocator.getHelpersRoot().getAbsolutePath());
|
||||
ProcessInfo[] list = ProcessUtils.getProcessList();
|
||||
return FluentIterable.from(Lists.newArrayList(list)).filter(new Predicate<ProcessInfo>() {
|
||||
@Override
|
||||
public boolean apply(ProcessInfo input) {
|
||||
|
||||
Reference in New Issue
Block a user