From c15551cb212b30572b676cee357909039ebfe8a0 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Wed, 27 Aug 2014 18:18:04 -0400 Subject: [PATCH] tmf: Fix custom text parser wizard preview highlighting - Does not match correctly when preview input has \r delimiters - Throws PatternSyntaxException if pattern is invalid with many root lines and at least one root line match in preview text - Does not highlight the root line match if last line in preview text Change-Id: Idc278df111edf93c37af53212a53a76d727c9d72 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/32443 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- .../CustomTxtParserInputWizardPage.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java index cfa68d7fc0..0dbe43dc7a 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/wizards/CustomTxtParserInputWizardPage.java @@ -664,15 +664,18 @@ public class CustomTxtParserInputWizardPage extends WizardPage { int rootLineMatches = 0; String firstEntryTimeStamp = null; String firstEntryTimeStampInputFormat = null; - String log = null; - event: while (scanner.hasNext()) { + String line = null; + boolean lineIsNull = true; // needed because of JDT bug with continue at label + event: while (scanner.hasNext() || !lineIsNull) { if (rootLineMatches > 0 && !updateAll) { break; } - if (log == null) { - log = scanner.next(); + if (line == null) { + line = scanner.next(); + lineIsNull = false; } - int length = log.length(); + int length = line.length(); + String log = line.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$ for (InputLine rootInputLine : definition.inputs) { Pattern pattern; try { @@ -700,12 +703,17 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } rawPos += length + 1; // +1 for \n while (scanner.hasNext()) { - log = scanner.next(); - length = log.length(); + line = scanner.next(); + length = line.length(); + log = line.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$ boolean processed = false; if (currentInput == null) { for (InputLine input : definition.inputs) { - matcher = input.getPattern().matcher(log); + try { + matcher = input.getPattern().matcher(log); + } catch (PatternSyntaxException e) { + continue; + } if (matcher.matches()) { continue event; } @@ -806,7 +814,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage { } } rawPos += length + 1; // +1 for \n - log = null; + line = null; + lineIsNull = true; } if (rootLineMatches == 1) { -- 2.34.1