cleaning up for Java Mode

This commit is contained in:
Ben Fry
2015-08-13 22:28:18 -04:00
parent 231de54cd5
commit 8f8d426cb1
14 changed files with 225 additions and 264 deletions
+8 -8
View File
@@ -778,9 +778,9 @@ public class JavaBuild {
// if name != exportSketchName, then that's weirdness
// BUG unfortunately, that can also be a bug in the preproc :(
if (!sketch.getName().equals(foundName)) {
Base.showWarning("Error during export",
"Sketch name is " + sketch.getName() + " but the sketch\n" +
"name in the code was " + foundName, null);
Messages.showWarning("Error during export",
"Sketch name is " + sketch.getName() + " but the sketch\n" +
"name in the code was " + foundName, null);
return false;
}
@@ -862,11 +862,11 @@ public class JavaBuild {
for (Library library : importedLibraries) {
if (!library.supportsArch(exportPlatform, exportVariant)) {
String pn = PConstants.platformNames[exportPlatform];
Base.showWarning("Quibbles 'n Bits",
"The application." + pn + exportVariant +
" folder will not be created\n" +
"because no " + exportVariant + " version of " +
library.getName() + " is available for " + pn, null);
Messages.showWarning("Quibbles 'n Bits",
"The application." + pn + exportVariant +
" folder will not be created\n" +
"because no " + exportVariant + " version of " +
library.getName() + " is available for " + pn, null);
return true; // don't cancel all exports for this, just move along
}
}
+16 -16
View File
@@ -360,9 +360,9 @@ public class JavaEditor extends Editor {
try {
new Welcome(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath()));
} catch (IOException ioe) {
Base.showWarning("Unwelcome Error",
"Please report this error to\n" +
"https://github.com/processing/processing/issues", ioe);
Messages.showWarning("Unwelcome Error",
"Please report this error to\n" +
"https://github.com/processing/processing/issues", ioe);
}
}
});
@@ -1101,15 +1101,15 @@ public class JavaEditor extends Editor {
protected boolean handleExportCheckModified() {
if (sketch.isReadOnly()) {
// if the files are read-only, need to first do a "save as".
Base.showMessage(Language.text("export.messages.is_read_only"),
Language.text("export.messages.is_read_only.description"));
Messages.showMessage(Language.text("export.messages.is_read_only"),
Language.text("export.messages.is_read_only.description"));
return false;
}
// don't allow if untitled
if (sketch.isUntitled()) {
Base.showMessage(Language.text("export.messages.cannot_export"),
Language.text("export.messages.cannot_export.description"));
Messages.showMessage(Language.text("export.messages.cannot_export"),
Language.text("export.messages.cannot_export.description"));
return false;
}
@@ -1753,7 +1753,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:
Base.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
Messages.loge("Illegal tab name to addBreakpointComments() " + tabFilename);
return;
}
List<LineBreakpoint> bps = debugger.getBreakpoints(tab.getFileName());
@@ -1988,7 +1988,7 @@ public class JavaEditor extends Editor {
for (AvailableContribution ac : installLibsHeaders) {
libList.append("\n • " + ac.getName());
}
int option = Base.showYesNoQuestion(this,
int option = Messages.showYesNoQuestion(this,
Language.text("contrib.import.dialog.title"),
Language.text("contrib.import.dialog.primary_text"),
libList.toString());
@@ -2624,14 +2624,14 @@ public class JavaEditor extends Editor {
/** Handle refactor operation */
private void handleRefactor() {
Base.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
Messages.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
errorCheckerService.getASTGenerator().handleRefactor();
}
/** Handle show usage operation */
private void handleShowUsage() {
Base.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
Messages.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
errorCheckerService.getASTGenerator().handleShowUsage();
}
@@ -2667,7 +2667,7 @@ public class JavaEditor extends Editor {
super.applyPreferences();
if (jmode != null) {
jmode.loadPreferences();
Base.log("Applying prefs");
Messages.log("Applying prefs");
// trigger it once to refresh UI
errorCheckerService.runManualErrorCheck();
}
@@ -2703,9 +2703,9 @@ public class JavaEditor extends Editor {
if (modified) {
// ask to keep the values
if (Base.showYesNoQuestion(this, Language.text("tweak_mode"),
Language.text("tweak_mode.keep_changes.line1"),
Language.text("tweak_mode.keep_changes.line2")) == JOptionPane.YES_OPTION) {
if (Messages.showYesNoQuestion(this, Language.text("tweak_mode"),
Language.text("tweak_mode.keep_changes.line1"),
Language.text("tweak_mode.keep_changes.line2")) == JOptionPane.YES_OPTION) {
for (int i = 0; i < sketch.getCodeCount(); i++) {
if (tweakedTabs[i]) {
sketch.getCode(i).setModified(true);
@@ -2729,7 +2729,7 @@ public class JavaEditor extends Editor {
try {
sketch.save();
} catch (IOException e) {
Base.showWarning("Error", "Could not save the modified sketch.", e);
Messages.showWarning("Error", "Could not save the modified sketch.", e);
}
// repaint the editor header (show the modified tabs)
+4 -4
View File
@@ -162,8 +162,8 @@ public class JavaMode extends Mode {
if (isSketchModified(sketch)) {
editor.deactivateRun();
Base.showMessage(Language.text("menu.file.save"),
Language.text("tweak_mode.save_before_tweak"));
Messages.showMessage(Language.text("menu.file.save"),
Language.text("tweak_mode.save_before_tweak"));
return null;
}
@@ -327,7 +327,7 @@ public class JavaMode extends Mode {
public void loadPreferences() {
Base.log("Load PDEX prefs");
Messages.log("Load PDEX prefs");
ensurePrefsExist();
errorCheckEnabled = Preferences.getBoolean(prefErrorCheck);
warningsEnabled = Preferences.getBoolean(prefWarnings);
@@ -345,7 +345,7 @@ public class JavaMode extends Mode {
public void savePreferences() {
Base.log("Saving PDEX prefs");
Messages.log("Saving PDEX prefs");
Preferences.setBoolean(prefErrorCheck, errorCheckEnabled);
Preferences.setBoolean(prefWarnings, warningsEnabled);
Preferences.setBoolean(prefCodeCompletionEnabled, codeCompletionsEnabled);
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import processing.app.Base;
import processing.app.Messages;
import processing.mode.java.Debugger;
import com.sun.jdi.AbsentInformationException;
@@ -220,13 +220,13 @@ public class LineBreakpoint implements ClassLoadListener {
@Override
public void classLoaded(ReferenceType theClass) {
// check if our class is being loaded
Base.log("Class Loaded: " + theClass.name());
Messages.log("Class Loaded: " + theClass.name());
if (theClass.name().equals(className())) {
this.theClass = theClass;
attach();
}
for (ReferenceType ct : theClass.nestedTypes()) {
Base.log("Nested " + ct.name());
Messages.log("Nested " + ct.name());
}
}
}
@@ -106,8 +106,8 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import processing.app.Base;
import processing.app.Library;
import processing.app.Messages;
import processing.app.Platform;
import processing.app.SketchCode;
import processing.app.Util;
@@ -243,7 +243,7 @@ public class ASTGenerator {
.types().get(0)));
//log("Total CU " + compilationUnit.types().size());
if(compilationUnit.types() == null || compilationUnit.types().isEmpty()){
Base.loge("No CU found!");
Messages.loge("No CU found!");
}
visitRecur((ASTNode) compilationUnit.types().get(0), codeTree);
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
@@ -869,7 +869,7 @@ public class ASTGenerator {
ASTNode testnode = parser.createAST(null);
//Base.loge("PREDICTION PARSER PROBLEMS: " + parser);
// Find closest ASTNode of the document to this word
Base.loge("Typed: " + word2 + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
Messages.loge("Typed: " + word2 + "|" + " temp Node type: " + testnode.getClass().getSimpleName());
if(testnode instanceof MethodInvocation){
MethodInvocation mi = (MethodInvocation)testnode;
log(mi.getName() + "," + mi.getExpression() + "," + mi.typeArguments().size());
@@ -882,7 +882,7 @@ public class ASTGenerator {
// Make sure nearestNode is not NULL if couldn't find a closeset node
nearestNode = (ASTNode) errorCheckerService.getLastCorrectCU().types().get(0);
}
Base.loge(lineNumber + " Nearest ASTNode to PRED "
Messages.loge(lineNumber + " Nearest ASTNode to PRED "
+ getNodeAsString(nearestNode));
candidates = new ArrayList<CompletionCandidate>();
@@ -890,7 +890,7 @@ public class ASTGenerator {
// Determine the expression typed
if (testnode instanceof SimpleName && !noCompare) {
Base.loge("One word expression " + getNodeAsString(testnode));
Messages.loge("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
@@ -974,7 +974,7 @@ public class ASTGenerator {
// ==> Complex expression of type blah.blah2().doIt,etc
// Have to resolve it by carefully traversing AST of testNode
Base.loge("Complex expression " + getNodeAsString(testnode));
Messages.loge("Complex expression " + getNodeAsString(testnode));
log("candidates empty");
ASTNode childExpr = getChildExpression(testnode);
log("Parent expression : " + getParentExpression(testnode));
@@ -1236,7 +1236,7 @@ public class ASTGenerator {
- lineElement.getStartOffset());
return javaLine;
} catch (BadLocationException e) {
Base.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
Messages.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
}
return null;
}
@@ -1263,7 +1263,7 @@ public class ASTGenerator {
// - lineElement.getStartOffset());
return lineElement;
} catch (BadLocationException e) {
Base.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
Messages.loge(e + " in getJavaSourceCodeline() for jinenum: " + javaLineNumber);
}
return null;
}
@@ -1744,7 +1744,7 @@ public class ASTGenerator {
ASTNodeWrapper declWrap = new ASTNodeWrapper(simpName2, nodeLabel);
//errorCheckerService.highlightNode(declWrap);
if (!declWrap.highlightNode(this)) {
Base.loge("Highlighting failed.");
Messages.loge("Highlighting failed.");
}
}
@@ -1859,7 +1859,7 @@ public class ASTGenerator {
@Override
public void valueChanged(TreeSelectionEvent e) {
Base.log(e.toString());
Messages.log(e.toString());
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
@Override
@@ -2159,8 +2159,7 @@ public class ASTGenerator {
if(wnode.getNode() == null){
return null;
}
Base.loge("Gonna find all occurrences of "
+ getNodeAsString(wnode.getNode()));
Messages.loge("Gonna find all occurrences of " + getNodeAsString(wnode.getNode()));
//If wnode is a constructor, find the TD instead.
if (wnode.getNodeType() == ASTNode.METHOD_DECLARATION) {
@@ -2176,7 +2175,7 @@ public class ASTGenerator {
if(node != null && node instanceof TypeDeclaration){
TypeDeclaration td = (TypeDeclaration) node;
if(td.getName().toString().equals(md.getName().toString())){
Base.loge("Renaming constructor of " + getNodeAsString(td));
Messages.loge("Renaming constructor of " + getNodeAsString(td));
wnode = new ASTNodeWrapper(td);
}
}
@@ -2414,7 +2413,7 @@ public class ASTGenerator {
}
log("Visiting: " + getNodeAsString(node));
ASTNode decl2 = findDeclaration(sn);
Base.loge("It's decl: " + getNodeAsString(decl2));
Messages.loge("It's decl: " + getNodeAsString(decl2));
log("But we need: "+getNodeAsString(decl));
for (ASTNode astNode : nodesToBeMatched) {
if(astNode.equals(decl2)){
@@ -3714,7 +3713,7 @@ public class ASTGenerator {
static private void log(Object object) {
Base.log(object == null ? "null" : object.toString());
Messages.log(object == null ? "null" : object.toString());
}
@@ -45,6 +45,7 @@ import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import processing.app.Base;
import processing.app.Messages;
/**
@@ -57,16 +58,16 @@ public class ASTNodeWrapper {
private String label;
private int lineNumber;
/*
* TODO: Every ASTNode object in ASTGenerator.codetree is stored as a
* ASTNodeWrapper instance. So how resource heavy would it be to store a
* pointer to ECS in every instance of ASTNodeWrapper? Currently I will rather
* pass an ECS pointer in the argument when I need to access a method which
* requires a method defined in ECS, i.e, only on demand.
* requires a method defined in ECS, i.e, only on demand.
* Bad design choice for ECS methods? IDK, yet.
*/
public ASTNodeWrapper(ASTNode node) {
if (node == null){
return;
@@ -79,7 +80,7 @@ public class ASTNodeWrapper {
label += " | Line " + lineNumber;
//apiLevel = 0;
}
public ASTNodeWrapper(ASTNode node, String label){
if (node == null){
return;
@@ -91,7 +92,7 @@ public class ASTNodeWrapper {
label = getNodeAsString(node);
if (label == null)
label = node.toString();
label += " | Line " + lineNumber;
}
lineNumber = getLineNumber(node);
@@ -106,7 +107,7 @@ public class ASTNodeWrapper {
public int[] getJavaCodeOffsets(ErrorCheckerService ecs) {
int nodeOffset = Node.getStartPosition(), nodeLength = Node
.getLength();
Base.log("0.nodeOffset " + nodeOffset);
Messages.log("0.nodeOffset " + nodeOffset);
ASTNode thisNode = Node;
while (thisNode.getParent() != null) {
if (getLineNumber(thisNode.getParent()) == lineNumber) {
@@ -117,64 +118,64 @@ public class ASTNodeWrapper {
}
/*
* There's an edge case here - multiple statements in a single line.
* After identifying the statement with the line number, I'll have to
* After identifying the statement with the line number, I'll have to
* look at previous tree nodes in the same level for same line number.
* The correct line start offset would be the line start offset of
* the first node with this line number.
*
* Using linear search for now. P.S: Eclipse AST iterators are messy.
*
* Using linear search for now. P.S: Eclipse AST iterators are messy.
* TODO: binary search might improve speed by 0.001%?
*/
int altStartPos = thisNode.getStartPosition();
Base.log("1.Altspos " + altStartPos);
Messages.log("1.Altspos " + altStartPos);
thisNode = thisNode.getParent();
Javadoc jd = null;
/*
/*
* There's another case that needs to be handled. If a TD, MD or FD
* contains javadoc comments(multi or single line) the starting position
* of the javadoc is treated as the beginning of the declaration by the AST parser.
* But that's clearly not what we need. The true decl begins after the javadoc ends.
* So this offset needs to be found carefully and stored in altStartPos
*
*
*/
if (thisNode instanceof TypeDeclaration) {
jd = ((TypeDeclaration) thisNode).getJavadoc();
altStartPos = getJavadocOffset((TypeDeclaration) thisNode);
Base.log("Has t jdoc " + ((TypeDeclaration) thisNode).getJavadoc());
Messages.log("Has t jdoc " + ((TypeDeclaration) thisNode).getJavadoc());
} else if (thisNode instanceof MethodDeclaration) {
altStartPos = getJavadocOffset((MethodDeclaration) thisNode);
jd = ((MethodDeclaration) thisNode).getJavadoc();
Base.log("Has m jdoc " + jd);
Messages.log("Has m jdoc " + jd);
} else if (thisNode instanceof FieldDeclaration) {
FieldDeclaration fd = ((FieldDeclaration) thisNode);
jd = fd.getJavadoc();
Base.log("Has f jdoc " + fd.getJavadoc());
Messages.log("Has f jdoc " + fd.getJavadoc());
altStartPos = getJavadocOffset(fd);
//nodeOffset = ((VariableDeclarationFragment)(fd.fragments().get(0))).getName().getStartPosition();
}
}
if (jd == null) {
Base.log("Visiting children of node " + getNodeAsString(thisNode));
Messages.log("Visiting children of node " + getNodeAsString(thisNode));
@SuppressWarnings("unchecked")
Iterator<StructuralPropertyDescriptor> it =
Iterator<StructuralPropertyDescriptor> it =
thisNode.structuralPropertiesForType().iterator();
boolean flag = true;
while (it.hasNext()) {
StructuralPropertyDescriptor prop = it.next();
if (prop.isChildListProperty()) {
@SuppressWarnings("unchecked")
List<ASTNode> nodelist = (List<ASTNode>)
List<ASTNode> nodelist = (List<ASTNode>)
thisNode.getStructuralProperty(prop);
Base.log("prop " + prop);
Messages.log("prop " + prop);
for (ASTNode cnode : nodelist) {
Base.log("Visiting node " + getNodeAsString(cnode));
Messages.log("Visiting node " + getNodeAsString(cnode));
if (getLineNumber(cnode) == lineNumber) {
if (flag) {
altStartPos = cnode.getStartPosition();
// log("multi...");
flag = false;
} else {
if (cnode == Node) {
@@ -184,16 +185,16 @@ public class ASTNodeWrapper {
// We've located the first node in the line.
// Now normalize offsets till Node
//altStartPos += normalizeOffsets(cnode);
}
}
}
}
}
Base.log("Altspos " + altStartPos);
Messages.log("Altspos " + altStartPos);
}
int pdeoffsets[] = getPDECodeOffsets(ecs);
String pdeCode = ecs.getPdeCodeAtLine(pdeoffsets[0],pdeoffsets[1] - 1).trim();
int vals[] = createOffsetMapping(ecs, pdeCode,nodeOffset - altStartPos,nodeLength);
@@ -201,16 +202,16 @@ public class ASTNodeWrapper {
return new int[] {
lineNumber, nodeOffset + vals[0] - altStartPos, vals[1] };
else {// no offset mapping needed
Base.log("joff[1] = " + (nodeOffset - altStartPos));
Messages.log("joff[1] = " + (nodeOffset - altStartPos));
return new int[] { lineNumber, nodeOffset - altStartPos, nodeLength };
}
}
/**
* When FD has javadoc attached, the beginning of FD is marked as the
* start of the javadoc. This kind of screws things when trying to locate
* the exact name of the FD. So, offset compensations...
*
*
* @param fd
* @return
*/
@@ -218,30 +219,30 @@ public class ASTNodeWrapper {
@SuppressWarnings("unchecked")
List<ASTNode> list = fd.modifiers();
SimpleName sn = (SimpleName) getNode();
Type tp = fd.getType();
int lineNum = getLineNumber(sn);
Base.log("SN "+sn + ", " + lineNum);
Messages.log("SN "+sn + ", " + lineNum);
for (ASTNode astNode : list) {
if(getLineNumber(astNode) == lineNum) {
Base.log("first node in that line " + astNode);
Base.log("diff " + (sn.getStartPosition() - astNode.getStartPosition()));
Messages.log("first node in that line " + astNode);
Messages.log("diff " + (sn.getStartPosition() - astNode.getStartPosition()));
return (astNode.getStartPosition());
}
}
if(getLineNumber(fd.getType()) == lineNum) {
Base.log("first node in that line " + tp);
Base.log("diff " + (sn.getStartPosition() - tp.getStartPosition()));
Messages.log("first node in that line " + tp);
Messages.log("diff " + (sn.getStartPosition() - tp.getStartPosition()));
return (tp.getStartPosition());
}
return 0;
return 0;
}
/**
* When MD has javadoc attached, the beginning of FD is marked as the
* start of the javadoc. This kind of screws things when trying to locate
* the exact name of the MD. So, offset compensations...
*
*
* @param md
* @return
*/
@@ -250,33 +251,33 @@ public class ASTNodeWrapper {
List<ASTNode> list = md.modifiers();
SimpleName sn = (SimpleName) getNode();
int lineNum = getLineNumber(sn);
Base.log("SN " + sn + ", " + lineNum);
Messages.log("SN " + sn + ", " + lineNum);
for (ASTNode astNode : list) {
if (getLineNumber(astNode) == lineNum) {
Base.log("first node in that line " + astNode);
Base.log("diff " + (sn.getStartPosition() - astNode.getStartPosition()));
Messages.log("first node in that line " + astNode);
Messages.log("diff " + (sn.getStartPosition() - astNode.getStartPosition()));
return (astNode.getStartPosition());
}
}
if (!md.isConstructor()) {
Type tp = md.getReturnType2();
if (getLineNumber(tp) == lineNum) {
Base.log("first node in that line " + tp);
Base.log("diff " + (sn.getStartPosition() - tp.getStartPosition()));
Messages.log("first node in that line " + tp);
Messages.log("diff " + (sn.getStartPosition() - tp.getStartPosition()));
return (tp.getStartPosition());
}
}
return 0;
}
/**
* When TD has javadoc attached, the beginning of FD is marked as the
* start of the javadoc. This kind of screws things when trying to locate
* the exact name of the TD. So, offset compensations...
*
*
* @param td
* @return
*/
@@ -285,26 +286,26 @@ public class ASTNodeWrapper {
@SuppressWarnings("unchecked")
List<ASTNode> list = td.modifiers();
SimpleName sn = (SimpleName) getNode();
int lineNum = getLineNumber(sn);
Base.log("SN "+sn + ", " + lineNum);
Messages.log("SN "+sn + ", " + lineNum);
for (ASTNode astNode : list) {
if (getLineNumber(astNode) == lineNum) {
Base.log("first node in that line " + astNode);
Base.log("diff " + (sn.getStartPosition() - astNode.getStartPosition()));
Messages.log("first node in that line " + astNode);
Messages.log("diff " + (sn.getStartPosition() - astNode.getStartPosition()));
return (astNode.getStartPosition());
}
}
if (td.getJavadoc() != null){
Base.log("diff "
Messages.log("diff "
+ (td.getJavadoc().getStartPosition() + td.getJavadoc().getLength() + 1));
return (td.getJavadoc().getStartPosition() + td.getJavadoc().getLength() + 1);
}
Base.log("getJavadocOffset(TypeDeclaration td) "+sn + ", found nothing. Meh.");
Messages.log("getJavadocOffset(TypeDeclaration td) "+sn + ", found nothing. Meh.");
return 0;
}
/**
* Finds the difference in pde and java code offsets
* @param source
@@ -313,7 +314,7 @@ public class ASTNodeWrapper {
* @return int[0] - difference in start offset, int[1] - node length
*/
private int[] createOffsetMapping(ErrorCheckerService ecs, String source, int inpOffset, int nodeLen) {
int ret[][] = getOffsetMapping(ecs, source);
if(ret == null){
// no offset mapping needed
@@ -335,7 +336,7 @@ public class ASTNodeWrapper {
pi++;
int startoffDif = pi - pj;
int stopindex = javaCodeMap[pj + nodeLen - 1];
Base.log(startIndex + "SI,St" + stopindex + "sod " + startoffDif);
Messages.log(startIndex + "SI,St" + stopindex + "sod " + startoffDif);
// count till stopindex
while (pdeCodeMap[pi] < stopindex && pi < pdeCodeMap.length) {
@@ -345,27 +346,27 @@ public class ASTNodeWrapper {
// log("PDE maps from " + pdeeCodeMap[pi]);
Base.log("pde len " + count);
Messages.log("pde len " + count);
return new int[] { startoffDif, count };
}
/**
* Generates offset mapping between java and pde code
*
*
* @param source
* @return int[0] - java code offsets, int[1] = pde code offsets
*/
public int[][] getOffsetMapping(ErrorCheckerService ecs, String source){
/*
* This is some tricky shiz. So detailed explanation follows:
*
*
* The main issue here is that pde enhancements like color vars, # literals
* and int() type casting deviate from standard java. But I need to exact
* index matching for pde and java versions of snippets.For ex:
* "color col = #ffaadd;" <-PDE version
* "color col = #ffaadd;" <-PDE version
* "int col = 0xffffaadd;" <-Converted to Java
*
*
* For exact index mapping, I need to know at which indices either is
* deviating from the other and by what amount. Turns out, it isn't quite
* easy.(1) First I take the pde version of the code as an argument(pde
@@ -378,25 +379,25 @@ public class ASTNodeWrapper {
* separate arrays) which allows me to look it up for matching any index
* between pde or java version of the snippet. This also lets me find out
* any difference in length between both versions.
*
*
* Keep in mind though, dark magic was involved in creating the final lookup
* table.
*
*
* TODO: This is a work in progress. There may be more bugs here in hiding.
*/
Base.log("Src:" + source);
// Instead of converting pde into java, how can I simply extract the same source
Messages.log("Src:" + source);
// Instead of converting pde into java, how can I simply extract the same source
// from the java code? Think. TODO
String sourceAlt = new String(source);
String sourceJava = ecs.astGenerator.getJavaSourceCodeLine(lineNumber);
TreeMap<Integer, Integer> offsetmap = new TreeMap<Integer, Integer>();
if(sourceJava.trim().startsWith("public") && !source.startsWith("public")){
offsetmap.put(0,6);
offsetmap.put(0,6);
//TODO: This is a temp fix. You GOTTA rewrite offset matching
}
// Find all #[web color]
// Find all #[web color]
// Should be 6 digits only.
final String webColorRegexp = "#{1}[A-F|a-f|0-9]{6}\\W";
Pattern webPattern = Pattern.compile(webColorRegexp);
@@ -437,9 +438,9 @@ public class ASTNodeWrapper {
+ Character.toUpperCase(dataType.charAt(0)) + dataType.substring(1)
+ "(");
}
}
if(offsetmap.isEmpty()){
Base.log("No offset matching needed.");
Messages.log("No offset matching needed.");
return null;
}
// replace with 0xff[webcolor] and others
@@ -454,11 +455,11 @@ public class ASTNodeWrapper {
colorMatcher = colorPattern.matcher(sourceAlt);
sourceAlt = colorMatcher.replaceAll("int");
Base.log("From direct source: ");
Messages.log("From direct source: ");
// sourceAlt = sourceJava;
Base.log(sourceAlt);
Messages.log(sourceAlt);
// Create code map. Beware! Dark magic ahead.
int javaCodeMap[] = new int[source.length() * 2];
@@ -473,7 +474,7 @@ public class ASTNodeWrapper {
pdeCodeMap[pj] = pdeCodeMap[pj - 1] + 1;
}
Base.log(key + ":" + offsetmap.get(key));
Messages.log(key + ":" + offsetmap.get(key));
int kval = offsetmap.get(key);
if (kval > 0) {
@@ -497,8 +498,8 @@ public class ASTNodeWrapper {
}
}
}
// after each adjustment, the key values need to keep
// after each adjustment, the key values need to keep
// up with changed offset
keySum += kval;
}
@@ -514,7 +515,7 @@ public class ASTNodeWrapper {
pdeCodeMap[pj] = pdeCodeMap[pj - 1] + 1;
pj++;
}
if (Base.DEBUG) {
// debug o/p
for (int i = 0; i < pdeCodeMap.length; i++) {
@@ -532,8 +533,8 @@ public class ASTNodeWrapper {
}
return new int[][] { javaCodeMap, pdeCodeMap };
}
/**
* Highlight the ASTNode in the editor, if it's of type
* SimpleName
@@ -542,7 +543,7 @@ public class ASTNodeWrapper {
*/
public boolean highlightNode(ASTGenerator astGenerator){
if (!(Node instanceof SimpleName)) {
return false;
return false;
}
SimpleName nodeName = (SimpleName) Node;
try {
@@ -555,31 +556,31 @@ public class ASTNodeWrapper {
Element lineElement = javaSource.getDefaultRootElement()
.getElement(javaLineNumber-1);
if(lineElement == null) {
Base.log(lineNumber + " line element null while highlighting " + nodeName);
Messages.log(lineNumber + " line element null while highlighting " + nodeName);
return false;
}
String javaLine = javaSource.getText(lineElement.getStartOffset(),
lineElement.getEndOffset()
- lineElement.getStartOffset());
astGenerator.editor.getSketch().setCurrentCode(pdeOffs[0]);
String pdeLine = astGenerator.editor.getLineText(pdeOffs[1]);
String lookingFor = nodeName.toString();
Base.log(lookingFor + ", " + nodeName.getStartPosition());
Base.log(javaLineNumber +" JL " + javaLine + " LSO " + lineElement.getStartOffset() + ","
Messages.log(lookingFor + ", " + nodeName.getStartPosition());
Messages.log(javaLineNumber +" JL " + javaLine + " LSO " + lineElement.getStartOffset() + ","
+ lineElement.getEndOffset());
Base.log(pdeOffs[1] + " PL " + pdeLine);
Messages.log(pdeOffs[1] + " PL " + pdeLine);
if (!javaLine.contains(lookingFor) || !pdeLine.contains(lookingFor)) {
Base.loge("Logical error in highLightNode(). Please file a bug report.");
Messages.loge("Logical error in highLightNode(). Please file a bug report.");
return false;
}
OffsetMatcher ofm = new OffsetMatcher(pdeLine, javaLine);
int highlightStart = ofm.getPdeOffForJavaOff(nodeName.getStartPosition()
- lineElement.getStartOffset(),
nodeName.getLength());
if (highlightStart == -1) {
Base.loge("Logical error in highLightNode() during offset matching. " +
Messages.loge("Logical error in highLightNode() during offset matching. " +
"Please file a bug report.");
return false;
}
@@ -612,24 +613,24 @@ public class ASTNodeWrapper {
}
}
log("pde lso " + (index - lookingFor.length()));
int lso = astGenerator.editor.ta.getLineStartOffset(pdeOffs[1]);
astGenerator.editor.setSelection(lso + index - lookingFor.length(), lso
+ index);
*/
return true;
} catch (BadLocationException e) {
Base.loge("BLE in highLightNode() for " + nodeName);
Messages.loge("BLE in highLightNode() for " + nodeName);
e.printStackTrace();
}
return false;
}
/**
* Gets offset mapping between java and pde code
* int[0][x] stores the java code offset and
* int[1][x] is the corresponding offset in pde code
* int[0][x] stores the java code offset and
* int[1][x] is the corresponding offset in pde code
* @param ecs
* @return int[0] - java code offset, int[1] - pde code offset
*/
@@ -638,9 +639,9 @@ public class ASTNodeWrapper {
String pdeCode = ecs.getPdeCodeAtLine(pdeoffsets[0],pdeoffsets[1] - 1).trim();
return getOffsetMapping(ecs, pdeCode);
}
/**
*
*
* @param ecs
* - ErrorCheckerService instance
* @return int[0] - tab number, int[1] - line number in the int[0] tab, int[2]
@@ -650,11 +651,11 @@ public class ASTNodeWrapper {
public int[] getPDECodeOffsets(ErrorCheckerService ecs) {
return ecs.JavaToPdeOffsets(lineNumber + 1, Node.getStartPosition());
}
public int getPDECodeOffsetForSN(ASTGenerator astGen){
if (Node instanceof SimpleName) {
Element lineElement = astGen.getJavaSourceCodeElement(lineNumber);
Base.log("Line element off " + lineElement.getStartOffset());
Messages.log("Line element off " + lineElement.getStartOffset());
OffsetMatcher ofm = new OffsetMatcher(astGen.getPDESourceCodeLine(lineNumber),
astGen.getJavaSourceCodeLine(lineNumber));
//log("");
@@ -684,7 +685,7 @@ public class ASTNodeWrapper {
public int getLineNumber() {
return lineNumber;
}
/**
* Applies pde enhancements to code.
* TODO: Code reuse happening here. :\
@@ -692,10 +693,10 @@ public class ASTNodeWrapper {
* @return
*/
public static String getJavaCode(String source){
Base.log("Src:" + source);
Messages.log("Src:" + source);
String sourceAlt = new String(source);
// Find all #[web color]
// Find all #[web color]
// Should be 6 digits only.
final String webColorRegexp = "#{1}[A-F|a-f|0-9]{6}\\W";
Pattern webPattern = Pattern.compile(webColorRegexp);
@@ -747,7 +748,7 @@ public class ASTNodeWrapper {
colorMatcher = colorPattern.matcher(sourceAlt);
sourceAlt = colorMatcher.replaceAll("int");
Base.log("Converted:"+sourceAlt);
Messages.log("Converted:"+sourceAlt);
return sourceAlt;
}
@@ -755,7 +756,7 @@ public class ASTNodeWrapper {
return ((CompilationUnit) node.getRoot()).getLineNumber(node
.getStartPosition());
}
/*private static int getLineNumber2(ASTNode thisNode) {
int jdocOffset = 0; Javadoc jd = null;
if(thisNode instanceof TypeDeclaration){
@@ -767,7 +768,7 @@ public class ASTNodeWrapper {
} else if(thisNode instanceof FieldDeclaration){
jd = ((FieldDeclaration)thisNode).getJavadoc();
log("Has f jdoc " + ((FieldDeclaration)thisNode).getJavadoc());
}
}
if(jd != null){
jdocOffset = 1+jd.getLength();
}
@@ -50,6 +50,7 @@ import javax.swing.plaf.basic.BasicScrollBarUI;
import javax.swing.text.BadLocationException;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Mode;
import processing.app.syntax.JEditTextArea;
import processing.mode.java.JavaEditor;
@@ -361,7 +362,7 @@ public class CompletionPanel {
}
}
Base.loge(subWord + " <= subword, Inserting suggestion=> "
Messages.loge(subWord + " <= subword, Inserting suggestion=> "
+ selectedSuggestion + " Current sub: " + currentSubword);
if (currentSubword.length() > 0) {
textarea.getDocument().remove(insertionPosition - currentSubwordLen,
@@ -382,7 +383,7 @@ public class CompletionPanel {
}
}
Base.log("Suggestion inserted: " + System.currentTimeMillis());
Messages.log("Suggestion inserted: " + System.currentTimeMillis());
if (completionList.getSelectedValue().getLabel().contains("...")) {
// log("No hide");
// Why not hide it? Coz this is the case of
@@ -568,11 +569,11 @@ public class CompletionPanel {
break;
default:
Base.log("(CustomListRenderer)Unknown CompletionCandidate type " + cc.getType());
Messages.log("(CustomListRenderer)Unknown CompletionCandidate type " + cc.getType());
break;
}
} else {
Base.log("(CustomListRenderer)Unknown CompletionCandidate object " + value);
Messages.log("(CustomListRenderer)Unknown CompletionCandidate object " + value);
}
return label;
}
@@ -49,8 +49,8 @@ import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import processing.app.Base;
import processing.app.Library;
import processing.app.Messages;
import processing.app.Sketch;
import processing.app.SketchCode;
import processing.app.Util;
@@ -65,7 +65,6 @@ import processing.mode.java.preproc.PdePreprocessor;
/**
* The main error checking service
* @author Manindra Moharana &lt;me@mkmoharana.com&gt;
*/
@SuppressWarnings("unchecked")
public class ErrorCheckerService implements Runnable {
@@ -222,7 +221,6 @@ public class ErrorCheckerService implements Runnable {
protected ErrorMessageSimplifier errorMsgSimplifier;
public ErrorCheckerService(JavaEditor debugEditor) {
ensureMinP5Version();
this.editor = debugEditor;
stopThread = new AtomicBoolean(false);
pauseThread = new AtomicBoolean(false);
@@ -264,47 +262,6 @@ public class ErrorCheckerService implements Runnable {
}
}
/**
* Initialiazes the Error Window
*/
/*public void initializeErrorWindow() {
if (editor == null) {
return;
}
if (errorWindow != null) {
return;
}
final ErrorCheckerService thisService = this;
final JavaEditor thisEditor = editor;
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
errorWindow = new ErrorWindow(thisEditor, thisService);
// errorWindow.setVisible(true);
editor.toFront();
errorWindow.errorTable.setFocusable(false);
editor.setSelection(0, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}*/
/**
* Ensure user is running the minimum P5 version
*/
public void ensureMinP5Version(){
//TODO: Now defunct?
// Processing 2.1.2 - Revision 0225
if(Base.getRevision() < 225){
// System.err.println("ERROR: PDE X requires Processing 2.1.2 or higher.");
Base.showWarning("Error", "ERROR: PDE X requires Processing 2.1.2 or higher.", null);
}
}
/**
* Error checking doesn't happen before this interval has ellapsed since the
@@ -312,12 +269,13 @@ public class ErrorCheckerService implements Runnable {
*/
private final static long errorCheckInterval = 500;
/**
* Bypass sleep time
*/
private volatile boolean noSleep = false;
/**
* The way the error checking happens is: DocumentListeners are added
* to each SketchCode object. Whenever the document is edited, runManualErrorCheck()
@@ -350,10 +308,10 @@ public class ErrorCheckerService implements Runnable {
}
else {
noSleep = false;
Base.log("Didn't sleep!");
Messages.log("Didn't sleep!");
}
} catch (Exception e) {
Base.log("Oops! [ErrorCheckerThreaded]: " + e);
Messages.log("Oops! [ErrorCheckerThreaded]: " + e);
// e.printStackTrace();
}
@@ -367,7 +325,7 @@ public class ErrorCheckerService implements Runnable {
// Check if a certain interval has passed after the call. Only then
// begin error check. Helps prevent unnecessary flickering. See #2677
if (System.currentTimeMillis() - lastErrorCheckCall > errorCheckInterval) {
Base.log("Interval passed, starting error check");
Messages.log("Interval passed, starting error check");
checkCode();
checkForMissingImports();
}
@@ -378,7 +336,7 @@ public class ErrorCheckerService implements Runnable {
checkerClass = null;
classLoader = null;
System.gc();
Base.loge("Thread stopped: " + editor.getSketch().getName());
Messages.loge("Thread stopped: " + editor.getSketch().getName());
System.gc();
}
@@ -410,7 +368,7 @@ public class ErrorCheckerService implements Runnable {
String args[] = p.getIProblem().getArguments();
if (args.length > 0) {
String missingClass = args[0];
Base.log("Will suggest for type:" + missingClass);
Messages.log("Will suggest for type:" + missingClass);
//astGenerator.suggestImports(missingClass);
}
}
@@ -528,7 +486,7 @@ public class ErrorCheckerService implements Runnable {
astGenerator.buildAST(cu);
if (!JavaMode.errorCheckEnabled) {
problemsList.clear();
Base.log("Error Check disabled, so not updating UI.");
Messages.log("Error Check disabled, so not updating UI.");
}
calcPdeOffsetsForProbList();
updateErrorTable();
@@ -552,7 +510,7 @@ public class ErrorCheckerService implements Runnable {
return true;
} catch (Exception e) {
Base.log("Oops! [ErrorCheckerService.checkCode]: " + e);
Messages.log("Oops! [ErrorCheckerService.checkCode]: " + e);
e.printStackTrace();
}
return false;
@@ -772,7 +730,7 @@ public class ErrorCheckerService implements Runnable {
Element lineElement =
javaSource.getDefaultRootElement().getElement(javaLineNumber);
if (lineElement == null) {
Base.log("calcPDEOffsetsForProbList(): " +
Messages.log("calcPDEOffsetsForProbList(): " +
"Couldn't fetch Java line number " +
javaLineNumber + "\nProblem: " + p);
p.setPDEOffsets(-1, -1);
@@ -786,7 +744,7 @@ public class ErrorCheckerService implements Runnable {
Element pdeLineElement =
doc.getDefaultRootElement().getElement(p.getLineNumber());
if (pdeLineElement == null) {
Base.log("calcPDEOffsetsForProbList(): " +
Messages.log("calcPDEOffsetsForProbList(): " +
"Couldn't fetch pde line number " +
javaLineNumber + "\nProblem: " + p);
p.setPDEOffsets(-1,-1);
@@ -996,7 +954,7 @@ public class ErrorCheckerService implements Runnable {
editor.updateTable(tm);
} catch (Exception e) {
Base.loge("Exception at updateErrorTable()", e);
Messages.loge("Exception at updateErrorTable()", e);
e.printStackTrace();
pauseThread();
}
@@ -1278,7 +1236,7 @@ public class ErrorCheckerService implements Runnable {
}
} catch (Exception e) {
Base.log("Exception in preprocessCode()");
Messages.log("Exception in preprocessCode()");
}
String sourceAlt = rawCode.toString();
// Replace comments with whitespaces
@@ -1372,11 +1330,11 @@ public class ErrorCheckerService implements Runnable {
* @return true - if highlighting happened correctly.
*/
private boolean highlightNode(ASTNodeWrapper awrap){
Base.log("Highlighting: " + awrap);
Messages.log("Highlighting: " + awrap);
try {
int pdeoffsets[] = awrap.getPDECodeOffsets(this);
int javaoffsets[] = awrap.getJavaCodeOffsets(this);
Base.log("offsets: " +pdeoffsets[0] + "," +
Messages.log("offsets: " +pdeoffsets[0] + "," +
pdeoffsets[1]+ "," +javaoffsets[1]+ "," +
javaoffsets[2]);
scrollToErrorLine(editor, pdeoffsets[0],
@@ -1384,7 +1342,7 @@ public class ErrorCheckerService implements Runnable {
javaoffsets[2]);
return true;
} catch (Exception e) {
Base.loge("Scrolling failed for " + awrap);
Messages.loge("Scrolling failed for " + awrap);
// e.printStackTrace();
}
return false;
@@ -1449,7 +1407,7 @@ public class ErrorCheckerService implements Runnable {
editor.repaint();
} catch (Exception e) {
Base.loge("Error while selecting text in scrollToErrorLine(), for problem: " + p, e);
Messages.loge("Error while selecting text in scrollToErrorLine(), for problem: " + p, e);
}
// log("---");
}
@@ -1480,7 +1438,7 @@ public class ErrorCheckerService implements Runnable {
edt.setSelection(lsno, lsno + length);
edt.getTextArea().scrollTo(lineNoInTab - 1, 0);
edt.repaint();
Base.log(lineStartOffset + " LSO,len " + length);
Messages.log(lineStartOffset + " LSO,len " + length);
} catch (Exception e) {
System.err.println(e
@@ -1625,7 +1583,7 @@ public class ErrorCheckerService implements Runnable {
if (!JavaMode.errorCheckEnabled) {
// unticked Menu Item
// pauseThread();
Base.log(editor.getSketch().getName()
Messages.log(editor.getSketch().getName()
+ " - Error Checker paused.");
editor.getErrorPoints().clear();
problemsList.clear();
@@ -1635,7 +1593,7 @@ public class ErrorCheckerService implements Runnable {
editor.repaintErrorBar();
} else {
//resumeThread();
Base.log(editor.getSketch().getName()
Messages.log(editor.getSketch().getName()
+ " - Error Checker resumed.");
runManualErrorCheck();
}
@@ -1645,7 +1603,7 @@ public class ErrorCheckerService implements Runnable {
* Stops the Error Checker Service thread
*/
public void stopThread() {
Base.loge("Stopping thread: " + editor.getSketch().getName());
Messages.loge("Stopping thread: " + editor.getSketch().getName());
stopThread.set(true);
}
@@ -35,7 +35,7 @@ import java.util.Map;
import javax.swing.DefaultListModel;
import javax.swing.SwingWorker;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Mode;
import processing.app.Platform;
import processing.app.syntax.JEditTextArea;
@@ -173,7 +173,7 @@ public class JavaTextArea extends JEditTextArea {
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
if (suggestion != null){
if (suggestion.isVisible()){
Base.log("esc key");
Messages.log("esc key");
hideSuggestion();
evt.consume();
return;
@@ -216,12 +216,12 @@ public class JavaTextArea extends JEditTextArea {
}
break;
case KeyEvent.VK_BACK_SPACE:
Base.log("BK Key");
Messages.log("BK Key");
break;
case KeyEvent.VK_SPACE:
if (suggestion != null) {
if (suggestion.isVisible()) {
Base.log("Space bar, hide completion list");
Messages.log("Space bar, hide completion list");
suggestion.setInvisible();
}
}
@@ -250,8 +250,8 @@ public class JavaTextArea extends JEditTextArea {
protected Object doInBackground() throws Exception {
// Provide completions only if it's enabled
if (JavaMode.codeCompletionsEnabled) {
Base.log("[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started");
Base.log("Typing: " + fetchPhrase(event));
Messages.log("[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started");
Messages.log("Typing: " + fetchPhrase(event));
}
return null;
}
@@ -276,8 +276,8 @@ public class JavaTextArea extends JEditTextArea {
if (keyChar == '.') {
if (JavaMode.codeCompletionsEnabled) {
Base.log("[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started");
Base.log("Typing: " + fetchPhrase(event));
Messages.log("[KeyEvent]" + KeyEvent.getKeyText(event.getKeyCode()) + " |Prediction started");
Messages.log("Typing: " + fetchPhrase(event));
}
} else if (keyChar == ' ') { // Trigger on Ctrl-Space
if (!Platform.isMacOS() && JavaMode.codeCompletionsEnabled &&
@@ -287,8 +287,8 @@ public class JavaTextArea extends JEditTextArea {
// Provide completions only if it's enabled
if (JavaMode.codeCompletionsEnabled) {
getDocument().remove(getCaretPosition() - 1, 1); // Remove the typed space
Base.log("[KeyEvent]" + event.getKeyChar() + " |Prediction started");
Base.log("Typing: " + fetchPhrase(event));
Messages.log("[KeyEvent]" + event.getKeyChar() + " |Prediction started");
Messages.log("Typing: " + fetchPhrase(event));
}
return null;
}
@@ -312,8 +312,8 @@ public class JavaTextArea extends JEditTextArea {
// Provide completions only if it's enabled
if (JavaMode.codeCompletionsEnabled &&
(JavaMode.ccTriggerEnabled || suggestion.isVisible())) {
Base.log("[KeyEvent]" + evt.getKeyChar() + " |Prediction started");
Base.log("Typing: " + fetchPhrase(evt));
Messages.log("[KeyEvent]" + evt.getKeyChar() + " |Prediction started");
Messages.log("Typing: " + fetchPhrase(evt));
}
return null;
}
@@ -327,7 +327,7 @@ public class JavaTextArea extends JEditTextArea {
* @param evt - the MouseEvent which triggered this method
*/
private String fetchPhrase(MouseEvent evt) {
Base.log("--handle Mouse Right Click--");
Messages.log("--handle Mouse Right Click--");
int off = xyToOffset(evt.getX(), evt.getY());
if (off < 0)
return null;
@@ -342,7 +342,7 @@ public class JavaTextArea extends JEditTextArea {
else {
int x = xToOffset(line, evt.getX()), x2 = x + 1, x1 = x - 1;
int xLS = off - getLineStartNonWhiteSpaceOffset(line);
Base.log("x=" + x);
Messages.log("x=" + x);
if (x < 0 || x >= s.length())
return null;
String word = s.charAt(x) + "";
@@ -382,7 +382,7 @@ public class JavaTextArea extends JEditTextArea {
if (Character.isDigit(word.charAt(0))) {
return null;
}
Base.log("Mouse click, word: " + word.trim());
Messages.log("Mouse click, word: " + word.trim());
editor.getErrorChecker().getASTGenerator().setLastClickedWord(line, word, xLS);
return word.trim();
}
@@ -396,14 +396,14 @@ public class JavaTextArea extends JEditTextArea {
*/
public String fetchPhrase(KeyEvent evt) {
int off = getCaretPosition();
Base.log("off " + off);
Messages.log("off " + off);
if (off < 0)
return null;
int line = getCaretLine();
if (line < 0)
return null;
String s = getLineText(line);
Base.log(" line " + line);
Messages.log(" line " + line);
//log2(s + " len " + s.length());
@@ -414,7 +414,7 @@ public class JavaTextArea extends JEditTextArea {
return null; //TODO: Does this check cause problems? Verify.
}
Base.log(" x char: " + s.charAt(x));
Messages.log(" x char: " + s.charAt(x));
if (!(Character.isLetterOrDigit(s.charAt(x)) || s.charAt(x) == '_'
|| s.charAt(x) == '(' || s.charAt(x) == '.')) {
@@ -821,7 +821,7 @@ public class JavaTextArea extends JEditTextArea {
hideSuggestion();
if (listModel.size() == 0) {
Base.log("TextArea: No suggestions to show.");
Messages.log("TextArea: No suggestions to show.");
} else {
int position = getCaretPosition();
@@ -47,7 +47,7 @@ import javax.swing.text.BadLocationException;
import javax.swing.text.Segment;
import javax.swing.text.Utilities;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Platform;
import processing.app.SketchCode;
import processing.app.syntax.SyntaxDocument;
@@ -155,7 +155,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
void handleCtrlClick(MouseEvent evt) {
Base.log("--handleCtrlClick--");
Messages.log("--handleCtrlClick--");
int off = textArea.xyToOffset(evt.getX(), evt.getY());
if (off < 0)
return;
@@ -169,7 +169,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
return;
else {
int x = textArea.xToOffset(line, evt.getX()), x2 = x + 1, x1 = x - 1;
Base.log("x="+x);
Messages.log("x="+x);
int xLS = off - textArea.getLineStartNonWhiteSpaceOffset(line);
if (x < 0 || x >= s.length())
return;
@@ -210,7 +210,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
if (Character.isDigit(word.charAt(0)))
return;
Base.log(getEditor().getErrorChecker().mainClassOffset + line + "|" + line + "| offset " + xLS + word + " <= \n");
Messages.log(getEditor().getErrorChecker().mainClassOffset + line + "|" + line + "| offset " + xLS + word + " <= \n");
getEditor().getErrorChecker().getASTGenerator().scrollToDeclaration(line, word, xLS);
}
}
@@ -245,7 +245,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
super.paintLine(gfx, line, x + Editor.LEFT_GUTTER, tokenMarker);
} catch (Exception e) {
Base.log(e.getMessage());
Messages.log(e.getMessage());
}
// formerly only when in debug mode
@@ -34,8 +34,8 @@ import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import javax.swing.text.BadLocationException;
import processing.app.Base;
import processing.app.Language;
import processing.app.Messages;
import processing.app.ui.Editor;
import processing.app.ui.Toolkit;
import processing.mode.java.JavaEditor;
@@ -78,7 +78,7 @@ public class XQErrorTable extends JTable {
int row = ((XQErrorTable) e.getSource()).getSelectedRow();
editor.getErrorChecker().scrollToErrorLine(row);
} catch (Exception e1) {
Base.log("Exception XQErrorTable mouseReleased " + e);
Messages.log("Exception XQErrorTable mouseReleased " + e);
}
}
});
@@ -225,7 +225,7 @@ public class XQErrorTable extends JTable {
if (classList.getSelectedValue() != null) {
try {
String t = classList.getSelectedValue().trim();
Base.log(t);
Messages.log(t);
int x = t.indexOf('(');
String impString = "import " + t.substring(x + 1, t.indexOf(')')) + ";\n";
int ct = editor.getSketch().getCurrentCodeIndex();
@@ -233,7 +233,7 @@ public class XQErrorTable extends JTable {
editor.getTextArea().getDocument().insertString(0, impString, null);
editor.getSketch().setCurrentCode(ct);
} catch (BadLocationException ble) {
Base.log("Failed to insert import");
Messages.log("Failed to insert import");
ble.printStackTrace();
}
}
@@ -32,7 +32,7 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import processing.app.Base;
import processing.app.Messages;
import processing.app.Preferences;
import processing.app.SketchException;
import processing.core.PApplet;
@@ -40,9 +40,11 @@ import processing.data.StringList;
import processing.mode.java.preproc.PdeLexer;
import processing.mode.java.preproc.PdeRecognizer;
import processing.mode.java.preproc.PdeTokenTypes;
import antlr.*;
import antlr.collections.AST;
/**
* Class that orchestrates preprocessing p5 syntax into straight Java.
* <P/>
@@ -379,7 +381,7 @@ public class PdePreprocessor {
"The size of this sketch could not be determined from your code.\n" +
"Use only numbers (not variables) for the size() command.\n" +
"Read the size() reference for more details.";
Base.showWarning("Could not find sketch size", message, null);
Messages.showWarning("Could not find sketch size", message, null);
// new Exception().printStackTrace(System.out);
// return null;
throw new SketchException("Please fix the size() line to continue.", false);
@@ -23,7 +23,7 @@
package processing.mode.java.preproc;
import processing.app.Base;
import processing.app.Messages;
import processing.core.PApplet;
import processing.data.StringList;
@@ -51,7 +51,7 @@ public class SurfaceInfo {
"The screenWidth and screenHeight variables are named\n" +
"displayWidth and displayHeight in Processing 3.\n" +
"Or you can use the fullScreen() method instead of size().";
Base.showWarning("Time for a quick update", message, null);
Messages.showWarning("Time for a quick update", message, null);
return true;
}
if (width.equals("screen.width") ||
@@ -62,7 +62,7 @@ public class SurfaceInfo {
"The screen.width and screen.height variables are named\n" +
"displayWidth and displayHeight in Processing 3.\n" +
"Or you can use the fullScreen() method instead of size().";
Base.showWarning("Time for a quick update", message, null);
Messages.showWarning("Time for a quick update", message, null);
return true;
}
return false;
@@ -433,9 +433,9 @@ public class Runner implements MessageConsumer {
if (errorStrings != null && errorStrings.length > 1) {
if (errorStrings[0].indexOf("Invalid maximum heap size") != -1) {
Base.showWarning("Way Too High",
"Please lower the value for \u201Cmaximum available memory\u201D in the\n" +
"Preferences window. For more information, read Help \u2192 Troubleshooting.", null);
Messages.showWarning("Way Too High",
"Please lower the value for \u201Cmaximum available memory\u201D in the\n" +
"Preferences window. For more information, read Help \u2192 Troubleshooting.", null);
} else {
for (String err : errorStrings) {
sketchErr.println(err);
@@ -595,9 +595,9 @@ public class Runner implements MessageConsumer {
return connector;
}
}
Base.showError("Compiler Error",
"findConnector() failed to find " +
connectorName + " inside Runner", null);
Messages.showError("Compiler Error",
"findConnector() failed to find " +
connectorName + " inside Runner", null);
return null; // Not reachable
}