Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 17 files changed
  • 0 commit comments
  • 1 contributor
Showing with 667 additions and 770 deletions.
  1. +19 −3 org.erlide.backend/src/org/erlide/backend/console/BackendShell.java
  2. +4 −0 org.erlide.model/src/org/erlide/model/internal/root/ErlModel.java
  3. +2 −0  org.erlide.runtime.api/src/org/erlide/runtime/shell/IBackendShell.java
  4. +10 −16 org.erlide.ui/plugin.xml
  5. +0 −9 org.erlide.ui/src/org/erlide/ui/console/ConsolePageParticipant.java
  6. +23 −3 org.erlide.ui/src/org/erlide/ui/console/ErlConsoleManager.java
  7. +21 −18 org.erlide.ui/src/org/erlide/ui/console/ErlangConsole.java
  8. +17 −2 org.erlide.ui/src/org/erlide/ui/console/ErlangConsolePage.java
  9. +13 −0 org.erlide.ui/src/org/erlide/ui/console/IErlangConsole.java
  10. +7 −0 org.erlide.ui/src/org/erlide/ui/console/IErlangConsolePage.java
  11. +349 −1 org.erlide.ui/src/org/erlide/ui/editors/erl/AbstractErlangEditor.java
  12. +3 −0  org.erlide.ui/src/org/erlide/ui/editors/erl/ConstructedErlangEditorMessages.properties
  13. +12 −329 org.erlide.ui/src/org/erlide/ui/editors/erl/ErlangEditor.java
  14. +1 −0  org.erlide.ui/src/org/erlide/ui/editors/erl/IErlangEditorActionDefinitionIds.java
  15. +156 −23 org.erlide.ui/src/org/erlide/ui/editors/erl/actions/SendToConsoleAction.java
  16. +22 −351 org.erlide.ui/src/org/erlide/ui/editors/scratchpad/ErlangScratchPad.java
  17. +8 −15 org.erlide.ui/src/org/erlide/ui/internal/ErlideUIPlugin.java
View
22 org.erlide.backend/src/org/erlide/backend/console/BackendShell.java
@@ -27,6 +27,7 @@
import com.ericsson.otp.erlang.OtpErlangPid;
import com.ericsson.otp.erlang.OtpErlangString;
import com.ericsson.otp.erlang.OtpErlangTuple;
+import com.google.common.collect.Lists;
public class BackendShell implements IBackendShell {
@@ -221,10 +222,12 @@ public void removeListener(final BackendShellListener listener) {
}
private void notifyListeners() {
+ final List<BackendShellListener> listenersCopy;
synchronized (listeners) {
- for (final BackendShellListener listener : listeners) {
- listener.changed(this);
- }
+ listenersCopy = Lists.newArrayList(listeners);
+ }
+ for (final BackendShellListener listener : listenersCopy) {
+ listener.changed(this);
}
}
@@ -250,4 +253,17 @@ public String getText() {
return res.toString();
}
+ @Override
+ public String[] getLastMessages(final int nMessages) {
+ final List<String> result = Lists.newArrayListWithCapacity(nMessages);
+ synchronized (requests) {
+ final int size = requests.size();
+ final int n = Math.min(nMessages, size);
+ for (int i = size - n; i < size; ++i) {
+ result.add(requests.get(i).getMessage());
+ }
+ }
+ return result.toArray(new String[nMessages]);
+ }
+
}
View
4 org.erlide.model/src/org/erlide/model/internal/root/ErlModel.java
@@ -351,6 +351,10 @@ public IErlModule findModule(final IFile file) {
@Override
public IErlProject findProject(final IProject project) {
+ try {
+ open(null);
+ } catch (final ErlModelException e) {
+ }
final IErlElement e = findElement(project);
if (e == null) {
return null;
View
2  org.erlide.runtime.api/src/org/erlide/runtime/shell/IBackendShell.java
@@ -47,4 +47,6 @@
String getText();
+ public abstract String[] getLastMessages(final int nMessages);
+
}
View
26 org.erlide.ui/plugin.xml
@@ -553,6 +553,11 @@
name="Send to console">
</command>
<command
+ description="Send to console with result"
+ id="org.erlide.ui.actions.sendToConsoleWithResult"
+ name="Send to console">
+ </command>
+ <command
categoryId="org.eclipse.search.ui.category.search"
description="Definitions in Workspace"
id="org.erlide.ui.search.implementors.in.workspace"
@@ -860,6 +865,11 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+Enter"/>
<key
+ commandId="org.erlide.ui.actions.sendToConsoleWithResult"
+ contextId="org.erlide.ui.erlangEditorScope"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+M2+Enter"/>
+ <key
commandId="org.erlide.ui.actions.show.outline"
contextId="org.erlide.ui.erlangEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
@@ -1518,22 +1528,6 @@
</wizard>
</extension>
<extension
- point="org.eclipse.ui.navigator.linkHelper">
- <linkHelper
- class="org.erlide.ui.actions.ErlangLinkHelperAction"
- id="org.erlide.ui.navigator.linkHelper">
- <selectionEnablement>
- <or>
- <adapt
- type="org.eclipse.core.resources.IFile">
- </adapt>
- </or></selectionEnablement>
- <editorInputEnablement>
- <instanceof value="org.eclipse.ui.IFileEditorInput"/>
- </editorInputEnablement>
- </linkHelper>
- </extension>
- <extension
point="org.eclipse.ui.decorators">
<decorator
adaptable="true"
View
9 org.erlide.ui/src/org/erlide/ui/console/ConsolePageParticipant.java
@@ -50,7 +50,6 @@
import org.erlide.ui.console.actions.ConsoleTerminateAction;
import org.erlide.ui.console.actions.ShowStandardOutAction;
import org.erlide.ui.console.actions.ShowWhenContentChangesAction;
-import org.erlide.ui.internal.ErlideUIPlugin;
import org.erlide.ui.util.DisplayUtils;
/**
@@ -123,10 +122,6 @@ public void init(final IPageBookViewPage page, final IConsole console) {
// create handler and submissions for EOF
fEOFHandler = new EOFHandler();
-
- // set global ref, used by the SendToConsole action
- // FIXME global is bad, use project's page (keyed by backend?)
- ErlideUIPlugin.getDefault().setConsolePage((ErlangConsolePage) fPage);
}
@Override
@@ -152,9 +147,6 @@ public void dispose() {
fStdOut = null;
}
fConsole = null;
- if (ErlideUIPlugin.getDefault().getConsolePage() == fPage) {
- ErlideUIPlugin.getDefault().setConsolePage(null);
- }
}
/**
@@ -246,7 +238,6 @@ public void activated() {
fActivatedContext = contextService.activateContext(fContextId);
fActivatedHandler = handlerService.activateHandler(
"org.eclipse.debug.ui.commands.eof", fEOFHandler); //$NON-NLS-1$
- ErlideUIPlugin.getDefault().setConsolePage((ErlangConsolePage) fPage);
}
@Override
View
26 org.erlide.ui/src/org/erlide/ui/console/ErlConsoleManager.java
@@ -1,6 +1,5 @@
package org.erlide.ui.console;
-import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.resources.IProject;
@@ -14,12 +13,16 @@
import org.erlide.util.ErlLogger;
import org.erlide.util.IDisposable;
+import com.google.common.collect.Maps;
+
public class ErlConsoleManager implements IDisposable, IBackendListener {
- private final Map<IBackend, IConsole> consoles;
+ private final Map<IBackend, IErlangConsole> consoles;
+ private final Map<IErlangConsole, IErlangConsolePage> pages;
private final IConsoleManager conMan;
public ErlConsoleManager() {
- consoles = new HashMap<IBackend, IConsole>();
+ consoles = Maps.newHashMap();
+ pages = Maps.newHashMap();
final ConsolePlugin consolePlugin = ConsolePlugin.getDefault();
conMan = consolePlugin.getConsoleManager();
@@ -52,6 +55,23 @@ public void runtimeRemoved(final IBackend b) {
conMan.removeConsoles(new IConsole[] { console });
}
+ public void addPage(final IErlangConsole console,
+ final IErlangConsolePage page) {
+ pages.put(console, page);
+ }
+
+ public void removePage(final IErlangConsole console) {
+ pages.remove(console);
+ }
+
+ public IErlangConsolePage getPage(final IErlangConsole console) {
+ return pages.get(console);
+ }
+
+ public IErlangConsole getConsole(final IBackend backend) {
+ return consoles.get(backend);
+ }
+
@Override
public void dispose() {
BackendCore.getBackendManager().removeBackendListener(this);
View
39 org.erlide.ui/src/org/erlide/ui/console/ErlangConsole.java
@@ -13,18 +13,15 @@
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.IConsoleConstants;
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.console.TextConsole;
import org.eclipse.ui.part.IPageBookViewPage;
import org.erlide.backend.IBackend;
import org.erlide.runtime.shell.IBackendShell;
+import org.erlide.ui.internal.ErlideUIPlugin;
-public class ErlangConsole extends TextConsole {
+public class ErlangConsole extends TextConsole implements IErlangConsole {
private final IBackendShell shell;
protected ListenerList consoleListeners;
protected ErlangConsolePartitioner partitioner;
@@ -45,13 +42,19 @@ public ErlangConsole(final IBackend backend) {
@Override
public IPageBookViewPage createPage(final IConsoleView view) {
- return new ErlangConsolePage(view, this, backend.getRpcSite());
+ final ErlangConsolePage erlangConsolePage = new ErlangConsolePage(view,
+ this, backend.getRpcSite());
+ ErlideUIPlugin.getDefault().getErlConsoleManager()
+ .addPage(this, erlangConsolePage);
+ return erlangConsolePage;
}
+ @Override
public IBackend getBackend() {
return backend;
}
+ @Override
public IBackendShell getShell() {
return shell;
}
@@ -80,18 +83,18 @@ public void removePropertyChangeListener(
final IPropertyChangeListener listener) {
}
- public void show() {
- final IWorkbenchPage page = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- final String id = IConsoleConstants.ID_CONSOLE_VIEW;
- IConsoleView view;
- try {
- view = (IConsoleView) page.showView(id);
- view.display(this);
- } catch (final PartInitException e) {
- e.printStackTrace();
- }
- }
+ // public void show() {
+ // final IWorkbenchPage page = PlatformUI.getWorkbench()
+ // .getActiveWorkbenchWindow().getActivePage();
+ // final String id = IConsoleConstants.ID_CONSOLE_VIEW;
+ // IConsoleView view;
+ // try {
+ // view = (IConsoleView) page.showView(id);
+ // view.display(this);
+ // } catch (final PartInitException e) {
+ // e.printStackTrace();
+ // }
+ // }
@Override
protected IConsoleDocumentPartitioner getPartitioner() {
View
19 org.erlide.ui/src/org/erlide/ui/console/ErlangConsolePage.java
@@ -75,13 +75,14 @@
import org.erlide.runtime.ParserException;
import org.erlide.runtime.RuntimeHelper;
import org.erlide.runtime.shell.IBackendShell;
+import org.erlide.ui.internal.ErlideUIPlugin;
import com.ericsson.otp.erlang.OtpErlangList;
import com.ericsson.otp.erlang.OtpErlangObject;
@SuppressWarnings("restriction")
public class ErlangConsolePage extends Page implements IAdaptable,
- IPropertyChangeListener {
+ IPropertyChangeListener, IErlangConsolePage {
public static final String ID = "org.erlide.ui.views.console";
Color bgColor_Ok;
@@ -141,6 +142,7 @@ public void dispose() {
bgColor_Err.dispose();
bgColor_Ok.dispose();
}
+ ErlideUIPlugin.getDefault().getErlConsoleManager().removePage(fConsole);
super.dispose();
}
@@ -167,6 +169,7 @@ protected void sendInput() {
consoleInput.setText("");
}
+ @Override
public void input(final String data) {
final String data2 = data.trim() + "\n";
shell.input(data2);
@@ -315,7 +318,7 @@ public void documentChanged(final DocumentEvent event) {
consoleOutputViewer.revealRange(end, 0);
}
};
- fDoc.addDocumentListener(documentListener);
+ addDocumentListener(documentListener);
final String id = "#ContextMenu"; //$NON-NLS-1$
// if (getConsole().getType() != null) {
@@ -524,4 +527,16 @@ protected void updateAction(final String actionId) {
((IUpdate) action).update();
}
}
+
+ public void addDocumentListener(final IDocumentListener documentListener) {
+ fDoc.addDocumentListener(documentListener);
+ }
+
+ public void removeDocumentListener(final IDocumentListener documentListener) {
+ fDoc.removeDocumentListener(documentListener);
+ }
+
+ public IBackendShell getShell() {
+ return shell;
+ }
}
View
13 org.erlide.ui/src/org/erlide/ui/console/IErlangConsole.java
@@ -0,0 +1,13 @@
+package org.erlide.ui.console;
+
+import org.eclipse.ui.console.IConsole;
+import org.erlide.backend.IBackend;
+import org.erlide.runtime.shell.IBackendShell;
+
+public interface IErlangConsole extends IConsole {
+
+ public abstract IBackendShell getShell();
+
+ public abstract IBackend getBackend();
+
+}
View
7 org.erlide.ui/src/org/erlide/ui/console/IErlangConsolePage.java
@@ -0,0 +1,7 @@
+package org.erlide.ui.console;
+
+public interface IErlangConsolePage {
+
+ public abstract void input(final String data);
+
+}
View
350 org.erlide.ui/src/org/erlide/ui/editors/erl/AbstractErlangEditor.java
@@ -1,19 +1,51 @@
package org.erlide.ui.editors.erl;
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.ITextViewerExtension4;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.ContentAssistAction;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.ITextEditorExtension3;
+import org.eclipse.ui.texteditor.ResourceAction;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+import org.eclipse.ui.texteditor.TextEditorAction;
+import org.eclipse.ui.texteditor.TextOperationAction;
import org.erlide.model.erlang.ErlToken;
import org.erlide.model.erlang.IErlModule;
import org.erlide.model.erlang.IErlScanner;
import org.erlide.model.root.IErlElement;
import org.erlide.model.root.IErlProject;
+import org.erlide.ui.actions.OpenAction;
+import org.erlide.ui.editors.erl.actions.IndentAction;
+import org.erlide.ui.editors.erl.actions.SendToConsoleAction;
+import org.erlide.ui.editors.erl.actions.ToggleCommentAction;
+import org.erlide.ui.editors.erl.scanner.IErlangPartitions;
import org.erlide.ui.prefs.PreferenceConstants;
public abstract class AbstractErlangEditor extends TextEditor {
@@ -24,6 +56,13 @@
protected final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
/** The bracket inserter. */
private ErlangViewerBracketInserter fBracketInserter = null;
+ private SendToConsoleAction sendToConsole;
+ private SendToConsoleAction sendToConsoleWithResult;
+ private OpenAction openAction;
+ private IndentAction indentAction;
+ private ToggleCommentAction toggleCommentAction;
+ private InformationPresenter fInformationPresenter;
+ private IErlScanner erlScanner;
public abstract void reconcileNow();
@@ -35,7 +74,14 @@
public abstract IDocument getDocument();
- public abstract IErlScanner getScanner();
+ public IErlScanner getScanner() {
+ if (erlScanner == null) {
+ erlScanner = getNewScanner();
+ }
+ return erlScanner;
+ }
+
+ protected abstract IErlScanner getNewScanner();
@Override
protected void configureSourceViewerDecorationSupport(
@@ -97,4 +143,306 @@ public boolean validInput() {
protected abstract void addFoldingSupport(final ISourceViewer viewer);
+ protected void createCommonActions() {
+ indentAction = new IndentAction(
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "Indent.", this); //$NON-NLS-1$
+ indentAction
+ .setActionDefinitionId(IErlangEditorActionDefinitionIds.INDENT);
+ setAction("Indent", indentAction); //$NON-NLS-1$
+ markAsStateDependentAction("Indent", true); //$NON-NLS-1$
+ markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
+ PlatformUI.getWorkbench().getHelpSystem()
+ .setHelp(indentAction, IErlangHelpContextIds.INDENT_ACTION);
+ final Action action = new IndentAction(
+ ErlangEditorMessages.getBundleForConstructedKeys(), "Indent.",
+ this);
+ setAction("IndentOnTab", action);
+ markAsStateDependentAction("IndentOnTab", true);
+ markAsSelectionDependentAction("IndentOnTab", true);
+
+ toggleCommentAction = new ToggleCommentAction(
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "ToggleComment.", this);
+ toggleCommentAction
+ .setActionDefinitionId(IErlangEditorActionDefinitionIds.TOGGLE_COMMENT);
+ setAction("ToggleComment", toggleCommentAction);
+ markAsStateDependentAction("ToggleComment", true);
+ markAsSelectionDependentAction("ToggleComment", true);
+ PlatformUI
+ .getWorkbench()
+ .getHelpSystem()
+ .setHelp(toggleCommentAction,
+ IErlangHelpContextIds.TOGGLE_COMMENT_ACTION);
+
+ openAction = new OpenAction(this);
+ openAction
+ .setActionDefinitionId(IErlangEditorActionDefinitionIds.OPEN_EDITOR);
+ setAction(IErlangEditorActionDefinitionIds.OPEN, openAction);
+
+ sendToConsole = new SendToConsoleAction(getSite(),
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "SendToConsole.", this, false, getProject());
+ sendToConsole
+ .setActionDefinitionId(IErlangEditorActionDefinitionIds.SEND_TO_CONSOLE);
+ setAction("SendToConsole", sendToConsole);
+ markAsStateDependentAction("sendToConsole", true);
+ markAsSelectionDependentAction("sendToConsole", true);
+
+ sendToConsoleWithResult = new SendToConsoleAction(getSite(),
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "SendToConsoleWithResult.", this, true, getProject());
+ sendToConsoleWithResult
+ .setActionDefinitionId(IErlangEditorActionDefinitionIds.SEND_TO_CONSOLE_WITH_RESULT);
+ setAction("SendToConsoleWithResult", sendToConsoleWithResult);
+ markAsStateDependentAction("sendToConsoleWithResult", true);
+ markAsSelectionDependentAction("sendToConsoleWithResult", true);
+
+ final Action act = new ContentAssistAction(
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "ContentAssistProposal.", this);
+ act.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ setAction("ContentAssistProposal", act);
+ markAsStateDependentAction("ContentAssistProposal", true);
+
+ ResourceAction resAction = new TextOperationAction(
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "ShowEDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
+ resAction = new InformationDispatchAction(
+ ErlangEditorMessages.getBundleForConstructedKeys(),
+ "ShowEDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
+ resAction
+ .setActionDefinitionId(IErlangEditorActionDefinitionIds.SHOW_EDOC);
+ setAction("ShowEDoc", resAction); //$NON-NLS-1$
+ PlatformUI.getWorkbench().getHelpSystem()
+ .setHelp(resAction, IErlangHelpContextIds.SHOW_EDOC_ACTION);
+ }
+
+ protected void addCommonActions(final IMenuManager menu) {
+ menu.prependToGroup(IContextMenuConstants.GROUP_OPEN,
+ toggleCommentAction);
+ menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, indentAction);
+ // TODO disabled until erl_tidy doean't destroy formatting
+ // menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, cleanUpAction);
+ menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, openAction);
+ menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, sendToConsole);
+ menu.prependToGroup(IContextMenuConstants.GROUP_OPEN,
+ sendToConsoleWithResult);
+ }
+
+ /**
+ * This action behaves in two different ways: If there is no current text
+ * hover, the javadoc is displayed using information presenter. If there is
+ * a current text hover, it is converted into a information presenter in
+ * order to make it sticky.
+ */
+ class InformationDispatchAction extends TextEditorAction {
+
+ /** The wrapped text operation action. */
+ private final TextOperationAction fTextOperationAction;
+
+ /**
+ * Creates a dispatch action.
+ *
+ * @param resourceBundle
+ * the resource bundle
+ * @param prefix
+ * the prefix
+ * @param textOperationAction
+ * the text operation action
+ */
+ public InformationDispatchAction(final ResourceBundle resourceBundle,
+ final String prefix,
+ final TextOperationAction textOperationAction) {
+ super(resourceBundle, prefix, AbstractErlangEditor.this);
+ if (textOperationAction == null) {
+ throw new IllegalArgumentException();
+ }
+ fTextOperationAction = textOperationAction;
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void run() {
+
+ /**
+ * Information provider used to present the information.
+ *
+ * @since 3.0
+ */
+ class InformationProvider implements IInformationProvider,
+ IInformationProviderExtension,
+ IInformationProviderExtension2 {
+
+ private final IRegion fHoverRegion;
+
+ private final String fHoverInfo;
+
+ private final IInformationControlCreator fControlCreator;
+
+ InformationProvider(final IRegion hoverRegion,
+ final String hoverInfo,
+ final IInformationControlCreator controlCreator) {
+ fHoverRegion = hoverRegion;
+ fHoverInfo = hoverInfo;
+ fControlCreator = controlCreator;
+ }
+
+ /*
+ * @seeorg.eclipse.jface.text.information.IInformationProvider#
+ * getSubject(org.eclipse.jface.text.ITextViewer, int)
+ */
+ @Override
+ public IRegion getSubject(final ITextViewer textViewer,
+ final int invocationOffset) {
+ return fHoverRegion;
+ }
+
+ @Override
+ public Object getInformation2(final ITextViewer textViewer,
+ final IRegion subject) {
+ return fHoverInfo;
+ }
+
+ /*
+ * @see
+ * org.eclipse.jface.text.information.IInformationProviderExtension2
+ * #getInformationPresenterControlCreator()
+ *
+ * @since 3.0
+ */
+ @Override
+ public IInformationControlCreator getInformationPresenterControlCreator() {
+ return fControlCreator;
+ }
+
+ @Override
+ @Deprecated
+ public String getInformation(final ITextViewer textViewer,
+ final IRegion subject) {
+ return null;
+ }
+ }
+
+ final ISourceViewer sourceViewer = getSourceViewer();
+ if (sourceViewer == null) {
+ fTextOperationAction.run();
+ return;
+ }
+
+ if (sourceViewer instanceof ITextViewerExtension4) {
+ final ITextViewerExtension4 extension4 = (ITextViewerExtension4) sourceViewer;
+ if (extension4.moveFocusToWidgetToken()) {
+ return;
+ }
+ }
+
+ if (!(sourceViewer instanceof ITextViewerExtension2)) {
+ fTextOperationAction.run();
+ return;
+ }
+
+ final ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer;
+
+ // does a text hover exist?
+ final ITextHover textHover = textViewerExtension2
+ .getCurrentTextHover();
+ if (textHover == null) {
+ // TODO this crashes... why?
+ // fTextOperationAction.run();
+ return;
+ }
+
+ final Point hoverEventLocation = textViewerExtension2
+ .getHoverEventLocation();
+ final int offset = computeOffsetAtLocation(sourceViewer,
+ hoverEventLocation.x, hoverEventLocation.y);
+ if (offset == -1) {
+ fTextOperationAction.run();
+ return;
+ }
+
+ try {
+ // get the text hover content
+ final String contentType = TextUtilities.getContentType(
+ sourceViewer.getDocument(),
+ IErlangPartitions.ERLANG_PARTITIONING, offset, true);
+
+ final IRegion hoverRegion = textHover.getHoverRegion(
+ sourceViewer, offset);
+ if (hoverRegion == null) {
+ return;
+ }
+
+ final String hoverInfo = "";
+ if (textHover instanceof ITextHoverExtension2) {
+ ((ITextHoverExtension2) textHover).getHoverInfo2(
+ sourceViewer, hoverRegion);
+ }
+
+ IInformationControlCreator controlCreator = null;
+ if (textHover instanceof IInformationProviderExtension2) {
+ controlCreator = ((IInformationProviderExtension2) textHover)
+ .getInformationPresenterControlCreator();
+ }
+
+ final IInformationProvider informationProvider = new InformationProvider(
+ hoverRegion, hoverInfo, controlCreator);
+
+ fInformationPresenter.setOffset(offset);
+ fInformationPresenter
+ .setDocumentPartitioning(IErlangPartitions.ERLANG_PARTITIONING);
+ fInformationPresenter.setInformationProvider(
+ informationProvider, contentType);
+ fInformationPresenter.showInformation();
+ } catch (final BadLocationException e) {
+ }
+ }
+
+ // modified version from TextViewer
+ private int computeOffsetAtLocation(final ITextViewer textViewer,
+ final int x, final int y) {
+
+ final StyledText styledText = textViewer.getTextWidget();
+ final IDocument document = textViewer.getDocument();
+
+ if (document == null) {
+ return -1;
+ }
+
+ try {
+ final int widgetLocation = styledText
+ .getOffsetAtLocation(new Point(x, y));
+ if (textViewer instanceof ITextViewerExtension5) {
+ final ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
+ return extension.widgetOffset2ModelOffset(widgetLocation);
+ }
+ final IRegion visibleRegion = textViewer.getVisibleRegion();
+ return widgetLocation + visibleRegion.getOffset();
+ } catch (final IllegalArgumentException e) {
+ return -1;
+ }
+
+ }
+ }
+
+ @Override
+ public void createPartControl(final Composite parent) {
+ super.createPartControl(parent);
+
+ final IInformationControlCreator informationControlCreator = getSourceViewerConfiguration()
+ .getInformationControlCreator(getSourceViewer());
+ fInformationPresenter = new InformationPresenter(
+ informationControlCreator);
+ // sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS
+ fInformationPresenter.setSizeConstraints(100, 12, true, true);
+ fInformationPresenter.install(getSourceViewer());
+ fInformationPresenter
+ .setDocumentPartitioning(getSourceViewerConfiguration()
+ .getConfiguredDocumentPartitioning(getSourceViewer()));
+ }
+
}
View
3  org.erlide.ui/src/org/erlide/ui/editors/erl/ConstructedErlangEditorMessages.properties
@@ -79,6 +79,9 @@ ShowEDoc.description=Shows the tooltip description for the element at the cursor
SendToConsole.label= Send To Console
SendToConsole.tooltip= Send the selected text to the console and evaluate it
SendToConsole.description= Send the selected text
+SendToConsoleWithResult.label= Send To Console with Result
+SendToConsoleWithResult.tooltip= Send the selected text to the console and evaluate it, insert the output in
+SendToConsoleWithResult.description= Send the selected text, get the result
ShowOutline.label= Quick Out&line
ShowOutline.tooltip= Shows the Quick Outline of Editor Input
View
341 org.erlide.ui/src/org/erlide/ui/editors/erl/ErlangEditor.java
@@ -12,37 +12,23 @@
package org.erlide.ui.editors.erl;
import java.util.Iterator;
-import java.util.ResourceBundle;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
-import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ISynchronizable;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension4;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.jface.text.information.IInformationProviderExtension2;
-import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.ICharacterPairMatcher;
@@ -82,13 +68,8 @@
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.ResourceAction;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.ui.views.properties.IPropertySource;
import org.erlide.core.ErlangPlugin;
@@ -106,15 +87,11 @@
import org.erlide.model.util.ModelUtils;
import org.erlide.ui.actions.CompositeActionGroup;
import org.erlide.ui.actions.ErlangSearchActionGroup;
-import org.erlide.ui.actions.OpenAction;
import org.erlide.ui.editors.erl.actions.CallHierarchyAction;
import org.erlide.ui.editors.erl.actions.CleanUpAction;
import org.erlide.ui.editors.erl.actions.ClearCacheAction;
import org.erlide.ui.editors.erl.actions.CompileAction;
-import org.erlide.ui.editors.erl.actions.IndentAction;
-import org.erlide.ui.editors.erl.actions.SendToConsoleAction;
import org.erlide.ui.editors.erl.actions.ShowOutlineAction;
-import org.erlide.ui.editors.erl.actions.ToggleCommentAction;
import org.erlide.ui.editors.erl.folding.IErlangFoldingStructureProvider;
import org.erlide.ui.editors.erl.folding.IErlangFoldingStructureProviderExtension;
import org.erlide.ui.editors.erl.hover.ErlangAnnotationIterator;
@@ -125,7 +102,6 @@
import org.erlide.ui.editors.erl.outline.IOutlineContentCreator;
import org.erlide.ui.editors.erl.outline.IOutlineSelectionHandler;
import org.erlide.ui.editors.erl.outline.ISortableContentOutlinePage;
-import org.erlide.ui.editors.erl.scanner.IErlangPartitions;
import org.erlide.ui.editors.erl.test.TestAction;
import org.erlide.ui.internal.ErlideUIPlugin;
import org.erlide.ui.prefs.PreferenceConstants;
@@ -150,28 +126,22 @@
private ColorManager colorManager;
private ErlangOutlinePage myOutlinePage;
private IPropertySource myPropertySource;
- ProjectionSupport fProjectionSupport;
- IErlangFoldingStructureProvider fProjectionModelUpdater;
- private OpenAction openAction;
- private IndentAction indentAction;
- private ToggleCommentAction toggleCommentAction;
+ private ProjectionSupport fProjectionSupport;
+ private IErlangFoldingStructureProvider fProjectionModelUpdater;
private TestAction testAction;
/** The selection changed listeners */
private EditorSelectionChangedListener fEditorSelectionChangedListener;
- private InformationPresenter fInformationPresenter;
private ShowOutlineAction fShowOutline;
private Object fSelection;
private final IPreferenceChangeListener fPreferenceChangeListener = new PreferenceChangeListener();
private ActionGroup fActionGroups;
private ActionGroup fContextMenuGroup;
private final ErlangEditorErrorTickUpdater fErlangEditorErrorTickUpdater;
- ToggleFoldingRunner fFoldingRunner;
+ private ToggleFoldingRunner fFoldingRunner;
private CompileAction compileAction;
private CleanUpAction cleanUpAction;
private ClearCacheAction clearCacheAction;
private CallHierarchyAction callhierarchy;
- // private final boolean initFinished = false;
- private SendToConsoleAction sendToConsole;
private IErlModule fModule = null;
final MarkOccurencesHandler markOccurencesHandler = new MarkOccurencesHandler(
@@ -179,7 +149,6 @@
new ActivationListener());
private String stateDirCached;
- private IErlScanner scanner;
/**
* Simple constructor
@@ -303,59 +272,12 @@ protected final boolean isActiveEditor() {
@Override
protected void createActions() {
super.createActions();
- // ActionGroup oeg, ovg, jsg;
ActionGroup esg;
- fActionGroups = new CompositeActionGroup(new ActionGroup[] {
- // oeg= new OpenEditorActionGroup(this),
- // ovg= new OpenViewActionGroup(this),
- esg = new ErlangSearchActionGroup(this) });
+ fActionGroups = new CompositeActionGroup(
+ new ActionGroup[] { esg = new ErlangSearchActionGroup(this) });
fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { esg });
- // openAction = new OpenAction(getSite(), getExternalModules(),
- // getExternalIncludes());
- openAction = new OpenAction(this);
- openAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.OPEN_EDITOR);
- setAction(IErlangEditorActionDefinitionIds.OPEN, openAction);
-
- sendToConsole = new SendToConsoleAction(getSite(),
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "SendToConsole.", this);
- sendToConsole
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.SEND_TO_CONSOLE);
- setAction("SendToConsole", sendToConsole);
- markAsStateDependentAction("sendToConsole", true);
- markAsSelectionDependentAction("sendToConsole", true);
-
- final Action act = new ContentAssistAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ContentAssistProposal.", this);
- act.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction("ContentAssistProposal", act);
- markAsStateDependentAction("ContentAssistProposal", true);
-
- ResourceAction resAction = new TextOperationAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ShowEDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
- resAction = new InformationDispatchAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ShowEDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
- resAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.SHOW_EDOC);
- setAction("ShowEDoc", resAction); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem()
- .setHelp(resAction, IErlangHelpContextIds.SHOW_EDOC_ACTION);
-
- indentAction = new IndentAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "Indent.", this); //$NON-NLS-1$
- indentAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.INDENT);
- setAction("Indent", indentAction); //$NON-NLS-1$
- markAsStateDependentAction("Indent", true); //$NON-NLS-1$
- markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem()
- .setHelp(indentAction, IErlangHelpContextIds.INDENT_ACTION);
+ createCommonActions();
compileAction = new CompileAction(getSite());
compileAction
@@ -388,27 +310,6 @@ protected void createActions() {
// IErlangHelpContextIds.INDENT_ACTION);
}
- final Action action = new IndentAction(
- ErlangEditorMessages.getBundleForConstructedKeys(), "Indent.",
- this);
- setAction("IndentOnTab", action);
- markAsStateDependentAction("IndentOnTab", true);
- markAsSelectionDependentAction("IndentOnTab", true);
-
- toggleCommentAction = new ToggleCommentAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ToggleComment.", this);
- toggleCommentAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.TOGGLE_COMMENT);
- setAction("ToggleComment", toggleCommentAction);
- markAsStateDependentAction("ToggleComment", true);
- markAsSelectionDependentAction("ToggleComment", true);
- PlatformUI
- .getWorkbench()
- .getHelpSystem()
- .setHelp(toggleCommentAction,
- IErlangHelpContextIds.TOGGLE_COMMENT_ACTION);
-
fShowOutline = new ShowOutlineAction(
ErlangEditorMessages.getBundleForConstructedKeys(),
"ShowOutline.", this);
@@ -463,13 +364,7 @@ protected void editorContextMenuAboutToShow(final IMenuManager menu) {
menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, callhierarchy);
menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, compileAction);
menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, fShowOutline);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN,
- toggleCommentAction);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, indentAction);
- // TODO disabled until erl_tidy doean't destroy formatting
- // menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, cleanUpAction);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, openAction);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, sendToConsole);
+ addCommonActions(menu);
final ActionContext context = new ActionContext(getSelectionProvider()
.getSelection());
fContextMenuGroup.setContext(context);
@@ -711,8 +606,8 @@ public IErlModule getModule() {
try {
fModule = ErlModelUtils.getModule(getEditorInput());
fModule.createScanner();
- scanner = fModule.getScanner();
- scanner.dispose();
+ final IErlScanner erlScanner = fModule.getScanner();
+ erlScanner.dispose();
} catch (final CoreException e) {
}
}
@@ -1114,18 +1009,6 @@ public void createPartControl(final Composite parent) {
final IEclipsePreferences node = ErlideUIPlugin.getPrefsNode();
node.addPreferenceChangeListener(fPreferenceChangeListener);
- final IInformationControlCreator informationControlCreator = getSourceViewerConfiguration()
- .getInformationControlCreator(getSourceViewer());
-
- fInformationPresenter = new InformationPresenter(
- informationControlCreator);
- // sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS
- fInformationPresenter.setSizeConstraints(100, 12, true, true);
- fInformationPresenter.install(getSourceViewer());
- fInformationPresenter
- .setDocumentPartitioning(getSourceViewerConfiguration()
- .getConfiguredDocumentPartitioning(getSourceViewer()));
-
PlatformUI.getWorkbench().addWindowListener(
markOccurencesHandler.fActivationListener);
@@ -1163,205 +1046,6 @@ protected boolean isActivePart() {
}
/**
- * This action behaves in two different ways: If there is no current text
- * hover, the javadoc is displayed using information presenter. If there is
- * a current text hover, it is converted into a information presenter in
- * order to make it sticky.
- */
- class InformationDispatchAction extends TextEditorAction {
-
- /** The wrapped text operation action. */
- private final TextOperationAction fTextOperationAction;
-
- /**
- * Creates a dispatch action.
- *
- * @param resourceBundle
- * the resource bundle
- * @param prefix
- * the prefix
- * @param textOperationAction
- * the text operation action
- */
- public InformationDispatchAction(final ResourceBundle resourceBundle,
- final String prefix,
- final TextOperationAction textOperationAction) {
- super(resourceBundle, prefix, ErlangEditor.this);
- if (textOperationAction == null) {
- throw new IllegalArgumentException();
- }
- fTextOperationAction = textOperationAction;
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- @SuppressWarnings("synthetic-access")
- @Override
- public void run() {
-
- /**
- * Information provider used to present the information.
- *
- * @since 3.0
- */
- class InformationProvider implements IInformationProvider,
- IInformationProviderExtension,
- IInformationProviderExtension2 {
-
- private final IRegion fHoverRegion;
-
- private final String fHoverInfo;
-
- private final IInformationControlCreator fControlCreator;
-
- InformationProvider(final IRegion hoverRegion,
- final String hoverInfo,
- final IInformationControlCreator controlCreator) {
- fHoverRegion = hoverRegion;
- fHoverInfo = hoverInfo;
- fControlCreator = controlCreator;
- }
-
- /*
- * @seeorg.eclipse.jface.text.information.IInformationProvider#
- * getSubject(org.eclipse.jface.text.ITextViewer, int)
- */
- @Override
- public IRegion getSubject(final ITextViewer textViewer,
- final int invocationOffset) {
- return fHoverRegion;
- }
-
- @Override
- public Object getInformation2(final ITextViewer textViewer,
- final IRegion subject) {
- return fHoverInfo;
- }
-
- /*
- * @see
- * org.eclipse.jface.text.information.IInformationProviderExtension2
- * #getInformationPresenterControlCreator()
- *
- * @since 3.0
- */
- @Override
- public IInformationControlCreator getInformationPresenterControlCreator() {
- return fControlCreator;
- }
-
- @Override
- @Deprecated
- public String getInformation(final ITextViewer textViewer,
- final IRegion subject) {
- return null;
- }
- }
-
- final ISourceViewer sourceViewer = getSourceViewer();
- if (sourceViewer == null) {
- fTextOperationAction.run();
- return;
- }
-
- if (sourceViewer instanceof ITextViewerExtension4) {
- final ITextViewerExtension4 extension4 = (ITextViewerExtension4) sourceViewer;
- if (extension4.moveFocusToWidgetToken()) {
- return;
- }
- }
-
- if (!(sourceViewer instanceof ITextViewerExtension2)) {
- fTextOperationAction.run();
- return;
- }
-
- final ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer;
-
- // does a text hover exist?
- final ITextHover textHover = textViewerExtension2
- .getCurrentTextHover();
- if (textHover == null) {
- // TODO this crashes... why?
- // fTextOperationAction.run();
- return;
- }
-
- final Point hoverEventLocation = textViewerExtension2
- .getHoverEventLocation();
- final int offset = computeOffsetAtLocation(sourceViewer,
- hoverEventLocation.x, hoverEventLocation.y);
- if (offset == -1) {
- fTextOperationAction.run();
- return;
- }
-
- try {
- // get the text hover content
- final String contentType = TextUtilities.getContentType(
- sourceViewer.getDocument(),
- IErlangPartitions.ERLANG_PARTITIONING, offset, true);
-
- final IRegion hoverRegion = textHover.getHoverRegion(
- sourceViewer, offset);
- if (hoverRegion == null) {
- return;
- }
-
- final String hoverInfo = "";
- if (textHover instanceof ITextHoverExtension2) {
- ((ITextHoverExtension2) textHover).getHoverInfo2(
- sourceViewer, hoverRegion);
- }
-
- IInformationControlCreator controlCreator = null;
- if (textHover instanceof IInformationProviderExtension2) {
- controlCreator = ((IInformationProviderExtension2) textHover)
- .getInformationPresenterControlCreator();
- }
-
- final IInformationProvider informationProvider = new InformationProvider(
- hoverRegion, hoverInfo, controlCreator);
-
- fInformationPresenter.setOffset(offset);
- fInformationPresenter
- .setDocumentPartitioning(IErlangPartitions.ERLANG_PARTITIONING);
- fInformationPresenter.setInformationProvider(
- informationProvider, contentType);
- fInformationPresenter.showInformation();
- } catch (final BadLocationException e) {
- }
- }
-
- // modified version from TextViewer
- private int computeOffsetAtLocation(final ITextViewer textViewer,
- final int x, final int y) {
-
- final StyledText styledText = textViewer.getTextWidget();
- final IDocument document = textViewer.getDocument();
-
- if (document == null) {
- return -1;
- }
-
- try {
- final int widgetLocation = styledText
- .getOffsetAtLocation(new Point(x, y));
- if (textViewer instanceof ITextViewerExtension5) {
- final ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
- return extension.widgetOffset2ModelOffset(widgetLocation);
- }
- final IRegion visibleRegion = textViewer.getVisibleRegion();
- return widgetLocation + visibleRegion.getOffset();
- } catch (final IllegalArgumentException e) {
- return -1;
- }
-
- }
- }
-
- /**
* Returns the annotation closest to the given range respecting the given
* direction. If an annotation is found, the annotations current position is
* copied into the provided annotation position.
@@ -1601,8 +1285,7 @@ public void resetAndCacheScannerAndParser() {
resetReconciler();
try {
module.createScanner();
- scanner = module.getScanner();
- scanner.dispose();
+ module.getScanner().dispose();
module.resetAndCacheScannerAndParser(getDocument().get());
} catch (final ErlModelException e) {
ErlLogger.error(e);
@@ -1885,8 +1568,8 @@ String getStateDir() {
}
@Override
- public IErlScanner getScanner() {
- return scanner;
+ protected IErlScanner getNewScanner() {
+ return getModule().getScanner();
}
/**
View
1  org.erlide.ui/src/org/erlide/ui/editors/erl/IErlangEditorActionDefinitionIds.java
@@ -33,6 +33,7 @@
public static final String COMPILE = "org.erlide.ui.actions.compile";
public static final String CALLHIERARCHY = "org.erlide.ui.actions.callhierarchy";
public static final String SEND_TO_CONSOLE = "org.erlide.ui.actions.sendToConsole";
+ public static final String SEND_TO_CONSOLE_WITH_RESULT = "org.erlide.ui.actions.sendToConsoleWithResult";
public static final String CLEAN_UP = "org.erlide.ui.actions.cleanUp";
}
View
179 org.erlide.ui/src/org/erlide/ui/editors/erl/actions/SendToConsoleAction.java
@@ -2,53 +2,186 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.Set;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension4;
import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.texteditor.ITextEditor;
+import org.erlide.backend.BackendCore;
+import org.erlide.backend.IBackend;
+import org.erlide.backend.IBackendManager;
+import org.erlide.model.root.IErlProject;
+import org.erlide.model.util.PluginUtils;
+import org.erlide.runtime.shell.BackendShellListener;
+import org.erlide.runtime.shell.IBackendShell;
import org.erlide.ui.actions.SelectionDispatchAction;
-import org.erlide.ui.console.ErlangConsolePage;
+import org.erlide.ui.console.ErlConsoleManager;
+import org.erlide.ui.console.IErlangConsole;
+import org.erlide.ui.console.IErlangConsolePage;
import org.erlide.ui.internal.ErlideUIPlugin;
+import org.erlide.util.ErlLogger;
public class SendToConsoleAction extends SelectionDispatchAction {
- private final ITextEditor fEditor;
+ private final class ConsoleBackendShellListener implements
+ BackendShellListener {
+
+ private int offset;
+ private int counter;
+
+ public ConsoleBackendShellListener() {
+ offset = 0;
+ counter = 0;
+ }
+
+ public void setup(final int offset) {
+ this.offset = offset;
+ counter = 0;
+ }
+
+ @Override
+ public void changed(final IBackendShell shell) {
+ if (shell == null) {
+ return;
+ }
+ counter++;
+ if (counter != 2) {
+ return;
+ }
+ final String[] messages = shell.getLastMessages(1);
+ if (messages.length == 0) {
+ return;
+ }
+ addMessage(offset, messages[0]);
+ }
+ }
+
+ private final ITextEditor editor;
+ private final boolean getOutput;
+ private final ConsoleBackendShellListener consoleBackendShellListener;
+ IErlProject project;
@Override
public void run(ITextSelection selection) {
- final ErlangConsolePage p = ErlideUIPlugin.getDefault()
- .getConsolePage();
- // make sure we have a console page to send it to
- if (p != null) {
- // if selection is empty, grab the whole line
- if (selection.getLength() == 0) { // don't use isEmpty()!
- selection = ErlangTextEditorAction.extendSelectionToWholeLines(
- fEditor.getDocumentProvider().getDocument(
- fEditor.getEditorInput()), selection);
+ final IBackendManager backendManager = BackendCore.getBackendManager();
+ final Set<IBackend> executionBackends = backendManager
+ .getExecutionBackends(project.getWorkspaceProject());
+ IErlangConsole console = null;
+ final ErlConsoleManager erlConsoleManager = ErlideUIPlugin.getDefault()
+ .getErlConsoleManager();
+ for (final IBackend backend : executionBackends) {
+ console = erlConsoleManager.getConsole(backend);
+ if (console != null) {
+ break;
}
- // try to make the text a full erlang expression, ending with dot
- String text = selection.getText().trim();
- if (text.endsWith(",") || text.endsWith(";")) { //$NON-NLS-1$ //$NON-NLS-2$
- text = text.substring(0, text.length() - 1);
+ }
+ if (console == null) {
+ final String message = "There is no runtime launched for this backend. Please start a runtime to send commands to.";
+ ErrorDialog
+ .openError(getShell(), "No runtime", message, PluginUtils
+ .makeStatus(new Exception("No runtime started")));
+
+ return;
+ }
+ // make sure we have a console page to send it to
+ final IErlangConsolePage consolePage = ErlideUIPlugin.getDefault()
+ .getErlConsoleManager().getPage(console);
+ console.getShell().removeListener(consoleBackendShellListener);
+ // if selection is empty, grab the whole line
+ selection = getLineSelection(selection, false);
+ // try to make the text a full erlang expression, ending with dot
+ String text = selection.getText().trim();
+ if (text.endsWith(",") || text.endsWith(";")) { //$NON-NLS-1$ //$NON-NLS-2$
+ text = text.substring(0, text.length() - 1);
+ }
+ if (!text.endsWith(".")) { //$NON-NLS-1$
+ text += "."; //$NON-NLS-1$
+ }
+ text += "\n"; //$NON-NLS-1$
+ // send it off to the console
+ if (getOutput) {
+ consoleBackendShellListener.setup(getLineSelection(selection, true)
+ .getOffset());
+ console.getShell().addListener(consoleBackendShellListener);
+ }
+ consolePage.input(text);
+ super.run(selection);
+ }
+
+ public void addMessage(final int offset, final String message) {
+ final IDocument document = editor.getDocumentProvider().getDocument(
+ editor.getEditorInput());
+ try {
+ final String delimiter = document.getLineDelimiter(document
+ .getLineOfOffset(offset - 1));
+ String nl = "";
+ if (delimiter == null) {
+ if (document instanceof IDocumentExtension4) {
+ final IDocumentExtension4 documentExtension4 = (IDocumentExtension4) document;
+ nl = documentExtension4.getDefaultLineDelimiter();
+ } else {
+ final String[] delimiters = document
+ .getLegalLineDelimiters();
+ nl = delimiters[0];
+ }
}
- if (!text.endsWith(".")) { //$NON-NLS-1$
- text += "."; //$NON-NLS-1$
+ final Display display = ErlideUIPlugin.getStandardDisplay();
+ final String addMessage = nl + message;
+ display.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ document.replace(offset, 0, addMessage);
+ } catch (final BadLocationException e) {
+ }
+ }
+ });
+ ErlLogger.debug("message %s", message);
+ } catch (final BadLocationException e) {
+ }
+ }
+
+ protected ITextSelection getLineSelection(ITextSelection selection,
+ final boolean beginningOfNextLine) {
+ final IDocument document = editor.getDocumentProvider().getDocument(
+ editor.getEditorInput());
+ if (selection.getLength() == 0) { // don't use isEmpty()!
+ selection = ErlangTextEditorAction.extendSelectionToWholeLines(
+ document, selection);
+ }
+ if (beginningOfNextLine) {
+ final int endLine = selection.getEndLine();
+ int offset;
+ try {
+ offset = document.getLineOffset(endLine)
+ + document.getLineLength(endLine);
+ selection = new TextSelection(offset, 0);
+ } catch (final BadLocationException e) {
+ offset = document.getLength();
}
- text += "\n"; //$NON-NLS-1$
- // send it off to the console
- p.input(text);
}
- super.run(selection);
+ return selection;
}
public SendToConsoleAction(final IWorkbenchSite site,
final ResourceBundle bundle, final String prefix,
- final ITextEditor editor) {
+ final ITextEditor editor, final boolean getOutput,
+ final IErlProject project) {
super(site);
+ this.getOutput = getOutput;
+ this.project = project;
setText(getString(bundle, prefix + "label")); //$NON-NLS-1$
setToolTipText(getString(bundle, prefix + "tooltip")); //$NON-NLS-1$
setDescription(getString(bundle, prefix + "description")); //$NON-NLS-1$
- fEditor = editor;
+ this.editor = editor;
+ consoleBackendShellListener = new ConsoleBackendShellListener();
}
protected static String getString(final ResourceBundle bundle,
View
373 org.erlide.ui/src/org/erlide/ui/editors/scratchpad/ErlangScratchPad.java
@@ -1,50 +1,23 @@
package org.erlide.ui.editors.scratchpad;
-import java.util.ResourceBundle;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextHoverExtension2;
-import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension4;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.jface.text.information.IInformationProviderExtension2;
-import org.eclipse.jface.text.information.InformationPresenter;
import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.search.ui.IContextMenuConstants;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.ISaveablePart2;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.ui.texteditor.ContentAssistAction;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.ResourceAction;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.ui.texteditor.TextOperationAction;
import org.erlide.model.erlang.ErlToken;
import org.erlide.model.erlang.IErlModule;
import org.erlide.model.erlang.IErlScanner;
@@ -53,18 +26,10 @@
import org.erlide.model.root.IErlProject;
import org.erlide.ui.actions.CompositeActionGroup;
import org.erlide.ui.actions.ErlangSearchActionGroup;
-import org.erlide.ui.actions.OpenAction;
import org.erlide.ui.editors.erl.AbstractErlangEditor;
import org.erlide.ui.editors.erl.ColorManager;
-import org.erlide.ui.editors.erl.ErlangEditorMessages;
import org.erlide.ui.editors.erl.ErlangSourceViewerConfiguration;
-import org.erlide.ui.editors.erl.IErlangEditorActionDefinitionIds;
-import org.erlide.ui.editors.erl.IErlangHelpContextIds;
-import org.erlide.ui.editors.erl.actions.IndentAction;
-import org.erlide.ui.editors.erl.actions.SendToConsoleAction;
-import org.erlide.ui.editors.erl.actions.ToggleCommentAction;
import org.erlide.ui.editors.erl.folding.IErlangFoldingStructureProvider;
-import org.erlide.ui.editors.erl.scanner.IErlangPartitions;
import org.erlide.ui.internal.ErlideUIPlugin;
import org.erlide.util.ErlLogger;
import org.erlide.util.Util;
@@ -73,15 +38,9 @@
ISaveablePart2 {
private ColorManager colorManager;
- private InformationPresenter fInformationPresenter;
private IErlangFoldingStructureProvider fProjectionModelUpdater;
private CompositeActionGroup fActionGroups;
private CompositeActionGroup fContextMenuGroup;
- private OpenAction openAction;
- private SendToConsoleAction sendToConsole;
- private IndentAction indentAction;
- private ToggleCommentAction toggleCommentAction;
- private IErlScanner erlScanner = null;
/**
* Simple constructor
@@ -161,77 +120,17 @@ public void createPartControl(final Composite parent) {
super.createPartControl(parent);
setupBracketInserter();
-
- final ProjectionViewer v = (ProjectionViewer) getSourceViewer();
- v.doOperation(ProjectionViewer.TOGGLE);
-
- final IInformationControlCreator informationControlCreator = getSourceViewerConfiguration()
- .getInformationControlCreator(getSourceViewer());
-
- fInformationPresenter = new InformationPresenter(
- informationControlCreator);
- // sizes: see org.eclipse.jface.text.TextViewer.TEXT_HOVER_*_CHARS
- fInformationPresenter.setSizeConstraints(100, 12, true, true);
- fInformationPresenter.install(getSourceViewer());
- fInformationPresenter
- .setDocumentPartitioning(getSourceViewerConfiguration()
- .getConfiguredDocumentPartitioning(getSourceViewer()));
}
@Override
protected void createActions() {
super.createActions();
- // ActionGroup oeg, ovg, jsg;
ActionGroup esg;
- fActionGroups = new CompositeActionGroup(new ActionGroup[] {
- // oeg= new OpenEditorActionGroup(this),
- // ovg= new OpenViewActionGroup(this),
- esg = new ErlangSearchActionGroup(this) });
+ fActionGroups = new CompositeActionGroup(
+ new ActionGroup[] { esg = new ErlangSearchActionGroup(this) });
fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { esg });
- openAction = new OpenAction(this);
- openAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.OPEN_EDITOR);
- setAction(IErlangEditorActionDefinitionIds.OPEN, openAction);
-
- sendToConsole = new SendToConsoleAction(getSite(),
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "SendToConsole.", this);
- sendToConsole
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.SEND_TO_CONSOLE);
- setAction("SendToConsole", sendToConsole);
- markAsStateDependentAction("sendToConsole", true);
- markAsSelectionDependentAction("sendToConsole", true);
-
- final Action act = new ContentAssistAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ContentAssistProposal.", this);
- act.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction("ContentAssistProposal", act);
- markAsStateDependentAction("ContentAssistProposal", true);
-
- ResourceAction resAction = new TextOperationAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ShowEDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
- resAction = new InformationDispatchAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ShowEDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
- resAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.SHOW_EDOC);
- setAction("ShowEDoc", resAction); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem()
- .setHelp(resAction, IErlangHelpContextIds.SHOW_EDOC_ACTION);
-
- indentAction = new IndentAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "Indent.", this); //$NON-NLS-1$
- indentAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.INDENT);
- setAction("Indent", indentAction); //$NON-NLS-1$
- markAsStateDependentAction("Indent", true); //$NON-NLS-1$
- markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem()
- .setHelp(indentAction, IErlangHelpContextIds.INDENT_ACTION);
+ createCommonActions();
// if (ErlideUtil.isTest()) {
// testAction = new TestAction(ErlangEditorMessages
@@ -245,228 +144,6 @@ protected void createActions() {
// // IErlangHelpContextIds.INDENT_ACTION);
// }
- final Action action = new IndentAction(
- ErlangEditorMessages.getBundleForConstructedKeys(), "Indent.",
- this);
- setAction("IndentOnTab", action);
- markAsStateDependentAction("IndentOnTab", true);
- markAsSelectionDependentAction("IndentOnTab", true);
-
- toggleCommentAction = new ToggleCommentAction(
- ErlangEditorMessages.getBundleForConstructedKeys(),
- "ToggleComment.", this);
- toggleCommentAction
- .setActionDefinitionId(IErlangEditorActionDefinitionIds.TOGGLE_COMMENT);
- setAction("ToggleComment", toggleCommentAction);
- markAsStateDependentAction("ToggleComment", true);
- markAsSelectionDependentAction("ToggleComment", true);
- PlatformUI
- .getWorkbench()
- .getHelpSystem()
- .setHelp(toggleCommentAction,
- IErlangHelpContextIds.TOGGLE_COMMENT_ACTION);
- }
-
- // FIXME Copied from ErlangEditor
- /**
- * This action behaves in two different ways: If there is no current text
- * hover, the javadoc is displayed using information presenter. If there is
- * a current text hover, it is converted into a information presenter in
- * order to make it sticky.
- */
- class InformationDispatchAction extends TextEditorAction {
-
- /** The wrapped text operation action. */
- private final TextOperationAction fTextOperationAction;
-
- /**
- * Creates a dispatch action.
- *
- * @param resourceBundle
- * the resource bundle
- * @param prefix
- * the prefix
- * @param textOperationAction
- * the text operation action
- */
- public InformationDispatchAction(final ResourceBundle resourceBundle,
- final String prefix,
- final TextOperationAction textOperationAction) {
- super(resourceBundle, prefix, ErlangScratchPad.this);
- if (textOperationAction == null) {
- throw new IllegalArgumentException();
- }
- fTextOperationAction = textOperationAction;
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- @SuppressWarnings("synthetic-access")
- @Override
- public void run() {
-
- /**
- * Information provider used to present the information.
- *
- * @since 3.0
- */
- class InformationProvider implements IInformationProvider,
- IInformationProviderExtension,
- IInformationProviderExtension2 {
-
- private final IRegion fHoverRegion;
-
- private final String fHoverInfo;
-
- private final IInformationControlCreator fControlCreator;
-
- InformationProvider(final IRegion hoverRegion,
- final String hoverInfo,
- final IInformationControlCreator controlCreator) {
- fHoverRegion = hoverRegion;
- fHoverInfo = hoverInfo;
- fControlCreator = controlCreator;
- }
-
- /*
- * @seeorg.eclipse.jface.text.information.IInformationProvider#
- * getSubject(org.eclipse.jface.text.ITextViewer, int)
- */
-
- @Override
- public IRegion getSubject(final ITextViewer textViewer,
- final int invocationOffset) {
- return fHoverRegion;
- }
-
- @Override
- public Object getInformation2(final ITextViewer textViewer,
- final IRegion subject) {
- return fHoverInfo;
- }
-
- /*
- * @see
- * org.eclipse.jface.text.information.IInformationProviderExtension2
- * #getInformationPresenterControlCreator()
- *
- * @since 3.0
- */
-
- @Override
- public IInformationControlCreator getInformationPresenterControlCreator() {
- return fControlCreator;
- }
-
- @Override
- @Deprecated
- public String getInformation(final ITextViewer textViewer,
- final IRegion subject) {
- return null;
- }
- }
-
- final ISourceViewer sourceViewer = getSourceViewer();
- if (sourceViewer == null) {
- fTextOperationAction.run();
- return;
- }
-
- if (sourceViewer instanceof ITextViewerExtension4) {
- final ITextViewerExtension4 extension4 = (ITextViewerExtension4) sourceViewer;
- if (extension4.moveFocusToWidgetToken()) {
- return;
- }
- }
-
- if (!(sourceViewer instanceof ITextViewerExtension2)) {
- fTextOperationAction.run();
- return;
- }
-
- final ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer;
-
- // does a text hover exist?
- final ITextHover textHover = textViewerExtension2
- .getCurrentTextHover();
- if (textHover == null) {
- // TODO this crashes...
- // fTextOperationAction.run();
- return;
- }
-
- final Point hoverEventLocation = textViewerExtension2
- .getHoverEventLocation();
- final int offset = computeOffsetAtLocation(sourceViewer,
- hoverEventLocation.x, hoverEventLocation.y);
- if (offset == -1) {
- fTextOperationAction.run();
- return;
- }
-
- try {
- // get the text hover content
- final String contentType = TextUtilities.getContentType(
- sourceViewer.getDocument(),
- IErlangPartitions.ERLANG_PARTITIONING, offset, true);
-
- final IRegion hoverRegion = textHover.getHoverRegion(
- sourceViewer, offset);
- if (hoverRegion == null) {
- return;
- }
-
- final String hoverInfo = "";
- if (textHover instanceof ITextHoverExtension2) {
- ((ITextHoverExtension2) textHover).getHoverInfo2(
- sourceViewer, hoverRegion);
- }
-
- IInformationControlCreator controlCreator = null;
- if (textHover instanceof IInformationProviderExtension2) {
- controlCreator = ((IInformationProviderExtension2) textHover)
- .getInformationPresenterControlCreator();
- }
-
- final IInformationProvider informationProvider = new InformationProvider(
- hoverRegion, hoverInfo, controlCreator);
-
- fInformationPresenter.setOffset(offset);
- fInformationPresenter
- .setDocumentPartitioning(IErlangPartitions.ERLANG_PARTITIONING);
- fInformationPresenter.setInformationProvider(
- informationProvider, contentType);
- fInformationPresenter.showInformation();
- } catch (final BadLocationException e) {
- }
- }
-
- // modified version from TextViewer
- private int computeOffsetAtLocation(final ITextViewer textViewer,
- final int x, final int y) {
-
- final StyledText styledText = textViewer.getTextWidget();
- final IDocument document = textViewer.getDocument();
-
- if (document == null) {
- return -1;
- }
-
- try {
- final int widgetLocation = styledText
- .getOffsetAtLocation(new Point(x, y));
- if (textViewer instanceof ITextViewerExtension5) {
- final ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
- return extension.widgetOffset2ModelOffset(widgetLocation);
- }
- final IRegion visibleRegion = textViewer.getVisibleRegion();
- return widgetLocation + visibleRegion.getOffset();
- } catch (final IllegalArgumentException e) {
- return -1;
- }
-
- }
}
@Override
@@ -476,11 +153,7 @@ protected void editorContextMenuAboutToShow(final IMenuManager menu) {
// if (ErlideUtil.isTest()) {
// menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, testAction);
// }
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN,
- toggleCommentAction);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, indentAction);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, openAction);
- menu.prependToGroup(IContextMenuConstants.GROUP_OPEN, sendToConsole);
+ addCommonActions(menu);
final ActionContext context = new ActionContext(getSelectionProvider()
.getSelection());
fContextMenuGroup.setContext(context);
@@ -537,27 +210,25 @@ private IFile getFile() {
}
@Override
- public IErlScanner getScanner() {
- if (erlScanner == null) {
- final IFile file = getFile();
- if (file != null) {
- try {
- final String filePath = file.getLocation()
- .toPortableString();
- String initialText;
- initialText = Util.getInputStreamAsString(
- file.getContents(), file.getCharset());
- erlScanner = ErlModelManager
- .getErlangModel()
- .getToolkit()
- .createScanner(getScannerName(), initialText,
- filePath, false);
- } catch (final CoreException e) {
- ErlLogger.warn(e);
- }
- }
+ protected IErlScanner getNewScanner() {
+ final IFile file = getFile();
+ if (file == null) {
+ return null;
}
- return erlScanner;
+ try {
+ final String filePath = file.getLocation().toPortableString();
+ String initialText;
+ initialText = Util.getInputStreamAsString(file.getContents(),
+ file.getCharset());
+ return ErlModelManager
+ .getErlangModel()
+ .getToolkit()
+ .createScanner(getScannerName(), initialText, filePath,
+ false);
+ } catch (final CoreException e) {
+ ErlLogger.warn(e);
+ }
+ return null;
}
@Override
View
23 org.erlide.ui/src/org/erlide/ui/internal/ErlideUIPlugin.java
@@ -60,7 +60,6 @@
import org.erlide.ui.ErlideImage;
import org.erlide.ui.ErlideUIConstants;
import org.erlide.ui.console.ErlConsoleManager;
-import org.erlide.ui.console.ErlangConsolePage;
import org.erlide.ui.editors.erl.ErlangEditor;
import org.erlide.ui.editors.erl.actions.ClearCacheAction;
import org.erlide.ui.editors.erl.completion.ErlangContextType;
@@ -114,7 +113,7 @@
private ProblemMarkerManager fProblemMarkerManager = null;
- private ErlConsoleManager erlConMan;
+ private ErlConsoleManager erlConsoleManager;
/** Key to store custom templates. */
private static final String CUSTOM_TEMPLATES_KEY = "org.erlide.ui.editor.customtemplates"; //$NON-NLS-1$
@@ -153,13 +152,13 @@ public void start(final BundleContext context) throws Exception {
ErlLogger.debug("Started UI");
- erlConMan = new ErlConsoleManager();
+ erlConsoleManager = new ErlConsoleManager();
if (SystemConfiguration.getInstance().isDeveloper()) {
try {
final IBackend ideBackend = BackendCore.getBackendManager()
.getIdeBackend();
if (!ideBackend.getData().hasConsole()) {
- erlConMan.runtimeAdded(ideBackend);
+ erlConsoleManager.runtimeAdded(ideBackend);
}
} catch (final Exception e) {
ErlLogger.warn(e);
@@ -173,6 +172,10 @@ public void start(final BundleContext context) throws Exception {
startPeriodicCacheCleaner();
}
+ public ErlConsoleManager getErlConsoleManager() {
+ return erlConsoleManager;
+ }
+
private void startPeriodicCacheCleaner() {
final Job job = new Job("erlide periodic cache cleaner") {
@@ -242,7 +245,7 @@ private long getTimeToMidnight() {
*/
@Override
public void stop(final BundleContext context) throws Exception {
- erlConMan.dispose();
+ erlConsoleManager.dispose();
super.stop(context);
BackendCore.getBackendManager().removeBackendListener(
erlangDebuggerBackendListener);
@@ -526,21 +529,11 @@ public static IEclipsePreferences getPrefsNode() {
return eclipsePreferences;
}
- private ErlangConsolePage fErlangConsolePage;
-
private ContributionContextTypeRegistry fContextTypeRegistry;
private ContributionTemplateStore fStore;
private ErlangDebuggerBackendListener erlangDebuggerBackendListener;
- public ErlangConsolePage getConsolePage() {
- return fErlangConsolePage;
- }
-
- public void setConsolePage(final ErlangConsolePage erlangConsolePage) {
- fErlangConsolePage = erlangConsolePage;
- }
-
public TemplateStore getTemplateStore() {
// this is to avoid recursive call when fContextTypeRegistry is null
getContextTypeRegistry();

No commit comments for this range

Something went wrong with that request. Please try again.