diff options
author | Roland Grunberg | 2013-03-07 22:22:13 +0000 |
---|---|---|
committer | Camilo Bernal | 2013-03-08 17:23:23 +0000 |
commit | 303efa3e5882222edafdda12565317893e4e4680 (patch) | |
tree | dcec07b65b19c84461f2847d4f106cf5f1ba5625 /profiling | |
parent | d69ce50b5e5aa7888d95cfc7fb3b53986353d8ef (diff) | |
download | org.eclipse.linuxtools-303efa3e5882222edafdda12565317893e4e4680.tar.gz org.eclipse.linuxtools-303efa3e5882222edafdda12565317893e4e4680.tar.xz org.eclipse.linuxtools-303efa3e5882222edafdda12565317893e4e4680.zip |
Clean up ProfileLaunchConfigurationDelegate.
Remove methods from ProfileLaunchConfigurationDelegate that are only
used by the Callgraph plugin and move them to the plugin itself.
Change-Id: I3268b87c0b44cf4f53660e856224713e52de378a
Reviewed-on: https://git.eclipse.org/r/10982
Tested-by: Hudson CI
Reviewed-by: Camilo Bernal <cabernal@redhat.com>
IP-Clean: Camilo Bernal <cabernal@redhat.com>
Tested-by: Camilo Bernal <cabernal@redhat.com>
Diffstat (limited to 'profiling')
3 files changed, 0 insertions, 148 deletions
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java index 4741e3f20f..e2b8e6c3d3 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/internal/profiling/launch/provider/launch/ProviderLaunchConfigurationDelegate.java @@ -106,11 +106,6 @@ public class ProviderLaunchConfigurationDelegate extends } @Override - public String generateCommand(ILaunchConfiguration config) { - return null; - } - - @Override protected String getPluginID() { return ProviderProfileConstants.PLUGIN_ID; } diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationDelegate.java index f483f7ecf4..81a287a25d 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationDelegate.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/ProfileLaunchConfigurationDelegate.java @@ -11,21 +11,14 @@ package org.eclipse.linuxtools.profiling.launch; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.util.ArrayList; import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.cdt.utils.spawner.ProcessFactory; -import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.IProcess; -import org.eclipse.jface.text.IDocument; -import org.eclipse.ui.console.ConsolePlugin; -import org.eclipse.ui.console.TextConsole; /** * Helper class for launching command line tools. Contains methods for creating a process and @@ -37,98 +30,7 @@ import org.eclipse.ui.console.TextConsole; */ public abstract class ProfileLaunchConfigurationDelegate extends AbstractCLaunchDelegate{ - /** - * Deletes and recreates the file at outputPath - * - * @param outputPath - * @return false if there is an IOException - */ - protected boolean testOutput(String outputPath) { - try { - //Make sure the output file exists - File tempFile = new File(outputPath); - tempFile.delete(); - tempFile.createNewFile(); - } catch (IOException e1) { - return false; - } - return true; - } - - /** - * This method will create a process in the command line with I/O directed to the Eclipse console. - * It returns a reference to the process. Note that the process runs independently of Eclipse's threads, - * so you will have to poll the process to determine when it has terminated. To grab output from the - * process, either attach a <code>org.eclipse.debug.core.model.IStreamMonitor</code> to one of the monitors - * in <code>process.getStreamsProxy()</code>, or use the static get methods in - * <code>ProfileLaunchConfigurationDelegate</code>. - * - * <br> - * Will call generateCommand(config) to create the command line. - * - * - * @param config -- Use the configuration passed as a parameter to the launch method. - * @param cmd -- Command string, as it would appear on the command line. - * @param launch -- use the launch passed as a parameter to the launch method. - * @return - * @throws CoreException - * @throws IOException - */ - - protected IProcess createProcess(ILaunchConfiguration config, ILaunch launch) throws CoreException, IOException { - File workDir = getWorkingDirectory(config); - if (workDir == null) { - workDir = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$ - } - - //Put command into a shell script - String cmd = generateCommand(config); - File script = File.createTempFile("org.eclipse.linuxtools.profiling.launch" + System.currentTimeMillis(), ".sh"); - String data = "#!/bin/sh\nexec " + cmd; //$NON-NLS-1$ - FileOutputStream out = null; - try { - out = new FileOutputStream(script); - out.write(data.getBytes()); - } finally { - if (out != null) { - out.close(); - } - } - - String[] commandArray = prepareCommand("sh " + script.getAbsolutePath()); - Process subProcess = execute(commandArray, getEnvironment(config), - workDir, true); - - IProcess process = createNewProcess(launch, subProcess,commandArray[0]); - // set the command line used - process.setAttribute(IProcess.ATTR_CMDLINE,cmd); - - return process; - } - - /** - * Use to generate the command. - * @param config - * @return The command string, as it would appear on command-line - */ - public abstract String generateCommand(ILaunchConfiguration config); - - /** - * Prepare cmd for execution - we need a command array of strings, - * no string can contain a space character. The resulting command - * array will be passed in to the process. - */ - protected String[] prepareCommand(String cmd) { - String tmp[] = cmd.split(" "); //$NON-NLS-1$ - ArrayList<String> cmdLine = new ArrayList<String>(); - for (String str : tmp) { - cmdLine.add(str); - } - return cmdLine.toArray(new String[cmdLine.size()]); - } - - /** * Executes a command array using pty * @@ -174,45 +76,5 @@ public abstract class ProfileLaunchConfigurationDelegate extends AbstractCLaunch return DebugPlugin.newProcess(launch, systemProcess, renderProcessLabel(programName)); } - - - /** - * - * @param search : A String that can be found in the console - * @return The TextConsole having 'name' somewhere within it's name - */ - public static TextConsole getConsole(String search) { - for (int i = 0; i < ConsolePlugin.getDefault().getConsoleManager() - .getConsoles().length; i++) { - if (ConsolePlugin.getDefault().getConsoleManager(). - getConsoles()[i].getName().contains(search)) { - return (TextConsole)ConsolePlugin.getDefault().getConsoleManager().getConsoles()[i]; - } - } - return null; - } - - - /** - * Returns the contents of a console as a String - * - * @param search : Console name - * @return The text contained within that console - */ - public static String getMainConsoleText(String search){ - TextConsole proc = getConsole(search); - return proc.getDocument().get(); - } - - /** - * Return the document attached to containing the given string. For best results, - * use <code>ILaunchConfiguration.getName()</code>. - * @param search - * @return - */ - public static IDocument getConsoleDocument(String search) { - return getConsole(search).getDocument(); - } - } diff --git a/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/stubby/StubbyLaunchConfigurationDelegate.java b/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/stubby/StubbyLaunchConfigurationDelegate.java index c6e380c77b..077a58b514 100644 --- a/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/stubby/StubbyLaunchConfigurationDelegate.java +++ b/profiling/org.eclipse.linuxtools.profiling.provider.tests/src/org/eclipse/linuxtools/profiling/provider/tests/stubby/StubbyLaunchConfigurationDelegate.java @@ -19,11 +19,6 @@ public class StubbyLaunchConfigurationDelegate extends ProfileLaunchConfigurationDelegate { @Override - public String generateCommand(ILaunchConfiguration config) { - return null; - } - - @Override public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) { } |