use of org.python.pydev.debug.model.remote.ReloadCodeCommand in project Pydev by fabioz.
the class PyReloadCode method onSave.
@Override
public void onSave(BaseEditor baseEditor, IProgressMonitor monitor) {
if (!DebugPrefsPage.getReloadModuleOnChange()) {
return;
}
PyEdit edit = (PyEdit) baseEditor;
File file = edit.getEditorFile();
if (file != null) {
IDebugTarget[] debugTargets = DebugPlugin.getDefault().getLaunchManager().getDebugTargets();
if (debugTargets.length > 0) {
ICallback<Boolean, IDebugTarget> callbackThatFilters = new ICallback<Boolean, IDebugTarget>() {
@Override
public Boolean call(IDebugTarget arg) {
return arg instanceof AbstractDebugTarget;
}
};
List<IDebugTarget> filter = ArrayUtils.filter(debugTargets, callbackThatFilters);
if (filter.size() > 0) {
try {
IPythonNature pythonNature = edit.getPythonNature();
if (pythonNature != null) {
String moduleName = pythonNature.resolveModule(file);
if (moduleName != null) {
for (IDebugTarget iDebugTarget : filter) {
AbstractDebugTarget target = (AbstractDebugTarget) iDebugTarget;
target.postCommand(new ReloadCodeCommand(target, moduleName));
}
}
}
} catch (MisconfigurationException e) {
Log.log(e);
}
}
}
}
}
Aggregations