Skip to content

Commit 60a088f

Browse files
committed
cleaning up for Java Mode
1 parent cea4621 commit 60a088f

File tree

14 files changed

+225
-264
lines changed

14 files changed

+225
-264
lines changed

java/src/processing/mode/java/JavaBuild.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,9 @@ protected boolean exportApplication() throws IOException, SketchException {
778778
// if name != exportSketchName, then that's weirdness
779779
// BUG unfortunately, that can also be a bug in the preproc :(
780780
if (!sketch.getName().equals(foundName)) {
781-
Base.showWarning("Error during export",
782-
"Sketch name is " + sketch.getName() + " but the sketch\n" +
783-
"name in the code was " + foundName, null);
781+
Messages.showWarning("Error during export",
782+
"Sketch name is " + sketch.getName() + " but the sketch\n" +
783+
"name in the code was " + foundName, null);
784784
return false;
785785
}
786786

@@ -862,11 +862,11 @@ protected boolean exportApplication(File destFolder,
862862
for (Library library : importedLibraries) {
863863
if (!library.supportsArch(exportPlatform, exportVariant)) {
864864
String pn = PConstants.platformNames[exportPlatform];
865-
Base.showWarning("Quibbles 'n Bits",
866-
"The application." + pn + exportVariant +
867-
" folder will not be created\n" +
868-
"because no " + exportVariant + " version of " +
869-
library.getName() + " is available for " + pn, null);
865+
Messages.showWarning("Quibbles 'n Bits",
866+
"The application." + pn + exportVariant +
867+
" folder will not be created\n" +
868+
"because no " + exportVariant + " version of " +
869+
library.getName() + " is available for " + pn, null);
870870
return true; // don't cancel all exports for this, just move along
871871
}
872872
}

java/src/processing/mode/java/JavaEditor.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ public void actionPerformed(ActionEvent e) {
360360
try {
361361
new Welcome(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath()));
362362
} catch (IOException ioe) {
363-
Base.showWarning("Unwelcome Error",
364-
"Please report this error to\n" +
365-
"https://github.com/processing/processing/issues", ioe);
363+
Messages.showWarning("Unwelcome Error",
364+
"Please report this error to\n" +
365+
"https://github.com/processing/processing/issues", ioe);
366366
}
367367
}
368368
});
@@ -1101,15 +1101,15 @@ public void actionPerformed(ActionEvent e) {
11011101
protected boolean handleExportCheckModified() {
11021102
if (sketch.isReadOnly()) {
11031103
// if the files are read-only, need to first do a "save as".
1104-
Base.showMessage(Language.text("export.messages.is_read_only"),
1105-
Language.text("export.messages.is_read_only.description"));
1104+
Messages.showMessage(Language.text("export.messages.is_read_only"),
1105+
Language.text("export.messages.is_read_only.description"));
11061106
return false;
11071107
}
11081108

11091109
// don't allow if untitled
11101110
if (sketch.isUntitled()) {
1111-
Base.showMessage(Language.text("export.messages.cannot_export"),
1112-
Language.text("export.messages.cannot_export.description"));
1111+
Messages.showMessage(Language.text("export.messages.cannot_export"),
1112+
Language.text("export.messages.cannot_export.description"));
11131113
return false;
11141114
}
11151115

@@ -1753,7 +1753,7 @@ protected void addBreakpointComments(String tabFilename) {
17531753
// this method gets called twice when saving sketch for the first time
17541754
// once with new name and another with old(causing NPE). Keep an eye out
17551755
// for potential issues. See #2675. TODO:
1756-
Base.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
1756+
Messages.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
17571757
return;
17581758
}
17591759
List<LineBreakpoint> bps = debugger.getBreakpoints(tab.getFileName());
@@ -1988,7 +1988,7 @@ protected void downloadImports() {
19881988
for (AvailableContribution ac : installLibsHeaders) {
19891989
libList.append("\n • " + ac.getName());
19901990
}
1991-
int option = Base.showYesNoQuestion(this,
1991+
int option = Messages.showYesNoQuestion(this,
19921992
Language.text("contrib.import.dialog.title"),
19931993
Language.text("contrib.import.dialog.primary_text"),
19941994
libList.toString());
@@ -2624,14 +2624,14 @@ public void updateErrorToggle() {
26242624

26252625
/** Handle refactor operation */
26262626
private void handleRefactor() {
2627-
Base.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
2627+
Messages.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
26282628
errorCheckerService.getASTGenerator().handleRefactor();
26292629
}
26302630

26312631

26322632
/** Handle show usage operation */
26332633
private void handleShowUsage() {
2634-
Base.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
2634+
Messages.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
26352635
errorCheckerService.getASTGenerator().handleShowUsage();
26362636
}
26372637

@@ -2667,7 +2667,7 @@ protected void applyPreferences() {
26672667
super.applyPreferences();
26682668
if (jmode != null) {
26692669
jmode.loadPreferences();
2670-
Base.log("Applying prefs");
2670+
Messages.log("Applying prefs");
26712671
// trigger it once to refresh UI
26722672
errorCheckerService.runManualErrorCheck();
26732673
}
@@ -2703,9 +2703,9 @@ protected void stopTweakMode(List<List<Handle>> handles) {
27032703

27042704
if (modified) {
27052705
// ask to keep the values
2706-
if (Base.showYesNoQuestion(this, Language.text("tweak_mode"),
2707-
Language.text("tweak_mode.keep_changes.line1"),
2708-
Language.text("tweak_mode.keep_changes.line2")) == JOptionPane.YES_OPTION) {
2706+
if (Messages.showYesNoQuestion(this, Language.text("tweak_mode"),
2707+
Language.text("tweak_mode.keep_changes.line1"),
2708+
Language.text("tweak_mode.keep_changes.line2")) == JOptionPane.YES_OPTION) {
27092709
for (int i = 0; i < sketch.getCodeCount(); i++) {
27102710
if (tweakedTabs[i]) {
27112711
sketch.getCode(i).setModified(true);
@@ -2729,7 +2729,7 @@ protected void stopTweakMode(List<List<Handle>> handles) {
27292729
try {
27302730
sketch.save();
27312731
} catch (IOException e) {
2732-
Base.showWarning("Error", "Could not save the modified sketch.", e);
2732+
Messages.showWarning("Error", "Could not save the modified sketch.", e);
27332733
}
27342734

27352735
// repaint the editor header (show the modified tabs)

java/src/processing/mode/java/JavaMode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ public Runner handleTweak(Sketch sketch,
162162

163163
if (isSketchModified(sketch)) {
164164
editor.deactivateRun();
165-
Base.showMessage(Language.text("menu.file.save"),
166-
Language.text("tweak_mode.save_before_tweak"));
165+
Messages.showMessage(Language.text("menu.file.save"),
166+
Language.text("tweak_mode.save_before_tweak"));
167167
return null;
168168
}
169169

@@ -327,7 +327,7 @@ void initLogger() {
327327

328328

329329
public void loadPreferences() {
330-
Base.log("Load PDEX prefs");
330+
Messages.log("Load PDEX prefs");
331331
ensurePrefsExist();
332332
errorCheckEnabled = Preferences.getBoolean(prefErrorCheck);
333333
warningsEnabled = Preferences.getBoolean(prefWarnings);
@@ -345,7 +345,7 @@ public void loadPreferences() {
345345

346346

347347
public void savePreferences() {
348-
Base.log("Saving PDEX prefs");
348+
Messages.log("Saving PDEX prefs");
349349
Preferences.setBoolean(prefErrorCheck, errorCheckEnabled);
350350
Preferences.setBoolean(prefWarnings, warningsEnabled);
351351
Preferences.setBoolean(prefCodeCompletionEnabled, codeCompletionsEnabled);

java/src/processing/mode/java/debug/LineBreakpoint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.logging.Level;
2525
import java.util.logging.Logger;
2626

27-
import processing.app.Base;
27+
import processing.app.Messages;
2828
import processing.mode.java.Debugger;
2929

3030
import com.sun.jdi.AbsentInformationException;
@@ -220,13 +220,13 @@ protected String className() {
220220
@Override
221221
public void classLoaded(ReferenceType theClass) {
222222
// check if our class is being loaded
223-
Base.log("Class Loaded: " + theClass.name());
223+
Messages.log("Class Loaded: " + theClass.name());
224224
if (theClass.name().equals(className())) {
225225
this.theClass = theClass;
226226
attach();
227227
}
228228
for (ReferenceType ct : theClass.nestedTypes()) {
229-
Base.log("Nested " + ct.name());
229+
Messages.log("Nested " + ct.name());
230230
}
231231
}
232232
}

java/src/processing/mode/java/pdex/ASTGenerator.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
import org.jsoup.nodes.Document;
107107
import org.jsoup.select.Elements;
108108

109-
import processing.app.Base;
110109
import processing.app.Library;
110+
import processing.app.Messages;
111111
import processing.app.Platform;
112112
import processing.app.SketchCode;
113113
import processing.app.Util;
@@ -243,7 +243,7 @@ protected DefaultMutableTreeNode buildAST(String source, CompilationUnit cu) {
243243
.types().get(0)));
244244
//log("Total CU " + compilationUnit.types().size());
245245
if(compilationUnit.types() == null || compilationUnit.types().isEmpty()){
246-
Base.loge("No CU found!");
246+
Messages.loge("No CU found!");
247247
}
248248
visitRecur((ASTNode) compilationUnit.types().get(0), codeTree);
249249
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
@@ -869,7 +869,7 @@ public void preparePredictions(final String word, final int line,
869869
ASTNode testnode = parser.createAST(null);
870870
//Base.loge("PREDICTION PARSER PROBLEMS: " + parser);
871871
// Find closest ASTNode of the document to this word
872-
Base.loge("Typed: " + word2 + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
872+
Messages.loge("Typed: " + word2 + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
873873
if(testnode instanceof MethodInvocation){
874874
MethodInvocation mi = (MethodInvocation)testnode;
875875
log(mi.getName() + "," + mi.getExpression() + "," + mi.typeArguments().size());
@@ -882,15 +882,15 @@ public void preparePredictions(final String word, final int line,
882882
// Make sure nearestNode is not NULL if couldn't find a closeset node
883883
nearestNode = (ASTNode) errorCheckerService.getLastCorrectCU().types().get(0);
884884
}
885-
Base.loge(lineNumber + " Nearest ASTNode to PRED "
885+
Messages.loge(lineNumber + " Nearest ASTNode to PRED "
886886
+ getNodeAsString(nearestNode));
887887

888888
candidates = new ArrayList<CompletionCandidate>();
889889
lastPredictedWord = word2;
890890
// Determine the expression typed
891891

892892
if (testnode instanceof SimpleName && !noCompare) {
893-
Base.loge("One word expression " + getNodeAsString(testnode));
893+
Messages.loge("One word expression " + getNodeAsString(testnode));
894894
//==> Simple one word exprssion - so is just an identifier
895895

896896
// Bottom up traversal of the AST to look for possible definitions at
@@ -974,7 +974,7 @@ public void preparePredictions(final String word, final int line,
974974

975975
// ==> Complex expression of type blah.blah2().doIt,etc
976976
// Have to resolve it by carefully traversing AST of testNode
977-
Base.loge("Complex expression " + getNodeAsString(testnode));
977+
Messages.loge("Complex expression " + getNodeAsString(testnode));
978978
log("candidates empty");
979979
ASTNode childExpr = getChildExpression(testnode);
980980
log("Parent expression : " + getParentExpression(testnode));
@@ -1236,7 +1236,7 @@ public String getJavaSourceCodeLine(int javaLineNumber) {
12361236
- lineElement.getStartOffset());
12371237
return javaLine;
12381238
} catch (BadLocationException e) {
1239-
Base.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
1239+
Messages.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
12401240
}
12411241
return null;
12421242
}
@@ -1263,7 +1263,7 @@ public Element getJavaSourceCodeElement(int javaLineNumber) {
12631263
// - lineElement.getStartOffset());
12641264
return lineElement;
12651265
} catch (BadLocationException e) {
1266-
Base.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
1266+
Messages.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
12671267
}
12681268
return null;
12691269
}
@@ -1744,7 +1744,7 @@ public ASTNodeWrapper getASTNodeAt(int lineNumber, String name, int offset,
17441744
ASTNodeWrapper declWrap = new ASTNodeWrapper(simpName2, nodeLabel);
17451745
//errorCheckerService.highlightNode(declWrap);
17461746
if (!declWrap.highlightNode(this)) {
1747-
Base.loge("Highlighting failed.");
1747+
Messages.loge("Highlighting failed.");
17481748
}
17491749
}
17501750

@@ -1859,7 +1859,7 @@ protected void addListeners(){
18591859

18601860
@Override
18611861
public void valueChanged(TreeSelectionEvent e) {
1862-
Base.log(e.toString());
1862+
Messages.log(e.toString());
18631863
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
18641864

18651865
@Override
@@ -2159,8 +2159,7 @@ protected DefaultMutableTreeNode findAllOccurrences(){
21592159
if(wnode.getNode() == null){
21602160
return null;
21612161
}
2162-
Base.loge("Gonna find all occurrences of "
2163-
+ getNodeAsString(wnode.getNode()));
2162+
Messages.loge("Gonna find all occurrences of " + getNodeAsString(wnode.getNode()));
21642163

21652164
//If wnode is a constructor, find the TD instead.
21662165
if (wnode.getNodeType() == ASTNode.METHOD_DECLARATION) {
@@ -2176,7 +2175,7 @@ protected DefaultMutableTreeNode findAllOccurrences(){
21762175
if(node != null && node instanceof TypeDeclaration){
21772176
TypeDeclaration td = (TypeDeclaration) node;
21782177
if(td.getName().toString().equals(md.getName().toString())){
2179-
Base.loge("Renaming constructor of " + getNodeAsString(td));
2178+
Messages.loge("Renaming constructor of " + getNodeAsString(td));
21802179
wnode = new ASTNodeWrapper(td);
21812180
}
21822181
}
@@ -2414,7 +2413,7 @@ protected boolean isInstanceOfType(ASTNode node,ASTNode decl, String name){
24142413
}
24152414
log("Visiting: " + getNodeAsString(node));
24162415
ASTNode decl2 = findDeclaration(sn);
2417-
Base.loge("It's decl: " + getNodeAsString(decl2));
2416+
Messages.loge("It's decl: " + getNodeAsString(decl2));
24182417
log("But we need: "+getNodeAsString(decl));
24192418
for (ASTNode astNode : nodesToBeMatched) {
24202419
if(astNode.equals(decl2)){
@@ -3714,7 +3713,7 @@ else if (className.endsWith("Type"))
37143713

37153714

37163715
static private void log(Object object) {
3717-
Base.log(object == null ? "null" : object.toString());
3716+
Messages.log(object == null ? "null" : object.toString());
37183717
}
37193718

37203719

0 commit comments

Comments
 (0)