use of org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData in project linuxtools by eclipse.
the class FunctionParser method addFunctionFromScript.
/**
* Searches the actual contents of a .stp script file for a specific function, and adds
* @param functionName The name of the function to search for.
* @param scriptText The contents of the script to search, with its comments removed
* (Use {@link CommentRemover} on file contents before passing them here, if necessary).
* @param scriptFilename The name of the script file being searched.
*/
private void addFunctionFromScript(String functionName, String scriptText, String scriptFilename) {
String regex = MessageFormat.format(FUNC_REGEX, functionName);
Matcher mScript = Pattern.compile(regex).matcher(scriptText);
if (mScript.find()) {
String functionLine = mScript.group();
String functionType = mScript.group(1);
// if it's really a void function, or if its return type is just unspecified
if (functionType == null && isPatternInScriptBlock(scriptText, mScript.end(), P_RETURN)) {
functionType = UNKNOWN_TYPE;
}
TreeDefinitionNode function = new TreeDefinitionNode(new FunctionNodeData(functionLine, functionType), functionName, scriptFilename, true);
tree.add(function);
addParamsFromString(mScript.group(2), function);
}
}
use of org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData in project linuxtools by eclipse.
the class TreeSettingsTest method testStapNodeData.
@Test
public void testStapNodeData() {
TreeNode temp;
TreeNode t1 = new TreeNode(new FunctionNodeData("function ftest(x:long)", null), true);
t1.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
TreeNode t2 = new TreeNode(new ProbeNodeData("ptest"), true);
t2.add(new TreeNode(new ProbevarNodeData("x:long"), false));
TreeSettings.setTrees(t1, t2);
temp = TreeSettings.getFunctionTree();
assertTrue("Improper data type - expected FunctionNodeData but was " + temp.getData().getClass().getSimpleName(), temp.getData() instanceof FunctionNodeData);
assertEquals("Function data not saved", t1.getData().toString(), temp.getData().toString());
assertEquals("Funcs has children", t1.getChildCount(), temp.getChildCount());
assertTrue("Improper data type", temp.getChildAt(0).getData() instanceof FuncparamNodeData);
assertEquals("Function parameter data not saved", t1.getChildAt(0).getData().toString(), temp.getChildAt(0).getData().toString());
temp = TreeSettings.getProbeTree();
assertTrue("Improper data type", temp.getData() instanceof ProbeNodeData);
assertEquals("Probe data not saved", t2.getData().toString(), temp.getData().toString());
assertEquals("Probs has children", t2.getChildCount(), temp.getChildCount());
assertTrue("Improper data type", temp.getChildAt(0).getData() instanceof ProbevarNodeData);
assertEquals("Probe variable data not saved", t2.getChildAt(0).getData().toString(), temp.getChildAt(0).getData().toString());
}
use of org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData in project linuxtools by eclipse.
the class TestCreateSystemtapScript method prepareTreeSettings.
/**
* Load custom contents into the Function/Probe views.
*/
private static void prepareTreeSettings() {
TapsetLibrary.stop();
try {
probeDef = File.createTempFile("probeDef", ".stp");
funcDef = File.createTempFile("funcDef", ".stp");
probeDef.deleteOnExit();
funcDef.deleteOnExit();
} catch (IOException e) {
}
// Leave one of the files blank to test token search failures.
try (PrintWriter writer = new PrintWriter(probeDef)) {
writer.print("test file\nptest\nlast line\n");
} catch (FileNotFoundException e) {
}
TreeNode testProbNodeParent = new TreeNode(null, false);
// Have static/alias folders to comply with convention (change this later).
testProbNodeParent.add(new TreeNode(probeCategoryEmpty, true));
testProbNodeParent.add(new TreeNode(probeCategoryFull, true));
TreeNode testProbNodeGroup = new TreeNode(probeGroup, true);
String innerProbe = "probegroup.inner";
TreeNode testProbNode = new TreeDefinitionNode(new ProbeNodeData(innerProbe), innerProbe, probeDef.getPath(), true);
testProbNode.add(new TreeNode(new ProbevarNodeData("s:string"), false));
testProbNodeGroup.add(testProbNode);
testProbNodeParent.getChildAt(1).add(testProbNodeGroup);
TreeNode testProbNode2 = new TreeDefinitionNode(new ProbeNodeData(probeSingleWithoutDef), probeSingleWithoutDef, null, true);
testProbNodeParent.getChildAt(1).add(testProbNode2);
TreeNode testFuncNodeParent = new TreeNode(null, false);
TreeNode testFuncNode = new TreeDefinitionNode(new FunctionNodeData("function ftest(x:long)", null), funcNodeName, funcDef.getPath(), true);
testFuncNode.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
testFuncNodeParent.add(testFuncNode);
TreeSettings.setTrees(testFuncNodeParent, testProbNodeParent);
TapsetLibrary.readTreeFile();
}
Aggregations