提交 ab812e31 编写于 作者: A Alexander Fedorov

#2556 navigate to source

Former-commit-id: b2a3f08e
上级 b93deecd
......@@ -21,3 +21,5 @@ Bundle-Name = DBeaver Debug Core
databaseBreakpoint.name=Database Breakpoint
databaseLineBreakpoint.name=Database Line Breakpoint
procedureSourceLocator.name = Procedure Source Locator
\ No newline at end of file
......@@ -30,5 +30,29 @@
name="%databaseLineBreakpoint.name">
</breakpoint>
</extension>
<extension
point="org.eclipse.debug.core.sourceLocators">
<sourceLocator
class="org.jkiss.dbeaver.debug.sourcelookup.ProcedureSourceLookupDirector"
id="org.jkiss.dbeaver.debug.core.procedureSourceLocator"
name="%procedureSourceLocator.name">
</sourceLocator>
</extension>
<extension
point="org.eclipse.debug.core.sourcePathComputers">
<sourcePathComputer
class="org.jkiss.dbeaver.debug.sourcelookup.ProcedureSourcePathComputer"
id="org.jkiss.dbeaver.debug.core.procedureSourcePathComputer">
</sourcePathComputer>
</extension>
<extension
point="org.eclipse.debug.core.sourceContainerTypes">
<sourceContainerType
class="org.jkiss.dbeaver.debug.sourcelookup.DatasourceSourceContainerTypeDelegate"
description="A collection of databases"
id="org.jkiss.dbeaver.debug.core.datasourceSourceContainerType"
name="Databases">
</sourceContainerType>
</extension>
</plugin>
......@@ -55,6 +55,8 @@ public class DebugCore {
public static final String BREAKPOINT_DATABASE = BUNDLE_SYMBOLIC_NAME + '.' + "databaseBreakpointMarker"; //$NON-NLS-1$
public static final String BREAKPOINT_DATABASE_LINE = BUNDLE_SYMBOLIC_NAME + '.' + "databaseLineBreakpointMarker"; //$NON-NLS-1$
public static final String SOURCE_CONTAINER_TYPE_DATASOURCE = BUNDLE_SYMBOLIC_NAME + '.' + "datasourceSourceContainerType"; //$NON-NLS-1$
public static final String ATTR_DRIVER_ID = BUNDLE_SYMBOLIC_NAME + '.' + "ATTR_DRIVER_ID"; //$NON-NLS-1$
public static final String ATTR_DRIVER_ID_DEFAULT = ""; //$NON-NLS-1$
......@@ -76,6 +78,9 @@ public class DebugCore {
public static final String ATTR_PROCEDURE_CALL = BUNDLE_SYMBOLIC_NAME + '.' + "ATTR_PROCEDURE_CALL"; //$NON-NLS-1$
public static final String ATTR_PROCEDURE_CALL_DEFAULT = ""; //$NON-NLS-1$
public static final String ATTR_NODE_PATH = BUNDLE_SYMBOLIC_NAME + '.' + "ATTR_NODE_PATH"; //$NON-NLS-1$
public static final String ATTR_NODE_PATH_DEFAULT = ""; //$NON-NLS-1$
private static Log log = Log.getLog(DebugCore.class);
public static void log(IStatus status) {
......@@ -183,6 +188,10 @@ public class DebugCore {
return extractStringAttribute(configuration, ATTR_PROCEDURE_CALL, ATTR_PROCEDURE_CALL_DEFAULT);
}
public static String extractNodePath(ILaunchConfiguration configuration) {
return extractStringAttribute(configuration, ATTR_NODE_PATH, ATTR_NODE_PATH_DEFAULT);
}
public static String extractStringAttribute(ILaunchConfiguration configuration, String attributeName,
String defaultValue) {
if (configuration == null) {
......
......@@ -306,6 +306,7 @@ public abstract class DatabaseDebugTarget extends DatabaseDebugElement implement
public void handleDebugEvent(DBGEvent event) {
DebugEvent debugEvent = toDebugEvent(event);
DebugEvents.fireEvent(debugEvent);
// DebugEvents.fireEvent(new DebugEvent(this, DebugEvent.SUSPEND, DebugEvent.BREAKPOINT));
}
}
......@@ -142,14 +142,14 @@ public class DatabaseStackFrame extends DatabaseDebugElement implements IStackFr
@Override
public int getCharStart() throws DebugException {
// TODO Auto-generated method stub
return 0;
// unknown
return -1;
}
@Override
public int getCharEnd() throws DebugException {
// TODO Auto-generated method stub
return 0;
// unknown
return -1;
}
@Override
......
package org.jkiss.dbeaver.debug.sourcelookup;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
import org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer;
import org.jkiss.dbeaver.debug.core.DebugCore;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
public class DatasourceSourceContainer extends CompositeSourceContainer {
private final DBPDataSourceContainer datasource;
private final DBNNode startNode;
public DatasourceSourceContainer(DataSourceDescriptor descriptor, DBNNode node) {
this.datasource = descriptor;
this.startNode = node;
}
@Override
public String getName() {
return datasource.getName();
}
@Override
protected Object[] findSourceElements(String name, ISourceContainer[] containers) throws CoreException {
if (startNode != null) {
return new Object[] {startNode};
}
return super.findSourceElements(name, containers);
}
@Override
public ISourceContainerType getType() {
return getSourceContainerType(DebugCore.SOURCE_CONTAINER_TYPE_DATASOURCE);
}
@Override
protected ISourceContainer[] createSourceContainers() throws CoreException {
// TODO Auto-generated method stub
return new ISourceContainer[0];
}
}
package org.jkiss.dbeaver.debug.sourcelookup;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
import org.jkiss.dbeaver.model.navigator.DBNNode;
public class DatasourceSourceContainerTypeDelegate extends AbstractSourceContainerTypeDelegate {
@Override
public ISourceContainer createSourceContainer(String memento) throws CoreException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getMemento(ISourceContainer container) throws CoreException {
// TODO Auto-generated method stub
return DBNNode.NodePathType.database.getPrefix();
}
}
package org.jkiss.dbeaver.debug.sourcelookup;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
public class ProcedureSourceLookupDirector extends AbstractSourceLookupDirector {
@Override
public void initializeParticipants() {
addParticipants(new ISourceLookupParticipant[] {new ProcedureSourceLookupParticipant()});
}
}
package org.jkiss.dbeaver.debug.sourcelookup;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
import org.jkiss.dbeaver.debug.core.model.DatabaseStackFrame;
public class ProcedureSourceLookupParticipant extends AbstractSourceLookupParticipant {
@Override
public String getSourceName(Object object) throws CoreException {
if (object instanceof DatabaseStackFrame) {
DatabaseStackFrame stackFrame = (DatabaseStackFrame) object;
return stackFrame.getName();
}
return String.valueOf(object);
}
}
package org.jkiss.dbeaver.debug.sourcelookup;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
import org.eclipse.osgi.util.NLS;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.debug.core.DebugCore;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.runtime.DefaultProgressMonitor;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.registry.DataSourceRegistry;
public class ProcedureSourcePathComputer implements ISourcePathComputerDelegate {
@Override
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor)
throws CoreException {
String datasourceId = DebugCore.extractDatasourceId(configuration);
String nodePath = DebugCore.extractNodePath(configuration);
DataSourceDescriptor descriptor = DataSourceRegistry.findDataSource(datasourceId);
final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
IProject project = descriptor.getRegistry().getProject();
DBNNode node;
try {
node = navigatorModel.getNodeByPath(new DefaultProgressMonitor(monitor), project, nodePath);
} catch (DBException e) {
String message = NLS.bind("Unable to extract node {0}", nodePath);
throw new CoreException(DebugCore.newErrorStatus(message, e));
}
DatasourceSourceContainer container = new DatasourceSourceContainer(descriptor, node);
return new ISourceContainer[] {container};
}
}
......@@ -25,21 +25,26 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorInput;
import org.jkiss.dbeaver.debug.core.DebugCore;
import org.jkiss.dbeaver.debug.ui.DatabaseDebugModelPresentation;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.ui.editors.entity.EntityEditorInput;
public class ProcedureDebugModelPresentation extends DatabaseDebugModelPresentation {
@Override
public IEditorInput getEditorInput(Object element)
{
// TODO Auto-generated method stub
if (element instanceof DBNDatabaseNode) {
DBNDatabaseNode dbnNode = (DBNDatabaseNode) element;
return new EntityEditorInput(dbnNode);
}
return null;
}
@Override
public String getEditorId(IEditorInput input, Object element)
{
// TODO Auto-generated method stub
return null;
//FIXME:AF: is there a constant anywhere?
return "org.jkiss.dbeaver.ui.editors.entity.EntityEditor";
}
@Override
......
......@@ -27,7 +27,9 @@
delegateName="%launchConfigurationTypes.launchConfigurationType.pgSQL.delegateName"
id="org.jkiss.dbeaver.ext.postgresql.debug.core.pgSQL"
modes="debug"
name="%launchConfigurationTypes.launchConfigurationType.pgSQL.name">
name="%launchConfigurationTypes.launchConfigurationType.pgSQL.name"
sourceLocatorId="org.jkiss.dbeaver.debug.core.procedureSourceLocator"
sourcePathComputerId="org.jkiss.dbeaver.debug.core.procedureSourcePathComputer">
</launchConfigurationType>
</extension>
......
......@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.osgi.util.NLS;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.debug.core.DebugCore;
import org.jkiss.dbeaver.ext.postgresql.debug.internal.PostgreDebugCoreMessages;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource;
......@@ -28,6 +29,9 @@ import org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure;
import org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.struct.DBSObject;
public class PostgreSqlDebugCore {
......@@ -63,6 +67,9 @@ public class PostgreSqlDebugCore {
workingCopy.setAttribute(DebugCore.ATTR_PROCEDURE_OID, String.valueOf(procedure.getObjectId()));
workingCopy.setAttribute(DebugCore.ATTR_PROCEDURE_NAME, procedureName);
workingCopy.setAttribute(DebugCore.ATTR_PROCEDURE_CALL, DebugCore.composeProcedureCall(procedure));
final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
DBNDatabaseNode node = navigatorModel.getNodeByObject(procedure);
workingCopy.setAttribute(DebugCore.ATTR_NODE_PATH, node.getNodeItemPath());
return workingCopy;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册