blob: d2aa260c5f0af8f96b1537129fa4334d19d1c53c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others.
* 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
*
*******************************************************************************/
package org.eclipse.dltk.ruby.internal.debug.ui.console;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.console.IHyperlink;
import org.eclipse.ui.console.IPatternMatchListenerDelegate;
import org.eclipse.ui.console.PatternMatchEvent;
import org.eclipse.ui.console.TextConsole;
/**
* Provides links for stack traces
*/
public class RubyConsoleTracker implements IPatternMatchListenerDelegate {
/**
* The console associated with this line tracker
*/
private TextConsole fConsole;
/* (non-Javadoc)
* @see org.eclipse.ui.console.IPatternMatchListenerDelegate#connect(org.eclipse.ui.console.IConsole)
*/
public void connect(TextConsole console) {
fConsole = console;
}
/* (non-Javadoc)
* @see org.eclipse.ui.console.IPatternMatchListenerDelegate#disconnect()
*/
public void disconnect() {
fConsole = null;
}
protected TextConsole getConsole() {
return fConsole;
}
/* (non-Javadoc)
* @see org.eclipse.ui.console.IPatternMatchListenerDelegate#matchFound(org.eclipse.ui.console.PatternMatchEvent)
*/
public void matchFound(PatternMatchEvent event) {
try {
int offset = event.getOffset();
int length = event.getLength();
IDocument document = getConsole().getDocument();
String text = document.get(offset, length);
if( text.indexOf("from -e") != -1) {
return;
}
IHyperlink link = new RubyFileHyperlink(fConsole);
fConsole.addHyperlink(link, offset, length);
} catch (BadLocationException e) {
}
}
}