/* * (non-Javadoc) Method declared on SelectionDispatchAction. */ @Override public void run(final ITextSelection selection) { final ErlangEditor editor = (ErlangEditor) getSite().getPage().getActiveEditor(); editor.reconcileNow(); final IErlModule module = editor.getModule(); if (module == null) { return; } final Backend b = ErlangCore.getBackendManager().getIdeBackend(); final int offset = selection.getOffset(); try { final IErlProject erlProject = module.getErlProject(); final IErlModel model = ErlangCore.getModel(); final OpenResult res = ErlideOpen.open( b, ErlangToolkit.createScannerModuleName(module), offset, ErlModelUtils.getImportsAsList(module), model.getExternalModules(erlProject), model.getPathVars()); ErlLogger.debug("open " + res); openOpenResult(editor, module, b, offset, erlProject, res); } catch (final Exception e) { ErlLogger.warn(e); } }
/* * Method declared on SelectionChangedAction. */ @Override public void run(final ITextSelection selection) { // if (!ActionUtil.isProcessable(fEditor)) { // return; // } IErlModule module = fEditor.getModule(); if (module == null) { return; } final Backend b = ErlangCore.getBackendManager().getIdeBackend(); final ISelection sel = getSelection(); final ITextSelection textSel = (ITextSelection) sel; final int offset = textSel.getOffset(); try { String scannerModuleName = ErlangToolkit.createScannerModuleName(module); final OpenResult res = ErlideOpen.open(b, scannerModuleName, offset, "", ErlangCore.getModel().getPathVars()); ErlLogger.debug("open " + res); // final String title = // "SearchMessages.SearchElementSelectionDialog_title"; // final String message = // "SearchMessages.SearchElementSelectionDialog_message"; if (res.isExternalCall()) { performNewSearch(SearchUtil.getRefFromOpenRes(res)); } } catch (final Exception e) { // final String title = "SearchMessages.Search_Error_search_title"; // final String message = "SearchMessages.Search_Error_codeResolve"; // ExceptionHandler.handle(e, getShell(), title, message); ErlLogger.debug(e); } }
@Override public void initialReconcile() { fModule = fEditor != null ? fEditor.getModule() : null; ErlLogger.debug("## initial reconcile " + (fModule != null ? fModule.getName() : "")); if (fModule != null) { fModule.initialReconcile(); } // notify(new OtpErlangAtom("initialReconcile")); }
/* * (non-Javadoc) * * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { final IErlModule module = erlangEditor.getModule(); if (module == null) { return; } for (String suffix : suffixes) { final String cacheFileOSPath = ErlangPlugin.getDefault() .getStateLocation() .append(ErlangToolkit.createScannerModuleName(module) + suffix) .toOSString(); final File cacheFile = new File(cacheFileOSPath); cacheFile.delete(); } erlangEditor.resetAndCacheScannerAndParser(); }
@Override public void launch(final IEditorPart editor, final String mode) { ErlLogger.debug("** Launch :: " + editor.getTitle()); if (editor instanceof ErlangEditor) { final ErlangEditor erlangEditor = (ErlangEditor) editor; final IErlModule module = erlangEditor.getModule(); if (module != null) { final IErlProject project = ModelUtils.getProject(module); if (project != null) { try { doLaunch(mode, Lists.newArrayList(project)); } catch (final CoreException e) { final IWorkbench workbench = PlatformUI.getWorkbench(); final Shell shell = workbench.getActiveWorkbenchWindow().getShell(); MessageDialog.openError(shell, "Error", e.getStatus().getMessage()); } } } } }
/** * 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) { if (getTextEditor() instanceof ErlangEditor) { final ErlangEditor erlangEditor = (ErlangEditor) getTextEditor(); final IErlModule module = erlangEditor.getModule(); if (module != null) { final int offset1 = selection.getOffset(), 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(); if (e1 == e2) { return extendSelectionToWholeLines( document, new TextSelection(document, r1.getOffset(), r1.getLength())); } else if (e2 == null) { return extendSelectionToWholeLines( document, new TextSelection( document, r1.getOffset(), selection.getLength() + selection.getOffset() - r1.getOffset())); } else if (e2 instanceof ISourceReference) { final ISourceReference ref2 = (ISourceReference) e2; final ISourceRange r2 = ref2.getSourceRange(); return extendSelectionToWholeLines( document, new TextSelection( document, r1.getOffset(), r2.getOffset() - r1.getOffset() + r2.getLength())); } } } catch (final ErlModelException e) { } } } return extendSelectionToWholeLines(document, selection); }