cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon/components/language/programming/java Javac.java
Date Tue, 04 Sep 2001 15:14:33 GMT
dims        01/09/04 08:14:33

  Modified:    src/org/apache/cocoon/components/language/programming/java
                        Tag: cocoon_20_branch Javac.java
  Log:
  Patch from Torsten Curdt <tcurdt@dff.st> for "error message from javac"
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.4   +40 -30    xml-cocoon2/src/org/apache/cocoon/components/language/programming/java/Javac.java
  
  Index: Javac.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/programming/java/Javac.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- Javac.java	2001/08/20 14:07:27	1.2.2.3
  +++ Javac.java	2001/09/04 15:14:32	1.2.2.4
  @@ -19,13 +19,14 @@
   import java.io.IOException;
   import java.util.ArrayList;
   import java.util.List;
  +import java.util.NoSuchElementException;
   import java.util.StringTokenizer;
   
   /**
    * This class wraps the Sun's Javac Compiler.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.2.2.3 $ $Date: 2001/08/20 14:07:27 $
  + * @version $Revision: 1.2.2.4 $ $Date: 2001/09/04 15:14:32 $
    * @since 2.0
    */
   
  @@ -127,18 +128,22 @@
      */
     private CompilerError parseModernError(String error) {
       StringTokenizer tokens = new StringTokenizer(error, ":");
  -    String file = tokens.nextToken();
  -    if (file.length() == 1) file += ":" + tokens.nextToken();
  -    int line = Integer.parseInt(tokens.nextToken());
  -
  -    String message = tokens.nextToken("\n").substring(1);
  -    String context = tokens.nextToken("\n");
  -    String pointer = tokens.nextToken("\n");
  -    int startcolumn = pointer.indexOf("^");
  -    int endcolumn = context.indexOf(" ", startcolumn);
  -    if (endcolumn == -1) endcolumn = context.length();
  -
  -    return new CompilerError(file, false, line, startcolumn, line, endcolumn, message);
  +    try {
  +      String file = tokens.nextToken();
  +      if (file.length() == 1) file += ":" + tokens.nextToken();
  +      int line = Integer.parseInt(tokens.nextToken());
  +
  +      String message = tokens.nextToken("\n").substring(1);
  +      String context = tokens.nextToken("\n");
  +      String pointer = tokens.nextToken("\n");
  +      int startcolumn = pointer.indexOf("^");
  +      int endcolumn = context.indexOf(" ", startcolumn);
  +      if (endcolumn == -1) endcolumn = context.length();
  +      return new CompilerError(file, false, line, startcolumn, line, endcolumn, message);
  +    }
  +    catch(NoSuchElementException nse) {
  +      return new CompilerError("could not parse error message: " + error);
  +    }
     }
   
     /**
  @@ -183,24 +188,29 @@
     private CompilerError parseClassicError(String error) {
   
       StringTokenizer tokens = new StringTokenizer(error, ":");
  -    String file = tokens.nextToken();
  -    if (file.length() == 1) file += ":" + tokens.nextToken();
  -    int line = Integer.parseInt(tokens.nextToken());
  -
  -    String last = tokens.nextToken();
  -    // In case the message contains ':', it should be reassembled
  -    while (tokens.hasMoreElements()) {
  -      last += tokens.nextToken();
  -    }
  -    tokens = new StringTokenizer(last.trim(), "\n");
  -    String message = tokens.nextToken();
  -    String context = tokens.nextToken();
  -    String pointer = tokens.nextToken();
  -    int startcolumn = pointer.indexOf("^");
  -    int endcolumn = context.indexOf(" ", startcolumn);
  -    if (endcolumn == -1) endcolumn = context.length();
  +    try {
  +      String file = tokens.nextToken();
  +      if (file.length() == 1) file += ":" + tokens.nextToken();
  +      int line = Integer.parseInt(tokens.nextToken());
  +
  +      String last = tokens.nextToken();
  +      // In case the message contains ':', it should be reassembled
  +      while (tokens.hasMoreElements()) {
  +        last += tokens.nextToken();
  +      }
  +      tokens = new StringTokenizer(last.trim(), "\n");
  +      String message = tokens.nextToken();
  +      String context = tokens.nextToken();
  +      String pointer = tokens.nextToken();
  +      int startcolumn = pointer.indexOf("^");
  +      int endcolumn = context.indexOf(" ", startcolumn);
  +      if (endcolumn == -1) endcolumn = context.length();
   
  -    return new CompilerError(srcDir + File.separator + file, true, line, startcolumn, line,
endcolumn, message);
  +      return new CompilerError(srcDir + File.separator + file, true, line, startcolumn,
line, endcolumn, message);
  +    }
  +    catch(NoSuchElementException nse) {
  +      return new CompilerError("could not parse error message: " + error);
  +    }
     }
   
     public String toString() {
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message