diff --git a/gradle.properties b/gradle.properties index acb37ac5e..159ed6443 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ # Warning, "version" should be the same in gradle.properties and Version.java # Any idea anyone how to magically synchronize those :-) ? -version = 1.2024.4beta3 +version = 1.2024.4beta4 org.gradle.workers.max = 3 \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/preproc/Defines.java b/src/net/sourceforge/plantuml/preproc/Defines.java index 14ec49a0e..eb2a1550f 100644 --- a/src/net/sourceforge/plantuml/preproc/Defines.java +++ b/src/net/sourceforge/plantuml/preproc/Defines.java @@ -56,7 +56,7 @@ import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityProfile; import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.TVariableScope; import net.sourceforge.plantuml.utils.Log; @@ -82,7 +82,7 @@ public class Defines implements Truth { return new Defines(); } - public void copyTo(TMemory memory, StringLocated location) throws EaterException { + public void copyTo(TMemory memory, StringLocated location) throws EaterExceptionLocated { for (Entry ent : values.entrySet()) { final String name = ent.getKey(); final Define def = ent.getValue(); diff --git a/src/net/sourceforge/plantuml/preproc/Sub.java b/src/net/sourceforge/plantuml/preproc/Sub.java index 00b7bddcd..e14e5e746 100644 --- a/src/net/sourceforge/plantuml/preproc/Sub.java +++ b/src/net/sourceforge/plantuml/preproc/Sub.java @@ -42,13 +42,13 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterStartsub; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; public class Sub { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ private final String name; private final List lines = new ArrayList<>(); @@ -79,7 +79,7 @@ public class Sub { } public static Sub fromFile(ReadLine reader, String blocname, TContext context, TMemory memory) - throws IOException, EaterException { + throws IOException, EaterExceptionLocated { Sub result = null; StringLocated s = null; boolean skip = false; diff --git a/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java b/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java index 4ed855154..4fc609f49 100644 --- a/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java +++ b/src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java @@ -53,8 +53,7 @@ import net.sourceforge.plantuml.preproc.StartDiagramExtractReader; import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.security.SURL; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; -import net.sourceforge.plantuml.utils.LineLocation; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.utils.Log; public class PreprocessorUtils { @@ -134,7 +133,7 @@ public class PreprocessorUtils { } public static ReadLine getReaderIncludeUrl(final SURL url, StringLocated s, String suf, Charset charset) - throws EaterException { + throws EaterExceptionLocated { try { if (StartDiagramExtractReader.containsStartDiagram(url, s, charset)) return StartDiagramExtractReader.build(url, s, suf, charset); @@ -142,16 +141,16 @@ public class PreprocessorUtils { return getReaderInclude(url, s, charset); } catch (IOException e) { Logme.error(e); - throw EaterException.located("Cannot open URL " + e.getMessage(), s); + throw EaterExceptionLocated.located("Cannot open URL " + e.getMessage(), s); } } public static ReadLine getReaderInclude(SURL url, StringLocated s, Charset charset) - throws EaterException, UnsupportedEncodingException { + throws EaterExceptionLocated, UnsupportedEncodingException { final InputStream is = url.openStream(); if (is == null) - throw EaterException.located("Cannot open URL", s); + throw EaterExceptionLocated.located("Cannot open URL", s); return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation()); } diff --git a/src/net/sourceforge/plantuml/tim/Eater.java b/src/net/sourceforge/plantuml/tim/Eater.java index 3ccc10440..20d123720 100644 --- a/src/net/sourceforge/plantuml/tim/Eater.java +++ b/src/net/sourceforge/plantuml/tim/Eater.java @@ -64,19 +64,19 @@ public abstract class Eater { return stringLocated; } - public abstract void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated; + public abstract void analyze(TContext context, TMemory memory) throws EaterExceptionLocated; public int getCurrentPosition() { return i; } - final protected String eatAllToEnd() throws EaterException { + final protected String eatAllToEnd() throws EaterExceptionLocated { final String result = stringLocated.getString().substring(i); i = stringLocated.length(); return result; } - final public TValue eatExpression(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + final public TValue eatExpression(TContext context, TMemory memory) throws EaterExceptionLocated { final char ch = peekChar(); if (ch == '{' || ch == '[') { final String data = eatAllToEnd(); @@ -89,23 +89,22 @@ public abstract class Eater { return tokenStack.getResult(getStringLocated(), context, memory); } - final protected TokenStack eatTokenStack() throws EaterException { + final protected TokenStack eatTokenStack() throws EaterExceptionLocated { final TokenStack tokenStack = new TokenStack(); addIntoTokenStack(tokenStack, false); if (tokenStack.size() == 0) - throw EaterException.located("Missing expression", stringLocated); + throw EaterExceptionLocated.located("Missing expression", stringLocated); return tokenStack; } - final protected TValue eatExpressionStopAtColon(TContext context, TMemory memory) - throws EaterException, EaterExceptionLocated { + final protected TValue eatExpressionStopAtColon(TContext context, TMemory memory) throws EaterExceptionLocated { final TokenStack tokenStack = new TokenStack(); addIntoTokenStack(tokenStack, true); return tokenStack.getResult(getStringLocated(), context, memory); } - final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterException { + final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterExceptionLocated { Token lastToken = null; while (true) { final Token token = TokenType.eatOneToken(lastToken, this, stopAtColon); @@ -118,10 +117,10 @@ public abstract class Eater { } } - final public String eatAndGetQuotedString() throws EaterException { + final public String eatAndGetQuotedString() throws EaterExceptionLocated { final char separator = peekChar(); if (TLineType.isQuote(separator) == false) - throw EaterException.located("quote10", stringLocated); + throw EaterExceptionLocated.located("quote10", stringLocated); checkAndEatChar(separator); final StringBuilder value = new StringBuilder(); @@ -130,7 +129,7 @@ public abstract class Eater { return value.toString(); } - final protected String eatAndGetOptionalQuotedString() throws EaterException { + final protected String eatAndGetOptionalQuotedString() throws EaterExceptionLocated { final char quote = peekChar(); if (TLineType.isQuote(quote)) return eatAndGetQuotedString(); @@ -142,7 +141,7 @@ public abstract class Eater { while (true) { char ch = peekChar(); if (ch == 0) - throw EaterException.located("until001", stringLocated); + throw EaterExceptionLocated.located("until001", stringLocated); if (level == 0 && (ch == ',' || ch == ')')) return value.toString().trim(); @@ -160,7 +159,7 @@ public abstract class Eater { // return value.toString(); } - final public String eatAndGetNumber() throws EaterException { + final public String eatAndGetNumber() throws EaterExceptionLocated { final StringBuilder result = new StringBuilder(); while (true) { final char ch = peekChar(); @@ -176,7 +175,7 @@ public abstract class Eater { } } - final public String eatAndGetSpaces() throws EaterException { + final public String eatAndGetSpaces() throws EaterExceptionLocated { final StringBuilder result = new StringBuilder(); while (true) { final char ch = peekChar(); @@ -187,19 +186,19 @@ public abstract class Eater { } } - final protected String eatAndGetVarname() throws EaterException { + final protected String eatAndGetVarname() throws EaterExceptionLocated { final StringBuilder varname = new StringBuilder("" + eatOneChar()); if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false) - throw EaterException.located("a002", stringLocated); + throw EaterExceptionLocated.located("a002", stringLocated); addUpToLastLetterOrUnderscoreOrDigit(varname); return varname.toString(); } - final protected String eatAndGetFunctionName() throws EaterException { + final protected String eatAndGetFunctionName() throws EaterExceptionLocated { final StringBuilder varname = new StringBuilder("" + eatOneChar()); if (TLineType.isLetterOrUnderscoreOrDollar(varname.charAt(0)) == false) - throw EaterException.located("a003", stringLocated); + throw EaterExceptionLocated.located("a003", stringLocated); addUpToLastLetterOrUnderscoreOrDigit(varname); return varname.toString(); @@ -247,14 +246,14 @@ public abstract class Eater { return ch; } - final protected void checkAndEatChar(char ch) throws EaterException { + final protected void checkAndEatChar(char ch) throws EaterExceptionLocated { if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) - throw EaterException.located("a001", stringLocated); + throw EaterExceptionLocated.located("a001", stringLocated); i++; } - final protected boolean safeCheckAndEatChar(char ch) throws EaterException { + final protected boolean safeCheckAndEatChar(char ch) throws EaterExceptionLocated { if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) return false; @@ -262,7 +261,7 @@ public abstract class Eater { return true; } - final protected void optionallyEatChar(char ch) throws EaterException { + final protected void optionallyEatChar(char ch) throws EaterExceptionLocated { if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) return; @@ -270,7 +269,7 @@ public abstract class Eater { i++; } - final protected void checkAndEatChar(String s) throws EaterException { + final protected void checkAndEatChar(String s) throws EaterExceptionLocated { for (int j = 0; j < s.length(); j++) checkAndEatChar(s.charAt(j)); @@ -299,8 +298,7 @@ public abstract class Eater { } final protected TFunctionImpl eatDeclareFunction(TContext context, TMemory memory, boolean unquoted, - StringLocated location, boolean allowNoParenthesis, TFunctionType type) - throws EaterException, EaterExceptionLocated { + StringLocated location, boolean allowNoParenthesis, TFunctionType type) throws EaterExceptionLocated { final List args = new ArrayList<>(); final String functionName = eatAndGetFunctionName(); skipSpaces(); @@ -308,7 +306,7 @@ public abstract class Eater { if (allowNoParenthesis) return new TFunctionImpl(functionName, args, unquoted, type); - throw EaterException.located("Missing opening parenthesis", stringLocated); + throw EaterExceptionLocated.located("Missing opening parenthesis", stringLocated); } while (true) { skipSpaces(); @@ -333,7 +331,7 @@ public abstract class Eater { checkAndEatChar(")"); break; } else { - throw EaterException.located("Error in function definition", stringLocated); + throw EaterExceptionLocated.located("Error in function definition", stringLocated); } } skipSpaces(); @@ -341,7 +339,7 @@ public abstract class Eater { } final protected TFunctionImpl eatDeclareReturnFunctionWithOptionalReturn(TContext context, TMemory memory, - boolean unquoted, StringLocated location) throws EaterException, EaterExceptionLocated { + boolean unquoted, StringLocated location) throws EaterExceptionLocated { final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false, TFunctionType.RETURN_FUNCTION); if (peekChar() == 'r') { @@ -359,7 +357,7 @@ public abstract class Eater { } final protected TFunctionImpl eatDeclareProcedure(TContext context, TMemory memory, boolean unquoted, - StringLocated location) throws EaterException, EaterExceptionLocated { + StringLocated location) throws EaterExceptionLocated { final TFunctionImpl result = eatDeclareFunction(context, memory, unquoted, location, false, TFunctionType.PROCEDURE); return result; diff --git a/src/net/sourceforge/plantuml/tim/EaterAffectation.java b/src/net/sourceforge/plantuml/tim/EaterAffectation.java index 726ef28f8..efe99b76f 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAffectation.java +++ b/src/net/sourceforge/plantuml/tim/EaterAffectation.java @@ -44,7 +44,7 @@ public class EaterAffectation extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java b/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java index aa689aeab..863f3d91f 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java +++ b/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java @@ -44,7 +44,7 @@ public class EaterAffectationDefine extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!define"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterAssert.java b/src/net/sourceforge/plantuml/tim/EaterAssert.java index e854c06ad..3c34cacb1 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAssert.java +++ b/src/net/sourceforge/plantuml/tim/EaterAssert.java @@ -44,7 +44,7 @@ public class EaterAssert extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!assert"); skipSpaces(); @@ -55,9 +55,9 @@ public class EaterAssert extends Eater { if (ch == ':') { checkAndEatChar(':'); final TValue message = eatExpression(context, memory); - throw EaterException.located("Assertion error : " + message.toString(), getStringLocated()); + throw EaterExceptionLocated.located("Assertion error : " + message.toString(), getStringLocated()); } - throw EaterException.located("Assertion error", getStringLocated()); + throw EaterExceptionLocated.located("Assertion error", getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java b/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java index 9c155df18..d0cdbdd16 100644 --- a/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java +++ b/src/net/sourceforge/plantuml/tim/EaterDeclareProcedure.java @@ -48,7 +48,7 @@ public class EaterDeclareProcedure extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!"); boolean unquoted = false; diff --git a/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java b/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java index 8c6415d1a..84bf4c5c2 100644 --- a/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/EaterDeclareReturnFunction.java @@ -48,7 +48,7 @@ public class EaterDeclareReturnFunction extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!"); boolean unquoted = false; diff --git a/src/net/sourceforge/plantuml/tim/EaterDumpMemory.java b/src/net/sourceforge/plantuml/tim/EaterDumpMemory.java index 33315178b..fcf4eac86 100644 --- a/src/net/sourceforge/plantuml/tim/EaterDumpMemory.java +++ b/src/net/sourceforge/plantuml/tim/EaterDumpMemory.java @@ -43,7 +43,7 @@ public class EaterDumpMemory extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!dump_memory"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterElseIf.java b/src/net/sourceforge/plantuml/tim/EaterElseIf.java index 8ddc5e35a..e83bbbf5a 100644 --- a/src/net/sourceforge/plantuml/tim/EaterElseIf.java +++ b/src/net/sourceforge/plantuml/tim/EaterElseIf.java @@ -46,7 +46,7 @@ public class EaterElseIf extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!elseif"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterException.java b/src/net/sourceforge/plantuml/tim/EaterException.java deleted file mode 100644 index ee3439e13..000000000 --- a/src/net/sourceforge/plantuml/tim/EaterException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2024, Arnaud Roques - * - * Project Info: https://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * https://plantuml.com/patreon (only 1$ per month!) - * https://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML 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 3 of the License, or - * (at your option) any later version. - * - * PlantUML 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 library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - */ -package net.sourceforge.plantuml.tim; - -import net.sourceforge.plantuml.text.StringLocated; - -public class EaterException extends Exception { - - private final String message; - - private EaterException(String message, StringLocated location) { - this.message = message; - } - - public static EaterException unlocated(String message, StringLocated location) { - return new EaterException(message, location); - } - - public static EaterException located(String message, StringLocated location) { - return unlocated(message, location); - } - - public final String getMessage() { - return message; - } - - public EaterExceptionLocated withLocation(StringLocated sl) { - return EaterExceptionLocated.located(message, sl); - } - -} diff --git a/src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java b/src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java index 36ee62187..4aeb0a0da 100644 --- a/src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java +++ b/src/net/sourceforge/plantuml/tim/EaterExceptionLocated.java @@ -52,6 +52,10 @@ public class EaterExceptionLocated extends Exception { return new EaterExceptionLocated(message, Objects.requireNonNull(location)); } + public static EaterExceptionLocated unlocated(String message, StringLocated location) { + return new EaterExceptionLocated(message, Objects.requireNonNull(location)); + } + public final String getMessage() { return message; } diff --git a/src/net/sourceforge/plantuml/tim/EaterForeach.java b/src/net/sourceforge/plantuml/tim/EaterForeach.java index b7be391da..c631ed8f7 100644 --- a/src/net/sourceforge/plantuml/tim/EaterForeach.java +++ b/src/net/sourceforge/plantuml/tim/EaterForeach.java @@ -48,7 +48,7 @@ public class EaterForeach extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!foreach"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java b/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java index 8e703fde8..767671aed 100644 --- a/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java +++ b/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java @@ -58,7 +58,7 @@ public class EaterFunctionCall extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipUntilChar('('); checkAndEatChar('('); skipSpaces(); @@ -119,9 +119,10 @@ public class EaterFunctionCall extends Eater { break; } if (unquoted) { - throw EaterException.located("unquoted function/procedure cannot use expression.", getStringLocated()); + throw EaterExceptionLocated.located("unquoted function/procedure cannot use expression.", + getStringLocated()); } - throw EaterException.located("call001", getStringLocated()); + throw EaterExceptionLocated.located("call001", getStringLocated()); } } @@ -133,7 +134,7 @@ public class EaterFunctionCall extends Eater { return Collections.unmodifiableMap(namedArguments); } - public final String getEndOfLine() throws EaterException { + public final String getEndOfLine() throws EaterExceptionLocated { return this.eatAllToEnd(); } diff --git a/src/net/sourceforge/plantuml/tim/EaterIf.java b/src/net/sourceforge/plantuml/tim/EaterIf.java index 50ad453da..ed544cba9 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIf.java +++ b/src/net/sourceforge/plantuml/tim/EaterIf.java @@ -46,7 +46,7 @@ public class EaterIf extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!if"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterIfdef.java b/src/net/sourceforge/plantuml/tim/EaterIfdef.java index b197abc20..7173965df 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIfdef.java +++ b/src/net/sourceforge/plantuml/tim/EaterIfdef.java @@ -48,7 +48,7 @@ public class EaterIfdef extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!ifdef"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterIfndef.java b/src/net/sourceforge/plantuml/tim/EaterIfndef.java index ae9d7478f..a79da59a6 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIfndef.java +++ b/src/net/sourceforge/plantuml/tim/EaterIfndef.java @@ -46,7 +46,7 @@ public class EaterIfndef extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!ifndef"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterImport.java b/src/net/sourceforge/plantuml/tim/EaterImport.java index 6784a01f2..c292af610 100644 --- a/src/net/sourceforge/plantuml/tim/EaterImport.java +++ b/src/net/sourceforge/plantuml/tim/EaterImport.java @@ -45,7 +45,7 @@ public class EaterImport extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!import"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterInclude.java b/src/net/sourceforge/plantuml/tim/EaterInclude.java index 5366d8a4a..fac2806ff 100644 --- a/src/net/sourceforge/plantuml/tim/EaterInclude.java +++ b/src/net/sourceforge/plantuml/tim/EaterInclude.java @@ -47,7 +47,7 @@ public class EaterInclude extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!include"); final char peekChar = peekChar(); diff --git a/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java b/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java index f0ffecce5..b275c1169 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java +++ b/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java @@ -45,7 +45,7 @@ public class EaterIncludeDef extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!includedef"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterIncludesub.java b/src/net/sourceforge/plantuml/tim/EaterIncludesub.java index bd93e2e1e..53778e2e1 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIncludesub.java +++ b/src/net/sourceforge/plantuml/tim/EaterIncludesub.java @@ -45,7 +45,7 @@ public class EaterIncludesub extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!includesub"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java b/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java index 532470560..bb0257003 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java +++ b/src/net/sourceforge/plantuml/tim/EaterLegacyDefine.java @@ -45,7 +45,7 @@ public class EaterLegacyDefine extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!define"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java b/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java index 54a782553..3b93fbfd1 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java +++ b/src/net/sourceforge/plantuml/tim/EaterLegacyDefineLong.java @@ -45,7 +45,7 @@ public class EaterLegacyDefineLong extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!definelong"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterLog.java b/src/net/sourceforge/plantuml/tim/EaterLog.java index 805a64306..53f938091 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLog.java +++ b/src/net/sourceforge/plantuml/tim/EaterLog.java @@ -44,7 +44,7 @@ public class EaterLog extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!log"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterReturn.java b/src/net/sourceforge/plantuml/tim/EaterReturn.java index 99ed3dd21..58ade8267 100644 --- a/src/net/sourceforge/plantuml/tim/EaterReturn.java +++ b/src/net/sourceforge/plantuml/tim/EaterReturn.java @@ -46,7 +46,7 @@ public class EaterReturn extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!return"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterStartsub.java b/src/net/sourceforge/plantuml/tim/EaterStartsub.java index 9bb1a02c9..ca67a6574 100644 --- a/src/net/sourceforge/plantuml/tim/EaterStartsub.java +++ b/src/net/sourceforge/plantuml/tim/EaterStartsub.java @@ -45,13 +45,13 @@ public class EaterStartsub extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!startsub"); skipSpaces(); this.subname = eatAllToEnd(); if (this.subname.matches("\\w+") == false) - throw EaterException.located("Bad sub name", getStringLocated()); + throw EaterExceptionLocated.located("Bad sub name", getStringLocated()); } diff --git a/src/net/sourceforge/plantuml/tim/EaterTheme.java b/src/net/sourceforge/plantuml/tim/EaterTheme.java index c43fdc33f..891b101a0 100644 --- a/src/net/sourceforge/plantuml/tim/EaterTheme.java +++ b/src/net/sourceforge/plantuml/tim/EaterTheme.java @@ -67,7 +67,7 @@ public class EaterTheme extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!theme"); skipSpaces(); @@ -85,7 +85,7 @@ public class EaterTheme extends Eater { } - public final ReadLine getTheme() throws EaterException { + public final ReadLine getTheme() throws EaterExceptionLocated { if (from == null) { try { final ReadLine reader = ThemeUtils.getReaderTheme(realName); @@ -101,24 +101,24 @@ public class EaterTheme extends Eater { } catch (IOException e) { Logme.error(e); } - throw EaterException.located("Cannot load " + realName, getStringLocated()); + throw EaterExceptionLocated.located("Cannot load " + realName, getStringLocated()); } if (from.startsWith("<") && from.endsWith(">")) { final ReadLine reader = ThemeUtils.getReaderTheme(realName, from); if (reader == null) - throw EaterException.located("No such theme " + realName + " in " + from, getStringLocated()); + throw EaterExceptionLocated.located("No such theme " + realName + " in " + from, getStringLocated()); return reader; } else if (from.startsWith("http://") || from.startsWith("https://")) { final SURL url = SURL.create(ThemeUtils.getFullPath(from, realName)); if (url == null) - throw EaterException.located("Cannot open URL", getStringLocated()); + throw EaterExceptionLocated.located("Cannot open URL", getStringLocated()); try { return PreprocessorUtils.getReaderInclude(url, getStringLocated(), UTF_8); } catch (UnsupportedEncodingException e) { Logme.error(e); - throw EaterException.located("Cannot decode charset", getStringLocated()); + throw EaterExceptionLocated.located("Cannot decode charset", getStringLocated()); } } @@ -126,12 +126,12 @@ public class EaterTheme extends Eater { final FileWithSuffix file = context.getFileWithSuffix(from, realName); final Reader tmp = file.getReader(UTF_8); if (tmp == null) - throw EaterException.located("No such theme " + realName, getStringLocated()); + throw EaterExceptionLocated.located("No such theme " + realName, getStringLocated()); return ReadLineReader.create(tmp, "theme " + realName); } catch (IOException e) { Logme.error(e); - throw EaterException.located("Cannot load " + realName, getStringLocated()); + throw EaterExceptionLocated.located("Cannot load " + realName, getStringLocated()); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterUndef.java b/src/net/sourceforge/plantuml/tim/EaterUndef.java index 01e48c910..525644758 100644 --- a/src/net/sourceforge/plantuml/tim/EaterUndef.java +++ b/src/net/sourceforge/plantuml/tim/EaterUndef.java @@ -43,7 +43,7 @@ public class EaterUndef extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!undef"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/EaterWhile.java b/src/net/sourceforge/plantuml/tim/EaterWhile.java index 8538d6978..4b3844b87 100644 --- a/src/net/sourceforge/plantuml/tim/EaterWhile.java +++ b/src/net/sourceforge/plantuml/tim/EaterWhile.java @@ -46,7 +46,7 @@ public class EaterWhile extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { skipSpaces(); checkAndEatChar("!while"); skipSpaces(); diff --git a/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java b/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java index cc65cc222..c1c6b6898 100644 --- a/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java +++ b/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java @@ -61,7 +61,7 @@ public class ExecutionContextWhile { } public TValue conditionValue(StringLocated location, TContext context, TMemory memory) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { return whileExpression.getResult(location, context, memory); } diff --git a/src/net/sourceforge/plantuml/tim/ExecutionContexts.java b/src/net/sourceforge/plantuml/tim/ExecutionContexts.java index 8a3cb8518..33ab5821b 100644 --- a/src/net/sourceforge/plantuml/tim/ExecutionContexts.java +++ b/src/net/sourceforge/plantuml/tim/ExecutionContexts.java @@ -79,12 +79,12 @@ public abstract class ExecutionContexts { return allForeachs.pollLast(); } - public boolean areAllIfOk(TContext context, TMemory memory) throws EaterException { - for (ExecutionContextIf conditionalContext : allIfs) { - if (conditionalContext.conditionIsOkHere() == false) { + public boolean areAllIfOk(TContext context, TMemory memory) throws EaterExceptionLocated { + for (ExecutionContextIf conditionalContext : allIfs) + if (conditionalContext.conditionIsOkHere() == false) return false; - } - } + + return true; } diff --git a/src/net/sourceforge/plantuml/tim/FunctionsSet.java b/src/net/sourceforge/plantuml/tim/FunctionsSet.java index 0f910fb66..b5702c62d 100644 --- a/src/net/sourceforge/plantuml/tim/FunctionsSet.java +++ b/src/net/sourceforge/plantuml/tim/FunctionsSet.java @@ -95,9 +95,9 @@ public class FunctionsSet { } public void executeLegacyDefine(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { if (this.pendingFunction != null) - throw EaterException.located("already0048", s); + throw EaterExceptionLocated.located("already0048", s); final EaterLegacyDefine legacyDefine = new EaterLegacyDefine(s); legacyDefine.analyze(context, memory); @@ -107,9 +107,9 @@ public class FunctionsSet { } public void executeLegacyDefineLong(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { if (this.pendingFunction != null) - throw EaterException.located("already0068", s); + throw EaterExceptionLocated.located("already0068", s); final EaterLegacyDefineLong legacyDefineLong = new EaterLegacyDefineLong(s); legacyDefineLong.analyze(context, memory); @@ -117,9 +117,9 @@ public class FunctionsSet { } public void executeDeclareReturnFunction(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { if (this.pendingFunction != null) - throw EaterException.located("already0068", s); + throw EaterExceptionLocated.located("already0068", s); final EaterDeclareReturnFunction declareFunction = new EaterDeclareReturnFunction(s); declareFunction.analyze(context, memory); @@ -127,7 +127,7 @@ public class FunctionsSet { final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature(); final TFunction previous = this.functions.get(declaredSignature); if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature))) - throw EaterException.located("This function is already defined", s); + throw EaterExceptionLocated.located("This function is already defined", s); if (finalFlag) this.functionsFinal.add(declaredSignature); @@ -140,9 +140,9 @@ public class FunctionsSet { } public void executeDeclareProcedure(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { if (this.pendingFunction != null) - throw EaterException.located("already0068", s); + throw EaterExceptionLocated.located("already0068", s); final EaterDeclareProcedure declareFunction = new EaterDeclareProcedure(s); declareFunction.analyze(context, memory); @@ -150,7 +150,7 @@ public class FunctionsSet { final TFunctionSignature declaredSignature = declareFunction.getFunction().getSignature(); final TFunction previous = this.functions.get(declaredSignature); if (previous != null && (finalFlag || this.functionsFinal.contains(declaredSignature))) - throw EaterException.located("This function is already defined", s); + throw EaterExceptionLocated.located("This function is already defined", s); if (finalFlag) this.functionsFinal.add(declaredSignature); diff --git a/src/net/sourceforge/plantuml/tim/StringEater.java b/src/net/sourceforge/plantuml/tim/StringEater.java index 85ca881c9..e8b2825e2 100644 --- a/src/net/sourceforge/plantuml/tim/StringEater.java +++ b/src/net/sourceforge/plantuml/tim/StringEater.java @@ -43,7 +43,7 @@ public class StringEater extends Eater { } @Override - public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { + public void analyze(TContext context, TMemory memory) throws EaterExceptionLocated { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/TContext.java b/src/net/sourceforge/plantuml/tim/TContext.java index 547313c90..86a3bb0b1 100644 --- a/src/net/sourceforge/plantuml/tim/TContext.java +++ b/src/net/sourceforge/plantuml/tim/TContext.java @@ -236,7 +236,7 @@ public class TContext { public Knowledge asKnowledge(final TMemory memory, final LineLocation location) { return new Knowledge() { - public TValue getVariable(String name) throws EaterException, EaterExceptionLocated { + public TValue getVariable(String name) throws EaterExceptionLocated { if (name.contains(".") || name.contains("[")) { final TValue result = fromJson(memory, name, location); return result; @@ -250,8 +250,7 @@ public class TContext { }; } - private TValue fromJson(TMemory memory, String name, LineLocation location) - throws EaterException, EaterExceptionLocated { + private TValue fromJson(TMemory memory, String name, LineLocation location) throws EaterExceptionLocated { final String result = applyFunctionsAndVariables(memory, new StringLocated(name, location)); try { final JsonValue json = Json.parse(result); @@ -284,23 +283,19 @@ public class TContext { final CodeIterator it = buildCodeIterator(memory, body); StringLocated s = null; - try { - while ((s = it.peek()) != null) { - final TValue result = executeOneLineSafe(memory, s, ftype, modeSpecial); - if (result != null) - return result; + while ((s = it.peek()) != null) { + final TValue result = executeOneLineSafe(memory, s, ftype, modeSpecial); + if (result != null) + return result; - it.next(); - } - return null; - } catch (EaterException e) { - throw e.withLocation(s); + it.next(); } + return null; } private void executeLinesInternal(TMemory memory, List body, TFunctionType ftype) - throws EaterExceptionLocated, EaterException { + throws EaterExceptionLocated { final CodeIterator it = buildCodeIterator(memory, body); StringLocated s = null; @@ -312,22 +307,20 @@ public class TContext { } private TValue executeOneLineSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { try { this.debug.add(s); return executeOneLineNotSafe(memory, s, ftype, modeSpecial); } catch (Exception e) { - if (e instanceof EaterException) - throw (EaterException) e; if (e instanceof EaterExceptionLocated) throw (EaterExceptionLocated) e; Logme.error(e); - throw EaterException.located("Fatal parsing error", s); + throw EaterExceptionLocated.located("Fatal parsing error", s); } } private TValue executeOneLineNotSafe(TMemory memory, StringLocated s, TFunctionType ftype, boolean modeSpecial) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { final TLineType type = s.getType(); if (type == TLineType.INCLUDESUB) { @@ -382,11 +375,11 @@ public class TContext { } else if (s.getString().matches("^\\s+$")) { return null; } else { - throw EaterException.located("Compile Error " + ftype + " " + type, s); + throw EaterExceptionLocated.located("Compile Error " + ftype + " " + type, s); } } - private void addPlain(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void addPlain(TMemory memory, StringLocated s) throws EaterExceptionLocated { final StringLocated tmp[] = applyFunctionsAndVariablesInternal(memory, s); if (tmp != null) { if (pendingAdd != null) { @@ -399,32 +392,31 @@ public class TContext { } } - private void simulatePlain(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void simulatePlain(TMemory memory, StringLocated s) throws EaterExceptionLocated { final StringLocated ignored[] = applyFunctionsAndVariablesInternal(memory, s); } - private void executeAffectationDefine(TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + private void executeAffectationDefine(TMemory memory, StringLocated s) throws EaterExceptionLocated { new EaterAffectationDefine(s).analyze(this, memory); } - private void executeDumpMemory(TMemory memory, StringLocated s) throws EaterException { + private void executeDumpMemory(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterDumpMemory condition = new EaterDumpMemory(s); condition.analyze(this, memory); } - private void executeAssert(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeAssert(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterAssert condition = new EaterAssert(s); condition.analyze(this, memory); } - private void executeUndef(TMemory memory, StringLocated s) throws EaterException { + private void executeUndef(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterUndef undef = new EaterUndef(s); undef.analyze(this, memory); } private StringLocated[] applyFunctionsAndVariablesInternal(TMemory memory, StringLocated located) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { if (memory.isEmpty() && functionsSet.size() == 0) return new StringLocated[] { located }; @@ -442,8 +434,7 @@ public class TContext { private String pendingAdd = null; - public String applyFunctionsAndVariables(TMemory memory, final StringLocated str) - throws EaterException, EaterExceptionLocated { + public String applyFunctionsAndVariables(TMemory memory, final StringLocated str) throws EaterExceptionLocated { // https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm // https://stackoverflow.com/questions/1326682/java-replacing-multiple-different-substring-in-a-string-at-once-or-in-the-most // https://en.wikipedia.org/wiki/String-searching_algorithm @@ -465,7 +456,7 @@ public class TContext { call.getNamedArguments().keySet()); final TFunction function = functionsSet.getFunctionSmart(signature); if (function == null) - throw EaterException.located("Function not found " + presentFunction, str); + throw EaterExceptionLocated.located("Function not found " + presentFunction, str); if (function.getFunctionType() == TFunctionType.PROCEDURE) { this.pendingAdd = result.toString(); @@ -503,11 +494,11 @@ public class TContext { } private void executeVoid3(StringLocated location, TMemory memory, TFunction function, EaterFunctionCall call) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { function.executeProcedureInternal(this, memory, location, call.getValues(), call.getNamedArguments()); } - private void executeImport(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeImport(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterImport _import = new EaterImport(s.getTrimmed()); _import.analyze(this, memory); @@ -520,13 +511,13 @@ public class TContext { } } catch (IOException e) { Logme.error(e); - throw EaterException.located("Cannot import " + e.getMessage(), s); + throw EaterExceptionLocated.located("Cannot import " + e.getMessage(), s); } - throw EaterException.located("Cannot import", s); + throw EaterExceptionLocated.located("Cannot import", s); } - private void executeLog(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeLog(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterLog log = new EaterLog(s.getTrimmed()); log.analyze(this, memory); } @@ -538,7 +529,7 @@ public class TContext { } - private void executeIncludesub(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeIncludesub(TMemory memory, StringLocated s) throws EaterExceptionLocated { ImportedFiles saveImportedFiles = null; try { final EaterIncludesub include = new EaterIncludesub(s.getTrimmed()); @@ -556,7 +547,7 @@ public class TContext { this.importedFiles = this.importedFiles.withCurrentDir(f2.getParentFile()); final Reader reader = f2.getReader(charset); if (reader == null) - throw EaterException.located("cannot include " + what, s); + throw EaterExceptionLocated.located("cannot include " + what, s); try { ReadLine readerline = ReadLineReader.create(reader, what, s.getLocation()); @@ -568,14 +559,14 @@ public class TContext { } } catch (IOException e) { Logme.error(e); - throw EaterException.located("cannot include " + what, s); + throw EaterExceptionLocated.located("cannot include " + what, s); } } if (sub == null) sub = subs.get(what); if (sub == null) - throw EaterException.located("cannot include " + what, s); + throw EaterExceptionLocated.located("cannot include " + what, s); executeLinesInternal(memory, sub.lines(), null); } finally { @@ -585,7 +576,7 @@ public class TContext { } } - private void executeIncludeDef(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeIncludeDef(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterIncludeDef include = new EaterIncludeDef(s.getTrimmed()); include.analyze(this, memory); final String definitionName = include.getLocation(); @@ -604,7 +595,7 @@ public class TContext { } while (true); } catch (IOException e) { Logme.error(e); - throw EaterException.located("" + e, s); + throw EaterExceptionLocated.located("" + e, s); } finally { try { reader2.close(); @@ -614,12 +605,12 @@ public class TContext { } } - private void executeTheme(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeTheme(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterTheme eater = new EaterTheme(s.getTrimmed(), importedFiles); eater.analyze(this, memory); final ReadLine reader = eater.getTheme(); if (reader == null) - throw EaterException.located("No such theme " + eater.getName(), s); + throw EaterExceptionLocated.located("No such theme " + eater.getName(), s); try { final List body = new ArrayList<>(); @@ -633,7 +624,7 @@ public class TContext { } while (true); } catch (IOException e) { Logme.error(e); - throw EaterException.located("Error reading theme " + e, s); + throw EaterExceptionLocated.located("Error reading theme " + e, s); } finally { try { reader.close(); @@ -643,7 +634,7 @@ public class TContext { } } - private void executeInclude(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeInclude(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterInclude include = new EaterInclude(s.getTrimmed()); include.analyze(this, memory); String location = include.getWhat(); @@ -661,7 +652,7 @@ public class TContext { if (location.startsWith("http://") || location.startsWith("https://")) { final SURL url = SURL.create(location); if (url == null) - throw EaterException.located("Cannot open URL", s); + throw EaterExceptionLocated.located("Cannot open URL", s); reader = PreprocessorUtils.getReaderIncludeUrl(url, s, suf, charset); } else if (location.startsWith("<") && location.endsWith(">")) { @@ -677,14 +668,14 @@ public class TContext { return; if (strategy == PreprocessorIncludeStrategy.ONCE && filesUsedCurrent.contains(f2)) - throw EaterException.located("This file has already been included", s); + throw EaterExceptionLocated.located("This file has already been included", s); if (StartDiagramExtractReader.containsStartDiagram(f2, s, charset)) { reader = StartDiagramExtractReader.build(f2, s, charset); } else { final Reader tmp = f2.getReader(charset); if (tmp == null) - throw EaterException.located("Cannot include file", s); + throw EaterExceptionLocated.located("Cannot include file", s); reader = ReadLineReader.create(tmp, location, s.getLocation()); } @@ -713,7 +704,7 @@ public class TContext { } } catch (IOException e) { Logme.error(e); - throw EaterException.located("cannot include " + e, s); + throw EaterExceptionLocated.located("cannot include " + e, s); } finally { if (reader != null) { try { @@ -724,7 +715,7 @@ public class TContext { } } - throw EaterException.located("cannot include " + location, s); + throw EaterExceptionLocated.located("cannot include " + location, s); } public boolean isLegacyDefine(String functionName) { diff --git a/src/net/sourceforge/plantuml/tim/TFunction.java b/src/net/sourceforge/plantuml/tim/TFunction.java index d6572f378..f8032a23e 100644 --- a/src/net/sourceforge/plantuml/tim/TFunction.java +++ b/src/net/sourceforge/plantuml/tim/TFunction.java @@ -50,10 +50,10 @@ public interface TFunction { public TFunctionType getFunctionType(); public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List args, - Map named) throws EaterException, EaterExceptionLocated; + Map named) throws EaterExceptionLocated; public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, - Map named) throws EaterException, EaterExceptionLocated; + Map named) throws EaterExceptionLocated; public boolean isUnquoted(); diff --git a/src/net/sourceforge/plantuml/tim/TFunctionImpl.java b/src/net/sourceforge/plantuml/tim/TFunctionImpl.java index 506dc465d..eb36bbb3e 100644 --- a/src/net/sourceforge/plantuml/tim/TFunctionImpl.java +++ b/src/net/sourceforge/plantuml/tim/TFunctionImpl.java @@ -133,7 +133,7 @@ public class TFunctionImpl implements TFunction { @Override public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG) throw new IllegalStateException(); @@ -143,23 +143,24 @@ public class TFunctionImpl implements TFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List args, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { if (functionType == TFunctionType.LEGACY_DEFINE) return executeReturnLegacyDefine(location.getLocation(), context, memory, args); if (functionType != TFunctionType.RETURN_FUNCTION) - throw EaterException.unlocated("Illegal call here. Is there a return directive in your function?", location); + throw EaterExceptionLocated.unlocated("Illegal call here. Is there a return directive in your function?", + location); final TMemory copy = getNewMemory(memory, args, named); final TValue result = context.executeLines(copy, body, TFunctionType.RETURN_FUNCTION, true); if (result == null) - throw EaterException.unlocated("No return directive found in your function", location); + throw EaterExceptionLocated.unlocated("No return directive found in your function", location); return result; } private TValue executeReturnLegacyDefine(LineLocation location, TContext context, TMemory memory, List args) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { if (legacyDefinition == null) throw new IllegalStateException(); diff --git a/src/net/sourceforge/plantuml/tim/TMemory.java b/src/net/sourceforge/plantuml/tim/TMemory.java index 466b5951b..cf89df812 100644 --- a/src/net/sourceforge/plantuml/tim/TMemory.java +++ b/src/net/sourceforge/plantuml/tim/TMemory.java @@ -45,7 +45,7 @@ public interface TMemory { public TValue getVariable(String varname); public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location) - throws EaterException; + throws EaterExceptionLocated; public void removeVariable(String varname); @@ -59,7 +59,7 @@ public interface TMemory { public ExecutionContextIf peekIf(); - public boolean areAllIfOk(TContext context, TMemory memory) throws EaterException; + public boolean areAllIfOk(TContext context, TMemory memory) throws EaterExceptionLocated; public void addIf(ExecutionContextIf context); diff --git a/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java b/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java index f5587df1b..f8d5aaec3 100644 --- a/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java +++ b/src/net/sourceforge/plantuml/tim/TMemoryGlobal.java @@ -73,10 +73,10 @@ public class TMemoryGlobal extends ExecutionContexts implements TMemory { @Override public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location) - throws EaterException { + throws EaterExceptionLocated { Log.info("[MemGlobal] Setting " + varname); if (scope == TVariableScope.LOCAL) - throw EaterException.unlocated("Cannot use local variable here", location); + throw EaterExceptionLocated.unlocated("Cannot use local variable here", location); this.globalVariables.put(varname, value); this.variables.add(varname); diff --git a/src/net/sourceforge/plantuml/tim/TMemoryLocal.java b/src/net/sourceforge/plantuml/tim/TMemoryLocal.java index 2603e1d0d..4271d6e36 100644 --- a/src/net/sourceforge/plantuml/tim/TMemoryLocal.java +++ b/src/net/sourceforge/plantuml/tim/TMemoryLocal.java @@ -79,7 +79,7 @@ public class TMemoryLocal extends ExecutionContexts implements TMemory { @Override public void putVariable(String varname, TValue value, TVariableScope scope, StringLocated location) - throws EaterException { + throws EaterExceptionLocated { if (scope == TVariableScope.GLOBAL) { memoryGlobal.putVariable(varname, value, scope, location); return; diff --git a/src/net/sourceforge/plantuml/tim/TimLoader.java b/src/net/sourceforge/plantuml/tim/TimLoader.java index 7d8bd5c93..09962e007 100644 --- a/src/net/sourceforge/plantuml/tim/TimLoader.java +++ b/src/net/sourceforge/plantuml/tim/TimLoader.java @@ -57,7 +57,7 @@ public class TimLoader { this.context = new TContext(importedFiles, defines, charset, definitionsContainer); try { defines.copyTo(global, location); - } catch (EaterException e) { + } catch (EaterExceptionLocated e) { Logme.error(e); } } diff --git a/src/net/sourceforge/plantuml/tim/VariableManager.java b/src/net/sourceforge/plantuml/tim/VariableManager.java index 1f9a66dc4..d8fc019ac 100644 --- a/src/net/sourceforge/plantuml/tim/VariableManager.java +++ b/src/net/sourceforge/plantuml/tim/VariableManager.java @@ -40,7 +40,6 @@ import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class VariableManager { @@ -54,7 +53,7 @@ public class VariableManager { this.location = location; } - public int replaceVariables(String str, int i, StringBuilder result) throws EaterException, EaterExceptionLocated { + public int replaceVariables(String str, int i, StringBuilder result) throws EaterExceptionLocated { final String presentVariable = getVarnameAt(str, i); if (result.toString().endsWith("##")) result.setLength(result.length() - 2); @@ -81,8 +80,7 @@ public class VariableManager { return i; } - private int replaceJson(JsonValue jsonValue, String str, int i, StringBuilder result) - throws EaterException, EaterExceptionLocated { + private int replaceJson(JsonValue jsonValue, String str, int i, StringBuilder result) throws EaterExceptionLocated { while (i < str.length()) { final char n = str.charAt(i); if (n == '.') { @@ -120,11 +118,11 @@ public class VariableManager { } else if (jsonValue instanceof JsonObject) { jsonValue = ((JsonObject) jsonValue).get(nbString); } else { - throw EaterException.unlocated("Major parsing error", location); + throw EaterExceptionLocated.unlocated("Major parsing error", location); } if (jsonValue == null) - throw EaterException.unlocated("Data parsing error", location); + throw EaterExceptionLocated.unlocated("Data parsing error", location); i++; } else { diff --git a/src/net/sourceforge/plantuml/tim/expression/Knowledge.java b/src/net/sourceforge/plantuml/tim/expression/Knowledge.java index 60723a615..b2fdb753d 100644 --- a/src/net/sourceforge/plantuml/tim/expression/Knowledge.java +++ b/src/net/sourceforge/plantuml/tim/expression/Knowledge.java @@ -34,14 +34,13 @@ */ package net.sourceforge.plantuml.tim.expression; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; public interface Knowledge { - public TValue getVariable(String name) throws EaterException, EaterExceptionLocated; + public TValue getVariable(String name) throws EaterExceptionLocated; public TFunction getFunction(TFunctionSignature signature); diff --git a/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java b/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java index 5ef785efd..67996cc69 100644 --- a/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java +++ b/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java @@ -41,7 +41,6 @@ import java.util.Deque; import java.util.List; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; @@ -54,7 +53,7 @@ public class ReversePolishInterpretor { private final boolean trace = false; public ReversePolishInterpretor(StringLocated location, TokenStack queue, Knowledge knowledge, TMemory memory, - TContext context) throws EaterException, EaterExceptionLocated { + TContext context) throws EaterExceptionLocated { final Deque stack = new ArrayDeque<>(); if (trace) @@ -73,45 +72,45 @@ public class ReversePolishInterpretor { final TValue v2 = stack.removeFirst(); final TValue v1 = stack.removeFirst(); final TokenOperator op = token.getTokenOperator(); - if (op == null) - throw EaterException.unlocated("bad op", location); - + if (op == null) + throw EaterExceptionLocated.unlocated("bad op", location); + final TValue tmp = op.operate(v1, v2); stack.addFirst(tmp); } else if (token.getTokenType() == TokenType.OPEN_PAREN_FUNC) { final int nb = Integer.parseInt(token.getSurface()); final Token token2 = it.nextToken(); - if (token2.getTokenType() != TokenType.FUNCTION_NAME) - throw EaterException.unlocated("rpn43", location); - + if (token2.getTokenType() != TokenType.FUNCTION_NAME) + throw EaterExceptionLocated.unlocated("rpn43", location); + if (trace) System.err.println("token2=" + token2); final TFunction function = knowledge.getFunction(new TFunctionSignature(token2.getSurface(), nb)); if (trace) System.err.println("function=" + function); - if (function == null) - throw EaterException.unlocated("Unknown built-in function " + token2.getSurface(), location); - - if (function.canCover(nb, Collections.emptySet()) == false) - throw EaterException.unlocated( + if (function == null) + throw EaterExceptionLocated.unlocated("Unknown built-in function " + token2.getSurface(), location); + + if (function.canCover(nb, Collections.emptySet()) == false) + throw EaterExceptionLocated.unlocated( "Bad number of arguments for " + function.getSignature().getFunctionName(), location); - + final List args = new ArrayList<>(); - for (int i = 0; i < nb; i++) + for (int i = 0; i < nb; i++) args.add(0, stack.removeFirst()); - + if (trace) System.err.println("args=" + args); - if (location == null) - throw EaterException.unlocated("rpn44", location); - + if (location == null) + throw EaterExceptionLocated.unlocated("rpn44", location); + final TValue r = function.executeReturnFunction(context, memory, location, args, Collections.emptyMap()); if (trace) System.err.println("r=" + r); stack.addFirst(r); } else { - throw EaterException.unlocated("rpn41", location); + throw EaterExceptionLocated.unlocated("rpn41", location); } } result = stack.removeFirst(); diff --git a/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java b/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java index 4b40aab8f..45ee8e008 100644 --- a/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java +++ b/src/net/sourceforge/plantuml/tim/expression/ShuntingYard.java @@ -38,7 +38,6 @@ import java.util.ArrayDeque; import java.util.Deque; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; // https://en.wikipedia.org/wiki/Shunting-yard_algorithm @@ -59,8 +58,7 @@ public class ShuntingYard { System.err.println(""); } - public ShuntingYard(TokenIterator it, Knowledge knowledge, StringLocated location) - throws EaterException, EaterExceptionLocated { + public ShuntingYard(TokenIterator it, Knowledge knowledge, StringLocated location) throws EaterExceptionLocated { while (it.hasMoreTokens()) { final Token token = it.nextToken(); @@ -76,7 +74,7 @@ public class ShuntingYard { final TValue variable = knowledge.getVariable(name); if (variable == null) { if (isVariableName(name) == false) - throw EaterException.unlocated("Parsing syntax error about " + name, location); + throw EaterExceptionLocated.unlocated("Parsing syntax error about " + name, location); ouputQueue.add(new Token(name, TokenType.QUOTED_STRING, null)); } else { diff --git a/src/net/sourceforge/plantuml/tim/expression/TokenStack.java b/src/net/sourceforge/plantuml/tim/expression/TokenStack.java index b25c96f6c..bed0e451d 100644 --- a/src/net/sourceforge/plantuml/tim/expression/TokenStack.java +++ b/src/net/sourceforge/plantuml/tim/expression/TokenStack.java @@ -44,7 +44,6 @@ import java.util.Map; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.Eater; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; @@ -87,7 +86,7 @@ public class TokenStack { return result; } - static public TokenStack eatUntilCloseParenthesisOrComma(Eater eater) throws EaterException { + static public TokenStack eatUntilCloseParenthesisOrComma(Eater eater) throws EaterExceptionLocated { final TokenStack result = new TokenStack(); int level = 0; Token lastToken = null; @@ -95,7 +94,7 @@ public class TokenStack { eater.skipSpaces(); final char ch = eater.peekChar(); if (ch == 0) - throw EaterException.unlocated("until001", eater.getStringLocated()); + throw EaterExceptionLocated.unlocated("until001", eater.getStringLocated()); if (level == 0 && (ch == ',' || ch == ')')) return result; @@ -113,12 +112,13 @@ public class TokenStack { } } - static public void eatUntilCloseParenthesisOrComma(TokenIterator it, StringLocated location) throws EaterException { + static public void eatUntilCloseParenthesisOrComma(TokenIterator it, StringLocated location) + throws EaterExceptionLocated { int level = 0; while (true) { final Token ch = it.peekToken(); if (ch == null) - throw EaterException.unlocated("until002", location); + throw EaterExceptionLocated.unlocated("until002", location); final TokenType typech = ch.getTokenType(); if (level == 0 && (typech == TokenType.COMMA || typech == TokenType.CLOSE_PAREN_MATH) @@ -135,7 +135,7 @@ public class TokenStack { } } - private int countFunctionArg(TokenIterator it, StringLocated location) throws EaterException { + private int countFunctionArg(TokenIterator it, StringLocated location) throws EaterExceptionLocated { // return 42; final TokenType type1 = it.peekToken().getTokenType(); if (type1 == TokenType.CLOSE_PAREN_MATH || type1 == TokenType.CLOSE_PAREN_FUNC) @@ -151,13 +151,13 @@ public class TokenStack { else if (type == TokenType.COMMA) result++; else - throw EaterException.unlocated("count13", location); + throw EaterExceptionLocated.unlocated("count13", location); } - throw EaterException.unlocated("count12", location); + throw EaterExceptionLocated.unlocated("count12", location); } - public void guessFunctions(StringLocated location) throws EaterException { + public void guessFunctions(StringLocated location) throws EaterExceptionLocated { final Deque open = new ArrayDeque<>(); final Map parens = new HashMap(); for (int i = 0; i < tokens.size(); i++) { @@ -210,8 +210,7 @@ public class TokenStack { return new InternalIterator(); } - public TValue getResult(StringLocated location, TContext context, TMemory memory) - throws EaterException, EaterExceptionLocated { + public TValue getResult(StringLocated location, TContext context, TMemory memory) throws EaterExceptionLocated { final Knowledge knowledge = context.asKnowledge(memory, location.getLocation()); final TokenStack tmp = withoutSpace(); tmp.guessFunctions(location); diff --git a/src/net/sourceforge/plantuml/tim/expression/TokenType.java b/src/net/sourceforge/plantuml/tim/expression/TokenType.java index a72a65bef..bdb7c445f 100644 --- a/src/net/sourceforge/plantuml/tim/expression/TokenType.java +++ b/src/net/sourceforge/plantuml/tim/expression/TokenType.java @@ -36,10 +36,10 @@ package net.sourceforge.plantuml.tim.expression; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.Eater; -import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; public enum TokenType { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ QUOTED_STRING, JSON_DATA, OPERATOR, OPEN_PAREN_MATH, COMMA, CLOSE_PAREN_MATH, NUMBER, PLAIN_TEXT, SPACES, FUNCTION_NAME, OPEN_PAREN_FUNC, CLOSE_PAREN_FUNC; @@ -77,7 +77,8 @@ public enum TokenType { return result; } - final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon) throws EaterException { + final static public Token eatOneToken(Token lastToken, Eater eater, boolean manageColon) + throws EaterExceptionLocated { char ch = eater.peekChar(); if (ch == 0) return null; @@ -121,7 +122,7 @@ public enum TokenType { return true; } - static private String eatAndGetTokenPlainText(Eater eater) throws EaterException { + static private String eatAndGetTokenPlainText(Eater eater) throws EaterExceptionLocated { final StringBuilder result = new StringBuilder(); while (true) { final char ch = eater.peekChar(); diff --git a/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java b/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java index a4e9a62aa..e01a9707c 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java +++ b/src/net/sourceforge/plantuml/tim/iterator/AbstractCodeIterator.java @@ -35,7 +35,6 @@ package net.sourceforge.plantuml.tim.iterator; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; public abstract class AbstractCodeIterator implements CodeIterator { @@ -47,7 +46,7 @@ public abstract class AbstractCodeIterator implements CodeIterator { } @Override - public void next() throws EaterException, EaterExceptionLocated { + public void next() throws EaterExceptionLocated { source.next(); } @@ -57,7 +56,8 @@ public abstract class AbstractCodeIterator implements CodeIterator { } @Override - final public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException { + final public void jumpToCodePosition(CodePosition newPosition, StringLocated location) + throws EaterExceptionLocated { source.jumpToCodePosition(newPosition, location); } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java index 48698ab5c..f6c613a00 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIterator.java @@ -35,18 +35,17 @@ package net.sourceforge.plantuml.tim.iterator; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; public interface CodeIterator { // ::remove folder when __HAXE__ - public StringLocated peek() throws EaterException, EaterExceptionLocated; + public StringLocated peek() throws EaterExceptionLocated; - public void next() throws EaterException, EaterExceptionLocated; + public void next() throws EaterExceptionLocated; public CodePosition getCodePosition(); - public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException; + public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterExceptionLocated; } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java index 0d380a436..bb341c11e 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorAffectation.java @@ -40,7 +40,6 @@ import net.sourceforge.plantuml.json.ParseException; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterAffectation; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TMemory; @@ -59,7 +58,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator { } @Override - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { final StringLocated result = source.peek(); if (result == null) { @@ -75,16 +74,16 @@ public class CodeIteratorAffectation extends AbstractCodeIterator { } } - private void doAffectation(StringLocated result) throws EaterException, EaterExceptionLocated { + private void doAffectation(StringLocated result) throws EaterExceptionLocated { int lastLocation = -1; for (int i = 0; i < 9999; i++) try { this.executeAffectation(context, memory, result); return; } catch (ParseException e) { - if (e.getColumn() <= lastLocation) - throw EaterException.located("Error in JSON format", result); - + if (e.getColumn() <= lastLocation) + throw EaterExceptionLocated.located("Error in JSON format", result); + lastLocation = e.getColumn(); next(); final StringLocated forward = source.peek(); @@ -93,7 +92,7 @@ public class CodeIteratorAffectation extends AbstractCodeIterator { } private void executeAffectation(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + throws EaterExceptionLocated { new EaterAffectation(s).analyze(context, memory); } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java index 87a783882..d6cb73027 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorForeach.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterForeach; import net.sourceforge.plantuml.tim.ExecutionContextForeach; @@ -61,7 +60,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { int level = 0; while (true) { final StringLocated result = source.peek(); @@ -91,7 +90,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator { } else if (result.getType() == TLineType.ENDFOREACH) { logs.add(result); if (foreach == null) - throw EaterException.located("No foreach related to this endforeach", result); + throw EaterExceptionLocated.located("No foreach related to this endforeach", result); foreach.inc(); if (foreach.isSkipMe()) { @@ -108,7 +107,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator { } } - private void executeForeach(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeForeach(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterForeach condition = new EaterForeach(s); condition.analyze(context, memory); final ExecutionContextForeach foreach = ExecutionContextForeach.fromValue(condition.getVarname(), @@ -122,7 +121,7 @@ public class CodeIteratorForeach extends AbstractCodeIterator { } private void setLoopVariable(TMemory memory, ExecutionContextForeach foreach, StringLocated position) - throws EaterException { + throws EaterExceptionLocated { final JsonValue first = foreach.getJsonArray().get(foreach.currentIndex()); memory.putVariable(foreach.getVarname(), TValue.fromJson(first), TVariableScope.GLOBAL, position); } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java index 43ae09658..f36954d28 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorIf.java @@ -39,7 +39,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; import net.sourceforge.plantuml.tim.EaterElseIf; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterIf; import net.sourceforge.plantuml.tim.EaterIfdef; @@ -61,7 +60,7 @@ public class CodeIteratorIf extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { final StringLocated result = source.peek(); if (result == null) { @@ -107,19 +106,17 @@ public class CodeIteratorIf extends AbstractCodeIterator { } } - private void executeIf(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + private void executeIf(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterIf condition = new EaterIf(s); condition.analyze(context, memory); final boolean isTrue = condition.isTrue(); memory.addIf(ExecutionContextIf.fromValue(isTrue)); } - private void executeElseIf(TContext context, TMemory memory, StringLocated s) - throws EaterException, EaterExceptionLocated { + private void executeElseIf(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated { final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf(); if (poll == null) - throw EaterException.located("No if related to this else", s); + throw EaterExceptionLocated.located("No if related to this else", s); poll.enteringElseIf(); if (poll.hasBeenBurn() == false) { @@ -132,32 +129,32 @@ public class CodeIteratorIf extends AbstractCodeIterator { } } - private void executeIfdef(TContext context, TMemory memory, StringLocated s) throws EaterException { + private void executeIfdef(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterIfdef condition = new EaterIfdef(s); condition.analyze(context, memory); final boolean isTrue = condition.isTrue(context, memory); memory.addIf(ExecutionContextIf.fromValue(isTrue)); } - private void executeIfndef(TContext context, TMemory memory, StringLocated s) throws EaterException { + private void executeIfndef(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterIfndef condition = new EaterIfndef(s); condition.analyze(context, memory); final boolean isTrue = condition.isTrue(context, memory); memory.addIf(ExecutionContextIf.fromValue(isTrue)); } - private void executeElse(TContext context, TMemory memory, StringLocated s) throws EaterException { + private void executeElse(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated { final ExecutionContextIf poll = (ExecutionContextIf) memory.peekIf(); if (poll == null) - throw EaterException.located("No if related to this else", s); + throw EaterExceptionLocated.located("No if related to this else", s); poll.nowInElse(); } - private void executeEndif(TContext context, TMemory memory, StringLocated s) throws EaterException { + private void executeEndif(TContext context, TMemory memory, StringLocated s) throws EaterExceptionLocated { final ExecutionContextIf poll = (ExecutionContextIf) memory.pollIf(); if (poll == null) - throw EaterException.located("No if related to this endif", s); + throw EaterExceptionLocated.located("No if related to this endif", s); } diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java index 985fcd398..c1bbd51a7 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorImpl.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.tim.iterator; import java.util.List; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorImpl implements CodeIterator { @@ -89,10 +89,10 @@ public class CodeIteratorImpl implements CodeIterator { } @Override - public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterException { + public void jumpToCodePosition(CodePosition newPosition, StringLocated location) throws EaterExceptionLocated { this.countJump++; if (this.countJump > 999) - throw EaterException.unlocated("Infinite loop?", location); + throw EaterExceptionLocated.unlocated("Infinite loop?", location); final Position pos = (Position) newPosition; this.current = pos.pos; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java index f7baab3e8..fe5a2d094 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorInnerComment.java @@ -35,7 +35,6 @@ package net.sourceforge.plantuml.tim.iterator; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorInnerComment extends AbstractCodeIterator { @@ -44,7 +43,7 @@ public class CodeIteratorInnerComment extends AbstractCodeIterator { super(source); } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { final StringLocated result = source.peek(); if (result == null) { return null; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java index 51670f20e..13709df73 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLegacyDefine.java @@ -38,7 +38,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.FunctionsSet; import net.sourceforge.plantuml.tim.TContext; @@ -61,7 +60,7 @@ public class CodeIteratorLegacyDefine extends AbstractCodeIterator { this.memory = memory; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java index 3f2cc2e0b..cc92cf384 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorLongComment.java @@ -38,7 +38,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorLongComment extends AbstractCodeIterator { @@ -50,7 +49,7 @@ public class CodeIteratorLongComment extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { if (source.peek() == null) { return null; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java index d03dfcc00..1b4be2503 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorProcedure.java @@ -38,7 +38,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.FunctionsSet; import net.sourceforge.plantuml.tim.TContext; @@ -62,7 +61,7 @@ public class CodeIteratorProcedure extends AbstractCodeIterator { this.memory = memory; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java index 8ff1feea5..791abad71 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorReturnFunction.java @@ -38,7 +38,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.FunctionsSet; import net.sourceforge.plantuml.tim.TContext; @@ -62,7 +61,7 @@ public class CodeIteratorReturnFunction extends AbstractCodeIterator { this.memory = memory; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java index b70c45584..f57bcab66 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorShortComment.java @@ -38,7 +38,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; public class CodeIteratorShortComment extends AbstractCodeIterator { @@ -50,7 +49,7 @@ public class CodeIteratorShortComment extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { while (true) { final StringLocated result = source.peek(); if (result == null) { diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java index 2c15a7b3e..1c28d1199 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorSub.java @@ -40,7 +40,6 @@ import java.util.Map; import net.sourceforge.plantuml.preproc.Sub; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterStartsub; import net.sourceforge.plantuml.tim.TContext; @@ -66,7 +65,7 @@ public class CodeIteratorSub extends AbstractCodeIterator { return Collections.unmodifiableMap(subs); } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { if (readingInProgress != null) return readingInProgress.peek(); @@ -83,7 +82,7 @@ public class CodeIteratorSub extends AbstractCodeIterator { StringLocated s = null; while ((s = source.peek()) != null) { if (s.getType() == TLineType.STARTSUB) { - throw EaterException.located("Cannot nest sub", result); + throw EaterExceptionLocated.located("Cannot nest sub", result); } else if (s.getType() == TLineType.ENDSUB) { source.next(); readingInProgress = new CodeIteratorImpl(created.lines()); @@ -101,7 +100,7 @@ public class CodeIteratorSub extends AbstractCodeIterator { } @Override - public void next() throws EaterException, EaterExceptionLocated { + public void next() throws EaterExceptionLocated { if (readingInProgress == null) { source.next(); return; diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java index 01b445898..db912021e 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java @@ -38,7 +38,6 @@ import java.util.List; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.text.TLineType; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.EaterWhile; import net.sourceforge.plantuml.tim.ExecutionContextWhile; @@ -60,7 +59,7 @@ public class CodeIteratorWhile extends AbstractCodeIterator { this.logs = logs; } - public StringLocated peek() throws EaterException, EaterExceptionLocated { + public StringLocated peek() throws EaterExceptionLocated { int level = 0; while (true) { final StringLocated result = source.peek(); @@ -90,7 +89,7 @@ public class CodeIteratorWhile extends AbstractCodeIterator { } else if (result.getType() == TLineType.ENDWHILE) { logs.add(result); if (currentWhile == null) - throw EaterException.located("No while related to this endwhile", result); + throw EaterExceptionLocated.located("No while related to this endwhile", result); final TValue value = currentWhile.conditionValue(result, context, memory); if (value.toBoolean()) @@ -106,7 +105,7 @@ public class CodeIteratorWhile extends AbstractCodeIterator { } } - private void executeWhile(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { + private void executeWhile(TMemory memory, StringLocated s) throws EaterExceptionLocated { final EaterWhile condition = new EaterWhile(s); condition.analyze(context, memory); final TokenStack whileExpression = condition.getWhileExpression(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java index 6d13ce01e..5991d486e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class AlwaysFalse extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { return TValue.fromBoolean(false); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java index e9a1362b6..d9cf561e0 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class AlwaysTrue extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { return TValue.fromBoolean(true); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java index 830f5bf25..6268cf54e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; @@ -60,13 +59,13 @@ public class CallUserFunction extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String fname = values.get(0).toString(); final List args = values.subList(1, values.size()); final TFunctionSignature signature = new TFunctionSignature(fname, args.size()); final TFunction func = context.getFunctionSmart(signature); if (func == null) - throw EaterException.unlocated("Cannot find void function " + fname, location); + throw EaterExceptionLocated.unlocated("Cannot find void function " + fname, location); return func.executeReturnFunction(context, memory, location, args, named); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java index aa7daa6cb..3dcbfc7d9 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Chr extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { try { final String value = String.valueOf(Character.toChars(values.get(0).toInt())); return TValue.fromString(value); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Darken.java b/src/net/sourceforge/plantuml/tim/stdlib/Darken.java index 1365c7614..bef84da7d 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Darken.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Darken.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -63,7 +62,7 @@ public class Darken extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String colorString = values.get(0).toString(); final int ratio = values.get(1).toInt(); try { @@ -71,7 +70,7 @@ public class Darken extends SimpleReturnFunction { color = color.darken(ratio); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color", location); + throw EaterExceptionLocated.located("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java index 0db1db510..1b77104eb 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java @@ -41,7 +41,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -61,7 +60,7 @@ public class DateFunction extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { if (values.size() == 0) return TValue.fromString(new Date().toString()); @@ -71,11 +70,11 @@ public class DateFunction extends SimpleReturnFunction { now = 1000L * values.get(1).toInt(); else now = System.currentTimeMillis(); - + try { return TValue.fromString(new SimpleDateFormat(format).format(now)); } catch (Exception e) { - throw EaterException.unlocated("Bad date pattern", location); + throw EaterExceptionLocated.unlocated("Bad date pattern", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java b/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java index 668f618da..b274f3a7c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Dec2hex extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { try { return TValue.fromString("" + Integer.toHexString(values.get(0).toInt())); } catch (Throwable t) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java b/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java index a3a0b4e9e..0eef6ddb9 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java @@ -40,7 +40,6 @@ import java.util.Set; import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -66,7 +65,7 @@ public class Dirpath extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { if (value == null) return TValue.fromString(""); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Eval.java b/src/net/sourceforge/plantuml/tim/stdlib/Eval.java index d08e45363..b08d6b263 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Eval.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Eval.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.StringEater; import net.sourceforge.plantuml.tim.TContext; @@ -60,7 +59,7 @@ public class Eval extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String exp = values.get(0).toString(); final StringEater eater = new StringEater(exp); final TValue value = eater.eatExpression(context, memory); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Feature.java b/src/net/sourceforge/plantuml/tim/stdlib/Feature.java index 042bfee0b..89ef049eb 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Feature.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Feature.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Feature extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String arg = values.get(0).toString(); if ("style".equalsIgnoreCase(arg)) return TValue.fromInt(1); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java b/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java index f43b345a1..bef8b2246 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java @@ -40,7 +40,6 @@ import java.util.Set; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class FileExists extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { // ::comment when __CORE__ final String path = values.get(0).toString(); return TValue.fromBoolean(new SFile(path).exists()); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Filename.java b/src/net/sourceforge/plantuml/tim/stdlib/Filename.java index fd6089946..812a0033e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Filename.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Filename.java @@ -40,7 +40,6 @@ import java.util.Set; import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -66,7 +65,7 @@ public class Filename extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { if (value == null) { return TValue.fromString(""); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java b/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java index f72dae133..1d72755cb 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class FunctionExists extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String name = values.get(0).toString(); return TValue.fromBoolean(context.doesFunctionExist(name)); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java b/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java index 2bc32f045..f03178410 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java @@ -45,7 +45,6 @@ import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -65,7 +64,7 @@ public class GetAllStdlib extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { switch (values.size()) { case 0: @@ -100,7 +99,7 @@ public class GetAllStdlib extends SimpleReturnFunction { default: assert false; // Should not append because of canCover() - throw EaterException.located("Error on get_all_stdlib: Too many arguments", location); + throw EaterExceptionLocated.located("Error on get_all_stdlib: Too many arguments", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java b/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java index f26379843..9404e09d9 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java @@ -43,7 +43,6 @@ import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.theme.ThemeUtils; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -63,7 +62,7 @@ public class GetAllTheme extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final JsonArray result = new JsonArray(); try { for (String theme : ThemeUtils.getAllThemeNames()) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java index 5b48e27c4..3067496d0 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -62,11 +61,11 @@ public class GetJsonKey extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final TValue data = values.get(0); if (data.isJson() == false) - throw EaterException.unlocated("Not JSON data", location); - + throw EaterExceptionLocated.unlocated("Not JSON data", location); + final JsonValue json = data.toJson(); if (json.isObject()) { final JsonObject object = (JsonObject) json; @@ -88,7 +87,7 @@ public class GetJsonKey extends SimpleReturnFunction { return TValue.fromJson(result); } - throw EaterException.unlocated("Bad JSON type", location); + throw EaterExceptionLocated.unlocated("Bad JSON type", location); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java index 17a2f164a..b27b68f90 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java @@ -40,7 +40,6 @@ import java.util.Set; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class GetJsonType extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final TValue data = values.get(0); if (data.isString()) return TValue.fromString("string"); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java b/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java index c950f7c7b..f7ffb4555 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class GetVariableValue extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String name = values.get(0).toString(); final TValue variable = memory.getVariable(name); if (variable == null) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java b/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java index 68e66ec23..b6d5e61c2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class GetVersion extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { return TValue.fromString(Version.versionString()); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java b/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java index 380448942..28a10472f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java @@ -40,7 +40,6 @@ import java.util.Set; import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class Getenv extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { // ::comment when __CORE__ final String value = getenv(values.get(0).toString()); if (value == null) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java index 0cc471567..f7c45b0ef 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Hex2dec extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { try { return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16)); } catch (Throwable t) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java index 2618bfbf6..34496e629 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java @@ -42,7 +42,6 @@ import java.util.Set; import net.sourceforge.plantuml.klimt.color.HColors; import net.sourceforge.plantuml.klimt.color.HSLColor; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -62,7 +61,7 @@ public class HslColor extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final int h = values.get(0).toInt(); final int s = values.get(1).toInt(); final int l = values.get(2).toInt(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java b/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java index b412cad9d..2b54cc99b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class IntVal extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String s = values.get(0).toString(); try { return TValue.fromInt(Integer.parseInt(s)); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java b/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java index 01e4f2036..6328e88f6 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; @@ -65,13 +64,13 @@ public class InvokeProcedure implements TFunction { @Override public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String fname = args.get(0).toString(); final List sublist = args.subList(1, args.size()); final TFunctionSignature signature = new TFunctionSignature(fname, sublist.size()); final TFunction func = context.getFunctionSmart(signature); if (func == null) - throw EaterException.located("Cannot find void function " + fname, location); + throw EaterExceptionLocated.located("Cannot find void function " + fname, location); func.executeProcedureInternal(context, memory, location, sublist, named); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java b/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java index f8fa6c394..f481264d2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -63,13 +62,13 @@ public class IsDark extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String colorString = values.get(0).toString(); try { final HColor color = HColorSet.instance().getColorLEGACY(colorString); return TValue.fromBoolean(color.isDark()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color", location); + throw EaterExceptionLocated.located("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java b/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java index 771425750..1528ea8fe 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -63,13 +62,13 @@ public class IsLight extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String colorString = values.get(0).toString(); try { final HColor color = HColorSet.instance().getColorLEGACY(colorString); return TValue.fromBoolean(!color.isDark()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color", location); + throw EaterExceptionLocated.located("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java b/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java index 71d6eaed8..bc22ce9a7 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java @@ -41,7 +41,6 @@ import java.util.Set; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -61,7 +60,7 @@ public class JsonKeyExists extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final TValue arg0 = values.get(0); if (arg0.isJson() == false) return TValue.fromBoolean(false); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java b/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java index 1ec5b593b..41d9a31d2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -63,7 +62,7 @@ public class Lighten extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String colorString = values.get(0).toString(); final int ratio = values.get(1).toInt(); try { @@ -71,7 +70,7 @@ public class Lighten extends SimpleReturnFunction { color = color.lighten(ratio); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color", location); + throw EaterExceptionLocated.located("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java b/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java index a03972239..40e5746c6 100755 --- a/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SURL; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -109,7 +108,7 @@ public class LoadJson extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String path = values.get(0).toString(); try { String data = loadStringData(path, getCharset(values)); @@ -120,11 +119,12 @@ public class LoadJson extends SimpleReturnFunction { return TValue.fromJson(jsonValue); } catch (ParseException pe) { Logme.error(pe); - throw EaterException.unlocated("JSON parse issue in source " + path + " on location " + pe.getLocation(), - location); + throw EaterExceptionLocated + .unlocated("JSON parse issue in source " + path + " on location " + pe.getLocation(), location); } catch (UnsupportedEncodingException e) { Logme.error(e); - throw EaterException.unlocated("JSON encoding issue in source " + path + ": " + e.getMessage(), location); + throw EaterExceptionLocated.unlocated("JSON encoding issue in source " + path + ": " + e.getMessage(), + location); } } @@ -163,7 +163,8 @@ public class LoadJson extends SimpleReturnFunction { * @return the decoded String from the data source * @throws EaterException if something went wrong on reading data */ - private String loadStringData(String path, String charset) throws EaterException, UnsupportedEncodingException { + private String loadStringData(String path, String charset) + throws EaterExceptionLocated, UnsupportedEncodingException { byte[] byteData = null; if (path.startsWith("http://") || path.startsWith("https://")) { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java index 3770e1b05..1bea47ee2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalAnd extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == false) return TValue.fromBoolean(false); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java index 7d655c92f..52345b792 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalNand extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == false) return TValue.fromBoolean(!false); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java index 12b003616..fe59542cf 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalNor extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == true) return TValue.fromBoolean(!true); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java index 7ffb3689e..0dbd650f5 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalNot extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final boolean arg = values.get(0).toBoolean(); return TValue.fromBoolean(!arg); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java index a5ed319e3..3abd60263 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalNxor extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { int cpt = 0; for (TValue v : values) if (v.toBoolean() == true) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java index e78dcc546..0d2e5ded2 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalOr extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == true) return TValue.fromBoolean(true); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java index da04addf5..9b9a66cbb 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class LogicalXor extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { int cpt = 0; for (TValue v : values) if (v.toBoolean() == true) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Now.java b/src/net/sourceforge/plantuml/tim/stdlib/Now.java index f827d6e9f..f24f75093 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Now.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Now.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Now extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final long now = System.currentTimeMillis() / 1000L; return TValue.fromInt((int) now); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Ord.java b/src/net/sourceforge/plantuml/tim/stdlib/Ord.java index 8ae31e5c4..1c509686a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Ord.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Ord.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Ord extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { try { final int codePoint = values.get(0).toString().codePointAt(0); return TValue.fromInt(codePoint); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java index d284045a6..f2c8c885f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java @@ -40,7 +40,6 @@ import java.util.Random; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -62,7 +61,7 @@ public class RandomFunction extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { switch (values.size()) { case 0: return TValue.fromInt(random.nextInt(2)); @@ -78,7 +77,7 @@ public class RandomFunction extends SimpleReturnFunction { default: assert false; // Should not append because of canCover() - throw EaterException.located("Error on Random: Too many argument", location); + throw EaterExceptionLocated.located("Error on Random: Too many argument", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java b/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java index 8c31c3520..5e5590ddf 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java @@ -40,7 +40,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; @@ -61,7 +60,7 @@ public class RetrieveProcedure extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String fname = values.get(0).toString(); final List args = values.subList(1, values.size()); final TFunctionSignature signature = new TFunctionSignature(fname, args.size()); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java index ef1d94ff3..e19fe4a30 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -62,14 +61,14 @@ public class ReverseColor extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String colorString = values.get(0).toString(); try { HColor color = HColorSet.instance().getColorLEGACY(colorString); color = color.reverse(); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color", location); + throw EaterExceptionLocated.located("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java index 041fe5cab..75a60e8ac 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.klimt.color.HColor; import net.sourceforge.plantuml.klimt.color.HColorSet; import net.sourceforge.plantuml.klimt.color.NoSuchColorException; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -62,14 +61,14 @@ public class ReverseHsluvColor extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String colorString = values.get(0).toString(); try { HColor color = HColorSet.instance().getColorLEGACY(colorString); color = color.reverseHsluv(); return TValue.fromString(color.asString()); } catch (NoSuchColorException e) { - throw EaterException.located("No such color", location); + throw EaterExceptionLocated.located("No such color", location); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java b/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java index 18123b644..fcc12260c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -60,7 +59,7 @@ public class SetVariableValue extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { // if (memory instanceof TMemoryLocal) { // memory = ((TMemoryLocal) memory).getGlobalForInternalUseOnly(); // } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java index c649a86a4..5276d495e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java @@ -38,7 +38,7 @@ import java.util.List; import java.util.Map; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionType; @@ -53,7 +53,7 @@ public abstract class SimpleReturnFunction implements TFunction { @Override final public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, - List args, Map named) throws EaterException { + List args, Map named) throws EaterExceptionLocated { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Size.java b/src/net/sourceforge/plantuml/tim/stdlib/Size.java index 0bf62d6d6..82a72c5ab 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Size.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Size.java @@ -42,7 +42,6 @@ import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.json.JsonObject; import net.sourceforge.plantuml.json.JsonValue; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -62,7 +61,7 @@ public class Size extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final TValue value = values.get(0); if (value.isNumber()) return TValue.fromInt(0); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java b/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java index 5e181ffca..f3e17784a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java @@ -41,7 +41,6 @@ import java.util.StringTokenizer; import net.sourceforge.plantuml.json.JsonArray; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -61,7 +60,7 @@ public class SplitStr extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final JsonArray result = new JsonArray(); final String str = values.get(0).toString(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java b/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java index 3aeb5b609..f97aad0de 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Strlen extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { return TValue.fromInt(values.get(0).toString().length()); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java b/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java index 8db94424f..b27796e0e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Strpos extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String full = values.get(0).toString(); final String searched = values.get(1).toString(); return TValue.fromInt(full.indexOf(searched)); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Substr.java b/src/net/sourceforge/plantuml/tim/stdlib/Substr.java index ec254565b..7f06da48f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Substr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Substr.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class Substr extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String full = values.get(0).toString(); final int pos = values.get(1).toInt(); if (pos >= full.length()) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java b/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java index 3f06d5e62..2e024b025 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java @@ -39,7 +39,6 @@ import java.util.Map; import java.util.Set; import net.sourceforge.plantuml.text.StringLocated; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; @@ -59,7 +58,7 @@ public class VariableExists extends SimpleReturnFunction { @Override public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, - Map named) throws EaterException, EaterExceptionLocated { + Map named) throws EaterExceptionLocated { final String name = values.get(0).toString(); return TValue.fromBoolean(memory.getVariable(name) != null); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 80dec5df6..fd32fba24 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -46,7 +46,7 @@ public class Version { // Warning, "version" should be the same in gradle.properties and Version.java // Any idea anyone how to magically synchronize those :-) ? - private static final String version = "1.2024.4beta3"; + private static final String version = "1.2024.4beta4"; public static String versionString() { return version; diff --git a/test/net/sourceforge/plantuml/tim/TimTestUtils.java b/test/net/sourceforge/plantuml/tim/TimTestUtils.java index 81993d3a2..724e227be 100644 --- a/test/net/sourceforge/plantuml/tim/TimTestUtils.java +++ b/test/net/sourceforge/plantuml/tim/TimTestUtils.java @@ -14,27 +14,27 @@ import net.sourceforge.plantuml.json.JsonValue; public class TimTestUtils { // Tfunc: () -> (String) - public static void assertTimExpectedOutput(TFunction func, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutput(TFunction func, String expected) throws EaterExceptionLocated { TValue tValue = func.executeReturnFunction(null, null, null, null, null); assertEquals(expected, tValue.toString()); } // Tfunc: (Integer) -> (String) - public static void assertTimExpectedOutputFromInput(TFunction func, Integer input, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutputFromInput(TFunction func, Integer input, String expected) throws EaterExceptionLocated { List values = Collections.singletonList(TValue.fromInt(input)); TValue tValue = func.executeReturnFunction(null, null, null, values, null); assertEquals(expected, tValue.toString()); } // Tfunc: (String) -> (String) - public static void assertTimExpectedOutputFromInput(TFunction func, String input, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutputFromInput(TFunction func, String input, String expected) throws EaterExceptionLocated { List values = Collections.singletonList(TValue.fromString(input)); TValue tValue = func.executeReturnFunction(null, null, null, values, null); assertEquals(expected, tValue.toString()); } // Tfunc: (JsonValue) -> (String) - public static void assertTimExpectedOutputFromInput(TFunction func, JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + public static void assertTimExpectedOutputFromInput(TFunction func, JsonValue input, String expected) throws EaterExceptionLocated { List values = Collections.singletonList(TValue.fromJson(input)); TValue tValue = func.executeReturnFunction(null, null, null, values, null); assertEquals(expected, tValue.toString()); diff --git a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java index addb2050c..595781c47 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysFalseTest.java @@ -6,11 +6,9 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; @@ -24,7 +22,7 @@ class AlwaysFalseTest { final String cutName = "AlwaysFalse"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "0"); } @@ -34,7 +32,7 @@ class AlwaysFalseTest { " 1 , 0 ", " 'a' , 0 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -44,7 +42,7 @@ class AlwaysFalseTest { " 1 , 0 ", " 123 , 0 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java index 439bde93d..cb9de4910 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java @@ -6,11 +6,9 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; @@ -24,7 +22,7 @@ class AlwaysTrueTest { final String cutName = "AlwaysTrue"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "1"); } @@ -34,7 +32,7 @@ class AlwaysTrueTest { " 1 , 1 ", " 'a' , 1 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -44,7 +42,7 @@ class AlwaysTrueTest { " 1 , 1 ", " 123 , 1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java index 6659ecd95..0294507fc 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; @@ -38,7 +37,7 @@ class ChrTest { " 128512 , 😀 ", " 128512 , \uD83D\uDE00 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java b/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java index 1134c293d..1603adbe6 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java @@ -6,11 +6,9 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; @@ -24,7 +22,7 @@ class Dec2hexTest { final String cutName = "Dec2hex"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, ""); } @@ -38,7 +36,7 @@ class Dec2hexTest { " 255 , 0 ", " 65535 , 0 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -52,7 +50,7 @@ class Dec2hexTest { " 255 , ff ", " 65535 , ffff ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java b/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java index 52507fb51..f8a8603aa 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java @@ -2,20 +2,19 @@ package net.sourceforge.plantuml.tim.stdlib; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; -import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -28,7 +27,7 @@ class FeatureTest { @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "0"); } @@ -43,7 +42,7 @@ class FeatureTest { " abc , 0", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -52,7 +51,7 @@ class FeatureTest { " 0, 0", " 10, 0", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -62,7 +61,7 @@ class FeatureTest { " \"theme\", 1", " 0, 0", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java index f274f52e7..16e3f8eed 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetAllStdlibTest.java @@ -2,14 +2,14 @@ package net.sourceforge.plantuml.tim.stdlib; import static org.assertj.core.api.Assertions.assertThat; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.expression.TValue; @@ -24,13 +24,14 @@ class GetAllStdlibTest { final String cutName = "GetAllStdlib"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { - final TValue tValue = cut.executeReturnFunction(null, null, null, Collections.emptyList(), null); + void Test_without_Param() throws EaterExceptionLocated { + final List empty = new ArrayList<>(); + final TValue tValue = cut.executeReturnFunction(null, null, null, empty, null); assertThat(tValue.toString()).contains("archimate", "aws", "tupadr3"); } @Test - void Test_with_one_argument() throws EaterException, EaterExceptionLocated { + void Test_with_one_argument() throws EaterExceptionLocated { final TValue tValue = cut.executeReturnFunction(null, null, null, Arrays.asList(TValue.fromInt(0)), null); assertThat(tValue.toString()).contains("archimate", "https://github.com/plantuml-stdlib/Archimate-PlantUML"); } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java index c17bc33d2..9201c2d99 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetAllThemeTest.java @@ -2,13 +2,13 @@ package net.sourceforge.plantuml.tim.stdlib; import static org.assertj.core.api.Assertions.assertThat; -import java.util.Collections; +import java.util.ArrayList; +import java.util.List; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.expression.TValue; @@ -23,8 +23,9 @@ class GetAllThemeTest { final String cutName = "GetAllTheme"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { - final TValue tValue = cut.executeReturnFunction(null, null, null, Collections.emptyList(), null); + void Test_without_Param() throws EaterExceptionLocated { + final List empty = new ArrayList<>(); + final TValue tValue = cut.executeReturnFunction(null, null, null, empty, null); assertThat(tValue.toString()).contains("_none_", "amiga", "vibrant"); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java index 80635e456..2f19ed62e 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java @@ -2,20 +2,19 @@ package net.sourceforge.plantuml.tim.stdlib; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; -import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -28,7 +27,7 @@ class GetJsonKeyTest { @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "0"); } @@ -39,7 +38,7 @@ class GetJsonKeyTest { " a, Not JSON data", " -1, Not JSON data", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -49,7 +48,7 @@ class GetJsonKeyTest { " 0, Not JSON data", " -1, Not JSON data", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -67,7 +66,7 @@ class GetJsonKeyTest { // - https://json-schema.org/understanding-json-schema/reference/array.html " '[3, \"different\", { \"types\" : \"of values\" }]', [\"types\"]", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java index 0fe35543c..80f5b90eb 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetJsonTypeTest.java @@ -2,20 +2,19 @@ package net.sourceforge.plantuml.tim.stdlib; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; -import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -28,7 +27,7 @@ class GetJsonTypeTest { @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "0"); } @@ -38,7 +37,7 @@ class GetJsonTypeTest { " a, string", " -1, string", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -47,7 +46,7 @@ class GetJsonTypeTest { " 0, number", " -1, number", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -67,7 +66,7 @@ class GetJsonTypeTest { " null , json ", " '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , object", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java b/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java index aea38a745..4bbfc443c 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/GetenvTest.java @@ -8,7 +8,6 @@ import java.util.List; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.expression.TValue; @@ -29,7 +28,7 @@ class GetenvTest { "plantuml.SECURITY.blabla", "plantuml.security.credentials.path", }) - void executeReturnFunctionSecurityTest(String name) throws EaterException, EaterExceptionLocated { + void executeReturnFunctionSecurityTest(String name) throws EaterExceptionLocated { System.setProperty("plantuml.security.blabla", "example"); Getenv cut = new Getenv(); @@ -49,7 +48,7 @@ class GetenvTest { "path.separator", "line.separator", }) - void executeReturnFunctionTest(String name) throws EaterException, EaterExceptionLocated { + void executeReturnFunctionTest(String name) throws EaterExceptionLocated { Getenv cut = new Getenv(); List values = Collections.singletonList(TValue.fromString(name)); diff --git a/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java b/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java index 329347b79..e11e52469 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java @@ -6,11 +6,9 @@ import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputF import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; @@ -24,7 +22,7 @@ class Hex2decTest { final String cutName = "Hex2dec"; @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "0"); } @@ -44,7 +42,7 @@ class Hex2decTest { " -1 , -1 ", " -a , -10 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -55,7 +53,7 @@ class Hex2decTest { " 10 , 16 ", " -1 , -1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java b/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java index 3b50a2d30..57910d42f 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java @@ -2,20 +2,19 @@ package net.sourceforge.plantuml.tim.stdlib; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; -import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -29,7 +28,7 @@ class LowerTest { // TODO: Manage Lower function without param. (today: we observe `Function not found %lower`) @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, ""); } @@ -44,7 +43,7 @@ class LowerTest { " É , é ", " 😀 , 😀 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -55,7 +54,7 @@ class LowerTest { " 10 , 10 ", " -1 , -1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -70,7 +69,7 @@ class LowerTest { // TODO: See JSON management of TRUE/FALSE //" TRUE , true ", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java b/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java index 4fd0411ab..9ae869b52 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/OrdTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; @@ -41,7 +40,7 @@ class OrdTest { " 😀 , 128512 ", " \uD83D\uDE00 , 128512 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java b/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java index c8505449e..226ddde52 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/RandomFuntionTest.java @@ -2,14 +2,14 @@ package net.sourceforge.plantuml.tim.stdlib; import static org.assertj.core.api.Assertions.assertThat; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.RepeatedTest; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.expression.TValue; @@ -25,26 +25,29 @@ class RandomFunctionTest { final String repetitionLabel = "[{currentRepetition}/{totalRepetitions}] "; @RepeatedTest(value = 10, name = repetitionLabel + cutName + "()") - void test_with_no_argument() throws EaterException, EaterExceptionLocated { - final TValue tValue = cut.executeReturnFunction(null, null, null, Collections.emptyList(), null); + void test_with_no_argument() throws EaterExceptionLocated { + final List empty = new ArrayList<>(); + final TValue tValue = cut.executeReturnFunction(null, null, null, empty, null); assertThat(tValue.toInt()).isIn(0, 1); } @RepeatedTest(value = 10, name = repetitionLabel + cutName + "(7)") - void test_with_one_argument() throws EaterException, EaterExceptionLocated { + void test_with_one_argument() throws EaterExceptionLocated { final TValue tValue = cut.executeReturnFunction(null, null, null, Arrays.asList(TValue.fromInt(7)), null); - assertThat(tValue.toInt()).isBetween(0, 7-1); + assertThat(tValue.toInt()).isBetween(0, 7 - 1); } @RepeatedTest(value = 10, name = repetitionLabel + cutName + "(0, 7)") - void test_with_two_argument_first_zero() throws EaterException, EaterExceptionLocated { - final TValue tValue = cut.executeReturnFunction(null, null, null, Arrays.asList(TValue.fromInt(0), TValue.fromInt(7)), null); - assertThat(tValue.toInt()).isBetween(0, 7-1); + void test_with_two_argument_first_zero() throws EaterExceptionLocated { + final TValue tValue = cut.executeReturnFunction(null, null, null, + Arrays.asList(TValue.fromInt(0), TValue.fromInt(7)), null); + assertThat(tValue.toInt()).isBetween(0, 7 - 1); } @RepeatedTest(value = 10, name = repetitionLabel + cutName + "(3, 7)") - void test_with_two_argument() throws EaterException, EaterExceptionLocated { - final TValue tValue = cut.executeReturnFunction(null, null, null, Arrays.asList(TValue.fromInt(3), TValue.fromInt(7)), null); - assertThat(tValue.toInt()).isBetween(3, 7-1); + void test_with_two_argument() throws EaterExceptionLocated { + final TValue tValue = cut.executeReturnFunction(null, null, null, + Arrays.asList(TValue.fromInt(3), TValue.fromInt(7)), null); + assertThat(tValue.toInt()).isBetween(3, 7 - 1); } } \ No newline at end of file diff --git a/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java b/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java index 6bcfd105e..a8c3c5218 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java @@ -2,20 +2,19 @@ package net.sourceforge.plantuml.tim.stdlib; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; -import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -29,7 +28,7 @@ class SizeTest { // TODO: Manage `Size` function without param. (today: we observe `Function not found`) @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, "0"); } @@ -48,7 +47,7 @@ class SizeTest { // " 😀 , 1 ", // " \uD83D\uDE00 , 1", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -58,7 +57,7 @@ class SizeTest { " 1 , 0 ", " 10 , 0 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -75,7 +74,7 @@ class SizeTest { " 1, 0 ", " null, 0 ", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java b/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java index 35c1e2e87..8a78cbb96 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java @@ -2,20 +2,19 @@ package net.sourceforge.plantuml.tim.stdlib; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput; import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput; -import static test.utils.JunitUtils.StringJsonConverter; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.IndicativeSentencesGeneration; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.converter.ConvertWith; import org.junit.jupiter.params.provider.CsvSource; import net.sourceforge.plantuml.json.JsonValue; -import net.sourceforge.plantuml.tim.EaterException; import net.sourceforge.plantuml.tim.EaterExceptionLocated; import net.sourceforge.plantuml.tim.TFunction; +import test.utils.JunitUtils.StringJsonConverter; /** * Tests the builtin function. @@ -29,7 +28,7 @@ class UpperTest { // TODO: Manage Upper function without param. (today: we observe `Function not found %upper`) @Disabled @Test - void Test_without_Param() throws EaterException, EaterExceptionLocated { + void Test_without_Param() throws EaterExceptionLocated { assertTimExpectedOutput(cut, ""); } @@ -44,7 +43,7 @@ class UpperTest { " é , É ", " 😀 , 😀 ", }) - void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_String(String input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -55,7 +54,7 @@ class UpperTest { " 10 , 10 ", " -1 , -1 ", }) - void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Integer(Integer input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } @@ -66,7 +65,7 @@ class UpperTest { " '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '{\"A\":[1,2],\"B\":\"ABC\",\"B\":TRUE}'", " true , TRUE ", }) - void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated { + void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterExceptionLocated { assertTimExpectedOutputFromInput(cut, input, expected); } }