Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 839d16f2a78fa743792022a5eeb62c49f1431c85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.eclipse.cdt.arduino.ui.internal.launch;

import org.eclipse.cdt.arduino.core.internal.console.ArduinoErrorParser;
import org.eclipse.cdt.arduino.ui.internal.Activator;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.ui.console.PatternMatchEvent;

public class ArduinoErrorMatchListener extends ArduinoPatternMatchListener {

	public ArduinoErrorMatchListener(ArduinoConsole arduinoConsole, ArduinoErrorParser parser) {
		super(arduinoConsole, parser);
	}

	@Override
	public void matchFound(PatternMatchEvent event) {
		try {
			String text = textConsole.getDocument().get(event.getOffset(), event.getLength());
			IMarker marker = ((ArduinoErrorParser) parser).generateMarker(arduinoConsole.getBuildDirectory(), text);
			if (marker != null) {
				textConsole.addHyperlink(new ArduinoHyperlink(marker),
						event.getOffset() + marker.getAttribute(ArduinoErrorParser.LINK_OFFSET, 0),
						marker.getAttribute(ArduinoErrorParser.LINK_LENGTH, event.getLength()));
			}
		} catch (BadLocationException e) {
			Activator.log(e);
		}
	}

}

Back to the top