CTF: Remove warnings in CallSiteParser
authorAbderrahmane Berhil <abdelrahmane.b@gmail.com>
Thu, 18 May 2017 18:30:19 +0000 (14:30 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 19 May 2017 13:06:59 +0000 (09:06 -0400)
Change-Id: Ia7a1443304fecd3ad8a4216e50539db24cf29707
Signed-off-by: Abderrahmane Berhil <abdelrahmane.b@gmail.com>
Reviewed-on: https://git.eclipse.org/r/97490
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/callsite/CallSiteParser.java

index 36756e674bc8e2cd4ffa2d3acbfb718ba91d0ba9..980e211be0a190cfb4c8718c2fd08c23f4a27821 100644 (file)
@@ -14,7 +14,6 @@ import org.antlr.runtime.tree.CommonTree;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
 import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ICommonTreeParser;
-import org.eclipse.tracecompass.internal.ctf.core.event.metadata.ParseException;
 
 /**
  * Callsite as described in section 7.4 of the TSDL spec in CTF 1.8.2
@@ -51,36 +50,42 @@ public final class CallSiteParser implements ICommonTreeParser {
     }
 
     @Override
-    public @NonNull CTFCallsite parse(CommonTree tree, ICommonTreeParserParameter param) throws ParseException {
-        List<CommonTree> children = tree.getChildren();
-        String name = null;
+    public @NonNull CTFCallsite parse(CommonTree tree, ICommonTreeParserParameter param)  {
+        /*
+         * this is to replace the previous quotes with nothing...
+         * effectively deleting them
+         */
+        final String emptyString = ""; //$NON-NLS-1$
+
+        /* this is a regex to find the leading and trailing quotes */
+        final String regex = "^\"|\"$"; //$NON-NLS-1$
+
+        String fileName = null;
         String funcName = null;
-        long lineNumber = -1;
+        String name = null;
+        long lineNumber =-1;
         long ip = -1;
-        String fileName = null;
 
+        List<CommonTree> children = tree.getChildren();
         for (CommonTree child : children) {
-            String left;
-            /* this is a regex to find the leading and trailing quotes */
-            final String regex = "^\"|\"$"; //$NON-NLS-1$
-            /*
-             * this is to replace the previous quotes with nothing...
-             * effectively deleting them
-             */
-            final String nullString = ""; //$NON-NLS-1$
-            left = child.getChild(0).getChild(0).getChild(0).getText();
+            String left = child.getChild(0).getChild(0).getChild(0).getText();
             if (left.equals(NAME)) {
-                name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+                name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, emptyString);
             } else if (left.equals(FUNC)) {
-                funcName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+                funcName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, emptyString);
             } else if (left.equals(IP)) {
                 ip = Long.decode(child.getChild(1).getChild(0).getChild(0).getText());
             } else if (left.equals(FILE)) {
-                fileName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+                fileName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, emptyString);
             } else if (left.equals(LINE)) {
                 lineNumber = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText());
             }
         }
+
+        if (name == null || funcName == null || fileName == null) {
+            throw new NullPointerException("CTFCallsite parameters shouldn't be null!"); //$NON-NLS-1$
+        }
+
         return new CTFCallsite(name, funcName, ip, fileName, lineNumber);
     }
 
This page took 0.0251 seconds and 5 git commands to generate.