diff options
author | Darin Wright | 2003-01-02 20:31:15 +0000 |
---|---|---|
committer | Darin Wright | 2003-01-02 20:31:15 +0000 |
commit | d2b325a82600e8cf2ced670ac4b38a9d0a94c317 (patch) | |
tree | 96ac76aa25486dd219ab34b5b3f346800e9c72ba /org.eclipse.ui.externaltools | |
parent | 1bca917e2f7f4aed584265e7b2f533d233f7ed11 (diff) | |
download | eclipse.platform.debug-d2b325a82600e8cf2ced670ac4b38a9d0a94c317.tar.gz eclipse.platform.debug-d2b325a82600e8cf2ced670ac4b38a9d0a94c317.tar.xz eclipse.platform.debug-d2b325a82600e8cf2ced670ac4b38a9d0a94c317.zip |
bug 27983
Diffstat (limited to 'org.eclipse.ui.externaltools')
5 files changed, 206 insertions, 20 deletions
diff --git a/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntProcessBuildLogger.java b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntProcessBuildLogger.java index 1c8ae369c..66582c864 100644 --- a/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntProcessBuildLogger.java +++ b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/AntProcessBuildLogger.java @@ -29,7 +29,9 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.ui.console.FileLink; import org.eclipse.debug.ui.console.IConsoleHyperlink; +import org.eclipse.jface.text.Region; import org.eclipse.ui.externaltools.internal.ant.AntSupportMessages; +import org.eclipse.ui.externaltools.internal.ant.launchConfigurations.*; import org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntProcess; import org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntStreamMonitor; import org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntStreamsProxy; @@ -59,11 +61,6 @@ public class AntProcessBuildLogger implements BuildLogger { private AntProcess fProcess = null; /** - * Current length of output - */ - private int fLength = 0; - - /** * @see org.eclipse.ui.externaltools.internal.ant.logger.NullBuildLogger#logMessage(java.lang.String, int) */ private void logMessage(String message, BuildEvent event, int overridePriority) { @@ -82,14 +79,14 @@ public class AntProcessBuildLogger implements BuildLogger { AntStreamMonitor monitor = getMonitor(priority); - if (event.getTarget() == null && event.getTarget() == null) { + if (event.getTarget() == null) { // look for "Buildfile:" message if (message.startsWith("Buildfile:")) { //$NON-NLS-1$ String fileName = message.substring(10).trim(); IFile file = getFileForLocation(fileName); if (file != null) { FileLink link = new FileLink(file, null, -1, -1, -1); - addLink(link, fLength + 11 + StringUtils.LINE_SEP.length(), fileName.length()); + TaskLinkManager.addTaskHyperlink(fProcess, link, new Region(11 + StringUtils.LINE_SEP.length(), fileName.length()), fileName); } } } @@ -106,7 +103,6 @@ public class AntProcessBuildLogger implements BuildLogger { monitor.append(message); logMessageToLogFile(message, priority); - fLength += message.length(); } /** @@ -128,22 +124,13 @@ public class AntProcessBuildLogger implements BuildLogger { fullMessage.append('['); fullMessage.append(name); fullMessage.append("] "); //$NON-NLS-1$ - int offset = fLength + Math.max(size, 0) + StringUtils.LINE_SEP.length(); - int length = LEFT_COLUMN_SIZE - size - 1; + int offset = Math.max(size, 0) + 1; + int length = LEFT_COLUMN_SIZE - size - 3; IConsoleHyperlink taskLink = getTaskLink(event); if (taskLink != null) { - addLink(taskLink, offset, length); + TaskLinkManager.addTaskHyperlink(fProcess, taskLink, new Region(offset, length), name); } } - - /** - * Adds the given link to the console - * - * @param link - */ - protected void addLink(IConsoleHyperlink link, int offset, int length) { - fProcess.getConsole().addLink(link, offset, length); - } private AntStreamMonitor getMonitor(int priority) { AntStreamsProxy proxy = (AntStreamsProxy)fProcess.getStreamsProxy(); diff --git a/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/TaskLineTracker.java b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/TaskLineTracker.java new file mode 100644 index 000000000..33d667e2c --- /dev/null +++ b/org.eclipse.ui.externaltools/Ant Runner Support/org/eclipse/ui/externaltools/internal/ant/logger/TaskLineTracker.java @@ -0,0 +1,51 @@ +package org.eclipse.ui.externaltools.internal.ant.logger; + +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html +**********************************************************************/ + +import org.eclipse.debug.ui.console.IConsole; +import org.eclipse.debug.ui.console.IConsoleLineTracker; +import org.eclipse.jface.text.IRegion; +import org.eclipse.ui.externaltools.internal.ant.launchConfigurations.*; + +/** + * Processes task hyperlinks as lines are appended to the console + */ +public class TaskLineTracker implements IConsoleLineTracker { + + private IConsole fConsole; + + /** + * Constructor for TaskLineTracker. + */ + public TaskLineTracker() { + super(); + } + + /** + * @see org.eclipse.debug.ui.console.IConsoleLineTracker#init(org.eclipse.debug.ui.console.IConsole) + */ + public void init(IConsole console) { + fConsole = console; + } + + /** + * @see org.eclipse.debug.ui.console.IConsoleLineTracker#lineAppended(org.eclipse.jface.text.IRegion) + */ + public void lineAppended(IRegion line) { + TaskLinkManager.processNewLine(fConsole, line); + } + + /** + * @see org.eclipse.debug.ui.console.IConsoleLineTracker#dispose() + */ + public void dispose() { + TaskLinkManager.dispose(fConsole.getProcess()); + fConsole = null; + } + +} diff --git a/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/launchConfigurations/TaskLinkManager.java b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/launchConfigurations/TaskLinkManager.java new file mode 100644 index 000000000..a834396d1 --- /dev/null +++ b/org.eclipse.ui.externaltools/Ant Tools Support/org/eclipse/ui/externaltools/internal/ant/launchConfigurations/TaskLinkManager.java @@ -0,0 +1,143 @@ +package org.eclipse.ui.externaltools.internal.ant.launchConfigurations; + +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation +********************************************************************/ + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.debug.core.model.IProcess; +import org.eclipse.debug.ui.console.IConsole; +import org.eclipse.debug.ui.console.IConsoleHyperlink; +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IRegion; + +/** + * Manages task links per process. As messages are logged to the console from + * build events, hyperlinks are created to link task names to the associated ant + * script. The build logger registers a task hyperlink with this manager for + * each build event associated with a task. When the associated line is later + * appended to the console, the corresponding text region in the console + * document is determined (as the length of a console document can not be + * determined beforehand), and the hyperlink is added to the document. + */ +public class TaskLinkManager { + + /** + * A map of processes to lists of queued task hyperlink entries + */ + private static Map fgProcessTable; + + private static class HyperlinkEntry { + private IConsoleHyperlink fLink; + private IRegion fRegion; + private String fTaskName; + + public HyperlinkEntry(IConsoleHyperlink link, IRegion region, String taskName) { + fLink = link; + fRegion = region; + fTaskName = taskName; + } + + public IRegion getRegion() { + return fRegion; + } + + public IConsoleHyperlink getLink() { + return fLink; + } + + public String getTaskName() { + return fTaskName; + } + } + + /** + * Not to be called. + */ + private TaskLinkManager() { + super(); + } + + /** + * Registers a hyperlink for the given process and task name. The given + * region is relative to the beginning of the line (not the document). + * + * @param process + * @param link + * @param region + * @param taskName + */ + public static void addTaskHyperlink(IProcess process, IConsoleHyperlink link, IRegion region, String taskName) { + if (fgProcessTable == null) { + fgProcessTable = new HashMap(10); + + } + List queue = (List)fgProcessTable.get(process); + if (queue == null) { + queue = new ArrayList(10); + fgProcessTable.put(process, queue); + } + synchronized (queue) { + queue.add(new HyperlinkEntry(link, region, taskName)); + } + } + + /** + * A new line has been added to the given console. Adds any task hyperlink + * associated with the line, to the console. + * + * @param console + * @param newLine + */ + public static void processNewLine(IConsole console, IRegion newLine) { + if (fgProcessTable == null) { + return; + } + IProcess process = console.getProcess(); + List queue = (List)fgProcessTable.get(process); + if (queue == null) { + return; + } + synchronized (queue) { + for (int i = 0; i < queue.size(); i++) { + HyperlinkEntry entry = (HyperlinkEntry)queue.get(i); + IRegion region = entry.getRegion(); + int offset = newLine.getOffset() + region.getOffset(); + int length = region.getLength(); + String text; + try { + text = console.getDocument().get(offset, length); + } catch (BadLocationException e) { + return; + } + if (text.equals(entry.getTaskName())) { + console.addLink(entry.getLink(), offset, length); + queue.remove(i); + return; + } + } + } + } + + /** + * Disposes any information stored for the given process. + * + * @param process + */ + public static void dispose(IProcess process) { + if (fgProcessTable != null) { + fgProcessTable.remove(process); + } + } + +} diff --git a/org.eclipse.ui.externaltools/lib/antrunner.jar b/org.eclipse.ui.externaltools/lib/antrunner.jar Binary files differindex 4d618c7f5..687392a6e 100644 --- a/org.eclipse.ui.externaltools/lib/antrunner.jar +++ b/org.eclipse.ui.externaltools/lib/antrunner.jar diff --git a/org.eclipse.ui.externaltools/plugin.xml b/org.eclipse.ui.externaltools/plugin.xml index a330ad28f..b7521a183 100644 --- a/org.eclipse.ui.externaltools/plugin.xml +++ b/org.eclipse.ui.externaltools/plugin.xml @@ -289,6 +289,11 @@ class = "org.eclipse.ui.externaltools.internal.ant.launchConfigurations.JavacLineTracker" processType = "ant"> </consoleLineTracker> + <consoleLineTracker + id = "org.eclipse.ui.externaltools.ant.taskLineTracker" + class = "org.eclipse.ui.externaltools.internal.ant.logger.TaskLineTracker" + processType = "ant"> + </consoleLineTracker> </extension> <!-- Variable Extensions --> |