Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2015-01-17 01:23:49 +0000
committerAlexander Kurtakov2015-01-22 06:55:45 +0000
commitaa10e5b5fa62bc80a92ff8bfa192888db113defe (patch)
treeb2c4ec46b5afec449396c1b8a7d2bb5d1a50acf5 /systemtap
parent403ec43efe86b728794b2d309b536e02c1584b1a (diff)
downloadorg.eclipse.linuxtools-aa10e5b5fa62bc80a92ff8bfa192888db113defe.tar.gz
org.eclipse.linuxtools-aa10e5b5fa62bc80a92ff8bfa192888db113defe.tar.xz
org.eclipse.linuxtools-aa10e5b5fa62bc80a92ff8bfa192888db113defe.zip
Systemtap: Refactor regex generator into its own class.
The feature for generating regexs from the "printf" statements in a stap script was originally included in SystemTapScriptGraphOptionsTab. Refactor it into its own class so that it may be easier to use in tests. Change-Id: I748a97c650e08cd08444c891836c957ed03bf2de Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/39802 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'systemtap')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapRegexGenerator.java205
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java255
2 files changed, 243 insertions, 217 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapRegexGenerator.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapRegexGenerator.java
new file mode 100644
index 0000000000..3a679d7c46
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapRegexGenerator.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Red Hat.
+ * All rights reserved. This program and the accompanying materials
+ * 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 implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher;
+
+import java.util.AbstractMap.SimpleEntry;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.CommentRemover;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * A class that is used for generating regular expressions that capture the output of .stp scripts.
+ */
+public class SystemTapRegexGenerator {
+ public static enum ErrResult { IO_EXCEPTION }
+
+ /**
+ * Generate a list of regular expressions that will capture the output of a given .stp script.
+ * Only output coming from <code>printf</code> statements will be captured.
+ * @param scriptPath The absolute path of the script to capture the output of.
+ * @param maxToFind The maximum number of regexs to create and return.
+ * A negative value indicates no limit.
+ * @return A list of generated regexs, each paired with the number of capturing groups it has.
+ */
+ public static List<Entry<String, Integer>> generateFromPrintf(IPath scriptPath, int maxToFind) {
+ List<Entry<String, Integer>> regexs = new ArrayList<>();
+ if (maxToFind == 0) {
+ return regexs;
+ }
+
+ String contents = null;
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+ IEditorPart editor = ResourceUtil.findEditor(
+ workbench.getActiveWorkbenchWindow().getActivePage(),
+ root.getFile(scriptPath.makeRelativeTo(root.getLocation())));
+ if (editor != null) {
+ // If editor of this file is open, take current file contents.
+ ITextEditor tEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
+ IDocument document = tEditor.getDocumentProvider().
+ getDocument(tEditor.getEditorInput());
+ contents = CommentRemover.exec(document.get());
+ } else {
+ // If chosen file is not being edited or is outside of the workspace, use the saved contents of the file itself.
+ contents = CommentRemover.execWithFile(scriptPath.toString());
+ }
+
+ // Now actually search the contents for "printf(...)" statements. (^|[\s({;])printf\("(.+?)",.+\)
+ Pattern pattern = Pattern.compile("(?<=[^\\w])printf\\(\"(.+?)\",.+?\\)"); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher(contents);
+
+ while (matcher.find() && (maxToFind < 0 || regexs.size() < maxToFind)) {
+ String regex = null;
+
+ // Note: allow optional "long" modifier 'l'. Not captured because it doesn't impact output format.
+ // Also, don't support variable width/precision modifiers (*).
+ // TODO: Consider %m & %M support.
+ Pattern format = Pattern.compile("%([-\\+ \\#0])?(\\d+)?(\\.\\d*)?l?([bcdiopsuxX%])"); //$NON-NLS-1$
+
+ // Only capture until newlines to preserve the "column" format.
+ // Don't try gluing together output from multiple printfs
+ // since asynchronous prints would make things messy.
+ String[] printls = matcher.group(1).split("\\\\n"); //$NON-NLS-1$
+ for (int i = 0; i < printls.length; i++) {
+ String printl = printls[i];
+ // Ignore newlines if they are escaped ("\\n").
+ if (printl.endsWith("\\")) { //$NON-NLS-1$
+ printls[i+1] = printl.concat("\\n" + printls[i+1]); //$NON-NLS-1$
+ continue;
+ }
+
+ Matcher fmatch = format.matcher(printl);
+ int lastend = 0;
+ int numColumns = 0;
+ while (fmatch.find()) {
+ numColumns++;
+ char chr = fmatch.group(4) == null ? '\0' : fmatch.group(4).charAt(0);
+ if (chr == '\0') {
+ // Skip this statement if an invalid regex is found.
+ regex = null;
+ break;
+ }
+ char flag = fmatch.group(1) == null ? '\0' : fmatch.group(1).charAt(0);
+ int width = fmatch.group(2) == null ? 0 : Integer.parseInt(fmatch.group(2));
+ String precision = fmatch.group(3) == null ? null : fmatch.group(3).substring(1);
+
+ // First, add any non-capturing characters.
+ String pre = addRegexEscapes(printl.substring(lastend, fmatch.start()));
+ regex = lastend > 0 ? regex.concat(pre) : pre;
+ lastend = fmatch.end();
+
+ // Now add what will be captured.
+ String target = "("; //$NON-NLS-1$
+ if (chr == 'u' || (flag != '#' && chr == 'o')) {
+ target = target.concat("\\d+"); //$NON-NLS-1$
+ }
+ else if (chr == 'd' || chr == 'i') {
+ if (flag == '+') {
+ target = target.concat("\\+|"); //$NON-NLS-1$
+ } else if (flag == ' ') {
+ target = target.concat(" |"); //$NON-NLS-1$
+ }
+ target = target.concat("-?\\d+"); //$NON-NLS-1$
+ }
+ else if (flag == '#' && chr == 'o') {
+ target = target.concat("0\\d+"); //$NON-NLS-1$
+ }
+ else if (chr == 'p') {
+ target = target.concat("0x[a-f0-9]+"); //$NON-NLS-1$
+ }
+ else if (chr == 'x') {
+ if (flag == '#') {
+ target = target.concat("0x"); //$NON-NLS-1$
+ }
+ target = target.concat("[a-f0-9]+"); //$NON-NLS-1$
+ }
+ else if (chr == 'X') {
+ if (flag == '#') {
+ target = target.concat("0X"); //$NON-NLS-1$
+ }
+ target = target.concat("[A-F0-9]+"); //$NON-NLS-1$
+ }
+ else if (chr == 'b') {
+ target = target.concat("."); //$NON-NLS-1$
+ }
+ else if (chr == 'c') {
+ if (flag != '#') {
+ target = target.concat("."); //$NON-NLS-1$
+ } else {
+ target = target.concat("\\([a-z]|[0-9]{3})|.|\\\\"); //$NON-NLS-1$
+ }
+ }
+ else if (chr == 's') {
+ if (precision != null) {
+ target = target.concat(".{" + precision + "}"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ target = target.concat(".+"); //$NON-NLS-1$
+ }
+ }
+ else {
+ // Invalid or unhandled format specifier. Skip this regex.
+ regex = null;
+ break;
+ }
+
+ target = target.concat(")"); //$NON-NLS-1$
+
+ // Handle the optional width specifier.
+ // Ignore it for %b, which uses the width value in a different way.
+ if (chr != 'b' && --width > 0) {
+ if (flag == '-') {
+ target = target.concat(" {0," + width + "}"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (flag != '0' || chr == 's' || chr == 'c') {
+ target = " {0," + width + "}".concat(target); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ regex = regex.concat(target);
+ }
+ if (regex != null) {
+ // Finally, add the uncaptured remainder of the print statement to the regex.
+ regexs.add(new SimpleEntry<>(regex.concat(addRegexEscapes(printl.substring(lastend))), numColumns));
+ }
+ }
+ }
+ return regexs;
+ }
+
+ /**
+ * This escapes all special regex characters in a string. Escapes must be added
+ * to the generated regexs to capture printf output that doesn't
+ * come from format specifiers (aka literal strings).
+ * @param s The string to add escapes to.
+ * @return The same string, after it has been modified with escapes.
+ */
+ private static String addRegexEscapes(String s) {
+ String schars = "[^$.|?*+(){}"; //$NON-NLS-1$
+ for (int i = 0; i < schars.length(); i++) {
+ s = s.replaceAll("(\\" + schars.substring(i,i+1) + ")", "\\\\$1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return s;
+ }
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java
index d0b2977767..a2c612142c 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/launcher/SystemTapScriptGraphOptionsTab.java
@@ -12,21 +12,16 @@
package org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.nio.charset.Charset;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -34,9 +29,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.linuxtools.internal.systemtap.ui.ide.CommentRemover;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
import org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSet;
import org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataSetParser;
@@ -67,13 +60,9 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.ResourceUtil;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
public class SystemTapScriptGraphOptionsTab extends
AbstractLaunchConfigurationTab {
@@ -163,7 +152,7 @@ public class SystemTapScriptGraphOptionsTab extends
/**
* A two-dimensional list that holds references to the names given to each regular expression's captured groups.
*/
- private List<ArrayList<String>> columnNamesList = new ArrayList<>();
+ private List<List<String>> columnNamesList = new ArrayList<>();
/**
* A list holding the data of every graph for the selected regular expression.
@@ -252,216 +241,48 @@ public class SystemTapScriptGraphOptionsTab extends
return;
}
- textListenersEnabled = false;
- // If editor of this file is open, take current file contents.
- String contents = null;
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IEditorPart editor = ResourceUtil.findEditor(workbench.getActiveWorkbenchWindow().getActivePage(), root.getFile(scriptPath.makeRelativeTo(root.getLocation())));
- if (editor != null) {
- ITextEditor tEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
- if (tEditor != null) {
- IDocumentProvider provider = tEditor.getDocumentProvider();
- IDocument document = provider.getDocument(tEditor.getEditorInput());
- contents = document.get();
- }
- }
-
- // If chosen file is not being edited or is outside of the workspace, use the saved contents of the file itself.
- if (contents == null) {
- File scriptFile = scriptPath.toFile();
- try (FileInputStream f = new FileInputStream(scriptFile)) {
- byte[] data = new byte[(int)scriptFile.length()];
- f.read(data);
- f.close();
- contents = new String(data, Charset.defaultCharset());
- } catch (IOException e1) {
- dialog = new MessageDialog(workbench
- .getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsErrorTitle, null,
- Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsError,
- MessageDialog.ERROR, new String[]{"OK"}, 0); //$NON-NLS-1$
- dialog.open();
- return;
- }
- }
-
- // Delete comments from the file contents. Ignore comment markers between quotes.
- contents = CommentRemover.exec(contents);
-
- // Now actually search the contents for "printf(...)" statements. (^|[\s({;])printf\("(.+?)",.+\)
- Pattern pattern = Pattern.compile("(?<=[^\\w])printf\\(\"(.+?)\",.+?\\)"); //$NON-NLS-1$
- Matcher matcher = pattern.matcher(contents);
- boolean firstfound = false;
- while (matcher.find() && (!firstfound || getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS)) {
- String regex = null;
-
- // Note: allow optional "long" modifier 'l'. Not captured because it doesn't impact output format.
- // Also, don't support variable width/precision modifiers (*).
- // TODO: Consider %m & %M support.
- Pattern format = Pattern.compile("%([-\\+ \\#0])?(\\d+)?(\\.\\d*)?l?([bcdiopsuxX%])"); //$NON-NLS-1$
-
- // Only capture until newlines to preserve the "column" format.
- // Don't try gluing together output from multiple printfs
- // since asynchronous prints would make things messy.
- String[] printls = matcher.group(1).split("\\\\n"); //$NON-NLS-1$
- for (int i = 0; i < printls.length; i++) {
- String printl = printls[i];
- // Ignore newlines if they are escaped ("\\n").
- if (printl.endsWith("\\")) { //$NON-NLS-1$
- printls[i+1] = printl.concat("\\n" + printls[i+1]); //$NON-NLS-1$
- continue;
- }
-
- Matcher fmatch = format.matcher(printl);
- int lastend = 0;
- ArrayList<String> columnNames = new ArrayList<>();
- int r = 0;
-
- while (fmatch.find()) {
- char chr = fmatch.group(4) == null ? '\0' : fmatch.group(4).charAt(0);
- if (chr == '\0') {
- // Skip this statement if an invalid regex is found.
- regex = null;
- break;
- }
- char flag = fmatch.group(1) == null ? '\0' : fmatch.group(1).charAt(0);
- int width = fmatch.group(2) == null ? 0 : Integer.parseInt(fmatch.group(2));
- String precision = fmatch.group(3) == null ? null : fmatch.group(3).substring(1);
-
- // First, add any non-capturing characters.
- String pre = addRegexEscapes(printl.substring(lastend, fmatch.start()));
- regex = lastend > 0 ? regex.concat(pre) : pre;
- lastend = fmatch.end();
-
- // Now add what will be captured.
- String target = "("; //$NON-NLS-1$
- if (chr == 'u' || (flag != '#' && chr == 'o')) {
- target = target.concat("\\d+"); //$NON-NLS-1$
- }
- else if (chr == 'd' || chr == 'i') {
- if (flag == '+') {
- target = target.concat("\\+|"); //$NON-NLS-1$
- } else if (flag == ' ') {
- target = target.concat(" |"); //$NON-NLS-1$
- }
- target = target.concat("-?\\d+"); //$NON-NLS-1$
- }
- else if (flag == '#' && chr == 'o') {
- target = target.concat("0\\d+"); //$NON-NLS-1$
- }
- else if (chr == 'p') {
- target = target.concat("0x[a-f0-9]+"); //$NON-NLS-1$
- }
- else if (chr == 'x') {
- if (flag == '#') {
- target = target.concat("0x"); //$NON-NLS-1$
- }
- target = target.concat("[a-f0-9]+"); //$NON-NLS-1$
- }
- else if (chr == 'X') {
- if (flag == '#') {
- target = target.concat("0X"); //$NON-NLS-1$
- }
- target = target.concat("[A-F0-9]+"); //$NON-NLS-1$
- }
- else if (chr == 'b') {
- target = target.concat("."); //$NON-NLS-1$
- }
- else if (chr == 'c') {
- if (flag != '#') {
- target = target.concat("."); //$NON-NLS-1$
- } else {
- target = target.concat("\\([a-z]|[0-9]{3})|.|\\\\"); //$NON-NLS-1$
- }
- }
- else if (chr == 's') {
- if (precision != null) {
- target = target.concat(".{" + precision + "}"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- target = target.concat(".+"); //$NON-NLS-1$
- }
- }
- else {
- // Invalid or unhandled format specifier. Skip this regex.
- regex = null;
- break;
- }
-
- target = target.concat(")"); //$NON-NLS-1$
-
- // Handle the optional width specifier.
- // Ignore it for %b, which uses the width value in a different way.
- if (chr != 'b' && --width > 0) {
- if (flag == '-') {
- target = target.concat(" {0," + width + "}"); //$NON-NLS-1$ //$NON-NLS-2$
- } else if (flag != '0' || chr == 's' || chr == 'c') {
- target = " {0," + width + "}".concat(target); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- regex = regex.concat(target);
- columnNames.add(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, ++r));
- }
- if (regex != null) {
- if (!firstfound) {
- // Since script output has been found, reset the configuration's regexs.
- // Only reset once/if something is found, and do it only one time.
- regularExpressionCombo.removeAll();
- outputList.clear();
- regexErrorMessages.clear();
- columnNamesList.clear();
- cachedNamesList.clear();
- graphsTable.removeAll();
- graphsDataList.clear();
- badGraphs.clear();
- firstfound = true;
- }
- // Finally, add the uncaptured remainder of the print statement to the regex.
- regex = regex.concat(addRegexEscapes(printl.substring(lastend)));
-
- regularExpressionCombo.add(regex);
- outputList.add(""); //$NON-NLS-1$ //For empty "sample output" entry.
- regexErrorMessages.add(null);
- columnNamesList.add(columnNames);
- cachedNamesList.add(new Stack<String>());
- graphsDataList.add(new LinkedList<GraphData>());
- }
- }
- }
- textListenersEnabled = true;
+ List<Entry<String, Integer>> regexs = SystemTapRegexGenerator.generateFromPrintf(scriptPath, MAX_NUMBER_OF_REGEXS);
- if (!firstfound) {
+ if (regexs.size() == 0) {
dialog = new MessageDialog(workbench
.getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsErrorTitle, null,
Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsEmpty,
MessageDialog.ERROR, new String[]{"OK"}, 0); //$NON-NLS-1$
dialog.open();
- return;
- }
-
- if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) {
- regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew);
- }
-
- removeRegexButton.setEnabled(getNumberOfRegexs() > 1);
- regularExpressionCombo.select(0);
- updateRegexSelection(0, true);
- checkAllOtherErrors(); // Check for errors in case there was a problem with regex generation
- updateLaunchConfigurationDialog();
- }
+ } else {
+ // Since script output has been found, reset the configuration's regexs.
+ textListenersEnabled = false;
+ regularExpressionCombo.removeAll();
+ outputList.clear();
+ regexErrorMessages.clear();
+ columnNamesList.clear();
+ cachedNamesList.clear();
+ graphsTable.removeAll();
+ graphsDataList.clear();
+ badGraphs.clear();
+ for (int i = 0, n = regexs.size(); i < n; i++) {
+ List<String> columnNames = new ArrayList<>();
+ for (int c = 0, numColumns = regexs.get(i).getValue(); c < numColumns; c++) {
+ columnNames.add(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, c+1));
+ }
+ regularExpressionCombo.add(regexs.get(i).getKey());
+ outputList.add(""); //$NON-NLS-1$ //For empty "sample output" entry.
+ regexErrorMessages.add(null);
+ columnNamesList.add(columnNames);
+ cachedNamesList.add(new Stack<String>());
+ graphsDataList.add(new LinkedList<GraphData>());
+ }
+ if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) {
+ regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew);
+ }
+ textListenersEnabled = true;
- /**
- * This escapes all special regex characters in a string. Escapes must be added
- * to the generated regexs to capture printf output that doesn't
- * come from format specifiers (aka literal strings).
- * @param s The string to add escapes to.
- * @return The same string, after it has been modified with escapes.
- */
- private String addRegexEscapes(String s) {
- String schars = "[^$.|?*+(){}"; //$NON-NLS-1$
- for (int i = 0; i < schars.length(); i++) {
- s = s.replaceAll("(\\" + schars.substring(i,i+1) + ")", "\\\\$1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ removeRegexButton.setEnabled(getNumberOfRegexs() > 1);
+ regularExpressionCombo.select(0);
+ updateRegexSelection(0, true);
+ checkAllOtherErrors(); // Check for errors in case there was a problem with regex generation
+ updateLaunchConfigurationDialog();
}
- return s;
}
};
@@ -983,7 +804,7 @@ public class SystemTapScriptGraphOptionsTab extends
// Update the number of columns and their titles here, and not in refreshRegexRows,
// using the list of saved active names instead of a cachedNames stack.
- ArrayList<String> columnNames = columnNamesList.get(selectedRegex);
+ List<String> columnNames = columnNamesList.get(selectedRegex);
int desiredNumberOfColumns = columnNames.size();
// Remove all columns to easily update them all immediately afterwards.
while (numberOfVisibleColumns > 0) {
@@ -1384,7 +1205,7 @@ public class SystemTapScriptGraphOptionsTab extends
configuration.setAttribute(REGULAR_EXPRESSION + r, regularExpressionCombo.getItem(r));
configuration.setAttribute(SAMPLE_OUTPUT + r, outputList.get(r));
- ArrayList<String> columnNames = columnNamesList.get(r);
+ List<String> columnNames = columnNamesList.get(r);
int numberOfColumns = columnNames.size();
for (int i = 0; i < numberOfColumns; i++) {
configuration.setAttribute(get2DConfigData(REGEX_BOX, r, i), columnNames.get(i));

Back to the top