use of org.eclipse.debug.ui.console.FileLink in project linuxtools by eclipse.
the class ErrorLineMatcher method matchFound.
@Override
public void matchFound(PatternMatchEvent event) {
String line = null;
try {
line = console.getDocument().get(event.getOffset(), event.getLength());
int lineNumber = Integer.parseInt(line.substring(12, line.indexOf(':', line.indexOf(LINE))).trim());
FileLink fileLink = new FileLink(console.getSpecfile().getAdapter(IFile.class), "org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor", -1, -1, // $NON-NLS-1$
lineNumber);
console.addHyperlink(fileLink, 7, line.indexOf(':', line.indexOf(LINE)) - 7);
} catch (BadLocationException e1) {
return;
}
}
use of org.eclipse.debug.ui.console.FileLink in project erlide_eclipse by erlang.
the class ErlPatternMatchListenerDelegate method matchFound.
@Override
public void matchFound(final PatternMatchEvent event) {
if (fConsole == null) {
return;
}
try {
final String txt = fConsole.getDocument().get(event.getOffset(), event.getLength());
final String[] v = txt.split(":");
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
IResource res = null;
for (final IProject prj : projects) {
if (!prj.isOpen()) {
continue;
}
try {
res = ErlPatternMatchListenerDelegate.recursiveFindNamedResourceWithReferences(prj, v[0]);
if (res != null) {
break;
}
} catch (final CoreException e) {
ErlLogger.warn(e);
}
}
IFile file = null;
if (res instanceof IFile) {
file = (IFile) res;
}
final IHyperlink link = new FileLink(file, null, -1, -1, Integer.parseInt(v[1]));
fConsole.addHyperlink(link, event.getOffset(), event.getLength());
} catch (final BadLocationException e) {
ErlLogger.warn(e);
}
}
use of org.eclipse.debug.ui.console.FileLink in project liferay-ide by liferay.
the class ConsoleLineTracker method lineAppended.
public void lineAppended(IRegion line) {
try {
String text = console.getDocument().get(line.getOffset(), line.getLength());
if (text.indexOf(CHECK) >= 0) {
// it might relate to us
int i1 = text.lastIndexOf(CHECK_TEMPLATE);
if (i1 < 0) {
int i2 = text.lastIndexOf(CHECK_LINE2);
if (i2 >= 0) {
i1 = text.indexOf(CHECK_TEMPLATE2, i2);
i1 -= 6;
}
}
if (i1 > 0) {
// this is most likely an error message
int linkOffset = i1 + 10;
int linkLength = text.length() - linkOffset;
String fileName = text.substring(linkOffset, text.length()).trim();
// $NON-NLS-1$
if (fileName.endsWith("."))
fileName = fileName.substring(0, fileName.length() - 1);
int lineNumber = -1;
try {
int i2 = text.lastIndexOf(CHECK_LINE);
if (i2 > 0) {
i2 += CHECK_LINE.length();
// $NON-NLS-1$
int i3 = text.indexOf(",", i2);
if (i3 > 0) {
lineNumber = Integer.parseInt(text.substring(i2, i3).trim());
}
} else {
i2 = text.lastIndexOf(CHECK_LINE2);
if (i2 > 0) {
i2 += CHECK_LINE2.length();
// $NON-NLS-1$
int i3 = text.indexOf(",", i2);
if (i3 > 0) {
lineNumber = Integer.parseInt(text.substring(i2, i3).trim());
}
}
}
} catch (Exception e) {
// we can still proceed if we don't get the line number
}
IPath path = new Path(fileName);
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
List files = new ArrayList();
for (int i = 0; i < projects.length; i++) {
IProject project = projects[i];
IJavaProject javaProject = JavaCore.create(project);
fileName = fileName.replace('\\', '/');
try {
// $NON-NLS-1$
populateMatchingFiles(project, files, fileName.split("/"));
} catch (CoreException e) {
// TODO log this exception
}
}
if (files.size() != 0) {
IFile file = (IFile) files.get(0);
if (file != null && file.exists()) {
FileLink link = new FileLink(file, null, -1, -1, lineNumber);
console.addLink(link, linkOffset, linkLength);
}
}
}
}
} catch (BadLocationException e) {
}
}
use of org.eclipse.debug.ui.console.FileLink in project ow by vtst.
the class LessCompilerLaunchConfigurationDelegate method addProcessListeners.
protected void addProcessListeners(ILaunchConfiguration config, final Fixture fixture, IProcessListenerAcceptor acceptor) {
acceptor.acceptTerminationListener(new IProcessTerminationListener() {
public void terminated(IProcess process, int exitValue) {
IConsole console = DebugUITools.getConsole(process);
if (console instanceof IOConsole) {
IOConsole ioConsole = (IOConsole) console;
IOConsoleOutputStream stream = ioConsole.newOutputStream();
if (exitValue == 0) {
try {
stream.write(messages.getString("less_compiler_success"));
stream.write("\n");
stream.flush();
} catch (IOException e) {
e.printStackTrace();
}
/*
FileLink link = new FileLink(destinationFile, null, -1, -1, -1);
console.defaultStream.hyperlink(link, messages.getString("less_link_to_output"));
console.defaultStream.println();
*/
} else {
try {
stream.write(messages.getString("less_compiler_error"));
stream.write("\n");
stream.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
try {
fixture.outputFile.refreshLocal(0, null);
} catch (CoreException e) {
}
}
});
acceptor.acceptPatternMatchListener(new EasyPatternMatchListener() {
private Pattern pattern = Pattern.compile("([0-9]+)( .*)");
private int numberOfLines = 0;
private int errorLineNumber = 0;
private String errorMessage = null;
@Override
public void connect(TextConsole console) {
super.connect(console);
try {
for (IMarker marker : fixture.inputFile.findMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO)) {
if (MARKER_SOURCE_ID.equals(marker.getAttribute(IMarker.SOURCE_ID))) {
marker.delete();
}
}
} catch (CoreException e) {
}
}
@Override
public void disconnect() {
if (errorLineNumber != 0 && errorMessage != null) {
try {
IMarker marker = fixture.inputFile.createMarker(MARKER_TYPE);
marker.setAttribute(IMarker.LINE_NUMBER, this.errorLineNumber);
marker.setAttribute(IMarker.MESSAGE, this.errorMessage);
marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
marker.setAttribute(IMarker.SOURCE_ID, MARKER_SOURCE_ID);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
private void processLine(int offset, int length) throws BadLocationException {
String line = document.get(offset, length);
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
this.numberOfLines++;
int lineNumber = Integer.parseInt(matcher.group(1));
if (this.numberOfLines <= 2)
errorLineNumber = lineNumber;
FileLink link = new FileLink(fixture.inputFile, null, -1, -1, lineNumber);
console.addHyperlink(link, offset, matcher.group(1).length());
} else {
if (this.numberOfLines == 0)
errorMessage = line;
}
}
@Override
public void matchFound(PatternMatchEvent matchEvent) {
try {
processLine(matchEvent.getOffset(), matchEvent.getLength());
} catch (BadLocationException e) {
// This should never arise if the code is correct
}
}
@Override
public String getPattern() {
return ".+";
}
});
}
Aggregations