use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ClearAllCachesAction method clearAllCaches.
public static void clearAllCaches() {
final String cacheFileOSPath = ErlangEngine.getInstance().getStateDir();
final File cacheFile = new File(cacheFileOSPath);
cacheFile.delete();
for (final IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
for (final IWorkbenchPage page : window.getPages()) {
for (final IEditorReference editor : page.getEditorReferences()) {
final IEditorPart ed = editor.getEditor(false);
if (ed instanceof ErlangEditor) {
((ErlangEditor) ed).resetAndCacheScannerAndParser();
}
}
}
}
}
use of org.erlide.ui.editors.erl.ErlangEditor 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.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class DefaultErlangFoldingStructureProvider method projectionEnabled.
/*
* @seeorg.eclipse.jface.text.source.projection.IProjectionListener#
* projectionEnabled()
*/
@Override
public void projectionEnabled() {
// http://home.ott.oti.com/teams/wswb/anon/out/vms/index.html
// projectionEnabled messages are not always paired with
// projectionDisabled
// i.e. multiple enabled messages may be sent out.
// we have to make sure that we disable first when getting an enable
// message.
projectionDisabled();
initialize();
if (fEditor instanceof ErlangEditor && fModule != null) {
boolean structureKnown = false;
try {
structureKnown = fModule.isStructureKnown();
} catch (final ErlModelException e1) {
}
if (structureKnown) {
final IErlElementDelta d = ErlangEngine.getInstance().getModel().createElementDelta(IErlElementDelta.CHANGED, IErlElementDelta.F_CONTENT, fModule);
processDelta(d);
} else {
try {
fModule.open(null);
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
}
}
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ErlangSearchPage method initSelections.
private void initSelections() throws ErlModelException {
final ISelection sel = getContainer().getSelection();
SearchPatternData initData = null;
if (sel instanceof IStructuredSelection) {
initData = tryStructuredSelection((IStructuredSelection) sel);
} else if (sel instanceof ITextSelection) {
final IEditorPart activePart = getActiveEditor();
if (activePart instanceof ErlangEditor) {
initData = tryErlangTextSelection(initData, activePart);
}
if (initData == null) {
initData = trySimpleTextSelection((ITextSelection) sel);
}
}
if (initData == null) {
initData = getDefaultInitValues();
}
fInitialData = initData;
fPattern.setText(initData.getPattern());
setSearchFor(initData.getSearchFor());
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ErlangAbstractHandler method getTextSelection.
/**
* Provide the text selection that is needed to execute the command. Default
* implementation, extend to Erlang elements selected.
*
* @param document
* text {@link IDocument}
* @param selection
* selection affected by command (extended by extendSelection)
* @return new {@link ITextSelection} with all text up to selection
*/
protected ITextSelection getTextSelection(final IDocument document, final ITextSelection selection, final ITextEditor editor) {
if (editor instanceof ErlangEditor) {
final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
final IErlModule module = erlangEditor.getModule();
if (module != null) {
final int offset1 = selection.getOffset();
final int offset2 = offset1 + selection.getLength();
try {
final IErlElement e1 = module.getElementAt(offset1);
final IErlElement e2 = module.getElementAt(offset2);
if (e1 instanceof ISourceReference) {
final ISourceReference ref1 = (ISourceReference) e1;
final ISourceRange r1 = ref1.getSourceRange();
final int offset = r1.getOffset();
int length = r1.getLength();
if (e1 == e2) {
final int docLength = document.getLength();
if (offset + length > docLength) {
length = docLength - offset;
}
return ErlangAbstractHandler.extendSelectionToWholeLines(document, new TextSelection(document, offset, length));
} else if (e2 == null) {
return ErlangAbstractHandler.extendSelectionToWholeLines(document, new TextSelection(document, offset, selection.getLength() + selection.getOffset() - offset));
} else if (e2 instanceof ISourceReference) {
final ISourceReference ref2 = (ISourceReference) e2;
final ISourceRange r2 = ref2.getSourceRange();
return ErlangAbstractHandler.extendSelectionToWholeLines(document, new TextSelection(document, offset, r2.getOffset() - offset + r2.getLength()));
}
}
} catch (final ErlModelException e) {
}
}
}
return ErlangAbstractHandler.extendSelectionToWholeLines(document, selection);
}
Aggregations