mirror of
https://github.com/processing/processing4.git
synced 2026-01-25 09:21:07 +01:00
refactoring SketchException to app:utils
This commit is contained in:
@@ -33,7 +33,7 @@ import processing.app.Platform;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.RunnerListener;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
import processing.app.Util;
|
||||
import processing.app.contrib.ModeContribution;
|
||||
import processing.core.PApplet;
|
||||
|
||||
@@ -26,7 +26,7 @@ package processing.mode.java;
|
||||
import processing.app.*;
|
||||
import processing.app.ui.Editor;
|
||||
import processing.core.*;
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -46,7 +46,7 @@ import processing.data.XML;
|
||||
import processing.mode.java.preproc.ImportStatement;
|
||||
import processing.mode.java.preproc.PdePreprocessor;
|
||||
import processing.mode.java.preproc.PreprocessorResult;
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
|
||||
|
||||
public class JavaBuild {
|
||||
@@ -281,8 +281,8 @@ public class JavaBuild {
|
||||
Library library = null;
|
||||
try{
|
||||
library = mode.getLibrary(entry);
|
||||
}catch (processing.app.SketchException e){
|
||||
throw new SketchException(e.getMessage(), e.getCodeIndex(), e.getCodeLine(), e.getCodeColumn(), e.isStackTraceEnabled());
|
||||
}catch (processing.utils.SketchException e){
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (library != null) {
|
||||
@@ -345,7 +345,7 @@ public class JavaBuild {
|
||||
for (SketchCode sc : sketch.getCode()) {
|
||||
if (sc.isExtension("java")) {
|
||||
// In most cases, no pre-processing services necessary for Java files.
|
||||
// Just write the the contents of 'program' to a .java file
|
||||
// Just write the contents of 'program' to a .java file
|
||||
// into the build directory. However, if a default package is being
|
||||
// used (as in Android), and no package is specified in the source,
|
||||
// then we need to move this code to the same package as the sketch.
|
||||
|
||||
@@ -33,7 +33,7 @@ import processing.app.ui.Editor;
|
||||
import processing.app.ui.EditorException;
|
||||
import processing.app.ui.EditorState;
|
||||
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
import processing.mode.java.runner.Runner;
|
||||
import processing.mode.java.tweak.SketchParser;
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ import processing.mode.java.preproc.TextTransform.OffsetMapper;
|
||||
import processing.data.IntList;
|
||||
import processing.data.StringList;
|
||||
|
||||
import processing.utils.SketchException;
|
||||
|
||||
|
||||
/**
|
||||
* Service which preprocesses code to check for and report on issues.
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.google.classpath.ClassPathFactory;
|
||||
|
||||
import processing.app.*;
|
||||
import processing.mode.java.preproc.ImportStatement;
|
||||
|
||||
import processing.utils.SketchException;
|
||||
|
||||
/**
|
||||
* Builder which generates runtime paths using a series of caches.
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
import processing.app.Preferences;
|
||||
import processing.utils.SketchException;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-08 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package processing.mode.java.preproc;
|
||||
|
||||
|
||||
/**
|
||||
* An exception with a line number attached that occurs
|
||||
* during either pre-processing, compile, or run time.
|
||||
*/
|
||||
public class SketchException extends Exception {
|
||||
protected String message;
|
||||
protected int codeIndex;
|
||||
protected int codeLine;
|
||||
protected int codeColumn;
|
||||
protected boolean showStackTrace;
|
||||
|
||||
|
||||
public SketchException(String message) {
|
||||
this(message, true);
|
||||
}
|
||||
|
||||
|
||||
public SketchException(String message, boolean showStackTrace) {
|
||||
this(message, -1, -1, -1, showStackTrace);
|
||||
}
|
||||
|
||||
|
||||
public SketchException(String message, int file, int line) {
|
||||
this(message, file, line, -1, true);
|
||||
}
|
||||
|
||||
|
||||
public SketchException(String message, int file, int line, int column) {
|
||||
this(message, file, line, column, true);
|
||||
}
|
||||
|
||||
|
||||
public SketchException(String message, int file, int line, int column,
|
||||
boolean showStackTrace) {
|
||||
this.message = message;
|
||||
this.codeIndex = file;
|
||||
this.codeLine = line;
|
||||
this.codeColumn = column;
|
||||
this.showStackTrace = showStackTrace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override getMessage() in Throwable, so that I can set
|
||||
* the message text outside the constructor.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
public int getCodeIndex() {
|
||||
return codeIndex;
|
||||
}
|
||||
|
||||
|
||||
public void setCodeIndex(int index) {
|
||||
codeIndex = index;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasCodeIndex() {
|
||||
return codeIndex != -1;
|
||||
}
|
||||
|
||||
|
||||
public int getCodeLine() {
|
||||
return codeLine;
|
||||
}
|
||||
|
||||
|
||||
public void setCodeLine(int line) {
|
||||
this.codeLine = line;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasCodeLine() {
|
||||
return codeLine != -1;
|
||||
}
|
||||
|
||||
|
||||
public void setCodeColumn(int column) {
|
||||
this.codeColumn = column;
|
||||
}
|
||||
|
||||
|
||||
public int getCodeColumn() {
|
||||
return codeColumn;
|
||||
}
|
||||
|
||||
|
||||
public void showStackTrace() {
|
||||
showStackTrace = true;
|
||||
}
|
||||
|
||||
|
||||
public void hideStackTrace() {
|
||||
showStackTrace = false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isStackTraceEnabled() {
|
||||
return showStackTrace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Nix the java.lang crap out of an exception message
|
||||
* because it scares the children.
|
||||
* <P>
|
||||
* This function must be static to be used with super()
|
||||
* in each of the constructors above.
|
||||
*/
|
||||
/*
|
||||
static public final String massage(String msg) {
|
||||
if (msg.indexOf("java.lang.") == 0) {
|
||||
//int dot = msg.lastIndexOf('.');
|
||||
msg = msg.substring("java.lang.".length());
|
||||
}
|
||||
return msg;
|
||||
//return (dot == -1) ? msg : msg.substring(dot+1);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void printStackTrace() {
|
||||
if (showStackTrace) {
|
||||
super.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ import com.sun.jdi.connect.*;
|
||||
import com.sun.jdi.connect.Connector.Argument;
|
||||
import com.sun.jdi.event.*;
|
||||
import com.sun.jdi.request.*;
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.junit.Test;
|
||||
import processing.app.Preferences;
|
||||
import processing.mode.java.preproc.PreprocessorResult;
|
||||
import processing.mode.java.preproc.PdePreprocessIssueException;
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
|
||||
|
||||
public class ParserTests {
|
||||
|
||||
@@ -10,7 +10,7 @@ import processing.app.Preferences;
|
||||
import processing.mode.java.preproc.PdePreprocessor;
|
||||
import processing.mode.java.preproc.PreprocessorResult;
|
||||
import processing.mode.java.preproc.PdePreprocessIssueException;
|
||||
import processing.mode.java.preproc.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
|
||||
|
||||
public class ProcessingTestUtil {
|
||||
|
||||
@@ -23,7 +23,7 @@ package processing.mode.java;
|
||||
import org.mockito.Mockito;
|
||||
import processing.app.Library;
|
||||
import processing.app.Sketch;
|
||||
import processing.app.SketchException;
|
||||
import processing.utils.SketchException;
|
||||
import processing.mode.java.preproc.ImportStatement;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
Reference in New Issue
Block a user