KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > console > EclipseJavacPatternMatcher


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.console;
12
13 import org.eclipse.ui.console.PatternMatchEvent;
14
15 public class EclipseJavacPatternMatcher extends AbstractJavacPatternMatcher {
16
17     private static final String JavaDoc fgError= "ERROR in"; //$NON-NLS-1$
18
private static final String JavaDoc fgWarning= "WARNING in"; //$NON-NLS-1$
19
private static final String JavaDoc fgStartOfLineNumber= " ("; //$NON-NLS-1$
20

21     /* [javac] 1. ERROR in /Users/kevinbarnes/Eclipse/runtime-workspace/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java (at line 66)
22      */

23     public void matchFound(PatternMatchEvent event) {
24         String JavaDoc matchedText= getMatchedText(event);
25         if (matchedText == null) {
26             return;
27         }
28         int index = matchedText.indexOf(fgError);
29         String JavaDoc filePath;
30         Integer JavaDoc type= fgErrorType;
31         if (index == -1) {
32             index = matchedText.indexOf(fgWarning);
33             filePath= matchedText.substring(index + 10).trim();
34             type= fgWarningType;
35         } else {
36             filePath= matchedText.substring(index + 8).trim();
37         }
38
39         int lineNumberStart = filePath.lastIndexOf(fgStartOfLineNumber);
40         if (lineNumberStart != -1) {
41             filePath = filePath.substring(0, lineNumberStart);
42         }
43         
44         int fileStart = matchedText.indexOf(filePath);
45         int eventOffset= event.getOffset() + fileStart;
46         int eventLength = filePath.length();
47         
48         int lineNumber = getLineNumber(lineNumberStart + eventOffset, true);
49         addLink(filePath, lineNumber, eventOffset, eventLength, type);
50     }
51 }
Popular Tags