mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 03:11:08 +01:00
clean up error/warning handling, differentiate errors/warnings in list (fixes #3406)
This commit is contained in:
@@ -2779,12 +2779,12 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current mode of the editor status bar: NOTICE, ERR or EDIT.
|
||||
*/
|
||||
public int getStatusMode() {
|
||||
return status.mode;
|
||||
}
|
||||
// /**
|
||||
// * Returns the current mode of the editor status bar: NOTICE, ERR or EDIT.
|
||||
// */
|
||||
// public int getStatusMode() {
|
||||
// return status.mode;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,9 +47,11 @@ public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
|
||||
Color[] bgcolor;
|
||||
Color[] fgcolor;
|
||||
|
||||
static public final int NOTICE = 0;
|
||||
static public final int ERR = 1;
|
||||
static public final int EDIT = 2;
|
||||
@SuppressWarnings("hiding")
|
||||
static public final int ERROR = 1;
|
||||
static public final int COMPILER_ERROR = 1; // temporary
|
||||
static public final int WARNING = 2;
|
||||
static public final int NOTICE = 0;
|
||||
|
||||
static final int YES = 1;
|
||||
static final int NO = 2;
|
||||
@@ -139,50 +141,45 @@ public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
|
||||
}
|
||||
|
||||
|
||||
public void notice(String message) {
|
||||
mode = NOTICE;
|
||||
public void message(String message, int mode) {
|
||||
this.message = message;
|
||||
this.mode = mode;
|
||||
|
||||
url = findURL(message);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void unnotice(String unmessage) {
|
||||
if (message.equals(unmessage)) empty();
|
||||
public void notice(String message) {
|
||||
message(message, NOTICE);
|
||||
// mode = NOTICE;
|
||||
// this.message = message;
|
||||
// url = findURL(message);
|
||||
// repaint();
|
||||
}
|
||||
|
||||
|
||||
// public void unnotice(String unmessage) {
|
||||
// if (message.equals(unmessage)) empty();
|
||||
// }
|
||||
|
||||
|
||||
public void warning(String message) {
|
||||
message(message, WARNING);
|
||||
// this.message = message;
|
||||
// mode = WARNING;
|
||||
// url = findURL(message);
|
||||
// repaint();
|
||||
}
|
||||
|
||||
|
||||
public void error(String message) {
|
||||
mode = ERR;
|
||||
this.message = message;
|
||||
url = findURL(message);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
// public void edit(String message, String dflt) {
|
||||
// mode = EDIT;
|
||||
message(message, ERROR);
|
||||
// this.message = message;
|
||||
//
|
||||
// response = 0;
|
||||
// okButton.setVisible(true);
|
||||
// cancelButton.setVisible(true);
|
||||
// editField.setVisible(true);
|
||||
// editField.setText(dflt);
|
||||
// editField.selectAll();
|
||||
// editField.requestFocusInWindow();
|
||||
//
|
||||
// mode = ERROR;
|
||||
// url = findURL(message);
|
||||
// repaint();
|
||||
// }
|
||||
|
||||
|
||||
// public void unedit() {
|
||||
// okButton.setVisible(false);
|
||||
// cancelButton.setVisible(false);
|
||||
// editField.setVisible(false);
|
||||
// editor.textarea.requestFocusInWindow();
|
||||
// empty();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public void startIndeterminate() {
|
||||
@@ -268,164 +265,6 @@ public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected void setup() {
|
||||
if (okButton == null) {
|
||||
cancelButton = new JButton(Preferences.PROMPT_CANCEL);
|
||||
okButton = new JButton(Preferences.PROMPT_OK);
|
||||
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (mode == EDIT) {
|
||||
unedit();
|
||||
//editor.toolbar.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
okButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// answering to rename/new code question
|
||||
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
|
||||
// os9 seems to work if bg of component is set, but x still a bastard
|
||||
if (Base.isMacOS()) {
|
||||
//yesButton.setBackground(bgcolor[EDIT]);
|
||||
//noButton.setBackground(bgcolor[EDIT]);
|
||||
cancelButton.setBackground(bgcolor[EDIT]);
|
||||
okButton.setBackground(bgcolor[EDIT]);
|
||||
}
|
||||
setLayout(null);
|
||||
|
||||
add(cancelButton);
|
||||
add(okButton);
|
||||
|
||||
cancelButton.setVisible(false);
|
||||
okButton.setVisible(false);
|
||||
|
||||
editField = new JTextField();
|
||||
// disabling, was not in use
|
||||
//editField.addActionListener(this);
|
||||
|
||||
//if (Base.platform != Base.MACOSX) {
|
||||
editField.addKeyListener(new KeyAdapter() {
|
||||
|
||||
// Grab ESC with keyPressed, because it's not making it to keyTyped
|
||||
public void keyPressed(KeyEvent event) {
|
||||
if (event.getKeyChar() == KeyEvent.VK_ESCAPE) {
|
||||
unedit();
|
||||
//editor.toolbar.clear();
|
||||
event.consume();
|
||||
}
|
||||
}
|
||||
|
||||
// use keyTyped to catch when the feller is actually
|
||||
// added to the text field. with keyTyped, as opposed to
|
||||
// keyPressed, the keyCode will be zero, even if it's
|
||||
// enter or backspace or whatever, so the keychar should
|
||||
// be used instead. grr.
|
||||
public void keyTyped(KeyEvent event) {
|
||||
//System.out.println("got event " + event);
|
||||
int c = event.getKeyChar();
|
||||
|
||||
if (c == KeyEvent.VK_ENTER) { // accept the input
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
event.consume();
|
||||
|
||||
// easier to test the affirmative case than the negative
|
||||
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
|
||||
(c == KeyEvent.VK_DELETE) ||
|
||||
(c == KeyEvent.VK_RIGHT) ||
|
||||
(c == KeyEvent.VK_LEFT) ||
|
||||
(c == KeyEvent.VK_UP) ||
|
||||
(c == KeyEvent.VK_DOWN) ||
|
||||
(c == KeyEvent.VK_HOME) ||
|
||||
(c == KeyEvent.VK_END) ||
|
||||
(c == KeyEvent.VK_SHIFT)) {
|
||||
// these events are ignored
|
||||
|
||||
// } else if (c == KeyEvent.VK_ESCAPE) {
|
||||
// unedit();
|
||||
// editor.toolbar.clear();
|
||||
// event.consume();
|
||||
|
||||
} else if (c == KeyEvent.VK_SPACE) {
|
||||
String t = editField.getText();
|
||||
int start = editField.getSelectionStart();
|
||||
int end = editField.getSelectionEnd();
|
||||
editField.setText(t.substring(0, start) + "_" +
|
||||
t.substring(end));
|
||||
editField.setCaretPosition(start+1);
|
||||
event.consume();
|
||||
|
||||
} else if ((c == '_') || (c == '.') || // allow .pde and .java
|
||||
((c >= 'A') && (c <= 'Z')) ||
|
||||
((c >= 'a') && (c <= 'z'))) {
|
||||
// these are ok, allow them through
|
||||
|
||||
} else if ((c >= '0') && (c <= '9')) {
|
||||
// getCaretPosition == 0 means that it's the first char
|
||||
// and the field is empty.
|
||||
// getSelectionStart means that it *will be* the first
|
||||
// char, because the selection is about to be replaced
|
||||
// with whatever is typed.
|
||||
if ((editField.getCaretPosition() == 0) ||
|
||||
(editField.getSelectionStart() == 0)) {
|
||||
// number not allowed as first digit
|
||||
//System.out.println("bad number bad");
|
||||
event.consume();
|
||||
}
|
||||
} else {
|
||||
event.consume();
|
||||
//System.out.println("code is " + code + " char = " + c);
|
||||
}
|
||||
//System.out.println("code is " + code + " char = " + c);
|
||||
}
|
||||
});
|
||||
add(editField);
|
||||
editField.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setButtonBounds() {
|
||||
int top = (sizeH - BUTTON_HEIGHT) / 2;
|
||||
int eachButton = Preferences.GUI_SMALL + Preferences.BUTTON_WIDTH;
|
||||
|
||||
int cancelLeft = sizeW - eachButton;
|
||||
int noLeft = cancelLeft - eachButton;
|
||||
int yesLeft = noLeft - eachButton;
|
||||
|
||||
//yesButton.setLocation(yesLeft, top);
|
||||
//noButton.setLocation(noLeft, top);
|
||||
cancelButton.setLocation(cancelLeft, top);
|
||||
okButton.setLocation(noLeft, top);
|
||||
|
||||
//yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
//noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
|
||||
cancelButton.setSize(Preferences.BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
okButton.setSize(Preferences.BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||
|
||||
// edit field height is awkward, and very different between mac and pc,
|
||||
// so use at least the preferred height for now.
|
||||
int editWidth = 2*Preferences.BUTTON_WIDTH;
|
||||
int editHeight = editField.getPreferredSize().height;
|
||||
int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil
|
||||
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
|
||||
editWidth, editHeight);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
@@ -439,22 +278,4 @@ public class EditorStatus extends BasicSplitPaneDivider { //JPanel {
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(super.getMaximumSize().width, HIGH);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == cancelButton) {
|
||||
if (mode == EDIT) unedit();
|
||||
//editor.toolbar.clear();
|
||||
|
||||
} else if (e.getSource() == okButton) {
|
||||
// answering to rename/new code question
|
||||
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
|
||||
String answer = editField.getText();
|
||||
editor.getSketch().nameCode(answer);
|
||||
unedit();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
@@ -36,7 +37,6 @@ import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import processing.app.Language;
|
||||
import processing.app.Messages;
|
||||
import processing.app.Mode;
|
||||
import processing.app.ui.Editor;
|
||||
|
||||
@@ -44,6 +44,11 @@ import processing.app.ui.Editor;
|
||||
public class ErrorTable extends JTable {
|
||||
Editor editor;
|
||||
|
||||
public interface Entry {
|
||||
public boolean isError();
|
||||
public boolean isWarning();
|
||||
}
|
||||
|
||||
static final String[] columnNames = {
|
||||
"", // the blank column used for spacing
|
||||
Language.text("editor.footer.errors.problem"),
|
||||
@@ -109,8 +114,8 @@ public class ErrorTable extends JTable {
|
||||
editor.errorTableDoubleClick(data);
|
||||
}
|
||||
// editor.getErrorChecker().scrollToErrorLine(row);
|
||||
} catch (Exception e1) {
|
||||
Messages.log("Exception XQErrorTable mouseReleased " + e);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -185,7 +190,7 @@ public class ErrorTable extends JTable {
|
||||
}
|
||||
|
||||
|
||||
public void addRow(Object data, String message, String filename, String line) {
|
||||
public void addRow(Entry data, String message, String filename, String line) {
|
||||
DefaultTableModel dtm = (DefaultTableModel) getModel();
|
||||
dtm.addRow(new Object[] { data, message, filename, line });
|
||||
}
|
||||
@@ -318,6 +323,12 @@ public class ErrorTable extends JTable {
|
||||
Color bgColor;
|
||||
Color textColorSelected;
|
||||
Color bgColorSelected;
|
||||
Color bgColorError;
|
||||
Color bgColorWarning;
|
||||
|
||||
// int indicatorSize;
|
||||
Color errorIndicatorColor;
|
||||
Color warningIndicatorColor;
|
||||
|
||||
public GradyRowRenderer(Mode mode) {
|
||||
setFont(mode.getFont("errors.row.font"));
|
||||
@@ -327,6 +338,13 @@ public class ErrorTable extends JTable {
|
||||
bgColor = mode.getColor("errors.row.bgcolor");
|
||||
textColorSelected = mode.getColor("errors.selection.fgcolor");
|
||||
bgColorSelected = mode.getColor("errors.selection.bgcolor");
|
||||
bgColorError = mode.getColor("errors.selection.error.bgcolor");
|
||||
bgColorWarning = mode.getColor("errors.selection.warning.bgcolor");
|
||||
|
||||
// indicatorSize = mode.getInteger("errors.indicator.size");
|
||||
errorIndicatorColor = mode.getColor("errors.indicator.error.color");
|
||||
warningIndicatorColor = mode.getColor("errors.indicator.warning.color");
|
||||
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@@ -335,19 +353,45 @@ public class ErrorTable extends JTable {
|
||||
boolean selected,
|
||||
boolean focused,
|
||||
int row, int column) {
|
||||
Entry entry = (Entry) table.getValueAt(row, DATA_COLUMN);
|
||||
|
||||
if (selected) {
|
||||
setForeground(textColorSelected);
|
||||
setBackground(bgColorSelected);
|
||||
if (entry.isError()) {
|
||||
setBackground(bgColorError);
|
||||
} else if (entry.isWarning()) {
|
||||
setBackground(bgColorWarning);
|
||||
} else {
|
||||
setBackground(bgColorSelected);
|
||||
}
|
||||
} else {
|
||||
setForeground(textColor);
|
||||
setBackground(bgColor);
|
||||
}
|
||||
if (column == DATA_COLUMN || value == null) {
|
||||
if (column == DATA_COLUMN) {
|
||||
setText("\u2022");
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
if (entry.isError()) {
|
||||
setForeground(errorIndicatorColor);
|
||||
} else if (entry.isWarning()) {
|
||||
setForeground(warningIndicatorColor);
|
||||
} else {
|
||||
setText(""); // no dot
|
||||
}
|
||||
} else if (value == null) {
|
||||
setText("");
|
||||
} else {
|
||||
setHorizontalAlignment(SwingConstants.LEFT);
|
||||
setText(value.toString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Component dot = new JComponent() {
|
||||
// @Override
|
||||
// public void paintComponent(Graphics g) {
|
||||
//
|
||||
// }
|
||||
// };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ status.notice.fgcolor = #000000
|
||||
status.notice.bgcolor = #818b95
|
||||
status.error.fgcolor = #ffffff
|
||||
status.error.bgcolor = #9E0A0A
|
||||
status.edit.fgcolor = #000000
|
||||
status.edit.bgcolor = #cc9900
|
||||
#status.edit.fgcolor = #000000
|
||||
#status.edit.bgcolor = #cc9900
|
||||
status.warning.bgcolor = #EF8115
|
||||
status.warning.fgcolor = #FFFFFF
|
||||
status.font = processing.sans,plain,13
|
||||
|
||||
# HEADER TABS
|
||||
@@ -150,6 +152,11 @@ errors.row.fgcolor = #484848
|
||||
errors.row.bgcolor = #FFFFFF
|
||||
errors.selection.fgcolor = #242424
|
||||
errors.selection.bgcolor = #E5E5E5
|
||||
errors.selection.error.bgcolor = #F5E6E6
|
||||
errors.selection.warning.bgcolor = #FDF2E7
|
||||
#errors.indicator.size = 3
|
||||
errors.indicator.error.color = #9E0A0A
|
||||
errors.indicator.warning.color = #EF8115
|
||||
|
||||
manager.tab.selected.color = #e0fffd
|
||||
manager.tab.unselected.color = #2d4251
|
||||
|
||||
@@ -1882,20 +1882,20 @@ public class JavaEditor extends Editor {
|
||||
* them.
|
||||
*/
|
||||
protected void downloadImports() {
|
||||
String importRegex = errorCheckerService.importRegexp;
|
||||
String tabCode;
|
||||
for (SketchCode sc : sketch.getCode()) {
|
||||
if (sc.isExtension("pde")) {
|
||||
tabCode = sc.getProgram();
|
||||
String tabCode = sc.getProgram();
|
||||
|
||||
String[][] pieces = PApplet.matchAll(tabCode, importRegex);
|
||||
String[][] pieces =
|
||||
PApplet.matchAll(tabCode, ErrorCheckerService.IMPORT_REGEX);
|
||||
|
||||
if (pieces != null) {
|
||||
ArrayList<String> importHeaders = new ArrayList<String>();
|
||||
for (String[] importStatement : pieces) {
|
||||
importHeaders.add(importStatement[2]);
|
||||
}
|
||||
List<AvailableContribution> installLibsHeaders = getNotInstalledAvailableLibs(importHeaders);
|
||||
List<AvailableContribution> installLibsHeaders =
|
||||
getNotInstalledAvailableLibs(importHeaders);
|
||||
if (!installLibsHeaders.isEmpty()) {
|
||||
StringBuilder libList = new StringBuilder("Would you like to install them now?");
|
||||
for (AvailableContribution ac : installLibsHeaders) {
|
||||
@@ -1907,8 +1907,7 @@ public class JavaEditor extends Editor {
|
||||
libList.toString());
|
||||
|
||||
if (option == JOptionPane.YES_OPTION) {
|
||||
ContributionManager.downloadAndInstallOnImport(base,
|
||||
installLibsHeaders);
|
||||
ContributionManager.downloadAndInstallOnImport(base, installLibsHeaders);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2403,10 +2402,21 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
public static final int STATUS_EMPTY = 100, STATUS_COMPILER_ERR = 200,
|
||||
STATUS_WARNING = 300, STATUS_INFO = 400, STATUS_ERR = 500;
|
||||
public int statusMessageType = STATUS_EMPTY;
|
||||
public String statusMessage;
|
||||
public void statusMessage(String message, int type) {
|
||||
status.message(message, type);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
static final int STATUS_EMPTY = 100;
|
||||
static final int STATUS_COMPILER_ERR = 200;
|
||||
static final int STATUS_WARNING = 300;
|
||||
static final int STATUS_INFO = 400;
|
||||
static final int STATUS_ERR = 500;
|
||||
|
||||
int statusMessageType = STATUS_EMPTY;
|
||||
String statusMessage;
|
||||
|
||||
public void statusMessage(final String what, int type){
|
||||
// Don't re-display the old message again
|
||||
if (type != STATUS_EMPTY) {
|
||||
@@ -2451,6 +2461,7 @@ public class JavaEditor extends Editor {
|
||||
statusMessageType = STATUS_EMPTY;
|
||||
super.statusEmpty();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// /**
|
||||
|
||||
@@ -22,6 +22,7 @@ package processing.mode.java.pdex;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -61,7 +62,6 @@ import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
@@ -110,6 +110,7 @@ import processing.app.Platform;
|
||||
import processing.app.SketchCode;
|
||||
import processing.app.Util;
|
||||
import processing.app.syntax.JEditTextArea;
|
||||
import processing.app.ui.EditorStatus;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.data.StringList;
|
||||
import processing.mode.java.JavaEditor;
|
||||
@@ -1771,10 +1772,9 @@ public class ASTGenerator {
|
||||
(SimpleName) simpName);
|
||||
//retLabelString = getNodeAsString(decl);
|
||||
} else {
|
||||
// Base.loge("null");
|
||||
if (scrollOnly) {
|
||||
editor.statusMessage(simpName + " is not defined in this sketch",
|
||||
JavaEditor.STATUS_ERR);
|
||||
EditorStatus.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2059,7 +2059,7 @@ public class ASTGenerator {
|
||||
DefaultMutableTreeNode defCU = findAllOccurrences(); //TODO: Repetition here
|
||||
if(defCU == null){
|
||||
editor.statusMessage("Can't locate definition of " + selText,
|
||||
JavaEditor.STATUS_ERR);
|
||||
EditorStatus.ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2156,14 +2156,14 @@ public class ASTGenerator {
|
||||
log("Last clicked word:" + lastClickedWord);
|
||||
if (lastClickedWord == null &&
|
||||
getSelectedText() == null) {
|
||||
editor.statusMessage("Highlight the class/function/variable name first"
|
||||
, JavaEditor.STATUS_INFO);
|
||||
editor.statusMessage("Highlight the class/function/variable name first",
|
||||
EditorStatus.NOTICE);
|
||||
return;
|
||||
}
|
||||
|
||||
if(errorCheckerService.hasSyntaxErrors()){
|
||||
editor.statusMessage("Can't perform action until syntax errors are " +
|
||||
"fixed :(", JavaEditor.STATUS_WARNING);
|
||||
if (errorCheckerService.hasSyntaxErrors()){
|
||||
editor.statusMessage("Can't perform action until errors are fixed",
|
||||
EditorStatus.WARNING);
|
||||
return;
|
||||
}
|
||||
DefaultMutableTreeNode defCU = findAllOccurrences();
|
||||
@@ -2171,7 +2171,7 @@ public class ASTGenerator {
|
||||
getSelectedText() : lastClickedWord;
|
||||
if (defCU == null) {
|
||||
editor.statusMessage("Can't locate definition of " + selText,
|
||||
JavaEditor.STATUS_ERR);
|
||||
EditorStatus.ERROR);
|
||||
return;
|
||||
}
|
||||
if(defCU.getChildCount() == 0)
|
||||
@@ -2499,13 +2499,13 @@ public class ASTGenerator {
|
||||
if (lastClickedWord == null &&
|
||||
getSelectedText() == null) {
|
||||
editor.statusMessage("Highlight the class/function/variable name first",
|
||||
JavaEditor.STATUS_INFO);
|
||||
EditorStatus.NOTICE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorCheckerService.hasSyntaxErrors()) {
|
||||
editor.statusMessage("Can't perform action until syntax errors are fixed :(",
|
||||
JavaEditor.STATUS_WARNING);
|
||||
EditorStatus.WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2513,8 +2513,8 @@ public class ASTGenerator {
|
||||
String selText = lastClickedWord == null ?
|
||||
getSelectedText() : lastClickedWord;
|
||||
if (defCU == null) {
|
||||
editor.statusMessage(selText + " isn't defined in this sketch, so it can't" +
|
||||
" be renamed", JavaEditor.STATUS_ERR);
|
||||
editor.statusMessage(selText + " isn't defined in this sketch, " +
|
||||
"so it cannot be renamed", EditorStatus.ERROR);
|
||||
return;
|
||||
}
|
||||
if (!frmRename.isVisible()){
|
||||
@@ -2524,7 +2524,7 @@ public class ASTGenerator {
|
||||
+ (editor.getHeight() - frmRename.getHeight())
|
||||
/ 2);
|
||||
frmRename.setVisible(true);
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String selText = lastClickedWord == null ? getSelectedText()
|
||||
|
||||
@@ -181,7 +181,8 @@ public class ErrorCheckerService {
|
||||
/**
|
||||
* Regexp for import statements. (Used from Processing source)
|
||||
*/
|
||||
public static final String importRegexp = "(?:^|;)\\s*(import\\s+)((?:static\\s+)?\\S+)(\\s*;)";
|
||||
public static final String IMPORT_REGEX =
|
||||
"(?:^|;)\\s*(import\\s+)((?:static\\s+)?\\S+)(\\s*;)";
|
||||
|
||||
// /**
|
||||
// * Regexp for function declarations. (Used from Processing source)
|
||||
@@ -945,7 +946,7 @@ public class ErrorCheckerService {
|
||||
* line or not
|
||||
*/
|
||||
public void updateEditorStatus() {
|
||||
if (editor.getStatusMode() == EditorStatus.EDIT) return;
|
||||
// if (editor.getStatusMode() == EditorStatus.EDIT) return;
|
||||
|
||||
// editor.statusNotice("Position: " +
|
||||
// editor.getTextArea().getCaretLine());
|
||||
@@ -954,20 +955,20 @@ public class ErrorCheckerService {
|
||||
if (errorMarker != null) {
|
||||
if (errorMarker.getType() == LineMarker.WARNING) {
|
||||
editor.statusMessage(errorMarker.getProblem().getMessage(),
|
||||
JavaEditor.STATUS_INFO);
|
||||
EditorStatus.WARNING);
|
||||
} else {
|
||||
editor.statusMessage(errorMarker.getProblem().getMessage(),
|
||||
JavaEditor.STATUS_COMPILER_ERR);
|
||||
EditorStatus.COMPILER_ERROR);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This line isn't an error line anymore, so probably just clear it
|
||||
if (editor.statusMessageType == JavaEditor.STATUS_COMPILER_ERR) {
|
||||
editor.statusEmpty();
|
||||
return;
|
||||
}
|
||||
// // This line isn't an error line anymore, so probably just clear it
|
||||
// if (editor.statusMessageType == JavaEditor.STATUS_COMPILER_ERR) {
|
||||
// editor.statusEmpty();
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -1462,7 +1463,7 @@ public class ErrorCheckerService {
|
||||
String tabSource = tabProgram;
|
||||
do {
|
||||
// log("-->\n" + sourceAlt + "\n<--");
|
||||
String[] pieces = PApplet.match(tabSource, importRegexp);
|
||||
String[] pieces = PApplet.match(tabSource, IMPORT_REGEX);
|
||||
|
||||
// Stop the loop if we've removed all the import lines
|
||||
if (pieces == null) {
|
||||
|
||||
@@ -25,16 +25,14 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.jdt.core.compiler.IProblem;
|
||||
|
||||
import processing.app.ui.ErrorTable;
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper class for IProblem.
|
||||
*
|
||||
* Stores the tabIndex and line number according to its tab, including the
|
||||
* original IProblem object
|
||||
*
|
||||
* @author Manindra Moharana <me@mkmoharana.com>
|
||||
*
|
||||
* Wrapper class for IProblem that stores the tabIndex and line number
|
||||
* according to its tab, including the original IProblem object
|
||||
*/
|
||||
public class Problem {
|
||||
public class Problem implements ErrorTable.Entry {
|
||||
/**
|
||||
* The IProblem which is being wrapped
|
||||
*/
|
||||
@@ -42,14 +40,14 @@ public class Problem {
|
||||
/**
|
||||
* The tab number to which the error belongs to
|
||||
*/
|
||||
private int tabIndex;
|
||||
private int tabIndex;
|
||||
/**
|
||||
* Line number(pde code) of the error
|
||||
*/
|
||||
private int lineNumber;
|
||||
|
||||
|
||||
private int lineStartOffset;
|
||||
|
||||
|
||||
private int lineStopOffset;
|
||||
|
||||
/**
|
||||
@@ -61,7 +59,7 @@ public class Problem {
|
||||
* The type of error - WARNING or ERROR.
|
||||
*/
|
||||
private int type;
|
||||
|
||||
|
||||
/**
|
||||
* If the error is a 'cannot find type' contains the list of suggested imports
|
||||
*/
|
||||
@@ -70,7 +68,7 @@ public class Problem {
|
||||
public static final int ERROR = 1, WARNING = 2;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param iProblem - The IProblem which is being wrapped
|
||||
* @param tabIndex - The tab number to which the error belongs to
|
||||
* @param lineNumber - Line number(pde code) of the error
|
||||
@@ -89,17 +87,17 @@ public class Problem {
|
||||
this.message = ErrorMessageSimplifier.getSimplifiedErrorMessage(this);
|
||||
//ErrorMessageSimplifier.getSimplifiedErrorMessage(this);
|
||||
}
|
||||
|
||||
|
||||
public void setPDEOffsets(int startOffset, int stopOffset){
|
||||
lineStartOffset = startOffset;
|
||||
lineStopOffset = stopOffset;
|
||||
}
|
||||
|
||||
public int getPDELineStartOffset(){
|
||||
|
||||
public int getPDELineStartOffset() {
|
||||
return lineStartOffset;
|
||||
}
|
||||
|
||||
public int getPDELineStopOffset(){
|
||||
|
||||
public int getPDELineStopOffset() {
|
||||
return lineStopOffset;
|
||||
}
|
||||
|
||||
@@ -109,37 +107,37 @@ public class Problem {
|
||||
+ message);
|
||||
}
|
||||
|
||||
public boolean isError(){
|
||||
public boolean isError() {
|
||||
return type == ERROR;
|
||||
}
|
||||
|
||||
public boolean isWarning(){
|
||||
public boolean isWarning() {
|
||||
return type == WARNING;
|
||||
}
|
||||
|
||||
public String getMessage(){
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public IProblem getIProblem(){
|
||||
public IProblem getIProblem() {
|
||||
return iProblem;
|
||||
}
|
||||
|
||||
public int getTabIndex(){
|
||||
|
||||
public int getTabIndex() {
|
||||
return tabIndex;
|
||||
}
|
||||
|
||||
public int getLineNumber(){
|
||||
|
||||
public int getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remember to subtract a -1 to line number because in compile check code an
|
||||
* extra package statement is added, so all line numbers are increased by 1
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getSourceLineNumber(){
|
||||
public int getSourceLineNumber() {
|
||||
return iProblem.getSourceLineNumber();
|
||||
}
|
||||
|
||||
@@ -150,11 +148,11 @@ public class Problem {
|
||||
type = WARNING;
|
||||
else throw new IllegalArgumentException("Illegal Problem type passed to Problem.setType(int)");
|
||||
}
|
||||
|
||||
|
||||
public String[] getImportSuggestions() {
|
||||
return importSuggestions;
|
||||
}
|
||||
|
||||
|
||||
public void setImportSuggestions(String[] a) {
|
||||
importSuggestions = a;
|
||||
}
|
||||
@@ -169,7 +167,7 @@ public class Problem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes error messages and attempts to make them a bit more english like.
|
||||
* Processes error messages and attempts to make them a bit more english like.
|
||||
* Currently performs:
|
||||
* <li>Remove all instances of token. "Syntax error on token 'blah', delete this token"
|
||||
* becomes "Syntax error on 'blah', delete this"
|
||||
@@ -179,7 +177,7 @@ public class Problem {
|
||||
public static String process(String message) {
|
||||
// Remove all instances of token
|
||||
// "Syntax error on token 'blah', delete this token"
|
||||
if(message == null) return null;
|
||||
if(message == null) return null;
|
||||
pattern = Pattern.compile(tokenRegExp);
|
||||
matcher = pattern.matcher(message);
|
||||
message = matcher.replaceAll("");
|
||||
@@ -187,7 +185,7 @@ public class Problem {
|
||||
return message;
|
||||
}
|
||||
|
||||
// Split camel case words into separate words.
|
||||
// Split camel case words into separate words.
|
||||
// "VaraibleDeclaration" becomes "Variable Declaration"
|
||||
// But sadly "PApplet" become "P Applet" and so on.
|
||||
public static String splitCamelCaseWord(String word) {
|
||||
|
||||
Reference in New Issue
Block a user