From 119012a5f9596b597b5330b587daaac11f3bb4c9 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 23 Sep 2002 18:04:06 +0000 Subject: [PATCH] Move addSourcePaths() to the source Manager. --- .../eclipse/cdt/debug/core/CDebugModel.java | 4 +- .../cdt/debug/core/cdi/ICDISession.java | 5 --- .../cdt/debug/core/cdi/ICDISourceManager.java | 12 ++++++ .../cdt/debug/mi/core/cdi/SourceManager.java | 42 ++++++++++++++++--- 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java index 19323f6535e..bf84cd3bdde 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java @@ -11,6 +11,7 @@ import java.util.HashMap; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; @@ -99,7 +100,8 @@ public class CDebugModel // Temporary try { - cdiTarget.getSession().addSearchPaths( new String[] { project.getLocation().toOSString() } ); + ICDISourceManager mgr = cdiTarget.getSession().getSourceManager(); + mgr.addSourcePaths( new String[] { project.getLocation().toOSString() }); } catch( CDIException e ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java index a83e9106e98..dc87f76c6b5 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISession.java @@ -110,9 +110,4 @@ public interface ICDISession { */ void terminate() throws CDIException; - /** - * Add directories to the begining of the search path - * for source files. - */ - void addSearchPaths(String[] dirs) throws CDIException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISourceManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISourceManager.java index 30cc08d628a..2a235b6fd45 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISourceManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDISourceManager.java @@ -15,6 +15,18 @@ import java.io.File; */ public interface ICDISourceManager extends ICDISessionObject { + /** + * Set the source search paths for the debu session. + * @param String + */ + void addSourcePaths(String[] srcPaths) throws CDIException; + + /** + * Return the array of source paths + * @return String array of search paths. + */ + String[] getSourcePaths() throws CDIException; + /** * Returns an array of directories. Returns the empty array * if the source path is empty. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java index 8547d19a3be..0992e8f805e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java @@ -6,22 +6,27 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; +import org.eclipse.cdt.debug.mi.core.MIException; +import org.eclipse.cdt.debug.mi.core.MISession; +import org.eclipse.cdt.debug.mi.core.command.CommandFactory; +import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory; +import org.eclipse.cdt.debug.mi.core.output.MIInfo; +import sun.security.krb5.internal.crypto.e; /** - * @author alain - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. */ public class SourceManager extends SessionObject implements ICDISourceManager { + List sourcePaths; + public SourceManager(CSession session) { super(session); + sourcePaths = new ArrayList(); } /** @@ -43,4 +48,29 @@ public class SourceManager extends SessionObject implements ICDISourceManager { public void set(File[] directories) throws CDIException { } + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#addSourcePaths(String[]) + */ + public void addSourcePaths(String[] dirs) throws CDIException { + MISession mi = getCSession().getMISession(); + CommandFactory factory = mi.getCommandFactory(); + MIEnvironmentDirectory dir = factory.createMIEnvironmentDirectory(dirs); + try { + mi.postCommand(dir); + MIInfo info = dir.getMIInfo(); + } catch (MIException e) { + throw new CDIException(e.getMessage()); + } + for (int i = 0; i < dirs.length; i++) { + sourcePaths.add(dirs[i]); + } + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getSourcePaths() + */ + public String[] getSourcePaths() { + return (String[])sourcePaths.toArray(new String[0]); + } + }