mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 01:29:17 +01:00
adding option for disabling completions, fixes #10
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
@@ -154,6 +155,7 @@ public class ASTGenerator {
|
||||
setupGUI();
|
||||
//addCompletionPopupListner();
|
||||
addListeners(); loadJavaDoc();
|
||||
predictionsEnabled = new AtomicBoolean(true);
|
||||
}
|
||||
|
||||
protected void setupGUI(){
|
||||
@@ -776,8 +778,10 @@ public class ASTGenerator {
|
||||
*/
|
||||
protected ArrayList<CompletionCandidate> candidates;
|
||||
protected String lastPredictedWord = " ";
|
||||
protected AtomicBoolean predictionsEnabled;
|
||||
|
||||
public void preparePredictions(final String word, final int line, final int lineStartNonWSOffset) {
|
||||
if(!predictionsEnabled.get()) return;
|
||||
// This method is called from TextArea.fetchPhrase, which is called via a SwingWorker instance
|
||||
// in TextArea.processKeyEvent
|
||||
if(caretWithinLineComment()){
|
||||
|
||||
@@ -166,6 +166,11 @@ public class DebugEditor extends JavaEditor implements ActionListener {
|
||||
*/
|
||||
protected JCheckBoxMenuItem writeErrorLog;
|
||||
|
||||
/**
|
||||
* Enable/Disable code completion
|
||||
*/
|
||||
protected JCheckBoxMenuItem completionsEnabled;
|
||||
|
||||
public DebugEditor(Base base, String path, EditorState state, Mode mode) {
|
||||
super(base, path, state, mode);
|
||||
|
||||
@@ -521,6 +526,17 @@ public class DebugEditor extends JavaEditor implements ActionListener {
|
||||
});
|
||||
debugMenu.add(showWarnings);
|
||||
|
||||
completionsEnabled = new JCheckBoxMenuItem("Code Completion Enabled");
|
||||
completionsEnabled.setSelected(true);
|
||||
completionsEnabled.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
errorCheckerService.getASTGenerator().predictionsEnabled
|
||||
.set(((JCheckBoxMenuItem) e.getSource()).isSelected());
|
||||
}
|
||||
});
|
||||
debugMenu.add(completionsEnabled);
|
||||
|
||||
debugMessagesEnabled = new JCheckBoxMenuItem("Show Debug Messages");
|
||||
debugMessagesEnabled.setSelected(ExperimentalMode.DEBUG);
|
||||
debugMessagesEnabled.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -179,7 +179,7 @@ public class TextArea extends JEditTextArea {
|
||||
}
|
||||
super.processKeyEvent(evt);
|
||||
|
||||
if (evt.getID() == KeyEvent.KEY_TYPED) {
|
||||
if (evt.getID() == KeyEvent.KEY_TYPED && editor.errorCheckerService.getASTGenerator().predictionsEnabled.get()) {
|
||||
final KeyEvent evt2 = evt;
|
||||
SwingWorker worker = new SwingWorker() {
|
||||
protected Object doInBackground() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user