View Javadoc
1   package org.codehaus.plexus.compiler.j2objc;
2   
3   import org.codehaus.plexus.compiler.CompilerMessage;
4   import org.codehaus.plexus.compiler.CompilerMessage.Kind;
5   
6   /**
7    * Handle the output of J2ObjC
8    *
9    * @author lmaitre
10   */
11  public class DefaultJ2ObjCCompilerParser
12  {
13  
14      private static String ERROR_PREFIX = "error: ";
15  
16      private static String CONVERT_PREFIX = "translating ";
17  
18      private static String TRANSLATION_PREFIX = "Translated ";
19  
20      /**
21       * Parse a line of log, reading the error and translating lines.
22       *
23       * @param line
24       * @return The compiler message for this line or null if there is no need of
25       * a message.
26       */
27      public static CompilerMessage parseLine( String line )
28      {
29          String file = null;
30          boolean error = false;
31          int startline = -1;
32          int startcolumn = -1;
33          int endline = -1;
34          int endcolumn = -1;
35          String message;
36  
37          if ( line.startsWith( ERROR_PREFIX ) )
38          {
39              message = line.substring( ERROR_PREFIX.length() );
40              error = true;
41          }
42          else if ( line.startsWith( CONVERT_PREFIX ) )
43          {
44              message = line;
45          }
46          else if ( line.startsWith( TRANSLATION_PREFIX ) )
47          {
48              message = line;
49          }
50          else
51          {
52              System.err.println( "Unknown output: " + line );
53  
54              return null;
55          }
56  
57          return new CompilerMessage( file, error ? Kind.ERROR : Kind.NOTE, startline, startcolumn, endline, endcolumn,
58                                      message );
59  
60      }
61  
62  }