use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class TreeSettings method readTree.
/**
* Opposite action as writeTree. Reconstruct a tree from a previously-saved {@link IMemento}.
* @param data The {@link IMemento} to read the tree out of.
* @return The reconstructed {@link TreeNode}.
*/
private static TreeNode readTree(IMemento data) {
String disp = data.getString(M_DISP);
String def = data.getString(M_DEFINITON);
boolean c = data.getBoolean(M_CLICKABLE);
Object d = StapTreeDataFactory.createObjectFromString(data.getString(M_DATA), data.getString(M_DATATYPE));
TreeNode parent;
if (def == null) {
parent = new TreeNode(d, disp, c);
} else {
parent = new TreeDefinitionNode(d, disp, getValueFromString(def), c);
}
for (IMemento child : data.getChildren()) {
parent.add(readTree(child));
}
return parent;
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode 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.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class ProbeParser method delTapsets.
@Override
protected int delTapsets(String[] tapsets, IProgressMonitor monitor) {
TreeNode aliases = tree.getChildByName(Messages.ProbeParser_aliasProbes);
// come from removed directories, and remove them from the group.
for (int i = 0; i < tapsets.length; i++) {
for (int g = 0, gn = aliases.getChildCount(); g < gn; g++) {
if (monitor.isCanceled()) {
return IStatus.CANCEL;
}
TreeNode group = aliases.getChildAt(g);
for (int p = 0, pn = group.getChildCount(); p < pn; p++) {
String definition = ((TreeDefinitionNode) group.getChildAt(p)).getDefinition();
if (definition != null && definition.startsWith(tapsets[i])) {
group.remove(p--);
pn--;
}
}
// If removing the only probe left in a probe group, remove the group.
if (group.getChildCount() == 0) {
aliases.remove(g--);
gn--;
}
}
}
return IStatus.OK;
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class DefinitionHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
TreeDefinitionNode t = getSelection(event);
if (t == null) {
return null;
}
String filename = t.getDefinition();
if (filename == null) {
return null;
}
File file = new File(filename);
OpenFileHandler open = new OpenFileHandler();
open.executeOnFile(file);
if (open.isSuccessful() && t.getData() instanceof ISearchableNode) {
IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
STPEditor editor = (STPEditor) editorPart;
editor.jumpToLocation(findDefinitionLine((ISearchableNode) t.getData(), editor) + 1, 0);
}
return null;
}
use of org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode in project linuxtools by eclipse.
the class DefinitionHandler method getSelection.
private TreeDefinitionNode getSelection(ExecutionEvent event) {
IStructuredSelection selection = HandlerUtil.getCurrentStructuredSelection(event);
Object[] selections = selection.toArray();
return (selections.length == 1 && selections[0] instanceof TreeDefinitionNode) ? (TreeDefinitionNode) selections[0] : null;
}
Aggregations