change Messages.loge() to Messages.err(), additional cleanup

This commit is contained in:
Ben Fry
2021-08-03 20:44:03 -04:00
parent 58dc712232
commit 0419b1ffb2
26 changed files with 97 additions and 111 deletions

View File

@@ -95,7 +95,7 @@ class ASTViewer {
void buildAndUpdateTree(PreprocSketch ps) {
CompilationUnit cu = ps.compilationUnit;
if (cu.types().isEmpty()){
Messages.loge("No Type found in CU");
Messages.err("No Type found in CU");
return;
}

View File

@@ -1750,7 +1750,7 @@ public class CompletionGenerator {
ASTNode testnode = parser.createAST(null);
//Base.loge("PREDICTION PARSER PROBLEMS: " + parser);
// Find closest ASTNode of the document to this word
Messages.loge("Typed: " + phrase + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
Messages.err("Typed: " + phrase + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
if(testnode instanceof MethodInvocation){
MethodInvocation mi = (MethodInvocation)testnode;
log(mi.getName() + "," + mi.getExpression() + "," + mi.typeArguments().size());
@@ -1762,7 +1762,7 @@ public class CompletionGenerator {
// Make sure nearestNode is not NULL if couldn't find a closest node
nearestNode = astRootNode;
}
Messages.loge(lineNumber + " Nearest ASTNode to PRED "
Messages.err(lineNumber + " Nearest ASTNode to PRED "
+ getNodeAsString(nearestNode));
candidates = new ArrayList<>();
@@ -1770,7 +1770,7 @@ public class CompletionGenerator {
// Determine the expression typed
if (testnode instanceof SimpleName && !noCompare) {
Messages.loge("One word expression " + getNodeAsString(testnode));
Messages.err("One word expression " + getNodeAsString(testnode));
//==> Simple one word exprssion - so is just an identifier
// Bottom up traversal of the AST to look for possible definitions at
@@ -1850,7 +1850,7 @@ public class CompletionGenerator {
} else {
// ==> Complex expression of type blah.blah2().doIt,etc
// Have to resolve it by carefully traversing AST of testNode
Messages.loge("Complex expression " + getNodeAsString(testnode));
Messages.err("Complex expression " + getNodeAsString(testnode));
log("candidates empty");
ASTNode childExpr = getChildExpression(testnode);
log("Parent expression : " + getParentExpression(testnode));

View File

@@ -96,7 +96,6 @@ public class CompletionPanel {
* @param subWord - Partial word which triggered the code completion and which needs to be completed
* @param items - completion candidates
* @param location - Point location where popup list is to be displayed
* @param dedit
*/
public CompletionPanel(final JEditTextArea textarea,
int position, String subWord,
@@ -377,7 +376,7 @@ public class CompletionPanel {
}
}
Messages.loge(subWord + " <= subword, Inserting suggestion=> " +
Messages.err(subWord + " <= subword, Inserting suggestion=> " +
selectedSuggestion + " Current sub: " + currentSubword);
if (currentSubword.length() > 0) {
textarea.getDocument().remove(insertionPosition - currentSubwordLen,

View File

@@ -27,7 +27,6 @@ import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -1326,7 +1325,7 @@ public class JavaEditor extends Editor {
// this method gets called twice when saving sketch for the first time
// once with new name and another with old(causing NPE). Keep an eye out
// for potential issues. See #2675. TODO:
Messages.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
Messages.err("Illegal tab name to addBreakpointComments() " + tabFilename);
return;
}
List<LineBreakpoint> bps = debugger.getBreakpoints(tab.getFileName());
@@ -1349,7 +1348,7 @@ public class JavaEditor extends Editor {
tab.setProgram(code);
tab.save();
} catch (IOException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
}

View File

@@ -335,7 +335,7 @@ public class JavaTextArea extends PdeTextArea {
}
});
} catch (Exception e) {
Messages.loge("error while preparing suggestions", e);
Messages.err("error while preparing suggestions", e);
}
});
}

View File

@@ -53,8 +53,6 @@ import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FileASTRequestor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
import processing.app.Messages;
import processing.app.Sketch;
@@ -154,7 +152,7 @@ public class PreprocService {
}
}
} catch (Exception e) {
Messages.loge("problem in preprocessor service loop", e);
Messages.err("problem in preprocessor service loop", e);
}
}
Messages.log("PPS: Bye!");
@@ -224,7 +222,7 @@ public class PreprocService {
.thenAcceptBothAsync(lastCallback, (ps, a) -> callback.accept(ps))
// Make sure exception in callback won't cancel whole callback chain
.handleAsync((res, e) -> {
if (e != null) Messages.loge("PPS: exception in callback", e);
if (e != null) Messages.err("PPS: exception in callback", e);
return res;
});
return lastCallback;
@@ -314,7 +312,7 @@ public class PreprocService {
try {
listener.accept(ps);
} catch (Exception e) {
Messages.loge("error when firing preprocessing listener", e);
Messages.err("error when firing preprocessing listener", e);
}
}
}
@@ -734,7 +732,7 @@ public class PreprocService {
* for the sketch's combined PDE code (not ".java" tabs).
* </p>
*/
private class ProcessingASTRequester extends FileASTRequestor {
static private class ProcessingASTRequester extends FileASTRequestor {
private final String mainSource;
private final List<IProblem> problems;
private CompilationUnit mainCompilationUnit;

View File

@@ -257,21 +257,21 @@ public class RuntimePathBuilder {
}
/**
* Invalidate all of the runtime path caches associated with sketch libraries.
* Invalidate all the runtime path caches associated with sketch libraries.
*/
public void markLibrariesChanged() {
invalidateAll(libraryDependentCaches);
}
/**
* Invalidate all of the runtime path caches associated with sketch library imports.
* Invalidate all the runtime path caches associated with sketch library imports.
*/
public void markLibraryImportsChanged() {
invalidateAll(libraryImportsDependentCaches);
}
/**
* Invalidate all of the runtime path caches associated with the code folder having changed.
* Invalidate all the runtime path caches associated with the code folder having changed.
*/
public void markCodeFolderChanged() {
invalidateAll(codeFolderDependentCaches);
@@ -324,7 +324,7 @@ public class RuntimePathBuilder {
try {
return Paths.get(path).toUri().toURL();
} catch (MalformedURLException e) {
Messages.loge("malformed URL when preparing sketch classloader", e);
Messages.err("malformed URL when preparing sketch classloader", e);
return null;
}
})
@@ -556,9 +556,7 @@ public class RuntimePathBuilder {
/**
* Determine if a package is ignorable because it is standard.
*
* Determine if a package is ignorable on the sketch path because it is standard. This is
* different than being ignorable in imports recommendations.
* This is different from being ignorable in imports recommendations.
*
* @param packageName The name of the package to evaluate.
* @return True if the package is part of standard Java (like java.lang.*). False otherwise.
@@ -570,8 +568,8 @@ public class RuntimePathBuilder {
/**
* Find a fully qualified jar name.
*
* @param jarName The jar name like "javafx.base.jar" for which a fully qualified entry should be
* created.
* @param jarName The jar name like "javafx.base.jar" for which a
* fully qualified entry should be created.
* @return The fully qualified classpath entry like ".../Processing.app/Contents/PlugIns/
* adoptopenjdk-11.0.1.jdk/Contents/Home/lib/javafx.base.jar"
*/

View File

@@ -53,7 +53,7 @@ public class ArrayFieldNode extends VariableNode {
try {
array.setValue(index, value);
} catch (InvalidTypeException | ClassNotLoadedException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
this.value = value;
}

View File

@@ -1547,15 +1547,15 @@ public class Debugger {
private void loge(String msg, Throwable t) {
if (t != null) {
Messages.loge(getClass().getName() + " " + msg, t);
Messages.err(getClass().getName() + " " + msg, t);
} else {
Messages.loge(getClass().getName() + " " + msg);
Messages.err(getClass().getName() + " " + msg);
}
}
static private void logitse(Throwable t) {
Messages.loge("incompatible thread state?", t);
Messages.err("incompatible thread state?", t);
}
@@ -1607,7 +1607,7 @@ public class Debugger {
} catch (VMDisconnectedException e) {
Messages.log("VMEventReader quit on VM disconnect");
} catch (Exception e) {
Messages.loge("VMEventReader quit", e);
Messages.err("VMEventReader quit", e);
}
}
}

View File

@@ -56,9 +56,9 @@ public class FieldNode extends VariableNode {
try {
obj.setValue(field, value);
} catch (InvalidTypeException ite) {
Messages.loge(null, ite);
Messages.err(null, ite);
} catch (ClassNotLoadedException cnle) {
Messages.loge(null, cnle);
Messages.err(null, cnle);
}
this.value = value;
}

View File

@@ -34,7 +34,7 @@ import com.sun.jdi.request.BreakpointRequest;
/**
* Model/Controller of a line breakpoint. Can be set before or while debugging.
* Adds a highlight using the debuggers view ({@link DebugEditor}).
* Adds a highlight using the debuggers view.
*/
public class LineBreakpoint implements ClassLoadListener {
protected Debugger dbg; // the debugger
@@ -131,7 +131,7 @@ public class LineBreakpoint implements ClassLoadListener {
log("attached breakpoint to " + line + " -> " + javaLine);
return true;
} catch (AbsentInformationException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
return false;
}
@@ -158,7 +158,7 @@ public class LineBreakpoint implements ClassLoadListener {
/**
* Set this breakpoint. Adds the line highlight. If Debugger is paused
* also attaches the breakpoint by calling {@link #attach()}.
* also attaches the breakpoint by calling {@link #attach}.
*/
protected void set() {
dbg.addClassLoadListener(this); // class may not yet be loaded

View File

@@ -37,8 +37,8 @@ import processing.app.Messages;
/**
* Describes an ID for a code line. Comprised of a file name and a (0-based)
* line number. Can track changes to the line number due to text editing by
* attaching a {@link Document}. Registered {@link LineListener}s are notified
* of changes to the line number.
* attaching a {@link Document}. Registered listeners are notified of changes
* to the line number.
*/
public class LineID implements DocumentListener {
protected String fileName; // the filename
@@ -151,7 +151,7 @@ public class LineID implements DocumentListener {
this.doc = doc;
doc.addDocumentListener(this);
} catch (BadLocationException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
pos = null;
this.doc = null;
}

View File

@@ -52,7 +52,7 @@ public class LocalVariableNode extends VariableNode {
try {
frame.setValue(var, value);
} catch (InvalidTypeException | ClassNotLoadedException ex) {
Messages.loge(null, ex);
Messages.err(null, ex);
}
this.value = value;
}

View File

@@ -288,11 +288,11 @@ public class Runner implements MessageConsumer {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
Messages.loge(getClass().getName() + " interrupted", ie);
Messages.err(getClass().getName() + " interrupted", ie);
// ie.printStackTrace(sketchErr);
}
} catch (IOException e) {
Messages.loge(getClass().getName() + " while attaching to VM", e);
Messages.err(getClass().getName() + " while attaching to VM", e);
}
}
// } catch (IOException exc) {