use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method createErlModuleList.
private ArrayList<IErlElement> createErlModuleList(final OtpErlangList modList) {
final ArrayList<IErlElement> modules = new ArrayList<>();
for (int i = 0; i < modList.arity(); ++i) {
IErlModule m;
try {
m = extractModule(modList.elementAt(i));
modules.add(m);
} catch (final ErlModelException e) {
}
}
return modules;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class DebuggerTraceView method gotoModuleLine.
// @Override
// public void createPartControl(final Composite parent) {
// viewer = new TreeViewer(new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL
// | SWT.MULTI | SWT.FULL_SELECTION));
// setViewer(viewer);
// super.createPartControl(parent);
// // parent.setLayout(new FillLayout());
//
// viewer.getTree().setLinesVisible(true);
// viewer.setUseHashlookup(true);
//
// createColumns();
//
// viewer.setContentProvider(getContentProvider());
// viewer.setLabelProvider(new ColumnLabelProvider());
// getSite().setSelectionProvider(viewer);
//
// viewer.setInput(this);
// DebugPlugin.getDefault().addDebugEventListener(this);
//
// // viewer.getTree().addTreeListener(new TreeAdapter() {
// // @Override
// // public void treeCollapsed(final TreeEvent e) {
// // removeExpandedCategory((MarkerCategory) e.item.getData());
// // }
// //
// // @Override
// // public void treeExpanded(final TreeEvent e) {
// // addExpandedCategory((MarkerCategory) e.item.getData());
// // }
// // });
//
// // // Set help on the view itself
// // viewer.getControl().addHelpListener(new HelpListener() {
// // public void helpRequested(HelpEvent e) {
// // Object provider = getAdapter(IContextProvider.class);
// // if (provider == null) {
// // return;
// // }
// //
// // IContext context = ((IContextProvider) provider)
// // .getContext(viewer.getControl());
// // PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
// // }
// //
// // });
//
// viewer.getTree().addSelectionListener(new SelectionAdapter() {
// @Override
// public void widgetSelected(final SelectionEvent e) {
// final Object o = getSelectedInTree();
// final String msg = o == null ? "" : o.toString(); //$NON-NLS-1$
// getViewSite().getActionBars().getStatusLineManager()
// .setMessage(msg);
//
// }
// });
//
// viewer.getTree().addMouseListener(new MouseListener() {
//
// public void mouseDoubleClick(final MouseEvent e) {
// final Object o = getSelectedInTree();
// if (o instanceof OtpErlangTuple) {
// final OtpErlangTuple t = (OtpErlangTuple) o;
// final OtpErlangTuple t2 = (OtpErlangTuple) t.elementAt(1);
// final OtpErlangTuple ieval = (OtpErlangTuple) t2
// .elementAt(0);
// final OtpErlangAtom mod = (OtpErlangAtom) ieval
// .elementAt(3);
// final String module = mod.atomValue();
// final OtpErlangLong lin = (OtpErlangLong) ieval
// .elementAt(2);
// try {
// final int line = lin.intValue();
// gotoModuleLine(module, line);
// } catch (final OtpErlangRangeException e1) {
// }
//
// }
// }
//
// public void mouseDown(final MouseEvent e) {
// }
//
// public void mouseUp(final MouseEvent e) {
// }
//
// });
// // PlatformUI.getWorkbench().getWorkingSetManager()
// // .addPropertyChangeListener(getWorkingSetListener());
//
// // registerContextMenu();
// // initDragAndDrop();
//
// }
protected void gotoModuleLine(final String moduleName, final int line) {
final IWorkbenchWindow window = ErlideUIPlugin.getActiveWorkbenchWindow();
if (window == null) {
return;
}
final IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
IEditorPart part = null;
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
IErlModule module;
try {
module = model.findModule(moduleName);
} catch (final ErlModelException e) {
ErlLogger.error(e);
return;
}
IEditorInput input = null;
input = EditorUtility.getEditorInput(module);
if (input != null) {
final String editorId = EditorUtility.getEditorID(input, module);
if (editorId != null) {
try {
part = page.openEditor(input, editorId);
} catch (final PartInitException e) {
ErlideUIPlugin.errorDialog(window.getShell(), "Go to File", "Exception occurred", //
e);
}
}
}
if (part instanceof ErlangEditor) {
part.setFocus();
final ErlangEditor ee = (ErlangEditor) part;
final IDocument d = ee.getDocument();
int lineStart;
int lineLength;
try {
lineStart = d.getLineOffset(line - 1);
lineLength = d.getLineLength(line - 1);
EditorUtility.revealInEditor(ee, lineStart, lineLength - 1);
} catch (final BadLocationException e) {
ErlLogger.error(e);
}
}
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class InterpretHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final InterpretedModulesView view = (InterpretedModulesView) HandlerUtil.getActivePart(event);
final String commandId = event.getCommand().getId();
if (commandId.equals(InterpretHandler.INTERPRET_COMMAND_ID)) {
final List<IErlModule> modules = DebugTab.getModulesFromAddModulesDialog(view.getSite().getShell());
for (final IErlModule module : modules) {
view.interpretOrDeinterpret(module, true);
}
} else if (commandId.equals(InterpretHandler.DEINTERPRET_COMMAND_ID)) {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (final Object o : structuredSelection.toArray()) {
final IErlModule module = (IErlModule) o;
view.interpretOrDeinterpret(module, false);
}
}
} else {
throw new ExecutionException("bad command id");
}
return null;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class EditorConfiguration method getReconciler.
@Override
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
final ErlReconcilingStrategy strategy = new ErlReconcilingStrategy(editor);
final IErlModule module = editor != null ? editor.getModule() : null;
final String path = module != null ? module.getFilePath() : null;
reconciler = new ErlReconciler(strategy, true, true, path, module, getEditor());
reconciler.setProgressMonitor(new NullProgressMonitor());
reconciler.setIsAllowedToModifyDocument(false);
reconciler.setDelay(500);
return reconciler;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class BreakpointUtils method getElement.
public static IErlElement getElement(final ILineBreakpoint breakpoint) {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlElement element = model.findElement(breakpoint.getMarker().getResource());
if (element instanceof IErlModule) {
final IErlModule m = (IErlModule) element;
try {
m.open(null);
final int lineNumber = breakpoint.getLineNumber();
return m.getElementAtLine(lineNumber - 1);
} catch (final Exception e) {
ErlLogger.warn(e);
}
}
return null;
}
Aggregations