use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlStructureCreator method getPath.
@Override
protected String[] getPath(final Object element, final Object input) {
if (element instanceof IErlElement) {
IErlElement e = (IErlElement) element;
// build a path starting at the given element and walk
// up the parent chain until we reach a module
final List<String> args = new ArrayList<>();
while (e != null) {
// each path component has a name that uses the same
// conventions as a ErlNode name
final String name = ErlangCompareUtilities.getErlElementID(e);
if (name == null) {
return null;
}
args.add(name);
if (e instanceof IErlModule) {
break;
}
e = (IErlElement) e.getParent();
}
Collections.reverse(args);
return args.toArray(new String[args.size()]);
}
return null;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class DefaultErlangFoldingStructureProvider method processDelta.
protected void processDelta(final IErlElementDelta delta) {
if (!isInstalled()) {
return;
}
if ((delta.getFlags() & (IErlElementDelta.F_CONTENT | IErlElementDelta.F_CHILDREN)) == 0) {
return;
}
final IErlElement de = delta.getElement();
if (de instanceof IErlModule && de != fModule) {
return;
}
final ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class);
if (model == null) {
return;
}
final IDocumentProvider provider = fEditor.getDocumentProvider();
try {
fCachedModel = model;
fCachedDocument = provider.getDocument(fEditor.getEditorInput());
if (fCachedDocument.getNumberOfLines() > PerformanceTuning.get().getFoldingLimit()) {
// disable folding for files larger than this
model.removeAllAnnotations();
return;
}
final Map<ErlangProjectionAnnotation, Position> additions = new HashMap<>();
final List<ErlangProjectionAnnotation> deletions = new ArrayList<>();
final List<ErlangProjectionAnnotation> updates = new ArrayList<>();
// use a linked map to maintain ordering of comments
final Map<ErlangProjectionAnnotation, Position> updated = new LinkedHashMap<>();
computeAdditions(fModule, updated);
final Map<Object, List<Tuple>> previous = createAnnotationMap(model);
for (final Entry<ErlangProjectionAnnotation, Position> entry : updated.entrySet()) {
final ErlangProjectionAnnotation newAnnotation = entry.getKey();
final IErlElement element = newAnnotation.getElement();
final Position newPosition = entry.getValue();
final List<Tuple> annotations = previous.get(element);
if (annotations == null) {
additions.put(newAnnotation, newPosition);
} else {
final Iterator<Tuple> x = annotations.iterator();
boolean matched = false;
while (x.hasNext()) {
final Tuple tuple = x.next();
final ErlangProjectionAnnotation existingAnnotation = tuple.annotation;
final Position existingPosition = tuple.position;
if (newAnnotation.isComment() == existingAnnotation.isComment()) {
if (existingPosition != null && !newPosition.equals(existingPosition)) {
existingPosition.setOffset(newPosition.getOffset());
existingPosition.setLength(newPosition.getLength());
updates.add(existingAnnotation);
}
matched = true;
x.remove();
break;
}
}
if (!matched) {
additions.put(newAnnotation, newPosition);
}
if (annotations.isEmpty()) {
previous.remove(element);
}
}
}
for (final List<Tuple> l : previous.values()) {
for (final Tuple t : l) {
deletions.add(t.annotation);
}
}
match(deletions, additions, updates);
final Annotation[] removals = new Annotation[deletions.size()];
deletions.toArray(removals);
final Annotation[] changes = new Annotation[updates.size()];
updates.toArray(changes);
model.modifyAnnotations(removals, additions, changes);
fFirstTimeInitialCollapse = false;
} finally {
fCachedDocument = null;
fCachedModel = null;
// fFirstType= null;
// fHasHeaderComment = false;
}
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class DebugTab method createControl.
/**
* @wbp.parser.entryPoint
*/
@Override
public void createControl(final Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
final GridLayout topLayout = new GridLayout();
comp.setLayout(topLayout);
distributedDebugCheck = createCheckButton(comp, "Debug all connected nodes");
final Group attachGroup = SWTUtil.createGroup(comp, "Auto Attach", 1, GridData.FILL_BOTH);
attachGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
attachOnFirstCallCheck = createCheckButton(attachGroup, "First &call");
attachOnBreakpointCheck = createCheckButton(attachGroup, "&Breakpoint");
attachOnExitCheck = createCheckButton(attachGroup, "E&xit");
distributedDebugCheck.addSelectionListener(fBasicSelectionListener);
attachOnFirstCallCheck.addSelectionListener(fBasicSelectionListener);
attachOnBreakpointCheck.addSelectionListener(fBasicSelectionListener);
attachOnExitCheck.addSelectionListener(fBasicSelectionListener);
final Group interpretedModulesGroup = new Group(comp, SWT.NONE);
final GridData gd_interpretedModulesGroup = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
gd_interpretedModulesGroup.widthHint = 387;
interpretedModulesGroup.setLayoutData(gd_interpretedModulesGroup);
interpretedModulesGroup.setText("Interpreted modules");
interpretedModulesGroup.setLayout(new GridLayout(2, false));
// final Label anyModuleHavingLabel = new Label(interpretedModulesGroup,
// SWT.WRAP);
// anyModuleHavingLabel.setLayoutData(new GridData(279, SWT.DEFAULT));
// anyModuleHavingLabel
// .setText("Any module having breakpoints enabled will be dynamically added to
// the list.\n\nThis widget is disabled for now, it takes 100%CPU for large
// projects. If you need to use \"attach on first call\" or \"attach on exit\",
// please mark the modules by setting a dummy breakpoint in them. Sorry for the
// inconvenience!");
listViewer = new ListViewer(interpretedModulesGroup, SWT.BORDER | SWT.MULTI);
listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
removeButton.setEnabled(!selection.isEmpty());
}
});
// checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
// @Override
// @SuppressWarnings("synthetic-access")
// public void checkStateChanged(final CheckStateChangedEvent event) {
// final DebugTreeItem dti = (DebugTreeItem) event.getElement();
// checkboxTreeViewer.setGrayed(dti, false);
// final boolean checked = event.getChecked();
// setSubtreeChecked(dti, checked);
// // checkUpwards(checkboxTreeViewer, dti, checked, false);
// updateLaunchConfigurationDialog();
// }
//
// });
listViewer.setLabelProvider(new ModuleItemLabelProvider());
contentProvider = new InterpretedModuleListContentProvider();
listViewer.setContentProvider(contentProvider);
final Control control = listViewer.getControl();
final GridData gd_list = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd_list.minimumWidth = 250;
gd_list.minimumHeight = 120;
gd_list.widthHint = 256;
gd_list.heightHint = 220;
control.setLayoutData(gd_list);
addButton = createPushButton(interpretedModulesGroup, "Add...", null);
addButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final List<IErlModule> result = DebugTab.getModulesFromAddModulesDialog(getShell());
contentProvider.addModules(result);
listViewer.refresh();
updateLaunchConfigurationDialog();
}
});
removeButton = createPushButton(interpretedModulesGroup, "Remove", null);
removeButton.setEnabled(false);
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
for (final Object o : selection.toArray()) {
contentProvider.removeModule((IErlModule) o);
}
listViewer.refresh();
updateLaunchConfigurationDialog();
}
});
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class DebugTab method performApply.
@Override
public void performApply(final ILaunchConfigurationWorkingCopy config) {
config.setAttribute(ErlRuntimeAttributes.DEBUG_FLAGS, ErlDebugFlags.getFlag(getFlagCheckboxes()));
final List<String> r = new ArrayList<>();
for (final Object o : contentProvider.getElements(null)) {
final IErlModule module = (IErlModule) o;
r.add(ErlangEngine.getInstance().getModelUtilService().getProject(module).getName() + ":" + module.getName());
}
config.setAttribute(ErlRuntimeAttributes.DEBUG_INTERPRET_MODULES, r);
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlangNodeLaunchShortcut method getProjectAndModuleNames.
private List<String> getProjectAndModuleNames(final Collection<IErlProject> projects) throws ErlModelException {
final List<String> moduleNames = Lists.newArrayList();
for (final IErlProject project : projects) {
final Collection<IErlModule> modules = project.getModules();
final String projectNameColon = project.getName() + ":";
for (final IErlModule module : modules) {
moduleNames.add(projectNameColon + module.getName());
}
}
return moduleNames;
}
Aggregations