ctf: Catch ANTLR runtime exceptions in Metadata parsing
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 27 Nov 2013 19:34:28 +0000 (14:34 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 27 Nov 2013 21:31:11 +0000 (16:31 -0500)
Change-Id: Ia50ee58b56a6e50b213e008950322c2e04231c28
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/19000

org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/exceptions/CtfAntlrException.java

index 7c9eed01c6412f2959647f19a10e04f96a0eb302..8fe1f602e48f0467b88f0e021c98ff6d11fc0ccd 100644 (file)
@@ -28,9 +28,9 @@ import java.util.UUID;
 
 import org.antlr.runtime.ANTLRReaderStream;
 import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.MismatchedTokenException;
 import org.antlr.runtime.RecognitionException;
 import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.RewriteCardinalityException;
 import org.eclipse.linuxtools.ctf.parser.CTFLexer;
 import org.eclipse.linuxtools.ctf.parser.CTFParser;
 import org.eclipse.linuxtools.ctf.parser.CTFParser.parse_return;
@@ -177,10 +177,10 @@ public class Metadata {
             tempException = new CTFReaderException(e);
         } catch (ParseException e) {
             tempException = new CTFReaderException(e);
-        } catch (MismatchedTokenException e) {
-            tempException = new CtfAntlrException(e);
         } catch (RecognitionException e) {
             tempException = new CtfAntlrException(e);
+        } catch (RewriteCardinalityException e){
+            tempException = new CtfAntlrException(e);
         }
 
         /* Ghetto resource management. Java 7 will deliver us from this... */
index e23d2539d0a79a3acb9273a2692f4ac58463c7a6..b918af008a7f6bcc6dd84aec32187499e5801257 100644 (file)
@@ -17,6 +17,7 @@ import java.lang.reflect.Field;
 
 import org.antlr.runtime.MismatchedTokenException;
 import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.tree.RewriteCardinalityException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.parser.CTFLexer;
 
@@ -40,7 +41,6 @@ public class CtfAntlrException extends CTFReaderException {
     private String fActualName = ""; //$NON-NLS-1$
     private int fActualValue = -1;
 
-
     /**
      * Re-throw the exception but read its data
      *
@@ -59,13 +59,25 @@ public class CtfAntlrException extends CTFReaderException {
      * @param e
      *            the previous recognition exception (Antlr specific)
      */
-    public CtfAntlrException(MismatchedTokenException e){
+    public CtfAntlrException(MismatchedTokenException e) {
         super(e);
         this.fErrorLine = e.line;
         this.fFile = "metadata"; //$NON-NLS-1$ // we're in CTF, the only thing using antlr is metadata
         parseMismatchedException(e);
     }
 
+    /**
+     * Re-throw the exception but read its data
+     *
+     * @param e
+     *            the previous rewrite exception (Antlr specific)
+     */
+    public CtfAntlrException(RewriteCardinalityException e) {
+        super(e);
+        this.fErrorLine = -1;
+        this.fFile = "metadata"; //$NON-NLS-1$ // we're in CTF, the only thing using antlr is metadata
+    }
+
     private void parseMismatchedException(MismatchedTokenException m) {
         // Iterate through the tokens that are hidden in the CTFLexer
         // They are private static final int fields.
This page took 0.028316 seconds and 5 git commands to generate.