diff options
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph')
17 files changed, 1332 insertions, 1332 deletions
diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java index 2b780ec041..23aa440a6a 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/CallgraphCorePlugin.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Red Hat - initial API and implementation *******************************************************************************/ @@ -25,82 +25,82 @@ import org.osgi.framework.BundleContext; /** - * Activator class behaves like standard Wizard-created activator, + * Activator class behaves like standard Wizard-created activator, * except for the checkRun() function. * */ public class CallgraphCorePlugin extends AbstractUIPlugin { - public static final String PLUGIN_ID = "org.eclipse.linuxtools.callgraph.core"; //$NON-NLS-1$ - // The shared instance - private static CallgraphCorePlugin plugin; - - /** - * The constructor - */ - public CallgraphCorePlugin() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static CallgraphCorePlugin getDefault() { - return plugin; - } - - - /** - * Returns the location of the plugin by checking the path of the bundle's - * locationURL. - * - * @return - */ - public static String getPluginLocation() { - Bundle bundle = Platform.getBundle(PLUGIN_ID); - - URL locationUrl = FileLocator.find(bundle,new Path("/"), null); //$NON-NLS-1$ - URL fileUrl = null; - try { - fileUrl = FileLocator.toFileURL(locationUrl); - return fileUrl.getFile(); - } catch (IOException e) { - e.printStackTrace(); - } - return new String(); - } - - /** - * Log specified exception. - * @param e Exception to log. - */ - public static void logException(Exception e) { - Status status = new Status(IStatus.ERROR, CallgraphCorePlugin.PLUGIN_ID, - e.getMessage()); - CallgraphCorePlugin.getDefault().getLog().log(status); - } + public static final String PLUGIN_ID = "org.eclipse.linuxtools.callgraph.core"; //$NON-NLS-1$ + // The shared instance + private static CallgraphCorePlugin plugin; + + /** + * The constructor + */ + public CallgraphCorePlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static CallgraphCorePlugin getDefault() { + return plugin; + } + + + /** + * Returns the location of the plugin by checking the path of the bundle's + * locationURL. + * + * @return + */ + public static String getPluginLocation() { + Bundle bundle = Platform.getBundle(PLUGIN_ID); + + URL locationUrl = FileLocator.find(bundle,new Path("/"), null); //$NON-NLS-1$ + URL fileUrl = null; + try { + fileUrl = FileLocator.toFileURL(locationUrl); + return fileUrl.getFile(); + } catch (IOException e) { + e.printStackTrace(); + } + return new String(); + } + + /** + * Log specified exception. + * @param e Exception to log. + */ + public static void logException(Exception e) { + Status status = new Status(IStatus.ERROR, CallgraphCorePlugin.PLUGIN_ID, + e.getMessage()); + CallgraphCorePlugin.getDefault().getLog().log(status); + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/DocWriter.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/DocWriter.java index 1081a6c4a8..d9a453806f 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/DocWriter.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/DocWriter.java @@ -19,55 +19,55 @@ import org.eclipse.ui.console.TextConsole; import org.eclipse.ui.progress.UIJob; public class DocWriter extends UIJob { - private TextConsole console; - private String message; - private int length; - private int start; + private TextConsole console; + private String message; + private int length; + private int start; - /** - * Initiate DocWriter class. DocWriter will append the given message - * to the given console in a separate UI job. By default, DocWriter will - * append to the end of the console and replace 0 characters. To change this, - * see DocWriter's set methods. - * - * - * @param name - * @param console - * @param message - */ - public DocWriter(String name, TextConsole console, String message) { + /** + * Initiate DocWriter class. DocWriter will append the given message + * to the given console in a separate UI job. By default, DocWriter will + * append to the end of the console and replace 0 characters. To change this, + * see DocWriter's set methods. + * + * + * @param name + * @param console + * @param message + */ + public DocWriter(String name, TextConsole console, String message) { - super(name); - this.console = console; - this.message = message; - this.start=-1; - this.length=-1; - } + super(name); + this.console = console; + this.message = message; + this.start=-1; + this.length=-1; + } - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (console == null) { - return Status.CANCEL_STATUS; - } - if (message == null) { - return Status.OK_STATUS; - } + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + if (console == null) { + return Status.CANCEL_STATUS; + } + if (message == null) { + return Status.OK_STATUS; + } - IDocument doc = console.getDocument(); + IDocument doc = console.getDocument(); - if (length < 0) { - length = 0; - } - if (start < 0) { - start = doc.getLength(); - } - try { - doc.replace(start, length, message); - } catch (BadLocationException e) { - e.printStackTrace(); - } + if (length < 0) { + length = 0; + } + if (start < 0) { + start = doc.getLength(); + } + try { + doc.replace(start, length, message); + } catch (BadLocationException e) { + e.printStackTrace(); + } - return Status.OK_STATUS; - } + return Status.OK_STATUS; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java index dc8c402163..c7dcd97f76 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/FileFinderOpener.java @@ -28,61 +28,61 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog; */ public class FileFinderOpener { - private static Map<String, int []> map = new HashMap<>(); + private static Map<String, int []> map = new HashMap<>(); - /** - * Seeks all functions in the given proejct that contains the given function name. - * Farms off the work of generating the list to the findFunctionsInProject function. - * Opens a selection dialog if more than one file is found. - * - * @param project - * @param functionName - * @return - */ - public static void findAndOpen(ICProject project, String functionName) { - //Safety valve: Do not enforce use of project names - if (project == null) { - return; - } + /** + * Seeks all functions in the given proejct that contains the given function name. + * Farms off the work of generating the list to the findFunctionsInProject function. + * Opens a selection dialog if more than one file is found. + * + * @param project + * @param functionName + * @return + */ + public static void findAndOpen(ICProject project, String functionName) { + //Safety valve: Do not enforce use of project names + if (project == null) { + return; + } - map = ProfileUIUtils.findFunctionsInProject(project, functionName, -1, null); - ArrayList<String> files = new ArrayList<>(map.keySet()); + map = ProfileUIUtils.findFunctionsInProject(project, functionName, -1, null); + ArrayList<String> files = new ArrayList<>(map.keySet()); - if (files == null || files.size() < 1) { - return; - } + if (files == null || files.size() < 1) { + return; + } - if (files.size() == 1) { - open(files.get(0), map.get(files.get(0))[0], map.get(files.get(0))[1]); - } else { - ElementListSelectionDialog d = new ElementListSelectionDialog(new Shell(), new LabelProvider()); - d.setTitle(Messages.getString("FileFinderOpener.MultipleFilesDialog")); //$NON-NLS-1$ - d.setMessage(Messages.getString("FileFinderOpener.MultFilesDialogM1") + functionName + Messages.getString("FileFinderOpener.MultFilesDialogM2") + //$NON-NLS-1$ //$NON-NLS-2$ - Messages.getString("FileFinderOpener.MultFilesDialogM3")); //$NON-NLS-1$ - d.setElements(files.toArray()); - d.open(); + if (files.size() == 1) { + open(files.get(0), map.get(files.get(0))[0], map.get(files.get(0))[1]); + } else { + ElementListSelectionDialog d = new ElementListSelectionDialog(new Shell(), new LabelProvider()); + d.setTitle(Messages.getString("FileFinderOpener.MultipleFilesDialog")); //$NON-NLS-1$ + d.setMessage(Messages.getString("FileFinderOpener.MultFilesDialogM1") + functionName + Messages.getString("FileFinderOpener.MultFilesDialogM2") + //$NON-NLS-1$ //$NON-NLS-2$ + Messages.getString("FileFinderOpener.MultFilesDialogM3")); //$NON-NLS-1$ + d.setElements(files.toArray()); + d.open(); - if (d.getResult() == null) { - return; - } + if (d.getResult() == null) { + return; + } - for (Object o : d.getResult()) { - if (o instanceof String) { - String s = (String) o; - open(s, map.get(s)[0], map.get(s)[1]); - } - } - } - } + for (Object o : d.getResult()) { + if (o instanceof String) { + String s = (String) o; + open(s, map.get(s)[0], map.get(s)[1]); + } + } + } + } - private static void open(String path, int offset, int length) { - if (path == null) { - return; - } - try { - ProfileUIUtils.openEditorAndSelect(path, offset, length); - } catch (PartInitException e) { - e.printStackTrace(); - } - } + private static void open(String path, int offset, int length) { + if (path == null) { + return; + } + try { + ProfileUIUtils.openEditorAndSelect(path, offset, length); + } catch (PartInitException e) { + e.printStackTrace(); + } + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Helper.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Helper.java index f39087ee63..38bd15d912 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Helper.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Helper.java @@ -23,62 +23,62 @@ import org.eclipse.ui.console.TextConsole; public class Helper { - /** - * @param name : A String that can be found in the console (BE AS SPECIFIC AS POSSIBLE) - * @return The TextConsole having 'name' somewhere within it's name - */ - public static TextConsole getConsoleByName(String name) { - for (int i = 0; i < ConsolePlugin.getDefault().getConsoleManager() - .getConsoles().length; i++) { - if (ConsolePlugin.getDefault().getConsoleManager(). - getConsoles()[i].getName().contains(name)) { - return (TextConsole)ConsolePlugin.getDefault().getConsoleManager().getConsoles()[i]; - } - } - return null; - } + /** + * @param name : A String that can be found in the console (BE AS SPECIFIC AS POSSIBLE) + * @return The TextConsole having 'name' somewhere within it's name + */ + public static TextConsole getConsoleByName(String name) { + for (int i = 0; i < ConsolePlugin.getDefault().getConsoleManager() + .getConsoles().length; i++) { + if (ConsolePlugin.getDefault().getConsoleManager(). + getConsoles()[i].getName().contains(name)) { + return (TextConsole)ConsolePlugin.getDefault().getConsoleManager().getConsoles()[i]; + } + } + return null; + } - /** - * Read the contents of a file - * @param absoluteFilePath : The absolute path of the file from which to read. - * @return : The contents of the file as a String. - */ - public static String readFile(String absoluteFilePath) { + /** + * Read the contents of a file + * @param absoluteFilePath : The absolute path of the file from which to read. + * @return : The contents of the file as a String. + */ + public static String readFile(String absoluteFilePath) { - try (BufferedReader bw = new BufferedReader(new FileReader(new File(absoluteFilePath)))) { - String output = ""; //$NON-NLS-1$ - String tmp = ""; //$NON-NLS-1$ - while ((tmp = bw.readLine()) != null) { - output+=tmp + "\n"; //$NON-NLS-1$ - } - bw.close(); + try (BufferedReader bw = new BufferedReader(new FileReader(new File(absoluteFilePath)))) { + String output = ""; //$NON-NLS-1$ + String tmp = ""; //$NON-NLS-1$ + while ((tmp = bw.readLine()) != null) { + output+=tmp + "\n"; //$NON-NLS-1$ + } + bw.close(); - return output; - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } + return output; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } - public static BufferedWriter setBufferedWriter(String absoluteFilePath) { - try { - File f = new File(absoluteFilePath); - f.delete(); - f.createNewFile(); - FileWriter fstream; - fstream = new FileWriter(absoluteFilePath, true); - return new BufferedWriter(fstream); - } catch (IOException e) { - SystemTapUIErrorMessages err = new SystemTapUIErrorMessages - (Messages.getString("SystemTapView.FileIOErr"), //$NON-NLS-1$ - Messages.getString("SystemTapView.FileIOErr"), //$NON-NLS-1$ - Messages.getString("SystemTapView.FileIOErrMsg")); //$NON-NLS-1$ - err.schedule(); - e.printStackTrace(); - return null; - } - } + public static BufferedWriter setBufferedWriter(String absoluteFilePath) { + try { + File f = new File(absoluteFilePath); + f.delete(); + f.createNewFile(); + FileWriter fstream; + fstream = new FileWriter(absoluteFilePath, true); + return new BufferedWriter(fstream); + } catch (IOException e) { + SystemTapUIErrorMessages err = new SystemTapUIErrorMessages + (Messages.getString("SystemTapView.FileIOErr"), //$NON-NLS-1$ + Messages.getString("SystemTapView.FileIOErr"), //$NON-NLS-1$ + Messages.getString("SystemTapView.FileIOErrMsg")); //$NON-NLS-1$ + err.schedule(); + e.printStackTrace(); + return null; + } + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/LaunchConfigurationConstants.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/LaunchConfigurationConstants.java index 17ffb5b9dd..447f864c22 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/LaunchConfigurationConstants.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/LaunchConfigurationConstants.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Red Hat - initial API and implementation *******************************************************************************/ @@ -12,85 +12,85 @@ package org.eclipse.linuxtools.internal.callgraph.core; /** - * Contains the name and default value of configuration variables, as well as + * Contains the name and default value of configuration variables, as well as * a few other plugin-specific constants. * */ public final class LaunchConfigurationConstants { - - - //Configuration type variables - private static final String INVALID = ""; //$NON-NLS-1$ - public static final String PLUGIN_ID = "org.eclipse.linuxtools.callgraph.launch"; //$NON-NLS-1$ - public static final String COMMAND_VERBOSE = PLUGIN_ID + ".COMMAND_VERBOSE"; //$NON-NLS-1$ - public static final String COMMAND_PASS = PLUGIN_ID + ".PASS"; //$NON-NLS-1$ - public static final String COMMAND_KEEP_TEMPORARY = PLUGIN_ID + ".KEEP_TEMPORARY"; //$NON-NLS-1$ - public static final String COMMAND_GURU = PLUGIN_ID + ".GURU"; //$NON-NLS-1$ - public static final String COMMAND_PROLOGUE_SEARCH = PLUGIN_ID + ".PROLOGUE_SEARCH"; //$NON-NLS-1$ - public static final String COMMAND_NO_CODE_ELISION = PLUGIN_ID + ".NO_CODE_ELISION"; //$NON-NLS-1$ - public static final String COMMAND_DISABLE_WARNINGS = PLUGIN_ID + ".DISABLE_WARNINGS"; //$NON-NLS-1$ - public static final String COMMAND_BULK_MODE = PLUGIN_ID + ".BULK_MODE"; //$NON-NLS-1$ - public static final String COMMAND_TIMING_INFO = PLUGIN_ID + ".TIMING_INFO"; //$NON-NLS-1$ - public static final String COMMAND_SKIP_BADVARS = PLUGIN_ID + ".SKIP_BADVARS"; //$NON-NLS-1$ - public static final String COMMAND_IGNORE_DWARF = PLUGIN_ID + ".IGNORE_DWARF"; //$NON-NLS-1$ - public static final String COMMAND_TAPSET_COVERAGE = PLUGIN_ID + ".TAPSET_COVERAGE"; //$NON-NLS-1$ - public static final String BINARY_PATH = PLUGIN_ID + ".BINARY_PATH"; //$NON-NLS-1$ - public static final String SCRIPT_PATH = PLUGIN_ID + ".SCRIPT_PATH"; //$NON-NLS-1$ - public static final String COMMAND_LEAVE_RUNNING = PLUGIN_ID + ".LEAVE_RUNNING"; //$NON-NLS-1$ - public static final String COMMAND_C_DIRECTIVES = PLUGIN_ID + ".C_DIRECTIVES"; //$NON-NLS-1$ - public static final String COMMAND_BUFFER_BYTES = PLUGIN_ID + ".BUFFER_BYTES"; //$NON-NLS-1$ - public static final String COMMAND_TARGET_PID = PLUGIN_ID + ".TARGET_PID"; //$NON-NLS-1$ - public static final String ARGUMENTS = PLUGIN_ID + ".ARGUMENTS"; //$NON-NLS-1$ - public static final String NUMBER_OF_ARGUMENTS = PLUGIN_ID + ".NUMBER_OF_ARGUMENTS"; //$NON-NLS-1$ - public static final String OUTPUT_PATH = PLUGIN_ID + ".OUTPUT_PATH"; //$NON-NLS-1$ - public static final String OVERWRITE = PLUGIN_ID + ".OVERWRITE"; //$NON-NLS-1$ - public static final String BUILD_PROJECT = PLUGIN_ID + ".BUILD_PROJECT"; //$NON-NLS-1$ - public static final String COMMAND_LIST = PLUGIN_ID + ".COMMAND_LIST"; //$NON-NLS-1$ - public static final String BINARY_ARGUMENTS = PLUGIN_ID + ".BINARY_ARGUMENTS"; //$NON-NLS-1$ - public static final String PARSER_CLASS = PLUGIN_ID + ".PARSER_CLASS"; //$NON-NLS-1$ - public static final String VIEW_CLASS = PLUGIN_ID + ".VIEW_CLASS"; //$NON-NLS-1$ - public static final String SECONDARY_VIEW_ID = PLUGIN_ID + ".SECONDARY_VIEW_ID"; //$NON-NLS-1$ + //Configuration type variables + private static final String INVALID = ""; //$NON-NLS-1$ + public static final String PLUGIN_ID = "org.eclipse.linuxtools.callgraph.launch"; //$NON-NLS-1$ + + public static final String COMMAND_VERBOSE = PLUGIN_ID + ".COMMAND_VERBOSE"; //$NON-NLS-1$ + public static final String COMMAND_PASS = PLUGIN_ID + ".PASS"; //$NON-NLS-1$ + public static final String COMMAND_KEEP_TEMPORARY = PLUGIN_ID + ".KEEP_TEMPORARY"; //$NON-NLS-1$ + public static final String COMMAND_GURU = PLUGIN_ID + ".GURU"; //$NON-NLS-1$ + public static final String COMMAND_PROLOGUE_SEARCH = PLUGIN_ID + ".PROLOGUE_SEARCH"; //$NON-NLS-1$ + public static final String COMMAND_NO_CODE_ELISION = PLUGIN_ID + ".NO_CODE_ELISION"; //$NON-NLS-1$ + public static final String COMMAND_DISABLE_WARNINGS = PLUGIN_ID + ".DISABLE_WARNINGS"; //$NON-NLS-1$ + public static final String COMMAND_BULK_MODE = PLUGIN_ID + ".BULK_MODE"; //$NON-NLS-1$ + public static final String COMMAND_TIMING_INFO = PLUGIN_ID + ".TIMING_INFO"; //$NON-NLS-1$ + public static final String COMMAND_SKIP_BADVARS = PLUGIN_ID + ".SKIP_BADVARS"; //$NON-NLS-1$ + public static final String COMMAND_IGNORE_DWARF = PLUGIN_ID + ".IGNORE_DWARF"; //$NON-NLS-1$ + public static final String COMMAND_TAPSET_COVERAGE = PLUGIN_ID + ".TAPSET_COVERAGE"; //$NON-NLS-1$ + public static final String BINARY_PATH = PLUGIN_ID + ".BINARY_PATH"; //$NON-NLS-1$ + public static final String SCRIPT_PATH = PLUGIN_ID + ".SCRIPT_PATH"; //$NON-NLS-1$ + public static final String COMMAND_LEAVE_RUNNING = PLUGIN_ID + ".LEAVE_RUNNING"; //$NON-NLS-1$ + public static final String COMMAND_C_DIRECTIVES = PLUGIN_ID + ".C_DIRECTIVES"; //$NON-NLS-1$ + public static final String COMMAND_BUFFER_BYTES = PLUGIN_ID + ".BUFFER_BYTES"; //$NON-NLS-1$ + public static final String COMMAND_TARGET_PID = PLUGIN_ID + ".TARGET_PID"; //$NON-NLS-1$ + public static final String ARGUMENTS = PLUGIN_ID + ".ARGUMENTS"; //$NON-NLS-1$ + public static final String NUMBER_OF_ARGUMENTS = PLUGIN_ID + ".NUMBER_OF_ARGUMENTS"; //$NON-NLS-1$ + public static final String OUTPUT_PATH = PLUGIN_ID + ".OUTPUT_PATH"; //$NON-NLS-1$ + public static final String OVERWRITE = PLUGIN_ID + ".OVERWRITE"; //$NON-NLS-1$ + public static final String BUILD_PROJECT = PLUGIN_ID + ".BUILD_PROJECT"; //$NON-NLS-1$ + public static final String COMMAND_LIST = PLUGIN_ID + ".COMMAND_LIST"; //$NON-NLS-1$ + public static final String BINARY_ARGUMENTS = PLUGIN_ID + ".BINARY_ARGUMENTS"; //$NON-NLS-1$ + public static final String PARSER_CLASS = PLUGIN_ID + ".PARSER_CLASS"; //$NON-NLS-1$ + public static final String VIEW_CLASS = PLUGIN_ID + ".VIEW_CLASS"; //$NON-NLS-1$ + public static final String SECONDARY_VIEW_ID = PLUGIN_ID + ".SECONDARY_VIEW_ID"; //$NON-NLS-1$ + + + public static final String GENERATED_SCRIPT = PLUGIN_ID + ".GENERATED_SCRIPT"; //$NON-NLS-1$ + public static final String NEED_TO_GENERATE = PLUGIN_ID + ".NEED_TO_GENERATE"; //$NON-NLS-1$ + public static final String USE_COLOUR = PLUGIN_ID + ".USE_COLOUR"; //$NON-NLS-1$ + public static final String COMMAND = ".COMMAND"; //$NON-NLS-1$ + + //Defaults + public static final int DEFAULT_COMMAND_VERBOSE = 0; + public static final int DEFAULT_COMMAND_PASS = 0; + public static final boolean DEFAULT_COMMAND_KEEP_TEMPORARY = false; + public static final boolean DEFAULT_COMMAND_GURU = false; + public static final boolean DEFAULT_COMMAND_PROLOGUE_SEARCH = false; + public static final boolean DEFAULT_COMMAND_NO_CODE_ELISION = false; + public static final boolean DEFAULT_COMMAND_DISABLE_WARNINGS = false; + public static final boolean DEFAULT_COMMAND_BULK_MODE = false; + public static final boolean DEFAULT_COMMAND_TIMING_INFO = false; + public static final boolean DEFAULT_COMMAND_SKIP_BADVARS = false; + public static final boolean DEFAULT_COMMAND_IGNORE_DWARF = false; + public static final boolean DEFAULT_COMMAND_TAPSET_COVERAGE = false; + public static final String DEFAULT_BINARY_PATH = INVALID; + public static final String DEFAULT_SCRIPT_PATH = INVALID; + public static final boolean DEFAULT_COMMAND_LEAVE_RUNNING = false; + public static final String DEFAULT_COMMAND_C_DIRECTIVES = INVALID; + public static final int DEFAULT_COMMAND_BUFFER_BYTES = 0; + public static final int DEFAULT_COMMAND_TARGET_PID = 0; + public static final String DEFAULT_ARGUMENTS = INVALID; + public static final String DEFAULT_OUTPUT_PATH = INVALID; + public static final boolean DEFAULT_OVERWRITE = false; + public static final int DEFAULT_NUMBER_OF_ARGUMENTS = 0; + public static final boolean DEFAULT_BUILD_PROJECT = true; + public static final String DEFAULT_COMMAND_LIST = INVALID; + public static final String DEFAULT_BINARY_ARGUMENTS = INVALID; + + public static final String DEFAULT_GENERATED_SCRIPT = INVALID; + public static final boolean DEFAULT_NEED_TO_GENERATE = false; + public static final boolean DEFAULT_USE_COLOUR = false; - public static final String GENERATED_SCRIPT = PLUGIN_ID + ".GENERATED_SCRIPT"; //$NON-NLS-1$ - public static final String NEED_TO_GENERATE = PLUGIN_ID + ".NEED_TO_GENERATE"; //$NON-NLS-1$ - public static final String USE_COLOUR = PLUGIN_ID + ".USE_COLOUR"; //$NON-NLS-1$ - public static final String COMMAND = ".COMMAND"; //$NON-NLS-1$ - - //Defaults - public static final int DEFAULT_COMMAND_VERBOSE = 0; - public static final int DEFAULT_COMMAND_PASS = 0; - public static final boolean DEFAULT_COMMAND_KEEP_TEMPORARY = false; - public static final boolean DEFAULT_COMMAND_GURU = false; - public static final boolean DEFAULT_COMMAND_PROLOGUE_SEARCH = false; - public static final boolean DEFAULT_COMMAND_NO_CODE_ELISION = false; - public static final boolean DEFAULT_COMMAND_DISABLE_WARNINGS = false; - public static final boolean DEFAULT_COMMAND_BULK_MODE = false; - public static final boolean DEFAULT_COMMAND_TIMING_INFO = false; - public static final boolean DEFAULT_COMMAND_SKIP_BADVARS = false; - public static final boolean DEFAULT_COMMAND_IGNORE_DWARF = false; - public static final boolean DEFAULT_COMMAND_TAPSET_COVERAGE = false; - public static final String DEFAULT_BINARY_PATH = INVALID; - public static final String DEFAULT_SCRIPT_PATH = INVALID; - public static final boolean DEFAULT_COMMAND_LEAVE_RUNNING = false; - public static final String DEFAULT_COMMAND_C_DIRECTIVES = INVALID; - public static final int DEFAULT_COMMAND_BUFFER_BYTES = 0; - public static final int DEFAULT_COMMAND_TARGET_PID = 0; - public static final String DEFAULT_ARGUMENTS = INVALID; - public static final String DEFAULT_OUTPUT_PATH = INVALID; - public static final boolean DEFAULT_OVERWRITE = false; - public static final int DEFAULT_NUMBER_OF_ARGUMENTS = 0; - public static final boolean DEFAULT_BUILD_PROJECT = true; - public static final String DEFAULT_COMMAND_LIST = INVALID; - public static final String DEFAULT_BINARY_ARGUMENTS = INVALID; - - public static final String DEFAULT_GENERATED_SCRIPT = INVALID; - public static final boolean DEFAULT_NEED_TO_GENERATE = false; - public static final boolean DEFAULT_USE_COLOUR = false; - - public static final String DEFAULT_PARSER_CLASS = INVALID; - public static final String DEFAULT_VIEW_CLASS = INVALID; - public static final String DEFAULT_SECONDARY_VIEW_ID = INVALID; + public static final String DEFAULT_PARSER_CLASS = INVALID; + public static final String DEFAULT_VIEW_CLASS = INVALID; + public static final String DEFAULT_SECONDARY_VIEW_ID = INVALID; } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Messages.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Messages.java index c80d00c580..36ce1c8a5a 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Messages.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/Messages.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Red Hat - initial API and implementation *******************************************************************************/ @@ -18,19 +18,19 @@ import java.util.ResourceBundle; * */ public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.callgraph.core.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.callgraph.core.messages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); - private Messages() { - } + private Messages() { + } - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java index cb33ddad85..ccba0d3838 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/PluginConstants.java @@ -12,61 +12,61 @@ package org.eclipse.linuxtools.internal.callgraph.core; public final class PluginConstants { - private static String PLUGIN_LOCATION = ""; //$NON-NLS-1$ - public static final String CONFIGURATION_TYPE_ID = "org.eclipse.linuxtools.callgraph.launch.systemtapLaunch"; //$NON-NLS-1$ - public static final String PARSER_CLASS = "org.eclipse.linuxtools.callgraph.core.parser"; //$NON-NLS-1$ - public static final String PARSER_RESOURCE = "org.eclipse.linuxtools.callgraph.core"; //$NON-NLS-1$ - public static final String PARSER_NAME = "parser"; //$NON-NLS-1$ - public static final String VIEW_CLASS = "org.eclipse.linuxtools.callgraph.core.view"; //$NON-NLS-1$ - public static final String VIEW_RESOURCE = "org.eclipse.ui"; //$NON-NLS-1$ - public static final String VIEW_NAME = "views"; //$NON-NLS-1$ - public static final String ATTR_CLASS = "class"; //$NON-NLS-1$ - public static final String ATTR_REALTIME = "realtime"; //$NON-NLS-1$ - public static final String VAL_TRUE = "true"; //$NON-NLS-1$ + private static String PLUGIN_LOCATION = ""; //$NON-NLS-1$ + public static final String CONFIGURATION_TYPE_ID = "org.eclipse.linuxtools.callgraph.launch.systemtapLaunch"; //$NON-NLS-1$ + public static final String PARSER_CLASS = "org.eclipse.linuxtools.callgraph.core.parser"; //$NON-NLS-1$ + public static final String PARSER_RESOURCE = "org.eclipse.linuxtools.callgraph.core"; //$NON-NLS-1$ + public static final String PARSER_NAME = "parser"; //$NON-NLS-1$ + public static final String VIEW_CLASS = "org.eclipse.linuxtools.callgraph.core.view"; //$NON-NLS-1$ + public static final String VIEW_RESOURCE = "org.eclipse.ui"; //$NON-NLS-1$ + public static final String VIEW_NAME = "views"; //$NON-NLS-1$ + public static final String ATTR_CLASS = "class"; //$NON-NLS-1$ + public static final String ATTR_REALTIME = "realtime"; //$NON-NLS-1$ + public static final String VAL_TRUE = "true"; //$NON-NLS-1$ - public static final String NEW_LINE = "\n"; //$NON-NLS-1$ - public static final int MAX_ERRORS = 500; //Maximum number of errors to tolerate - public static int SYSTEMTAP_OPTIONS_TAB_HORIZONTAL_SPACING = 30; - public static String STAP_PATH = "stap"; //$NON-NLS-1$ + public static final String NEW_LINE = "\n"; //$NON-NLS-1$ + public static final int MAX_ERRORS = 500; //Maximum number of errors to tolerate + public static int SYSTEMTAP_OPTIONS_TAB_HORIZONTAL_SPACING = 30; + public static String STAP_PATH = "stap"; //$NON-NLS-1$ - public static final String DEFAULT_VIEW_ID = "org.eclipse.linuxtools.callgraph.core.staptextview"; //$NON-NLS-1$ - public static final String DEFAULT_PARSER_ID = "org.eclipse.linuxtools.callgraph.core.systemtaptextparser"; //$NON-NLS-1$ - private static String DEFAULT_OUTPUT = ""; //$NON-NLS-1$ - private static String STAP_GRAPH_DEFAULT_IO_PATH = ""; //$NON-NLS-1$ + public static final String DEFAULT_VIEW_ID = "org.eclipse.linuxtools.callgraph.core.staptextview"; //$NON-NLS-1$ + public static final String DEFAULT_PARSER_ID = "org.eclipse.linuxtools.callgraph.core.systemtaptextparser"; //$NON-NLS-1$ + private static String DEFAULT_OUTPUT = ""; //$NON-NLS-1$ + private static String STAP_GRAPH_DEFAULT_IO_PATH = ""; //$NON-NLS-1$ - /** - * Sets the absolute path of the Plugin folder and updates - * the PLUGIN_LOCATION. - * - * @param loc - */ - public static void setPluginLocation(String loc) { - PLUGIN_LOCATION = loc; - } + /** + * Sets the absolute path of the Plugin folder and updates + * the PLUGIN_LOCATION. + * + * @param loc + */ + public static void setPluginLocation(String loc) { + PLUGIN_LOCATION = loc; + } - public static String getPluginLocation() { - if (PLUGIN_LOCATION.length() < 1) { - PluginConstants.setPluginLocation(CallgraphCorePlugin.getPluginLocation()); - } + public static String getPluginLocation() { + if (PLUGIN_LOCATION.length() < 1) { + PluginConstants.setPluginLocation(CallgraphCorePlugin.getPluginLocation()); + } - return PLUGIN_LOCATION; - } + return PLUGIN_LOCATION; + } - public static String getDefaultOutput() { - if (DEFAULT_OUTPUT.length() < 1){ - DEFAULT_OUTPUT = CallgraphCorePlugin.getDefault().getStateLocation().toString()+"/"; //$NON-NLS-1$ - } + public static String getDefaultOutput() { + if (DEFAULT_OUTPUT.length() < 1){ + DEFAULT_OUTPUT = CallgraphCorePlugin.getDefault().getStateLocation().toString()+"/"; //$NON-NLS-1$ + } - return DEFAULT_OUTPUT; - } + return DEFAULT_OUTPUT; + } - public static String getDefaultIOPath() { - if (STAP_GRAPH_DEFAULT_IO_PATH.length() < 1) - { - STAP_GRAPH_DEFAULT_IO_PATH = CallgraphCorePlugin.getDefault().getStateLocation().toString()+"/callgraph.out"; //$NON-NLS-1$ - } - return STAP_GRAPH_DEFAULT_IO_PATH; - } + public static String getDefaultIOPath() { + if (STAP_GRAPH_DEFAULT_IO_PATH.length() < 1) + { + STAP_GRAPH_DEFAULT_IO_PATH = CallgraphCorePlugin.getDefault().getStateLocation().toString()+"/callgraph.out"; //$NON-NLS-1$ + } + return STAP_GRAPH_DEFAULT_IO_PATH; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/StapUIJob.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/StapUIJob.java index 9d77870403..f6afd0ebf6 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/StapUIJob.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/StapUIJob.java @@ -23,46 +23,46 @@ import org.eclipse.ui.progress.UIJob; * */ public class StapUIJob extends UIJob { - private SystemTapParser parser; - private String viewID; - private SystemTapView viewer; + private SystemTapParser parser; + private String viewID; + private SystemTapView viewer; - public StapUIJob(String name, SystemTapParser parser, String viewID) { - super(name); - // CREATE THE SHELL - this.parser = parser; - this.viewID = viewID; - } + public StapUIJob(String name, SystemTapParser parser, String viewID) { + super(name); + // CREATE THE SHELL + this.parser = parser; + this.viewID = viewID; + } - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (parser.getSecondaryID() != null && parser.getSecondaryID().length() > 0) { - viewer = ViewFactory.createView(viewID, parser.getSecondaryID()); - } else { - viewer = ViewFactory.createView(viewID); - } - if (!viewer.setParser(parser)) { - return Status.CANCEL_STATUS; - } - if (viewer.initializeView(this.getDisplay(), monitor) == Status.CANCEL_STATUS) { - return Status.CANCEL_STATUS; - } + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + if (parser.getSecondaryID() != null && parser.getSecondaryID().length() > 0) { + viewer = ViewFactory.createView(viewID, parser.getSecondaryID()); + } else { + viewer = ViewFactory.createView(viewID); + } + if (!viewer.setParser(parser)) { + return Status.CANCEL_STATUS; + } + if (viewer.initializeView(this.getDisplay(), monitor) == Status.CANCEL_STATUS) { + return Status.CANCEL_STATUS; + } - if (!parser.realTime) { - viewer.updateMethod(); - } - viewer.setSourcePath(parser.getFile()); - viewer.setKillButtonEnabled(true); + if (!parser.realTime) { + viewer.updateMethod(); + } + viewer.setSourcePath(parser.getFile()); + viewer.setKillButtonEnabled(true); - return Status.OK_STATUS; - } + return Status.OK_STATUS; + } - /** - * Returns the viewer object. Viewer is initialized within the run method, and - * is not guaranteed to be non-null until the job has terminated. - * @return - */ - public SystemTapView getViewer() { - return viewer; - } + /** + * Returns the viewer object. Viewer is initialized within the run method, and + * is not guaranteed to be non-null until the job has terminated. + * @return + */ + public SystemTapView getViewer() { + return viewer; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java index 643cd18da5..a93fb35319 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapCommandGenerator.java @@ -20,83 +20,83 @@ import java.util.ArrayList; */ public class SystemTapCommandGenerator { - private static boolean needsToSendCommand; - private static boolean needsArguments; - private static String arguments; - private static String scriptPath; - private static String flags; - private static String binaryPath = null; - private static String binaryArguments; - private static String command; - - - public static String generateCommand(String scrPath, String binPath, String opts, boolean needBinary, boolean needsArgs, String arg, String binArguments, - String cmdTarget) { - needsToSendCommand = needBinary; - needsArguments = needsArgs; - binaryPath = binPath; - scriptPath = scrPath; - arguments = "--runtime=dyninst " + arg; //$NON-NLS-1$ - flags = opts; - binaryArguments = binArguments; - command = cmdTarget; - - - String[] script = buildScript(); - - String cmd = ""; //$NON-NLS-1$ - for (int i = 0; i < script.length-1; i++) { - cmd = cmd + script[i] + " "; //$NON-NLS-1$ - } - cmd = cmd + script[script.length-1]; - - return cmd; - } - - - /** - * Parses the data created from generateCommand - * @return An array of strings to be joined and executed by the shell - */ - private static String[] buildScript() { - //TODO: Take care of this in the next release. For now only the guru mode is sent - ArrayList<String> cmdList = new ArrayList<>(); - String[] script; - - if (flags.length() > 0){ - cmdList.add(flags); - } - - //Execute a binary - if (needsToSendCommand){ - if (binaryArguments.length() < 1){ - cmdList.add("-c '" + binaryPath + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - cmdList.add("-c \"" + binaryPath + " " + binaryArguments +"\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - - - if (needsArguments) { - script = new String[cmdList.size() + 3]; - script[script.length-2] = scriptPath; - script[script.length-1] = arguments; - } else { - script = new String[cmdList.size() + 2]; - script[script.length-1] = scriptPath; - } - - script[0] = command; - - for(int i=0; i< cmdList.size(); i++) { - if (cmdList.get(i) != null) { - script[i +1] = cmdList.get(i); - } else { - script[i + 1] = ""; //$NON-NLS-1$ - } - } - return script; - - } + private static boolean needsToSendCommand; + private static boolean needsArguments; + private static String arguments; + private static String scriptPath; + private static String flags; + private static String binaryPath = null; + private static String binaryArguments; + private static String command; + + + public static String generateCommand(String scrPath, String binPath, String opts, boolean needBinary, boolean needsArgs, String arg, String binArguments, + String cmdTarget) { + needsToSendCommand = needBinary; + needsArguments = needsArgs; + binaryPath = binPath; + scriptPath = scrPath; + arguments = "--runtime=dyninst " + arg; //$NON-NLS-1$ + flags = opts; + binaryArguments = binArguments; + command = cmdTarget; + + + String[] script = buildScript(); + + String cmd = ""; //$NON-NLS-1$ + for (int i = 0; i < script.length-1; i++) { + cmd = cmd + script[i] + " "; //$NON-NLS-1$ + } + cmd = cmd + script[script.length-1]; + + return cmd; + } + + + /** + * Parses the data created from generateCommand + * @return An array of strings to be joined and executed by the shell + */ + private static String[] buildScript() { + //TODO: Take care of this in the next release. For now only the guru mode is sent + ArrayList<String> cmdList = new ArrayList<>(); + String[] script; + + if (flags.length() > 0){ + cmdList.add(flags); + } + + //Execute a binary + if (needsToSendCommand){ + if (binaryArguments.length() < 1){ + cmdList.add("-c '" + binaryPath + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + } else { + cmdList.add("-c \"" + binaryPath + " " + binaryArguments +"\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + } + + + if (needsArguments) { + script = new String[cmdList.size() + 3]; + script[script.length-2] = scriptPath; + script[script.length-1] = arguments; + } else { + script = new String[cmdList.size() + 2]; + script[script.length-1] = scriptPath; + } + + script[0] = command; + + for(int i=0; i< cmdList.size(); i++) { + if (cmdList.get(i) != null) { + script[i +1] = cmdList.get(i); + } else { + script[i + 1] = ""; //$NON-NLS-1$ + } + } + return script; + + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapErrorHandler.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapErrorHandler.java index be0cc1c0f1..d90b4ae2bf 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapErrorHandler.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapErrorHandler.java @@ -56,35 +56,35 @@ public class SystemTapErrorHandler { try (BufferedReader buff1 = new BufferedReader(new FileReader(file))) { String line; for (String message : errorsList) { - try (BufferedReader innerBuff = new BufferedReader( - new FileReader(file))) { - while ((line = innerBuff.readLine()) != null) { - if (m != null && m.isCanceled()) { - return; - } - int index = line.indexOf('='); - Pattern pat = Pattern.compile(line.substring(0, index), - Pattern.DOTALL); - Matcher matcher = pat.matcher(message); - - if (matcher.matches()) { - if (!isErrorRecognized()) { - // First error - errorMessage - .append(Messages - .getString("SystemTapErrorHandler.ErrorMessage2")); //$NON-NLS-1$ - errorRecognized = true; - } - String errorFound = line.substring(index + 1); - - if (!errorMessage.toString().contains(errorFound)) { - errorMessage.append(errorFound - + PluginConstants.NEW_LINE); - } - break; - } - } - } + try (BufferedReader innerBuff = new BufferedReader( + new FileReader(file))) { + while ((line = innerBuff.readLine()) != null) { + if (m != null && m.isCanceled()) { + return; + } + int index = line.indexOf('='); + Pattern pat = Pattern.compile(line.substring(0, index), + Pattern.DOTALL); + Matcher matcher = pat.matcher(message); + + if (matcher.matches()) { + if (!isErrorRecognized()) { + // First error + errorMessage + .append(Messages + .getString("SystemTapErrorHandler.ErrorMessage2")); //$NON-NLS-1$ + errorRecognized = true; + } + String errorFound = line.substring(index + 1); + + if (!errorMessage.toString().contains(errorFound)) { + errorMessage.append(errorFound + + PluginConstants.NEW_LINE); + } + break; + } + } + } } logContents.append(errors); @@ -148,8 +148,8 @@ public class SystemTapErrorHandler { * time. */ private void writeToLog() { - IStatus status = new Status(IStatus.ERROR,CallgraphCorePlugin.PLUGIN_ID,logContents.toString()); - CallgraphCorePlugin.getDefault().getLog().log(status); + IStatus status = new Status(IStatus.ERROR,CallgraphCorePlugin.PLUGIN_ID,logContents.toString()); + CallgraphCorePlugin.getDefault().getLog().log(status); logContents = new StringBuilder(); } @@ -166,6 +166,6 @@ public class SystemTapErrorHandler { * @return The error message string */ public String getErrorMessage(){ - return errorMessage.toString(); + return errorMessage.toString(); } }
\ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapParser.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapParser.java index 7356689d6a..e558a220a0 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapParser.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapParser.java @@ -22,309 +22,309 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; public abstract class SystemTapParser extends Job { - protected IProgressMonitor monitor; - protected String sourcePath; - protected String viewID; - protected SystemTapView view; - protected boolean realTime = false; - protected Object data; - protected Object internalData; - private String secondaryID = ""; //$NON-NLS-1$ - - public boolean done; - - public SystemTapParser() { - super("Parsing data"); //$NON-NLS-1$ - this.sourcePath = PluginConstants.getDefaultIOPath(); - this.viewID = null; - initialize(); - done = false; - - //PURELY FOR TESTING - if (monitor == null){ - monitor = new NullProgressMonitor(); - } - } - - - public SystemTapParser(String name, String filePath) { - super(name); - // BY DEFAULT READ/WRITE FROM HERE - if (filePath != null) { - this.sourcePath = filePath; - } else { - this.sourcePath = PluginConstants.getDefaultIOPath(); - } - this.viewID = null; - initialize(); - } - - - /** - * Initialize will be called in the constructors for this class. Use this - * method to initialize variables. - */ - protected abstract void initialize(); - - - /** - * Implement this method to execute parsing. The return from - * executeParsing() will be the return value of the run command. - * - * SystemTapParser will call executeParsing() within its run method. (i.e. - * will execute in a separate, non-UI thread) - * - * @return - */ - public abstract IStatus nonRealTimeParsing(); - - - /** - * Implement this method if your parser is to execute in realtime. This method - * will be called as part of a while loop in a separate Job. Use the setInternalData - * method to initialize some data object for use in realTimeParsing. The default - * setInternalMethod method will set internalData to a BufferedReader - * <br> <br> - * After the isDone flag is set to true, the realTimeParsing() method will - * be run one more time to catch any stragglers. - */ - public abstract IStatus realTimeParsing(); - - - /** - * Cleans names of form 'name").return', returning just the name - * - * @param name - */ - protected String cleanFunctionName(String name) { - return name.split("\"")[0]; //$NON-NLS-1$ - } - - /** - * Checks for quotations and brackets in the function name - * - * @param name - */ - protected boolean isFunctionNameClean(String name) { - if (name.contains("\"") || name.contains(")")) //$NON-NLS-1$ //$NON-NLS-2$ - return false; - return true; - } - - /** - * Creates a popup error dialog in a separate UI thread. Dialog title is - * 'Unexpected symbol,' name is 'ParseError' and body is the specified - * message. - * - * @param message - */ - protected void parsingError(String message) { - SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( - Messages.getString("SystemTapParser.ParseErr"), //$NON-NLS-1$ - Messages.getString("SystemTapParser.ErrSymbol"), //$NON-NLS-1$ - message); - mess.schedule(); - } - - /** - * Load the specified viewID by creating a StapUIJob. Does not return until the StapUIJob has. - * Returns true if the makeView was successful, false otherwise. - */ - private boolean makeView() { - // Create a UIJob to handle the rest - if (viewID != null && viewID.length() > 0) { - try { - StapUIJob uijob = new StapUIJob( - Messages.getString("StapGraphParser.JobName"), this, viewID); //$NON-NLS-1$ - uijob.schedule(); - uijob.join(); - view = uijob.getViewer(); - return true; - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - return false; - } - - @Override - protected IStatus run(IProgressMonitor monitor) { - // Generate real-time job - IStatus returnStatus = Status.CANCEL_STATUS; - this.monitor = monitor; - if (this.monitor == null) { - this.monitor = new NullProgressMonitor(); - } - - makeView(); - if (realTime) { - try { - setInternalData(); - while (!done){ - returnStatus = realTimeParsing(); - if (monitor.isCanceled() || returnStatus == Status.CANCEL_STATUS) { - done = true; - return Status.CANCEL_STATUS; - } - - Thread.sleep(500); - } - if (!monitor.isCanceled()) returnStatus = realTimeParsing(); - done = true; - return returnStatus; - } catch (InterruptedException e) { - SystemTapUIErrorMessages m = new SystemTapUIErrorMessages( - Messages.getString("SystemTapParser.InternalData"), //$NON-NLS-1$ - Messages.getString("SystemTapParser.FailedToSetData"), //$NON-NLS-1$ - Messages.getString("SystemTapParser.FailedToSetDataMessage")); //$NON-NLS-1$ - m.schedule(); - return Status.CANCEL_STATUS; - } catch (FileNotFoundException e) { - SystemTapUIErrorMessages m = new SystemTapUIErrorMessages( - Messages.getString("SystemTapParser.InternalData"), //$NON-NLS-1$ - Messages.getString("SystemTapParser.FailedToSetData"), //$NON-NLS-1$ - Messages.getString("SystemTapParser.FailedToSetDataMessage")); //$NON-NLS-1$ - m.schedule(); - return Status.CANCEL_STATUS; - } - } else { - returnStatus = nonRealTimeParsing(); - if (!returnStatus.isOK()){ - return returnStatus; - } - - setData(this); - return returnStatus; - } - - } - - /** - * For easier JUnit testing only. Allows public access to run method without - * scheduling an extra job. - * - * @param m - * @return - */ - public IStatus testRun(IProgressMonitor m, boolean realTime) { - try { - internalData = new BufferedReader(new FileReader(new File( - sourcePath))); - if (realTime) { - return realTimeParsing(); - } else { - return nonRealTimeParsing(); - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - return Status.CANCEL_STATUS; - } - - - /** - * @return the Data object - */ - public Object getData() { - return data; - } - - /** - * Generic method for setting the internalData object. This will be called - * by a real-time-parser immediately before its main polling loop. By default, - * this method will attempt to create a bufferedReader around File(filePath) - * @throws FileNotFoundException - */ - protected void setInternalData() throws FileNotFoundException { - File file = new File(sourcePath); - internalData = new BufferedReader(new FileReader(file)); - } - - /** - * Gets the file to read from - * - * @return - */ - public String getFile() { - return sourcePath; - } - - /** - * Sets the file to read from - * - * @param source - */ - public void setSourcePath(String source) { - this.sourcePath = source; - } - - /** - * Will terminate the parser at the next opportunity (~once every 0.5s)s - * - * @param val - */ - public void setDone(boolean val) { - done = val; - } - - public void setMonitor(IProgressMonitor m) { - this.monitor = m; - } - - /** - * Set whether or not this parser runs in real time. If viewID has already - * been set, this will also attempt to open the view. - */ - public void setRealTime(boolean val) { - realTime = val; - - } - - /** - * Set the viewID to use for this parser -- see the callgraph.core view - * extension point. If realTime is set to true, this will also attempt to - * open the view. - */ - public void setViewID(String value) { - viewID = value; - } - - /** - * Called at the end of a non-realtime run. - * Feel free to override this method if using non-realtime functions. - * The setData method will be called after executeParsing() is run. - * The getData() method will be used by the SystemTapView to get the - * data associated with this parser. - * <br><br> - * Alternatively, you can cast the parser within SystemTapView to your - * own parser class and access its data structures that way. - */ - public void setData(Object obj) { - data = obj; - } - - /** - * Sends a message to cancel the job. Job may not terminate immediately. - */ - public void cancelJob() { - done = true; - } - - public boolean isDone() { - return done; - } - - public void setKillButtonEnabled(boolean val) { - if (view != null) { - view.setKillButtonEnabled(val); - } - } - - public void setSecondaryID(String secondaryID) { - this.secondaryID = secondaryID; - } - - public String getSecondaryID() { - return secondaryID; - } + protected IProgressMonitor monitor; + protected String sourcePath; + protected String viewID; + protected SystemTapView view; + protected boolean realTime = false; + protected Object data; + protected Object internalData; + private String secondaryID = ""; //$NON-NLS-1$ + + public boolean done; + + public SystemTapParser() { + super("Parsing data"); //$NON-NLS-1$ + this.sourcePath = PluginConstants.getDefaultIOPath(); + this.viewID = null; + initialize(); + done = false; + + //PURELY FOR TESTING + if (monitor == null){ + monitor = new NullProgressMonitor(); + } + } + + + public SystemTapParser(String name, String filePath) { + super(name); + // BY DEFAULT READ/WRITE FROM HERE + if (filePath != null) { + this.sourcePath = filePath; + } else { + this.sourcePath = PluginConstants.getDefaultIOPath(); + } + this.viewID = null; + initialize(); + } + + + /** + * Initialize will be called in the constructors for this class. Use this + * method to initialize variables. + */ + protected abstract void initialize(); + + + /** + * Implement this method to execute parsing. The return from + * executeParsing() will be the return value of the run command. + * + * SystemTapParser will call executeParsing() within its run method. (i.e. + * will execute in a separate, non-UI thread) + * + * @return + */ + public abstract IStatus nonRealTimeParsing(); + + + /** + * Implement this method if your parser is to execute in realtime. This method + * will be called as part of a while loop in a separate Job. Use the setInternalData + * method to initialize some data object for use in realTimeParsing. The default + * setInternalMethod method will set internalData to a BufferedReader + * <br> <br> + * After the isDone flag is set to true, the realTimeParsing() method will + * be run one more time to catch any stragglers. + */ + public abstract IStatus realTimeParsing(); + + + /** + * Cleans names of form 'name").return', returning just the name + * + * @param name + */ + protected String cleanFunctionName(String name) { + return name.split("\"")[0]; //$NON-NLS-1$ + } + + /** + * Checks for quotations and brackets in the function name + * + * @param name + */ + protected boolean isFunctionNameClean(String name) { + if (name.contains("\"") || name.contains(")")) //$NON-NLS-1$ //$NON-NLS-2$ + return false; + return true; + } + + /** + * Creates a popup error dialog in a separate UI thread. Dialog title is + * 'Unexpected symbol,' name is 'ParseError' and body is the specified + * message. + * + * @param message + */ + protected void parsingError(String message) { + SystemTapUIErrorMessages mess = new SystemTapUIErrorMessages( + Messages.getString("SystemTapParser.ParseErr"), //$NON-NLS-1$ + Messages.getString("SystemTapParser.ErrSymbol"), //$NON-NLS-1$ + message); + mess.schedule(); + } + + /** + * Load the specified viewID by creating a StapUIJob. Does not return until the StapUIJob has. + * Returns true if the makeView was successful, false otherwise. + */ + private boolean makeView() { + // Create a UIJob to handle the rest + if (viewID != null && viewID.length() > 0) { + try { + StapUIJob uijob = new StapUIJob( + Messages.getString("StapGraphParser.JobName"), this, viewID); //$NON-NLS-1$ + uijob.schedule(); + uijob.join(); + view = uijob.getViewer(); + return true; + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + return false; + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + // Generate real-time job + IStatus returnStatus = Status.CANCEL_STATUS; + this.monitor = monitor; + if (this.monitor == null) { + this.monitor = new NullProgressMonitor(); + } + + makeView(); + if (realTime) { + try { + setInternalData(); + while (!done){ + returnStatus = realTimeParsing(); + if (monitor.isCanceled() || returnStatus == Status.CANCEL_STATUS) { + done = true; + return Status.CANCEL_STATUS; + } + + Thread.sleep(500); + } + if (!monitor.isCanceled()) returnStatus = realTimeParsing(); + done = true; + return returnStatus; + } catch (InterruptedException e) { + SystemTapUIErrorMessages m = new SystemTapUIErrorMessages( + Messages.getString("SystemTapParser.InternalData"), //$NON-NLS-1$ + Messages.getString("SystemTapParser.FailedToSetData"), //$NON-NLS-1$ + Messages.getString("SystemTapParser.FailedToSetDataMessage")); //$NON-NLS-1$ + m.schedule(); + return Status.CANCEL_STATUS; + } catch (FileNotFoundException e) { + SystemTapUIErrorMessages m = new SystemTapUIErrorMessages( + Messages.getString("SystemTapParser.InternalData"), //$NON-NLS-1$ + Messages.getString("SystemTapParser.FailedToSetData"), //$NON-NLS-1$ + Messages.getString("SystemTapParser.FailedToSetDataMessage")); //$NON-NLS-1$ + m.schedule(); + return Status.CANCEL_STATUS; + } + } else { + returnStatus = nonRealTimeParsing(); + if (!returnStatus.isOK()){ + return returnStatus; + } + + setData(this); + return returnStatus; + } + + } + + /** + * For easier JUnit testing only. Allows public access to run method without + * scheduling an extra job. + * + * @param m + * @return + */ + public IStatus testRun(IProgressMonitor m, boolean realTime) { + try { + internalData = new BufferedReader(new FileReader(new File( + sourcePath))); + if (realTime) { + return realTimeParsing(); + } else { + return nonRealTimeParsing(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + return Status.CANCEL_STATUS; + } + + + /** + * @return the Data object + */ + public Object getData() { + return data; + } + + /** + * Generic method for setting the internalData object. This will be called + * by a real-time-parser immediately before its main polling loop. By default, + * this method will attempt to create a bufferedReader around File(filePath) + * @throws FileNotFoundException + */ + protected void setInternalData() throws FileNotFoundException { + File file = new File(sourcePath); + internalData = new BufferedReader(new FileReader(file)); + } + + /** + * Gets the file to read from + * + * @return + */ + public String getFile() { + return sourcePath; + } + + /** + * Sets the file to read from + * + * @param source + */ + public void setSourcePath(String source) { + this.sourcePath = source; + } + + /** + * Will terminate the parser at the next opportunity (~once every 0.5s)s + * + * @param val + */ + public void setDone(boolean val) { + done = val; + } + + public void setMonitor(IProgressMonitor m) { + this.monitor = m; + } + + /** + * Set whether or not this parser runs in real time. If viewID has already + * been set, this will also attempt to open the view. + */ + public void setRealTime(boolean val) { + realTime = val; + + } + + /** + * Set the viewID to use for this parser -- see the callgraph.core view + * extension point. If realTime is set to true, this will also attempt to + * open the view. + */ + public void setViewID(String value) { + viewID = value; + } + + /** + * Called at the end of a non-realtime run. + * Feel free to override this method if using non-realtime functions. + * The setData method will be called after executeParsing() is run. + * The getData() method will be used by the SystemTapView to get the + * data associated with this parser. + * <br><br> + * Alternatively, you can cast the parser within SystemTapView to your + * own parser class and access its data structures that way. + */ + public void setData(Object obj) { + data = obj; + } + + /** + * Sends a message to cancel the job. Job may not terminate immediately. + */ + public void cancelJob() { + done = true; + } + + public boolean isDone() { + return done; + } + + public void setKillButtonEnabled(boolean val) { + if (view != null) { + view.setKillButtonEnabled(val); + } + } + + public void setSecondaryID(String secondaryID) { + this.secondaryID = secondaryID; + } + + public String getSecondaryID() { + return secondaryID; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextParser.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextParser.java index c658ee2f70..14ee480726 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextParser.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextParser.java @@ -18,47 +18,47 @@ import org.eclipse.core.runtime.Status; public class SystemTapTextParser extends SystemTapParser{ - protected String contents; + protected String contents; - @Override - public IStatus nonRealTimeParsing() { - contents = Helper.readFile(sourcePath); - System.out.println(contents); - return Status.OK_STATUS; - } + @Override + public IStatus nonRealTimeParsing() { + contents = Helper.readFile(sourcePath); + System.out.println(contents); + return Status.OK_STATUS; + } - @Override - protected void initialize() { - // Empty - } + @Override + protected void initialize() { + // Empty + } - @Override - public IStatus realTimeParsing() { - if (!(internalData instanceof BufferedReader)) { - return Status.CANCEL_STATUS; - } + @Override + public IStatus realTimeParsing() { + if (!(internalData instanceof BufferedReader)) { + return Status.CANCEL_STATUS; + } - BufferedReader buff = (BufferedReader) internalData; - StringBuffer text = new StringBuffer(); + BufferedReader buff = (BufferedReader) internalData; + StringBuffer text = new StringBuffer(); - String line; - try { - while ((line = buff.readLine()) != null) { - if (monitor.isCanceled()) { - return Status.CANCEL_STATUS; - } - text.append(line + "\n"); //$NON-NLS-1$ - } - setData(text.toString()); - if (text.length() > 0) { - System.out.println(text.toString()); - } - view.update(); - } catch (IOException|InterruptedException e) { - e.printStackTrace(); - } + String line; + try { + while ((line = buff.readLine()) != null) { + if (monitor.isCanceled()) { + return Status.CANCEL_STATUS; + } + text.append(line + "\n"); //$NON-NLS-1$ + } + setData(text.toString()); + if (text.length() > 0) { + System.out.println(text.toString()); + } + view.update(); + } catch (IOException|InterruptedException e) { + e.printStackTrace(); + } - return Status.OK_STATUS; - } + return Status.OK_STATUS; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextView.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextView.java index 493cc5e707..b646b14162 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextView.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapTextView.java @@ -26,209 +26,209 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; public class SystemTapTextView extends SystemTapView { - private StyledText viewer; - - private Display display; - private int previousEnd; - - - /** - * Passing the focus request to the viewer's control. - */ - @Override - public void setFocus() { - if (viewer != null && !viewer.isDisposed()) { - viewer.setFocus(); - } - } - - private void createViewer(Composite parent) { - viewer = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI - | SWT.V_SCROLL | SWT.WRAP); - - viewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - Font font = new Font(parent.getDisplay(), "Monospace", 11, SWT.NORMAL); //$NON-NLS-1$ - viewer.setFont(font); - masterComposite = parent; - display = masterComposite.getDisplay(); - } - - /** - * Print with colour codes. Colour codes accepted in the form of ~(R,G,B)~, - * and apply for the rest of the line or until another code is encountered - * @param text - */ - private void prettyPrintln(String text) { - List<StyleRange> styles = new ArrayList<>(); - String[] txt = text.split("\\n"); //$NON-NLS-1$ - int lineOffset = 0; - int inLineOffset; - - // txt[] contains text, with one entry for each new line - for (String line: txt) { - - // Skip blank strings - if (line.isEmpty()) { - viewer.append(PluginConstants.NEW_LINE); - continue; - } - - // Search for colour codes, if none exist then continue - String[] split_txt = line.split("~\\("); //$NON-NLS-1$ - if (split_txt.length == 1) { - viewer.append(split_txt[0]); - viewer.append(PluginConstants.NEW_LINE); - continue; - } - - inLineOffset = 0; - for (String split: split_txt) { - // Skip blank substrings - if (split.isEmpty()) { - continue; - } - - // Split for the number codes - String[] coloursAndText = split.split("\\)~"); //$NON-NLS-1$ - - // If the string is properly formatted, colours should be length - // 2 - // If it is not properly formatted, don't colour (just print) - if (coloursAndText.length != 2) { - for (String colourAndText: coloursAndText) { - viewer.append(colourAndText); - inLineOffset += colourAndText.length(); - } - continue; - } - - // The first element in the array should contain the colours - String[] colours = coloursAndText[0].split(","); //$NON-NLS-1$ - if (colours.length < 3) { - continue; - } - - // The second element in the array should contain the text - viewer.append(coloursAndText[1]); - - // Create a colour based on the 3 integers (if there are any - // more integers, just ignore) - int R = new Integer(colours[0].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ - int G = new Integer(colours[1].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ - int B = new Integer(colours[2].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ - - if (R > 255) R = 255; - if (G > 255) G = 255; - if (B > 255) B = 255; - - if (R < 0) R = 0; - if (G < 0) G = 0; - if (B < 0) B = 0; - - Color newColor = new Color(display, R, G, B); - - // Find the offset of the current line - lineOffset = viewer.getOffsetAtLine(viewer.getLineCount() - 1); - - // Create a new style that lasts no further than the length of - // the line - StyleRange newStyle = new StyleRange(lineOffset + inLineOffset, - coloursAndText[1].length(), newColor, null); - styles.add(newStyle); - - inLineOffset += coloursAndText[1].length(); - } - - viewer.append(PluginConstants.NEW_LINE); - } - - // Create a new style range - StyleRange[] s = new StyleRange[styles.size()]; - styles.toArray(s); - - int cnt = viewer.getCharCount(); - - // Using replaceStyleRanges with previousEnd, etc, effectively adds - // the StyleRange to the existing set of Style Ranges (so we don't - // waste time fudging with old style ranges that haven't changed) - viewer.replaceStyleRanges(previousEnd, cnt - previousEnd, s); - previousEnd = cnt; - - // Change focus and update - viewer.setTopIndex(viewer.getLineCount() - 1); - viewer.update(); - } - - /** - * Default print, just dumps text into the viewer. - * @param text - */ - public void println(String text) { - if (viewer != null && !viewer.isDisposed()) { - viewer.append(text); - viewer.setTopIndex(viewer.getLineCount() - 1); - viewer.update(); - } - } - - public void clearAll() { - if (viewer != null && !viewer.isDisposed()) { - previousEnd = 0; - viewer.setText(""); //$NON-NLS-1$ - viewer.update(); - } - } - - /** - * Testing convenience method to see what was printed - * - * @return viewer text - */ - public String getText() { - return viewer.getText(); - } - - - @Override - public IStatus initializeView(Display targetDisplay, IProgressMonitor monitor) { - previousEnd = 0; - viewer.setText(""); //$NON-NLS-1$ - viewer.update(); - return Status.OK_STATUS; - } - - @Override - public void createPartControl(Composite parent) { - createViewer(parent); - - addKillButton(); - addFileMenu(); - addHelpMenu(); - ViewFactory.addView(this); - } - - @Override - public void updateMethod() { - if (getParser().getData() instanceof String) { - String data = (String) getParser().getData(); - if (data.length() > 0) { - prettyPrintln((String) getParser().getData()); - } - } - } - - @Override - public void setViewID() { - viewID = "org.eclipse.linuxtools.callgraph.core.staptextview"; //$NON-NLS-1$ - } - - @Override - protected boolean createOpenAction() { - return false; - } - - @Override - protected boolean createOpenDefaultAction() { - return false; - } + private StyledText viewer; + + private Display display; + private int previousEnd; + + + /** + * Passing the focus request to the viewer's control. + */ + @Override + public void setFocus() { + if (viewer != null && !viewer.isDisposed()) { + viewer.setFocus(); + } + } + + private void createViewer(Composite parent) { + viewer = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI + | SWT.V_SCROLL | SWT.WRAP); + + viewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + Font font = new Font(parent.getDisplay(), "Monospace", 11, SWT.NORMAL); //$NON-NLS-1$ + viewer.setFont(font); + masterComposite = parent; + display = masterComposite.getDisplay(); + } + + /** + * Print with colour codes. Colour codes accepted in the form of ~(R,G,B)~, + * and apply for the rest of the line or until another code is encountered + * @param text + */ + private void prettyPrintln(String text) { + List<StyleRange> styles = new ArrayList<>(); + String[] txt = text.split("\\n"); //$NON-NLS-1$ + int lineOffset = 0; + int inLineOffset; + + // txt[] contains text, with one entry for each new line + for (String line: txt) { + + // Skip blank strings + if (line.isEmpty()) { + viewer.append(PluginConstants.NEW_LINE); + continue; + } + + // Search for colour codes, if none exist then continue + String[] split_txt = line.split("~\\("); //$NON-NLS-1$ + if (split_txt.length == 1) { + viewer.append(split_txt[0]); + viewer.append(PluginConstants.NEW_LINE); + continue; + } + + inLineOffset = 0; + for (String split: split_txt) { + // Skip blank substrings + if (split.isEmpty()) { + continue; + } + + // Split for the number codes + String[] coloursAndText = split.split("\\)~"); //$NON-NLS-1$ + + // If the string is properly formatted, colours should be length + // 2 + // If it is not properly formatted, don't colour (just print) + if (coloursAndText.length != 2) { + for (String colourAndText: coloursAndText) { + viewer.append(colourAndText); + inLineOffset += colourAndText.length(); + } + continue; + } + + // The first element in the array should contain the colours + String[] colours = coloursAndText[0].split(","); //$NON-NLS-1$ + if (colours.length < 3) { + continue; + } + + // The second element in the array should contain the text + viewer.append(coloursAndText[1]); + + // Create a colour based on the 3 integers (if there are any + // more integers, just ignore) + int R = new Integer(colours[0].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ + int G = new Integer(colours[1].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ + int B = new Integer(colours[2].replaceAll(" ", "")).intValue(); //$NON-NLS-1$ //$NON-NLS-2$ + + if (R > 255) R = 255; + if (G > 255) G = 255; + if (B > 255) B = 255; + + if (R < 0) R = 0; + if (G < 0) G = 0; + if (B < 0) B = 0; + + Color newColor = new Color(display, R, G, B); + + // Find the offset of the current line + lineOffset = viewer.getOffsetAtLine(viewer.getLineCount() - 1); + + // Create a new style that lasts no further than the length of + // the line + StyleRange newStyle = new StyleRange(lineOffset + inLineOffset, + coloursAndText[1].length(), newColor, null); + styles.add(newStyle); + + inLineOffset += coloursAndText[1].length(); + } + + viewer.append(PluginConstants.NEW_LINE); + } + + // Create a new style range + StyleRange[] s = new StyleRange[styles.size()]; + styles.toArray(s); + + int cnt = viewer.getCharCount(); + + // Using replaceStyleRanges with previousEnd, etc, effectively adds + // the StyleRange to the existing set of Style Ranges (so we don't + // waste time fudging with old style ranges that haven't changed) + viewer.replaceStyleRanges(previousEnd, cnt - previousEnd, s); + previousEnd = cnt; + + // Change focus and update + viewer.setTopIndex(viewer.getLineCount() - 1); + viewer.update(); + } + + /** + * Default print, just dumps text into the viewer. + * @param text + */ + public void println(String text) { + if (viewer != null && !viewer.isDisposed()) { + viewer.append(text); + viewer.setTopIndex(viewer.getLineCount() - 1); + viewer.update(); + } + } + + public void clearAll() { + if (viewer != null && !viewer.isDisposed()) { + previousEnd = 0; + viewer.setText(""); //$NON-NLS-1$ + viewer.update(); + } + } + + /** + * Testing convenience method to see what was printed + * + * @return viewer text + */ + public String getText() { + return viewer.getText(); + } + + + @Override + public IStatus initializeView(Display targetDisplay, IProgressMonitor monitor) { + previousEnd = 0; + viewer.setText(""); //$NON-NLS-1$ + viewer.update(); + return Status.OK_STATUS; + } + + @Override + public void createPartControl(Composite parent) { + createViewer(parent); + + addKillButton(); + addFileMenu(); + addHelpMenu(); + ViewFactory.addView(this); + } + + @Override + public void updateMethod() { + if (getParser().getData() instanceof String) { + String data = (String) getParser().getData(); + if (data.length() > 0) { + prettyPrintln((String) getParser().getData()); + } + } + } + + @Override + public void setViewID() { + viewID = "org.eclipse.linuxtools.callgraph.core.staptextview"; //$NON-NLS-1$ + } + + @Override + protected boolean createOpenAction() { + return false; + } + + @Override + protected boolean createOpenDefaultAction() { + return false; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapUIErrorMessages.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapUIErrorMessages.java index c7ec1b3bf6..ead7506ca6 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapUIErrorMessages.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapUIErrorMessages.java @@ -24,35 +24,35 @@ import org.eclipse.ui.progress.UIJob; * */ public class SystemTapUIErrorMessages extends UIJob { - private String title, message; - private static boolean active = true; + private String title, message; + private static boolean active = true; - public SystemTapUIErrorMessages(String name, String title, String message) { - super(name); - this.title = title; - this.message = message; - } + public SystemTapUIErrorMessages(String name, String title, String message) { + super(name); + this.title = title; + this.message = message; + } - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (!active) { - return Status.CANCEL_STATUS; - } - //Test that this job is running in the UI thread - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + if (!active) { + return Status.CANCEL_STATUS; + } + //Test that this job is running in the UI thread + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - return Status.CANCEL_STATUS; //Something is wrong! - } + if (window == null) { + return Status.CANCEL_STATUS; //Something is wrong! + } - Shell sh = new Shell(); + Shell sh = new Shell(); - MessageDialog.openError(sh, title, message); - return Status.OK_STATUS; - } + MessageDialog.openError(sh, title, message); + return Status.OK_STATUS; + } - public static void setActive(boolean val) { - active = val; - } + public static void setActive(boolean val) { + active = val; + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java index fd74e61757..5294858310 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapView.java @@ -140,7 +140,7 @@ public abstract class SystemTapView extends ViewPart { * @return */ public SystemTapParser getParser() { - return parser; + return parser; } /** @@ -152,11 +152,11 @@ public abstract class SystemTapView extends ViewPart { * @return */ public boolean setParser(SystemTapParser parser) { - this.parser = parser; - if (this.parser == null) { - return false; + this.parser = parser; + if (this.parser == null) { + return false; } - return true; + return true; } /** @@ -231,9 +231,9 @@ public abstract class SystemTapView extends ViewPart { private void createHelpActions() { helpVersion = new Action(Messages.getString("SystemTapView.Version")) { //$NON-NLS-1$ @Override - public void run() { + public void run() { try { - Process pr = RuntimeProcessFactory.getFactory().exec("stap -V", null); //$NON-NLS-1$ + Process pr = RuntimeProcessFactory.getFactory().exec("stap -V", null); //$NON-NLS-1$ BufferedReader buf = new BufferedReader( new InputStreamReader(pr.getErrorStream())); String line = ""; //$NON-NLS-1$ @@ -265,7 +265,7 @@ public abstract class SystemTapView extends ViewPart { //Save callgraph.out saveFile = new Action(Messages.getString("SystemTapView.SaveMenu")){ //$NON-NLS-1$ @Override - public void run(){ + public void run(){ Shell sh = new Shell(); FileDialog dialog = new FileDialog(sh, SWT.SAVE); String filePath = dialog.open(); @@ -283,7 +283,7 @@ public abstract class SystemTapView extends ViewPart { kill = new Action(Messages.getString("SystemTapView.StopScript"), //$NON-NLS-1$ AbstractUIPlugin.imageDescriptorFromPlugin(CallgraphCorePlugin.PLUGIN_ID, "icons/progress_stop.gif")) { //$NON-NLS-1$ @Override - public void run() { + public void run() { getParser().cancelJob(); } }; @@ -306,33 +306,33 @@ public abstract class SystemTapView extends ViewPart { * @param sourcePath */ public void saveData(String targetFile) { - try { - File file = new File(targetFile); - file.delete(); - file.createNewFile(); - - File sFile = new File(sourcePath); - if (!sFile.exists()) { - return; - } - - try (FileInputStream fileIn = new FileInputStream(sFile); FileOutputStream fileOut = new FileOutputStream(file); - FileChannel channelIn = fileIn.getChannel(); FileChannel channelOut = fileOut.getChannel()){ - - if (channelIn == null || channelOut == null) { - return; - } - - long size = channelIn.size(); - MappedByteBuffer buf = channelIn.map( - FileChannel.MapMode.READ_ONLY, 0, size); - - channelOut.write(buf); - } - } catch (IOException e) { - CallgraphCorePlugin.logException(e); - } - } + try { + File file = new File(targetFile); + file.delete(); + file.createNewFile(); + + File sFile = new File(sourcePath); + if (!sFile.exists()) { + return; + } + + try (FileInputStream fileIn = new FileInputStream(sFile); FileOutputStream fileOut = new FileOutputStream(file); + FileChannel channelIn = fileIn.getChannel(); FileChannel channelOut = fileOut.getChannel()){ + + if (channelIn == null || channelOut == null) { + return; + } + + long size = channelIn.size(); + MappedByteBuffer buf = channelIn.map( + FileChannel.MapMode.READ_ONLY, 0, size); + + channelOut.write(buf); + } + } catch (IOException e) { + CallgraphCorePlugin.logException(e); + } + } public void setSourcePath(String file) { sourcePath = file; diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/ViewFactory.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/ViewFactory.java index 265e98243e..ca31107d83 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/ViewFactory.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/ViewFactory.java @@ -25,75 +25,75 @@ import org.eclipse.ui.PlatformUI; */ public class ViewFactory { - private static List<IViewPart> views; - private static SystemTapView newView; + private static List<IViewPart> views; + private static SystemTapView newView; - /** - * Create a view of type designated by the viewID argument - * @param viewID : A string corresponding to a type of View - * @return : The view object that corresponds to the viewID - */ - public static SystemTapView createView(final String viewID) { - Display.getDefault().syncExec(new Runnable() { + /** + * Create a view of type designated by the viewID argument + * @param viewID : A string corresponding to a type of View + * @return : The view object that corresponds to the viewID + */ + public static SystemTapView createView(final String viewID) { + Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - try { - IViewPart view = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(). - showView(viewID); - if (!(view instanceof SystemTapView)) { - return; - } + @Override + public void run() { + try { + IViewPart view = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(). + showView(viewID); + if (!(view instanceof SystemTapView)) { + return; + } - newView = ((SystemTapView) view); - newView.setViewID(); - } catch (PartInitException e) { - e.printStackTrace(); - } - } - }); + newView = ((SystemTapView) view); + newView.setViewID(); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + }); - addView(newView); - return newView; - } + addView(newView); + return newView; + } - /** - * Create a view of type designated by the viewID argument - * @param viewID : A string corresponding to a type of View - * @return : The view object that corresponds to the viewID - */ - public static SystemTapView createView(final String viewID, final String secondaryID) { - Display.getDefault().syncExec(new Runnable() { + /** + * Create a view of type designated by the viewID argument + * @param viewID : A string corresponding to a type of View + * @return : The view object that corresponds to the viewID + */ + public static SystemTapView createView(final String viewID, final String secondaryID) { + Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - try { - IViewPart view = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage().showView(viewID, secondaryID, IWorkbenchPage.VIEW_VISIBLE); - if (!(view instanceof SystemTapView)) { - return; - } - newView = ((SystemTapView) view); - newView.setViewID(); - } catch (PartInitException e) { - e.printStackTrace(); - } - } - }); + @Override + public void run() { + try { + IViewPart view = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage().showView(viewID, secondaryID, IWorkbenchPage.VIEW_VISIBLE); + if (!(view instanceof SystemTapView)) { + return; + } + newView = ((SystemTapView) view); + newView.setViewID(); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + }); - addView(newView); - return newView; - } + addView(newView); + return newView; + } - /** - * Adds a view to the factory's list of active SystemTapViews. - */ - public static void addView(SystemTapView view) { - if (views == null) { - views = new ArrayList<>(); - } - views.add(view); - } + /** + * Adds a view to the factory's list of active SystemTapViews. + */ + public static void addView(SystemTapView view) { + if (views == null) { + views = new ArrayList<>(); + } + views.add(view); + } } diff --git a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/XMLParser.java b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/XMLParser.java index 70d78cf9ad..8f39292c15 100644 --- a/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/XMLParser.java +++ b/systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/XMLParser.java @@ -21,168 +21,168 @@ import java.util.Map; public class XMLParser { - private Map<Integer, HashMap<String,String>> keyValues; - private List<Integer> idList; - private int id; - private int currentlyIn; - private static final String ATTR_NAME = "name"; //$NON-NLS-1$ - private static final String ATTR_TEXT = "text"; //$NON-NLS-1$ - private static final String noName = "NoName"; //$NON-NLS-1$ - private boolean textMode; - XMLParser() { - id = 0; - currentlyIn = 0; - if (keyValues != null) { - keyValues.clear(); - } - keyValues = new HashMap<>(); - - if (idList != null) { - idList.clear(); - } - idList = new ArrayList<>(); - - textMode = false; - } - - /** - * Helper method to call parse on the contents of a file. - * @param file - */ - public void parse(File file) { - parse(getContents(file)); - } - - - /** - * Parses a String according to XML formatting rules. Will return a HashMap indexed by an - * identification number, where each value is a further HashMap of String, String pairs representing - * attributes. - * @param message - */ - public void parse(String message) { - String tabstrip = message.replaceAll("\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ - String[] lines = tabstrip.split("\n"); //$NON-NLS-1$ - - for (String line : lines) { - if (line.length() < 1) { - continue; - } - - if (line.charAt(0) == '<') { - //Either an open or close tag - if (line.charAt(1) == '/') { - //Closing tag -- assume properly formed - idList.remove((Integer) currentlyIn); - currentlyIn = -1; - if (idList.size() > 0) { - currentlyIn = idList.get(idList.size()-1); - } - setTextMode(true); - - } else if (line.substring(line.length()-2, line.length() - 1).equals("/>")) { //$NON-NLS-1$ - //This tag opens and closes in one line - id++; - String[] tokens = line.split(" "); //$NON-NLS-1$ - HashMap<String,String> map = new HashMap<>(); - map.put(ATTR_NAME, tokens[0]); - keyValues.put(id,map); - textMode = false; - addAttributes(currentlyIn, tokens, 1); - - } else { - //Open tag - idList.add(id); - id++; - currentlyIn = id; - - String[] tokens = line.split(" "); //$NON-NLS-1$ - - //Add name variable - HashMap<String,String> map = new HashMap<>(); - map.put(ATTR_NAME, tokens[0]); - keyValues.put(id,map); - - addAttributes(currentlyIn, tokens, 1); - } - } else { - //Attribute addition - if (currentlyIn < 0 ) { - continue; - } - - if (textMode) { - HashMap<String,String> map = keyValues.get(currentlyIn); - map.put(ATTR_TEXT, line); - } - - String[] tokens = line.split(" "); //$NON-NLS-1$ - addAttributes(currentlyIn, tokens, 0); - } - } - } - - /** - * Turns an array of Strings of form attribute=value into attribute/value pairings for the specified node. - * Starts looking at token number start. - * @param tokens - * @param start - */ - private void addAttributes(int id, String[] tokens, int start) { - HashMap<String,String> map = keyValues.get(id); - int nameless = 0; - - - for (int j = start; j < tokens.length; j++) { - String[] kvPair = tokens[j].split("="); //$NON-NLS-1$ - String value = ""; //$NON-NLS-1$ - String key = ""; //$NON-NLS-1$ - if (kvPair.length < 1) { - continue; - } - - if (kvPair.length < 2) { - value = kvPair[0]; - if (value.charAt(value.length() - 1) == '>') { - - setTextMode(true); - value = value.substring(0, value.length()-1); - } - map.put(noName + nameless, value); - nameless++; - continue; - } - - value = kvPair[0]; - key = kvPair[1]; - if (value.charAt(value.length() - 1) == '>') { - setTextMode(true); - value = value.substring(0, value.length()-1); - } - - map.put(key, value); - } - - keyValues.put(id, map); - } - - private static String getContents(File file) { - StringBuilder contents = new StringBuilder(); - - try (BufferedReader input = new BufferedReader(new FileReader(file))) { - String line = null; - while ((line = input.readLine()) != null) { - contents.append(line); - contents.append("\n"); //$NON-NLS-1$ - } - } catch (IOException ex) { - ex.printStackTrace(); - } - - return contents.toString(); - } - - private void setTextMode(boolean val) { - textMode = val; - } + private Map<Integer, HashMap<String,String>> keyValues; + private List<Integer> idList; + private int id; + private int currentlyIn; + private static final String ATTR_NAME = "name"; //$NON-NLS-1$ + private static final String ATTR_TEXT = "text"; //$NON-NLS-1$ + private static final String noName = "NoName"; //$NON-NLS-1$ + private boolean textMode; + XMLParser() { + id = 0; + currentlyIn = 0; + if (keyValues != null) { + keyValues.clear(); + } + keyValues = new HashMap<>(); + + if (idList != null) { + idList.clear(); + } + idList = new ArrayList<>(); + + textMode = false; + } + + /** + * Helper method to call parse on the contents of a file. + * @param file + */ + public void parse(File file) { + parse(getContents(file)); + } + + + /** + * Parses a String according to XML formatting rules. Will return a HashMap indexed by an + * identification number, where each value is a further HashMap of String, String pairs representing + * attributes. + * @param message + */ + public void parse(String message) { + String tabstrip = message.replaceAll("\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ + String[] lines = tabstrip.split("\n"); //$NON-NLS-1$ + + for (String line : lines) { + if (line.length() < 1) { + continue; + } + + if (line.charAt(0) == '<') { + //Either an open or close tag + if (line.charAt(1) == '/') { + //Closing tag -- assume properly formed + idList.remove((Integer) currentlyIn); + currentlyIn = -1; + if (idList.size() > 0) { + currentlyIn = idList.get(idList.size()-1); + } + setTextMode(true); + + } else if (line.substring(line.length()-2, line.length() - 1).equals("/>")) { //$NON-NLS-1$ + //This tag opens and closes in one line + id++; + String[] tokens = line.split(" "); //$NON-NLS-1$ + HashMap<String,String> map = new HashMap<>(); + map.put(ATTR_NAME, tokens[0]); + keyValues.put(id,map); + textMode = false; + addAttributes(currentlyIn, tokens, 1); + + } else { + //Open tag + idList.add(id); + id++; + currentlyIn = id; + + String[] tokens = line.split(" "); //$NON-NLS-1$ + + //Add name variable + HashMap<String,String> map = new HashMap<>(); + map.put(ATTR_NAME, tokens[0]); + keyValues.put(id,map); + + addAttributes(currentlyIn, tokens, 1); + } + } else { + //Attribute addition + if (currentlyIn < 0 ) { + continue; + } + + if (textMode) { + HashMap<String,String> map = keyValues.get(currentlyIn); + map.put(ATTR_TEXT, line); + } + + String[] tokens = line.split(" "); //$NON-NLS-1$ + addAttributes(currentlyIn, tokens, 0); + } + } + } + + /** + * Turns an array of Strings of form attribute=value into attribute/value pairings for the specified node. + * Starts looking at token number start. + * @param tokens + * @param start + */ + private void addAttributes(int id, String[] tokens, int start) { + HashMap<String,String> map = keyValues.get(id); + int nameless = 0; + + + for (int j = start; j < tokens.length; j++) { + String[] kvPair = tokens[j].split("="); //$NON-NLS-1$ + String value = ""; //$NON-NLS-1$ + String key = ""; //$NON-NLS-1$ + if (kvPair.length < 1) { + continue; + } + + if (kvPair.length < 2) { + value = kvPair[0]; + if (value.charAt(value.length() - 1) == '>') { + + setTextMode(true); + value = value.substring(0, value.length()-1); + } + map.put(noName + nameless, value); + nameless++; + continue; + } + + value = kvPair[0]; + key = kvPair[1]; + if (value.charAt(value.length() - 1) == '>') { + setTextMode(true); + value = value.substring(0, value.length()-1); + } + + map.put(key, value); + } + + keyValues.put(id, map); + } + + private static String getContents(File file) { + StringBuilder contents = new StringBuilder(); + + try (BufferedReader input = new BufferedReader(new FileReader(file))) { + String line = null; + while ((line = input.readLine()) != null) { + contents.append(line); + contents.append("\n"); //$NON-NLS-1$ + } + } catch (IOException ex) { + ex.printStackTrace(); + } + + return contents.toString(); + } + + private void setTextMode(boolean val) { + textMode = val; + } } |