merging DebugEditor into JavaEditor

This commit is contained in:
Ben Fry
2015-01-24 10:11:01 -05:00
parent a34aade96f
commit 67559781d4
19 changed files with 2025 additions and 2194 deletions
@@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package processing.mode.java.debug;
package processing.mode.java;
import java.awt.Graphics;
import java.awt.Image;
@@ -31,9 +31,10 @@ import processing.app.Base;
import processing.app.Editor;
import processing.app.Language;
import processing.app.Toolkit;
import processing.mode.java.JavaToolbar;
import processing.mode.java.pdex.XQConsoleToggle;
/**
* Custom toolbar for the editor window. Preserves original button numbers
* ({@link JavaToolbar#RUN}, {@link JavaToolbar#STOP}, {@link JavaToolbar#NEW},
@@ -190,7 +191,7 @@ public class DebugToolbar extends JavaToolbar {
@Override
public void handlePressed(MouseEvent e, int idx) {
boolean shift = e.isShiftDown();
DebugEditor deditor = (DebugEditor) editor;
JavaEditor deditor = (JavaEditor) editor;
int id = buttonId(idx); // convert index/position to button id
switch (id) {
@@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package processing.mode.java.debug;
package processing.mode.java;
import com.sun.jdi.*;
import com.sun.jdi.event.*;
@@ -41,21 +41,28 @@ import javax.swing.tree.DefaultMutableTreeNode;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.mode.java.JavaBuild;
import processing.mode.java.debug.ArrayFieldNode;
import processing.mode.java.debug.ClassLoadListener;
import processing.mode.java.debug.FieldNode;
import processing.mode.java.debug.LineBreakpoint;
import processing.mode.java.debug.LineID;
import processing.mode.java.debug.LocalVariableNode;
import processing.mode.java.debug.VariableInspector;
import processing.mode.java.debug.VariableNode;
import processing.mode.java.pdex.VMEventListener;
import processing.mode.java.pdex.VMEventReader;
import processing.mode.java.runner.Runner;
/**
* Main controller class for debugging mode. Mainly works with DebugEditor as
* Main controller class for debugging mode. Mainly works with JavaEditor as
* the corresponding "view". Uses DebugRunner to launch a VM.
*
* @author Martin Leopold <m@martinleopold.com>
*/
public class Debugger implements VMEventListener {
protected DebugEditor editor; // editor window, acting as main view
protected JavaEditor editor; // editor window, acting as main view
protected Runner runtime; // the runtime, contains debuggee VM
protected boolean started = false; // debuggee vm has started, VMStartEvent received, main class loaded
protected boolean paused = false; // currently paused at breakpoint or step
@@ -75,7 +82,7 @@ public class Debugger implements VMEventListener {
*
* @param editor The Editor that will act as primary view
*/
public Debugger(DebugEditor editor) {
public Debugger(JavaEditor editor) {
this.editor = editor;
}
@@ -97,7 +104,7 @@ public class Debugger implements VMEventListener {
*
* @return the editor object
*/
public DebugEditor editor() {
public JavaEditor editor() {
return editor;
}
@@ -1057,7 +1064,7 @@ public class Debugger implements VMEventListener {
* @param maxDepth max recursion depth. 0 will give only direct children
* @return list of child fields of the given value
*/
protected List<VariableNode> getFields(Value value, int maxDepth, boolean includeInherited) {
public List<VariableNode> getFields(Value value, int maxDepth, boolean includeInherited) {
return getFields(value, 0, maxDepth, includeInherited);
}
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -32,7 +32,6 @@ import java.util.logging.Logger;
import javax.swing.ImageIcon;
import processing.app.*;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.runner.Runner;
import processing.mode.java.tweak.SketchParser;
@@ -40,7 +39,7 @@ import processing.mode.java.tweak.SketchParser;
public class JavaMode extends Mode {
public Editor createEditor(Base base, String path, EditorState state) {
return new DebugEditor(base, path, state, this);
return new JavaEditor(base, path, state, this);
}
@@ -111,7 +110,7 @@ public class JavaMode extends Mode {
public Runner handleRun(Sketch sketch,
RunnerListener listener) throws SketchException {
final DebugEditor editor = (DebugEditor)listener;
final JavaEditor editor = (JavaEditor)listener;
editor.errorCheckerService.quickErrorCheck();
if (enableTweak) {
enableTweak = false;
@@ -124,7 +123,7 @@ public class JavaMode extends Mode {
public Runner handlePresent(Sketch sketch,
RunnerListener listener) throws SketchException {
final DebugEditor editor = (DebugEditor)listener;
final JavaEditor editor = (JavaEditor)listener;
editor.errorCheckerService.quickErrorCheck();
if (enableTweak) {
enableTweak = false;
@@ -157,7 +156,7 @@ public class JavaMode extends Mode {
public Runner handleTweak(Sketch sketch,
RunnerListener listener,
final boolean present) throws SketchException {
final DebugEditor editor = (DebugEditor)listener;
final JavaEditor editor = (JavaEditor)listener;
boolean launchInteractive = false;
if (isSketchModified(sketch)) {
File diff suppressed because it is too large Load Diff
@@ -25,6 +25,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import processing.app.Base;
import processing.mode.java.Debugger;
import com.sun.jdi.AbsentInformationException;
import com.sun.jdi.Location;
@@ -24,6 +24,9 @@ import java.awt.Color;
import java.util.HashSet;
import java.util.Set;
import processing.mode.java.JavaEditor;
/**
* Model/Controller for a highlighted source code line. Implements a custom
* background color and a text based marker placed in the left-hand gutter area.
@@ -32,57 +35,63 @@ import java.util.Set;
*/
public class LineHighlight implements LineListener {
protected DebugEditor editor; // the view, used for highlighting lines by setting a background color
protected Color bgColor; // the background color for highlighting lines
protected LineID lineID; // the id of the line
protected String marker; //
protected Color markerColor;
protected int priority = 0;
protected static Set<LineHighlight> allHighlights = new HashSet<LineHighlight>();
protected JavaEditor editor; // the view, used for highlighting lines by setting a background color
protected Color bgColor; // the background color for highlighting lines
protected LineID lineID; // the id of the line
protected String marker; //
protected Color markerColor;
protected int priority = 0;
protected static Set<LineHighlight> allHighlights = new HashSet<LineHighlight>();
protected static boolean isHighestPriority(LineHighlight hl) {
for (LineHighlight check : allHighlights) {
if (check.lineID().equals(hl.lineID()) && check.priority() > hl.priority()) {
return false;
}
}
return true;
/**
* Create a {@link LineHighlight}.
*
* @param lineID the line id to highlight
* @param bgColor the background color used for highlighting
* @param editor the {@link JavaEditor}
*/
public LineHighlight(LineID lineID, Color bgColor, JavaEditor editor) {
this.lineID = lineID;
this.bgColor = bgColor;
this.editor = editor;
lineID.addListener(this);
lineID.startTracking(editor.getTab(lineID.fileName()).getDocument()); // TODO: overwrite a previous doc?
paint(); // already checks if on current tab
allHighlights.add(this);
}
protected static boolean isHighestPriority(LineHighlight hl) {
for (LineHighlight check : allHighlights) {
if (check.getLineID().equals(hl.getLineID()) &&
check.priority() > hl.priority()) {
return false;
}
}
return true;
}
/**
* Create a {@link LineHighlight}.
*
* @param lineID the line id to highlight
* @param bgColor the background color used for highlighting
* @param editor the {@link DebugEditor}
*/
public LineHighlight(LineID lineID, Color bgColor, DebugEditor editor) {
this.lineID = lineID;
this.bgColor = bgColor;
this.editor = editor;
lineID.addListener(this);
lineID.startTracking(editor.getTab(lineID.fileName()).getDocument()); // TODO: overwrite a previous doc?
paint(); // already checks if on current tab
allHighlights.add(this);
}
public void setPriority(int p) {
this.priority = p;
}
public void setPriority(int p) {
this.priority = p;
}
public int priority() {
return priority;
}
public int priority() {
return priority;
}
/**
* Create a {@link LineHighlight} on the current tab.
*
* @param lineIdx the line index on the current tab to highlight
* @param bgColor the background color used for highlighting
* @param editor the {@link DebugEditor}
* @param editor the {@link JavaEditor}
*/
// TODO: Remove and replace by {@link #LineHighlight(LineID lineID, Color bgColor, DebugEditor editor)}
public LineHighlight(int lineIdx, Color bgColor, DebugEditor editor) {
// TODO: Remove and replace by {@link #LineHighlight(LineID lineID, Color bgColor, JavaEditor editor)}
public LineHighlight(int lineIdx, Color bgColor, JavaEditor editor) {
this(editor.getLineIDInCurrentTab(lineIdx), bgColor, editor);
}
@@ -114,7 +123,7 @@ public class LineHighlight implements LineListener {
*
* @return the line id
*/
public LineID lineID() {
public LineID getLineID() {
return lineID;
}
@@ -61,6 +61,8 @@ import org.netbeans.swing.outline.RowModel;
import com.sun.jdi.Value;
import processing.mode.java.Debugger;
import processing.mode.java.JavaEditor;
import processing.mode.java.JavaMode;
@@ -79,7 +81,7 @@ public class VariableInspector extends JFrame {
protected List<VariableNode> locals; // current local variables
protected List<VariableNode> thisFields; // all fields of the current this-object
protected List<VariableNode> declaredThisFields; // declared i.e. non-inherited fields of this
protected DebugEditor editor; // the editor
protected JavaEditor editor; // the editor
protected Debugger dbg; // the debugger
protected List<TreePath> expandedNodes = new ArrayList<TreePath>(); // list of expanded tree paths. (using list to maintain the order of expansion)
protected boolean p5mode = true; // processing / "advanced" mode flag (currently not used
@@ -87,7 +89,7 @@ public class VariableInspector extends JFrame {
/**
* Creates new form VariableInspector
*/
public VariableInspector(DebugEditor editor) {
public VariableInspector(JavaEditor editor) {
this.editor = editor;
this.dbg = editor.dbg();
@@ -111,8 +111,8 @@ import processing.app.Base;
import processing.app.Library;
import processing.app.SketchCode;
import processing.app.Toolkit;
import processing.mode.java.JavaEditor;
import processing.mode.java.JavaMode;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.preproc.PdePreprocessor;
import com.google.classpath.ClassPath;
@@ -124,7 +124,7 @@ public class ASTGenerator {
protected ErrorCheckerService errorCheckerService;
protected DebugEditor editor;
protected JavaEditor editor;
public DefaultMutableTreeNode codeTree = new DefaultMutableTreeNode();
@@ -1751,7 +1751,7 @@ public class ASTGenerator {
// Base.loge("null");
if (scrollOnly) {
editor.statusMessage(simpName + " is not defined in this sketch",
DebugEditor.STATUS_ERR);
JavaEditor.STATUS_ERR);
}
}
@@ -2036,7 +2036,7 @@ public class ASTGenerator {
DefaultMutableTreeNode defCU = findAllOccurrences(); //TODO: Repetition here
if(defCU == null){
editor.statusMessage("Can't locate definition of " + selText,
DebugEditor.STATUS_ERR);
JavaEditor.STATUS_ERR);
return;
}
@@ -2132,13 +2132,13 @@ public class ASTGenerator {
log("Last clicked word:" + lastClickedWord);
if(lastClickedWord == null && editor.ta.getSelectedText() == null){
editor.statusMessage("Highlight the class/function/variable name first"
, DebugEditor.STATUS_INFO);
, JavaEditor.STATUS_INFO);
return;
}
if(errorCheckerService.hasSyntaxErrors()){
editor.statusMessage("Can't perform action until syntax errors are " +
"fixed :(", DebugEditor.STATUS_WARNING);
"fixed :(", JavaEditor.STATUS_WARNING);
return;
}
DefaultMutableTreeNode defCU = findAllOccurrences();
@@ -2146,7 +2146,7 @@ public class ASTGenerator {
: lastClickedWord;
if(defCU == null){
editor.statusMessage("Can't locate definition of " + selText,
DebugEditor.STATUS_ERR);
JavaEditor.STATUS_ERR);
return;
}
if(defCU.getChildCount() == 0)
@@ -2476,14 +2476,14 @@ public class ASTGenerator {
log("Last clicked word:" + lastClickedWord);
if(lastClickedWord == null && editor.ta.getSelectedText() == null){
editor.statusMessage("Highlight the class/function/variable name first",
DebugEditor.STATUS_INFO);
JavaEditor.STATUS_INFO);
return;
}
if(errorCheckerService.hasSyntaxErrors()){
editor
.statusMessage("Can't perform action until syntax errors are fixed :(",
DebugEditor.STATUS_WARNING);
JavaEditor.STATUS_WARNING);
return;
}
@@ -2492,7 +2492,7 @@ public class ASTGenerator {
: lastClickedWord;
if(defCU == null){
editor.statusMessage(selText + " isn't defined in this sketch, so it can't" +
" be renamed", DebugEditor.STATUS_ERR);
" be renamed", JavaEditor.STATUS_ERR);
return;
}
if (!frmRename.isVisible()){
@@ -51,7 +51,7 @@ import javax.swing.text.BadLocationException;
import processing.app.Base;
import processing.app.syntax.JEditTextArea;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
/**
@@ -87,7 +87,7 @@ public class CompletionPanel {
*/
private JScrollPane scrollPane;
protected DebugEditor editor;
protected JavaEditor editor;
public static final int MOUSE_COMPLETION = 10, KEYBOARD_COMPLETION = 20;
@@ -101,7 +101,7 @@ public class CompletionPanel {
* @param dedit
*/
public CompletionPanel(final JEditTextArea textarea, int position, String subWord,
DefaultListModel<CompletionCandidate> items, final Point location, DebugEditor dedit) {
DefaultListModel<CompletionCandidate> items, final Point location, JavaEditor dedit) {
this.textarea = (JavaTextArea) textarea;
editor = dedit;
this.insertionPosition = position;
@@ -38,7 +38,7 @@ import javax.swing.text.BadLocationException;
import processing.app.Base;
import processing.app.SketchCode;
import processing.mode.java.JavaMode;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
/**
* The bar on the left of the text area which displays all errors as rectangles. <br>
@@ -83,9 +83,9 @@ public class ErrorBar extends JPanel {
public Color backgroundColor; // = new Color(0x2C343D);
/**
* DebugEditor instance
* JavaEditor instance
*/
protected DebugEditor editor;
protected JavaEditor editor;
/**
* ErrorCheckerService instance
@@ -130,7 +130,7 @@ public class ErrorBar extends JPanel {
}
public ErrorBar(DebugEditor editor, int height, JavaMode mode) {
public ErrorBar(JavaEditor editor, int height, JavaMode mode) {
this.editor = editor;
this.preferredHeight = height;
this.errorCheckerService = editor.errorCheckerService;
@@ -55,7 +55,7 @@ import processing.app.SketchCode;
import processing.app.syntax.SyntaxDocument;
import processing.core.PApplet;
import processing.mode.java.JavaMode;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
import processing.mode.java.preproc.PdePreprocessor;
@@ -66,7 +66,7 @@ import processing.mode.java.preproc.PdePreprocessor;
@SuppressWarnings("unchecked")
public class ErrorCheckerService implements Runnable {
protected DebugEditor editor;
protected JavaEditor editor;
/** Error check happens every sleepTime milliseconds */
public static final int sleepTime = 1000;
@@ -217,7 +217,7 @@ public class ErrorCheckerService implements Runnable {
protected ErrorMessageSimplifier errorMsgSimplifier;
public ErrorCheckerService(DebugEditor debugEditor) {
public ErrorCheckerService(JavaEditor debugEditor) {
ensureMinP5Version();
this.editor = debugEditor;
stopThread = new AtomicBoolean(false);
@@ -274,7 +274,7 @@ public class ErrorCheckerService implements Runnable {
}
final ErrorCheckerService thisService = this;
final DebugEditor thisEditor = editor;
final JavaEditor thisEditor = editor;
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
@@ -1101,10 +1101,10 @@ public class ErrorCheckerService implements Runnable {
if (emarker.getProblem().getLineNumber() == editor.getTextArea().getCaretLine()) {
if (emarker.getType() == ErrorMarker.Warning) {
editor.statusMessage(emarker.getProblem().getMessage(),
DebugEditor.STATUS_INFO);
JavaEditor.STATUS_INFO);
} else {
editor.statusMessage(emarker.getProblem().getMessage(),
DebugEditor.STATUS_COMPILER_ERR);
JavaEditor.STATUS_COMPILER_ERR);
}
return;
}
@@ -1113,7 +1113,7 @@ public class ErrorCheckerService implements Runnable {
}
// This line isn't an error line anymore, so probably just clear it
if (editor.statusMessageType == DebugEditor.STATUS_COMPILER_ERR) {
if (editor.statusMessageType == JavaEditor.STATUS_COMPILER_ERR) {
editor.statusEmpty();
return;
}
@@ -1748,7 +1748,7 @@ public class ErrorCheckerService implements Runnable {
pauseThread.set(false);
}
public DebugEditor getEditor() {
public JavaEditor getEditor() {
return editor;
}
@@ -37,7 +37,7 @@ import javax.swing.table.TableModel;
import processing.app.Editor;
import processing.app.Toolkit;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
/**
* Error Window that displays a tablular list of errors. Clicking on an error
@@ -58,7 +58,7 @@ public class ErrorWindow extends JFrame {
*/
protected JScrollPane scrollPane;
protected DebugEditor thisEditor;
protected JavaEditor thisEditor;
private JFrame thisErrorWindow;
/**
@@ -75,7 +75,7 @@ public class ErrorWindow extends JFrame {
* - Editor
* @param ecs - ErrorCheckerService
*/
public ErrorWindow(DebugEditor editor, ErrorCheckerService ecs) {
public ErrorWindow(JavaEditor editor, ErrorCheckerService ecs) {
thisErrorWindow = this;
errorCheckerService = ecs;
thisEditor = editor;
@@ -22,7 +22,7 @@ package processing.mode.java.pdex;
import processing.mode.java.JavaInputHandler;
import processing.mode.java.JavaMode;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
import processing.mode.java.tweak.ColorControlBox;
import processing.mode.java.tweak.Handle;
@@ -57,7 +57,7 @@ import processing.app.syntax.TextAreaDefaults;
*/
public class JavaTextArea extends JEditTextArea {
protected PdeTextAreaDefaults defaults;
protected DebugEditor editor;
protected JavaEditor editor;
protected MouseListener[] mouseListeners; // cached mouselisteners, these are wrapped by MouseHandler
@@ -89,9 +89,9 @@ public class JavaTextArea extends JEditTextArea {
}
//public JavaTextArea(TextAreaDefaults defaults, InputHandler inputHandler, DebugEditor editor) {
//public JavaTextArea(DebugEditor editor) {
public JavaTextArea(TextAreaDefaults defaults, DebugEditor editor) {
//public JavaTextArea(TextAreaDefaults defaults, InputHandler inputHandler, JavaEditor editor) {
//public JavaTextArea(JavaEditor editor) {
public JavaTextArea(TextAreaDefaults defaults, JavaEditor editor) {
super(defaults, new JavaInputHandler(editor));
//super(defaults, inputHandler);
this.editor = editor;
@@ -21,7 +21,7 @@ along with this program; if not, write to the Free Software Foundation, Inc.
package processing.mode.java.pdex;
import processing.mode.java.JavaMode;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
import processing.mode.java.tweak.*;
import java.awt.Color;
@@ -845,7 +845,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
private DebugEditor getEditor() {
private JavaEditor getEditor() {
return ((JavaTextArea) textArea).editor;
}
@@ -55,7 +55,7 @@ import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
public class SketchOutline {
@@ -65,7 +65,7 @@ public class SketchOutline {
protected DefaultMutableTreeNode soNode, tempNode;
protected final JTree soTree;
protected JTextField searchField;
protected DebugEditor editor;
protected JavaEditor editor;
protected boolean internalSelection = false;
@@ -51,7 +51,8 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;
import processing.app.SketchCode;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
public class TabOutline {
protected JFrame frmOutlineView;
@@ -66,7 +67,7 @@ public class TabOutline {
protected JLabel lblCaption;
protected DebugEditor editor;
protected JavaEditor editor;
protected ErrorCheckerService errorCheckerService;
@@ -84,10 +85,8 @@ public class TabOutline {
frmOutlineView.setUndecorated(true);
Point tp = errorCheckerService.getEditor().ta.getLocationOnScreen();
lblCaption = new JLabel("Tabs List (type to filter)");
// int minWidth = (int) (editor.getMinimumSize().width * 0.7f), maxWidth = (int) (editor
// .getMinimumSize().width * 0.9f);
int minWidth = estimateFrameWidth(), maxWidth = (int) (editor
.getMinimumSize().width * 0.9f);
int minWidth = estimateFrameWidth();
int maxWidth = (int) (editor.getMinimumSize().width * 0.9f);
frmOutlineView.setLayout(new BoxLayout(frmOutlineView.getContentPane(),
BoxLayout.Y_AXIS));
JPanel panelTop = new JPanel(), panelMiddle = new JPanel(), panelBottom = new JPanel();
@@ -31,7 +31,7 @@ import java.awt.event.MouseListener;
import javax.swing.JPanel;
import processing.app.Language;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
/**
* Toggle Button displayed in the editor line status panel for toggling bewtween
@@ -51,10 +51,10 @@ public class XQConsoleToggle extends JPanel implements MouseListener {
* Height of the component
*/
protected int height;
protected DebugEditor editor;
protected JavaEditor editor;
protected String buttonName;
public XQConsoleToggle(DebugEditor editor, String buttonName, int height) {
public XQConsoleToggle(JavaEditor editor, String buttonName, int height) {
this.editor = editor;
this.height = height;
this.buttonName = buttonName;
@@ -33,7 +33,7 @@ import javax.swing.text.BadLocationException;
import processing.app.Base;
import processing.app.Language;
import processing.mode.java.debug.DebugEditor;
import processing.mode.java.JavaEditor;
/**
@@ -219,7 +219,7 @@ public class XQErrorTable extends JTable {
frmImportSuggest.getContentPane().add(panel);
frmImportSuggest.pack();
final DebugEditor editor = errorCheckerService.getEditor();
final JavaEditor editor = errorCheckerService.getEditor();
classList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (classList.getSelectedValue() != null) {