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
}
@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);
}