Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2004-08-28 01:32:53 +0000
committerKevin Barnes2004-08-28 01:32:53 +0000
commit13245be5907ab032def4ef2498dc459751c7005a (patch)
tree1eae4f0ef0df3404b9dffa369f3271d11d4b3f27
parent984ab5d2400b559dd705a7c01267d3e1a17b35ae (diff)
downloadeclipse.platform.debug-13245be5907ab032def4ef2498dc459751c7005a.tar.gz
eclipse.platform.debug-13245be5907ab032def4ef2498dc459751c7005a.tar.xz
eclipse.platform.debug-13245be5907ab032def4ef2498dc459751c7005a.zip
Bug 72167 - ProcessConsole should extend IOConsole
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java37
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java19
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java2
3 files changed, 26 insertions, 32 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java
index 834771414..df086e87c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleLineNotifier.java
@@ -11,6 +11,8 @@
package org.eclipse.debug.internal.ui.views.console;
+import java.util.regex.Pattern;
+
import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.debug.ui.console.IConsoleLineTracker;
import org.eclipse.debug.ui.console.IConsoleLineTrackerExtension;
@@ -115,47 +117,36 @@ public class ConsoleLineNotifier implements IPatternMatchListener {
* @see org.eclipse.ui.console.IPatternMatchListener#getPattern()
*/
public String getPattern() {
-// .*[\r,\n,\r\n]
- StringBuffer buffer = new StringBuffer(".*["); //$NON-NLS-1$
- for (int i = 0; i < lineDelimiters.length; i++) {
- String ld = lineDelimiters[i];
- buffer.append(ld);
- if (i != lineDelimiters.length-1) {
- buffer.append(","); //$NON-NLS-1$
- }
- }
- buffer.append("]"); //$NON-NLS-1$
- return buffer.toString();
+ return ".*\n";
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.IPatternMatchListener#getModifiers()
+ */
+ public int getCompilerFlags() {
+ return Pattern.UNIX_LINES;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.console.IPatternMatchListener#matchFound(org.eclipse.ui.console.PatternMatchEvent)
*/
public void matchFound(PatternMatchEvent event) {
- //the match includes the delimiter. Need to create a region that does
- //not include it. Windows /r/n is two characters.
try {
IDocument document = fConsole.getDocument();
- int line = document.getLineOfOffset(event.getOffset());
- String delimiter = document.getLineDelimiter(line);
- // int delimLength = delimiter != null ? delimiter.length() : 0;
- // TODO: looks like a bug in text support - on Windows, line delim is /r/n
- // but the event on includes /r
String text = document.get(event.getOffset(), event.getLength());
- int delimStart = text.lastIndexOf(delimiter.charAt(0));
- Region region = new Region(event.getOffset(), delimStart);
+ text = text.replaceAll("[\r\n]", "");
+ Region region = new Region(event.getOffset(), text.length());
lineAppended(region);
} catch (BadLocationException e) {}
}
-
- int numLines = 0;
public void lineAppended(IRegion region) {
- numLines++;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
IConsoleLineTracker listener = (IConsoleLineTracker)listeners[i];
listener.lineAppended(region);
}
}
+
+
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
index 83073f33c..71cb47dc7 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
@@ -331,7 +331,7 @@ public class IOConsole extends AbstractConsole implements IDocumentListener {
throw new IllegalArgumentException("Pattern cannot be null"); //$NON-NLS-1$
}
- Pattern pattern = Pattern.compile(matchListener.getPattern());
+ Pattern pattern = Pattern.compile(matchListener.getPattern(), matchListener.getCompilerFlags());
CompiledPatternMatchListener notifier = new CompiledPatternMatchListener(pattern, matchListener);
patterns.add(notifier);
@@ -371,7 +371,10 @@ public class IOConsole extends AbstractConsole implements IDocumentListener {
synchronized(patterns) {
for (Iterator iter = patterns.iterator(); iter.hasNext();) {
CompiledPatternMatchListener pattern = (CompiledPatternMatchListener) iter.next();
- int start = Math.min(pattern.end, event.fOffset);
+ int start = pattern.end;
+ if (event.fLength > 0) {
+ start = Math.min(pattern.end, event.fOffset);
+ }
try {
testForMatch(pattern, start);
} catch (BadLocationException e) {
@@ -386,12 +389,10 @@ public class IOConsole extends AbstractConsole implements IDocumentListener {
Matcher matcher = compiled.pattern.matcher(contents);
IPatternMatchListener notifier = compiled.listener;
while(matcher.find()) {
- String group = matcher.group();
- if (group.length() > 0) {
- int matchOffset = documentOffset + matcher.start();
- notifier.matchFound(new PatternMatchEvent(this, matchOffset, group.length()));
- compiled.end = matcher.end() + documentOffset;
- }
+ String group = matcher.group();
+ int matchOffset = documentOffset + matcher.start();
+ notifier.matchFound(new PatternMatchEvent(this, matchOffset, group.length()));
+ compiled.end = matcher.end() + documentOffset + 1;
}
}
@@ -405,4 +406,4 @@ public class IOConsole extends AbstractConsole implements IDocumentListener {
this.listener = matchListener;
}
}
-} \ No newline at end of file
+}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java
index e4ea78269..0f9039954 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java
@@ -27,6 +27,8 @@ public interface IPatternMatchListener {
*/
public String getPattern();
+ public int getCompilerFlags();
+
/**
* Notification that a match has been found.
*

Back to the top