use of org.eclipse.cdt.core.model.ICElement in project linuxtools by eclipse.
the class ProfileUIUtils method findCProjectWithAbsolutePath.
/**
* Find an ICProject that contains the specified absolute path.
*
* @param absPath An absolute path (usually to some file/folder in a project)
* @return an ICProject corresponding to the project that contains the absolute path
* @throws CoreException can be thrown if visiting (accepting) a project walking the ICElement tree fails.
*/
public static ICProject findCProjectWithAbsolutePath(final String absPath) throws CoreException {
final String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString();
final ArrayList<ICProject> ret = new ArrayList<>();
// visitor object to check for the matching path string
ICElementVisitor vis = element -> {
if (element.getElementType() == ICElement.C_CCONTAINER || element.getElementType() == ICElement.C_PROJECT) {
return true;
} else if (absPath.equals(workspaceLoc + element.getPath().toFile().getAbsolutePath())) {
ret.add(element.getCProject());
}
return false;
};
ICProject[] cProjects = CCorePlugin.getDefault().getCoreModel().getCModel().getCProjects();
for (ICProject proj : cProjects) {
// visit every project
proj.accept(vis);
}
// is it possible to find more than one matching project ?
return ret.isEmpty() ? null : ret.get(0);
}
use of org.eclipse.cdt.core.model.ICElement in project linuxtools by eclipse.
the class CachegrindFunction method findElement.
private ICElement findElement(String name, IParent parent) throws CModelException {
ICElement element = null;
List<ICElement> dom = parent.getChildrenOfType(ICElement.C_FUNCTION);
dom.addAll(parent.getChildrenOfType(ICElement.C_METHOD));
for (int i = 0; i < dom.size(); i++) {
ICElement func = dom.get(i);
if ((func instanceof IFunction || func instanceof IMethod) && func.getElementName().equals(name)) {
element = func;
}
}
return element;
}
use of org.eclipse.cdt.core.model.ICElement in project linuxtools by eclipse.
the class GcovAnnotationModelTracker method annotateCEditor.
private void annotateCEditor(IWorkbenchPartReference partref) {
IWorkbenchPart part = partref.getPart(false);
if (part instanceof ICEditor) {
ICEditor editor = (ICEditor) part;
ICElement element = CDTUITools.getEditorInputCElement(editor.getEditorInput());
IProject project = element.getCProject().getProject();
// Attach our annotation model to any compatible editor. (ICEditor)
GcovAnnotationModel.attach((ITextEditor) part);
// If a user triggers a build we will not render annotations.
ResourcesPlugin.getWorkspace().addResourceChangeListener(new ProjectBuildListener(project, editor), IResourceChangeEvent.POST_BUILD);
}
}
use of org.eclipse.cdt.core.model.ICElement in project linuxtools by eclipse.
the class ListTreeContentProvider method getElements.
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof List) {
for (Object element : (List<?>) inputElement) if (element instanceof ICContainer)
try {
ICElement[] array = ((ICContainer) element).getChildren();
ArrayList<ICElement> output = new ArrayList<>();
for (ICElement item : array) {
if ((item instanceof ICContainer) && checkForValidChildren((ICContainer) item)) {
output.add(item);
}
if (SystemTapLaunchShortcut.validElement(item)) {
output.add(item);
}
}
return output.toArray();
} catch (CModelException e) {
e.printStackTrace();
}
}
return null;
}
use of org.eclipse.cdt.core.model.ICElement in project linuxtools by eclipse.
the class SystemTapOptionsTab method setDefaults.
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_VERBOSE, LaunchConfigurationConstants.DEFAULT_COMMAND_VERBOSE);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_KEEP_TEMPORARY, LaunchConfigurationConstants.DEFAULT_COMMAND_KEEP_TEMPORARY);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_GURU, LaunchConfigurationConstants.DEFAULT_COMMAND_GURU);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_PROLOGUE_SEARCH, LaunchConfigurationConstants.DEFAULT_COMMAND_PROLOGUE_SEARCH);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_NO_CODE_ELISION, LaunchConfigurationConstants.DEFAULT_COMMAND_NO_CODE_ELISION);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_DISABLE_WARNINGS, LaunchConfigurationConstants.DEFAULT_COMMAND_DISABLE_WARNINGS);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_BULK_MODE, LaunchConfigurationConstants.DEFAULT_COMMAND_BULK_MODE);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_TIMING_INFO, LaunchConfigurationConstants.DEFAULT_COMMAND_TIMING_INFO);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_SKIP_BADVARS, LaunchConfigurationConstants.DEFAULT_COMMAND_SKIP_BADVARS);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_IGNORE_DWARF, LaunchConfigurationConstants.DEFAULT_COMMAND_IGNORE_DWARF);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_TAPSET_COVERAGE, LaunchConfigurationConstants.DEFAULT_COMMAND_TAPSET_COVERAGE);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_LEAVE_RUNNING, LaunchConfigurationConstants.DEFAULT_COMMAND_LEAVE_RUNNING);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_PASS, LaunchConfigurationConstants.DEFAULT_COMMAND_PASS);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_BUFFER_BYTES, LaunchConfigurationConstants.DEFAULT_COMMAND_BUFFER_BYTES);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_TARGET_PID, LaunchConfigurationConstants.DEFAULT_COMMAND_TARGET_PID);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_C_DIRECTIVES, LaunchConfigurationConstants.DEFAULT_COMMAND_C_DIRECTIVES);
configuration.setAttribute(LaunchConfigurationConstants.BINARY_PATH, LaunchConfigurationConstants.DEFAULT_BINARY_PATH);
configuration.setAttribute(LaunchConfigurationConstants.SCRIPT_PATH, LaunchConfigurationConstants.DEFAULT_SCRIPT_PATH);
configuration.setAttribute(LaunchConfigurationConstants.OUTPUT_PATH, LaunchConfigurationConstants.DEFAULT_OUTPUT_PATH);
configuration.setAttribute(LaunchConfigurationConstants.ARGUMENTS, LaunchConfigurationConstants.DEFAULT_ARGUMENTS);
configuration.setAttribute(LaunchConfigurationConstants.BINARY_ARGUMENTS, LaunchConfigurationConstants.DEFAULT_BINARY_ARGUMENTS);
configuration.setAttribute(LaunchConfigurationConstants.GENERATED_SCRIPT, LaunchConfigurationConstants.DEFAULT_GENERATED_SCRIPT);
configuration.setAttribute(LaunchConfigurationConstants.NEED_TO_GENERATE, LaunchConfigurationConstants.DEFAULT_NEED_TO_GENERATE);
configuration.setAttribute(LaunchConfigurationConstants.PARSER_CLASS, LaunchConfigurationConstants.DEFAULT_PARSER_CLASS);
configuration.setAttribute(LaunchConfigurationConstants.VIEW_CLASS, LaunchConfigurationConstants.DEFAULT_VIEW_CLASS);
configuration.setAttribute(LaunchConfigurationConstants.USE_COLOUR, LaunchConfigurationConstants.DEFAULT_USE_COLOUR);
configuration.setAttribute(LaunchConfigurationConstants.COMMAND_LIST, ConfigurationOptionsSetter.setOptions(configuration));
ICElement cElement = null;
cElement = getContext(configuration, getPlatform(configuration));
if (cElement != null) {
initializeCProject(cElement, configuration);
} else {
// don't want to remember the interim value from before
configuration.setMappedResources(null);
}
IBinary bin = getBinary(configuration);
if (bin != null) {
String programName = bin.getResource().getProjectRelativePath().toString();
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programName);
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
LaunchStapGraph launch = new LaunchStapGraph();
// Do not run callgraph
launch.setTestMode(true);
// $NON-NLS-1$
launch.launch(bin, "", configuration);
}
}
Aggregations