From 436fb37f1a37b52190880c837fa30972f3734d6b Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Thu, 22 Feb 2024 18:33:29 +0100 Subject: [PATCH] refactor: prepare preprocessor error improvement (in progress) https://github.com/plantuml/plantuml/pull/1668 --- gradle.properties | 2 +- .../plantuml/text/StringLocated.java | 4 ++ src/net/sourceforge/plantuml/tim/Eater.java | 60 +++++++++--------- .../plantuml/tim/EaterAffectation.java | 3 +- .../plantuml/tim/EaterAffectationDefine.java | 2 +- .../plantuml/tim/EaterFunctionCall.java | 13 ++-- .../sourceforge/plantuml/tim/EaterImport.java | 9 +-- .../plantuml/tim/EaterInclude.java | 3 +- .../plantuml/tim/EaterIncludeDef.java | 3 +- .../plantuml/tim/EaterIncludesub.java | 3 +- .../sourceforge/plantuml/tim/EaterLog.java | 3 +- .../sourceforge/plantuml/tim/EaterTheme.java | 4 +- .../plantuml/tim/ExecutionContextWhile.java | 3 +- .../sourceforge/plantuml/tim/StringEater.java | 4 +- .../sourceforge/plantuml/tim/TContext.java | 40 ++++++------ .../sourceforge/plantuml/tim/TFunction.java | 8 +-- .../plantuml/tim/TFunctionImpl.java | 12 ++-- .../plantuml/tim/VariableManager.java | 6 +- .../expression/ReversePolishInterpretor.java | 3 +- .../plantuml/tim/expression/TokenStack.java | 5 +- .../tim/iterator/CodeIteratorWhile.java | 12 ++-- .../plantuml/tim/package-info.java | 6 +- .../plantuml/tim/stdlib/AlwaysFalse.java | 6 +- .../plantuml/tim/stdlib/AlwaysTrue.java | 4 +- .../plantuml/tim/stdlib/CallUserFunction.java | 4 +- .../sourceforge/plantuml/tim/stdlib/Chr.java | 4 +- .../plantuml/tim/stdlib/Darken.java | 4 +- .../plantuml/tim/stdlib/DateFunction.java | 4 +- .../plantuml/tim/stdlib/Dec2hex.java | 4 +- .../plantuml/tim/stdlib/Dirpath.java | 8 +-- .../sourceforge/plantuml/tim/stdlib/Eval.java | 4 +- .../plantuml/tim/stdlib/Feature.java | 12 ++-- .../plantuml/tim/stdlib/FileExists.java | 4 +- .../plantuml/tim/stdlib/Filename.java | 4 +- .../plantuml/tim/stdlib/FunctionExists.java | 6 +- .../plantuml/tim/stdlib/GetAllStdlib.java | 62 +++++++++---------- .../plantuml/tim/stdlib/GetAllTheme.java | 6 +- .../plantuml/tim/stdlib/GetJsonKey.java | 4 +- .../plantuml/tim/stdlib/GetJsonType.java | 4 +- .../plantuml/tim/stdlib/GetVariableValue.java | 8 +-- .../plantuml/tim/stdlib/GetVersion.java | 4 +- .../plantuml/tim/stdlib/Getenv.java | 6 +- .../plantuml/tim/stdlib/Hex2dec.java | 4 +- .../plantuml/tim/stdlib/HslColor.java | 4 +- .../plantuml/tim/stdlib/IntVal.java | 4 +- .../plantuml/tim/stdlib/InvokeProcedure.java | 14 ++--- .../plantuml/tim/stdlib/IsDark.java | 4 +- .../plantuml/tim/stdlib/IsLight.java | 4 +- .../plantuml/tim/stdlib/JsonKeyExists.java | 4 +- .../plantuml/tim/stdlib/Lighten.java | 4 +- .../plantuml/tim/stdlib/LoadJson.java | 4 +- .../plantuml/tim/stdlib/LogicalAnd.java | 4 +- .../plantuml/tim/stdlib/LogicalNand.java | 4 +- .../plantuml/tim/stdlib/LogicalNor.java | 4 +- .../plantuml/tim/stdlib/LogicalNot.java | 4 +- .../plantuml/tim/stdlib/LogicalNxor.java | 4 +- .../plantuml/tim/stdlib/LogicalOr.java | 4 +- .../plantuml/tim/stdlib/LogicalXor.java | 4 +- .../plantuml/tim/stdlib/Lower.java | 4 +- .../plantuml/tim/stdlib/Newline.java | 4 +- .../sourceforge/plantuml/tim/stdlib/Now.java | 4 +- .../sourceforge/plantuml/tim/stdlib/Ord.java | 4 +- .../plantuml/tim/stdlib/RandomFunction.java | 28 ++++----- .../tim/stdlib/RetrieveProcedure.java | 6 +- .../plantuml/tim/stdlib/ReverseColor.java | 4 +- .../tim/stdlib/ReverseHsluvColor.java | 4 +- .../plantuml/tim/stdlib/SetVariableValue.java | 4 +- .../tim/stdlib/SimpleReturnFunction.java | 6 +- .../sourceforge/plantuml/tim/stdlib/Size.java | 4 +- .../plantuml/tim/stdlib/SplitStr.java | 4 +- .../plantuml/tim/stdlib/StringFunction.java | 4 +- .../plantuml/tim/stdlib/Strlen.java | 4 +- .../plantuml/tim/stdlib/Strpos.java | 4 +- .../plantuml/tim/stdlib/Substr.java | 4 +- .../plantuml/tim/stdlib/Upper.java | 4 +- .../plantuml/tim/stdlib/VariableExists.java | 4 +- .../sourceforge/plantuml/version/Version.java | 2 +- 77 files changed, 281 insertions(+), 265 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6f86d3d81..4336095e9 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.4beta1 +version = 1.2024.4beta2 org.gradle.workers.max = 3 \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/text/StringLocated.java b/src/net/sourceforge/plantuml/text/StringLocated.java index ed15e2f11..bc99b864a 100644 --- a/src/net/sourceforge/plantuml/text/StringLocated.java +++ b/src/net/sourceforge/plantuml/text/StringLocated.java @@ -158,4 +158,8 @@ final public class StringLocated { return s.length(); } + public char charAt(int i) { + return s.charAt(i); + } + } diff --git a/src/net/sourceforge/plantuml/tim/Eater.java b/src/net/sourceforge/plantuml/tim/Eater.java index c23fbf085..193a62c5f 100644 --- a/src/net/sourceforge/plantuml/tim/Eater.java +++ b/src/net/sourceforge/plantuml/tim/Eater.java @@ -50,20 +50,18 @@ import net.sourceforge.plantuml.utils.LineLocation; public abstract class Eater { private int i = 0; - private final String s; - private final LineLocation lineLocation; + private final StringLocated stringLocated; - public Eater(StringLocated sl) { - this(sl.getString(), sl.getLocation()); - } - - protected Eater(String s, LineLocation lineLocation) { - this.s = s; - this.lineLocation = lineLocation; + public Eater(StringLocated stringLocated) { + this.stringLocated = stringLocated; } public final LineLocation getLineLocation() { - return lineLocation; + return stringLocated.getLocation(); + } + + public final StringLocated getStringLocated() { + return stringLocated; } public abstract void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated; @@ -73,8 +71,8 @@ public abstract class Eater { } final protected String eatAllToEnd() throws EaterException { - final String result = s.substring(i); - i = s.length(); + final String result = stringLocated.getString().substring(i); + i = stringLocated.length(); return result; } @@ -88,7 +86,7 @@ public abstract class Eater { return TValue.fromJson(json); } final TokenStack tokenStack = eatTokenStack(); - return tokenStack.getResult(getLineLocation(), context, memory); + return tokenStack.getResult(getStringLocated(), context, memory); } final protected TokenStack eatTokenStack() throws EaterException { @@ -104,7 +102,7 @@ public abstract class Eater { throws EaterException, EaterExceptionLocated { final TokenStack tokenStack = new TokenStack(); addIntoTokenStack(tokenStack, true); - return tokenStack.getResult(getLineLocation(), context, memory); + return tokenStack.getResult(getStringLocated(), context, memory); } final protected void addIntoTokenStack(TokenStack tokenStack, boolean stopAtColon) throws EaterException { @@ -208,56 +206,56 @@ public abstract class Eater { } final public void skipSpaces() { - while (i < s.length() && Character.isWhitespace(s.charAt(i))) + while (i < stringLocated.length() && Character.isWhitespace(stringLocated.charAt(i))) i++; } final protected void skipUntilChar(char ch) { - while (i < s.length() && s.charAt(i) != ch) + while (i < stringLocated.length() && stringLocated.charAt(i) != ch) i++; } final public char peekChar() { - if (i >= s.length()) + if (i >= stringLocated.length()) return 0; - return s.charAt(i); + return stringLocated.charAt(i); } final public boolean matchAffectation() { - final String tmp = s.substring(i); + final String tmp = stringLocated.getString().substring(i); final boolean result = tmp.matches("^\\$?[_\\p{L}][_\\p{L}0-9]*\\s*=.*"); return result; } final public char peekCharN2() { - if (i + 1 >= s.length()) + if (i + 1 >= stringLocated.length()) return 0; - return s.charAt(i + 1); + return stringLocated.charAt(i + 1); } final protected boolean hasNextChar() { - return i < s.length(); + return i < stringLocated.length(); } final public char eatOneChar() { - final char ch = s.charAt(i); + final char ch = stringLocated.charAt(i); i++; return ch; } final protected void checkAndEatChar(char ch) throws EaterException { - if (i >= s.length() || s.charAt(i) != ch) + if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) throw EaterException.located("a001"); i++; } final protected boolean safeCheckAndEatChar(char ch) throws EaterException { - if (i >= s.length() || s.charAt(i) != ch) + if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) return false; i++; @@ -265,10 +263,10 @@ public abstract class Eater { } final protected void optionallyEatChar(char ch) throws EaterException { - if (i >= s.length() || s.charAt(i) != ch) + if (i >= stringLocated.length() || stringLocated.charAt(i) != ch) return; - assert s.charAt(i) == ch; + assert stringLocated.charAt(i) == ch; i++; } @@ -279,8 +277,8 @@ public abstract class Eater { } final protected void addUpToLastLetterOrUnderscoreOrDigit(StringBuilder sb) { - while (i < s.length()) { - final char ch = s.charAt(i); + while (i < stringLocated.length()) { + final char ch = stringLocated.charAt(i); if (TLineType.isLetterOrUnderscoreOrDigit(ch) == false) return; @@ -290,7 +288,7 @@ public abstract class Eater { } final protected void addUpTo(char separator, StringBuilder sb) { - while (i < s.length()) { + while (i < stringLocated.length()) { final char ch = peekChar(); if (ch == separator) return; @@ -323,7 +321,7 @@ public abstract class Eater { eatOneChar(); final TokenStack def = TokenStack.eatUntilCloseParenthesisOrComma(this); def.guessFunctions(); - defValue = def.getResult(getLineLocation(), context, memory); + defValue = def.getResult(getStringLocated(), context, memory); // System.err.println("result=" + defValue); } else { defValue = null; diff --git a/src/net/sourceforge/plantuml/tim/EaterAffectation.java b/src/net/sourceforge/plantuml/tim/EaterAffectation.java index 1c7297580..99d25e20f 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAffectation.java +++ b/src/net/sourceforge/plantuml/tim/EaterAffectation.java @@ -53,7 +53,8 @@ public class EaterAffectation extends Eater { if (scope != null) { skipSpaces(); if (peekChar() == '?' || peekChar() == '=') { - // The variable itself is "local" or "glocal", which is not a good idea by the way + // The variable itself is "local" or "glocal", which is not a good idea by the + // way scope = null; } else varname = eatAndGetVarname(); diff --git a/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java b/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java index d5a4fb950..c6cb3fbd2 100644 --- a/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java +++ b/src/net/sourceforge/plantuml/tim/EaterAffectationDefine.java @@ -51,7 +51,7 @@ public class EaterAffectationDefine extends Eater { final String varname = eatAndGetVarname(); skipSpaces(); final String tmp = eatAllToEnd(); - final String tmp2 = context.applyFunctionsAndVariables(memory, getLineLocation(), tmp); + final String tmp2 = context.applyFunctionsAndVariables(memory, new StringLocated(tmp, getLineLocation())); final TValue value = TValue.fromString(tmp2); // if (memory instanceof TMemoryLocal) { // memory = ((TMemoryLocal) memory).getGlobalForInternalUseOnly(); diff --git a/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java b/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java index 22c233868..1c116eab0 100644 --- a/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java +++ b/src/net/sourceforge/plantuml/tim/EaterFunctionCall.java @@ -70,7 +70,8 @@ public class EaterFunctionCall extends Eater { skipSpaces(); if (isLegacyDefine) { final String read = eatAndGetOptionalQuotedString(); - final String value = context.applyFunctionsAndVariables(memory, getLineLocation(), read); + final String value = context.applyFunctionsAndVariables(memory, + new StringLocated(read, getLineLocation())); final TValue result = TValue.fromString(value); values.add(result); } else if (unquoted) { @@ -80,12 +81,14 @@ public class EaterFunctionCall extends Eater { checkAndEatChar('='); skipSpaces(); final String read = eatAndGetOptionalQuotedString(); - final String value = context.applyFunctionsAndVariables(memory, getLineLocation(), read); + final String value = context.applyFunctionsAndVariables(memory, + new StringLocated(read, getLineLocation())); final TValue result = TValue.fromString(value); namedArguments.put(varname, result); } else { final String read = eatAndGetOptionalQuotedString(); - final String value = context.applyFunctionsAndVariables(memory, getLineLocation(), read); + final String value = context.applyFunctionsAndVariables(memory, + new StringLocated(read, getLineLocation())); final TValue result = TValue.fromString(value); values.add(result); } @@ -98,12 +101,12 @@ public class EaterFunctionCall extends Eater { skipSpaces(); final TokenStack tokens = TokenStack.eatUntilCloseParenthesisOrComma(this).withoutSpace(); tokens.guessFunctions(); - final TValue result = tokens.getResult(getLineLocation(), context, memory); + final TValue result = tokens.getResult(getStringLocated(), context, memory); namedArguments.put(varname, result); } else { final TokenStack tokens = TokenStack.eatUntilCloseParenthesisOrComma(this).withoutSpace(); tokens.guessFunctions(); - final TValue result = tokens.getResult(getLineLocation(), context, memory); + final TValue result = tokens.getResult(getStringLocated(), context, memory); values.add(result); } } diff --git a/src/net/sourceforge/plantuml/tim/EaterImport.java b/src/net/sourceforge/plantuml/tim/EaterImport.java index b17727d17..6784a01f2 100644 --- a/src/net/sourceforge/plantuml/tim/EaterImport.java +++ b/src/net/sourceforge/plantuml/tim/EaterImport.java @@ -38,7 +38,7 @@ import net.sourceforge.plantuml.text.StringLocated; public class EaterImport extends Eater { - private String location; + private String what; public EaterImport(StringLocated s) { super(s); @@ -49,12 +49,13 @@ public class EaterImport extends Eater { skipSpaces(); checkAndEatChar("!import"); skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.what = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); } - public final String getLocation() { - return location; + public final String getWhat() { + return what; } } diff --git a/src/net/sourceforge/plantuml/tim/EaterInclude.java b/src/net/sourceforge/plantuml/tim/EaterInclude.java index c41bd9f88..dd16097f9 100644 --- a/src/net/sourceforge/plantuml/tim/EaterInclude.java +++ b/src/net/sourceforge/plantuml/tim/EaterInclude.java @@ -65,7 +65,8 @@ public class EaterInclude extends Eater { } } skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.location = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); // final TValue value = eatExpression(context, memory); // this.location = value.toString(); diff --git a/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java b/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java index 1cb813363..f0ffecce5 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java +++ b/src/net/sourceforge/plantuml/tim/EaterIncludeDef.java @@ -49,7 +49,8 @@ public class EaterIncludeDef extends Eater { skipSpaces(); checkAndEatChar("!includedef"); skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.location = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); } diff --git a/src/net/sourceforge/plantuml/tim/EaterIncludesub.java b/src/net/sourceforge/plantuml/tim/EaterIncludesub.java index 355b11605..cfd9da7dc 100644 --- a/src/net/sourceforge/plantuml/tim/EaterIncludesub.java +++ b/src/net/sourceforge/plantuml/tim/EaterIncludesub.java @@ -49,7 +49,8 @@ public class EaterIncludesub extends Eater { skipSpaces(); checkAndEatChar("!includesub"); skipSpaces(); - this.location = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + this.location = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); } diff --git a/src/net/sourceforge/plantuml/tim/EaterLog.java b/src/net/sourceforge/plantuml/tim/EaterLog.java index 4a0bc62df..805a64306 100644 --- a/src/net/sourceforge/plantuml/tim/EaterLog.java +++ b/src/net/sourceforge/plantuml/tim/EaterLog.java @@ -48,7 +48,8 @@ public class EaterLog extends Eater { skipSpaces(); checkAndEatChar("!log"); skipSpaces(); - final String logData = context.applyFunctionsAndVariables(memory, getLineLocation(), this.eatAllToEnd()); + final String logData = context.applyFunctionsAndVariables(memory, + new StringLocated(this.eatAllToEnd(), getLineLocation())); Log.error("[Log] " + logData); } diff --git a/src/net/sourceforge/plantuml/tim/EaterTheme.java b/src/net/sourceforge/plantuml/tim/EaterTheme.java index 35dfc4938..09e292785 100644 --- a/src/net/sourceforge/plantuml/tim/EaterTheme.java +++ b/src/net/sourceforge/plantuml/tim/EaterTheme.java @@ -76,12 +76,12 @@ public class EaterTheme extends Eater { final int x = this.name.toLowerCase().indexOf(" from "); if (x != -1) { final String fromTmp = this.name.substring(x + " from ".length()).trim(); - this.from = context.applyFunctionsAndVariables(memory, getLineLocation(), fromTmp); + this.from = context.applyFunctionsAndVariables(memory, new StringLocated(fromTmp, getLineLocation())); this.name = this.name.substring(0, x).trim(); this.context = context; } - this.realName = context.applyFunctionsAndVariables(memory, getLineLocation(), this.name); + this.realName = context.applyFunctionsAndVariables(memory, new StringLocated(this.name, getLineLocation())); } diff --git a/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java b/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java index 424a3d845..cc65cc222 100644 --- a/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java +++ b/src/net/sourceforge/plantuml/tim/ExecutionContextWhile.java @@ -34,6 +34,7 @@ */ package net.sourceforge.plantuml.tim; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; import net.sourceforge.plantuml.tim.expression.TokenStack; import net.sourceforge.plantuml.tim.iterator.CodePosition; @@ -59,7 +60,7 @@ public class ExecutionContextWhile { return new ExecutionContextWhile(whileExpression, codePosition); } - public TValue conditionValue(LineLocation location, TContext context, TMemory memory) + public TValue conditionValue(StringLocated location, TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { return whileExpression.getResult(location, context, memory); } diff --git a/src/net/sourceforge/plantuml/tim/StringEater.java b/src/net/sourceforge/plantuml/tim/StringEater.java index 6e6a1489a..85ca881c9 100644 --- a/src/net/sourceforge/plantuml/tim/StringEater.java +++ b/src/net/sourceforge/plantuml/tim/StringEater.java @@ -34,10 +34,12 @@ */ package net.sourceforge.plantuml.tim; +import net.sourceforge.plantuml.text.StringLocated; + public class StringEater extends Eater { public StringEater(String s) { - super(s, null); + super(new StringLocated(s, null)); } @Override diff --git a/src/net/sourceforge/plantuml/tim/TContext.java b/src/net/sourceforge/plantuml/tim/TContext.java index f37dd7819..6a79011f4 100644 --- a/src/net/sourceforge/plantuml/tim/TContext.java +++ b/src/net/sourceforge/plantuml/tim/TContext.java @@ -252,7 +252,7 @@ public class TContext { private TValue fromJson(TMemory memory, String name, LineLocation location) throws EaterException, EaterExceptionLocated { - final String result = applyFunctionsAndVariables(memory, location, name); + final String result = applyFunctionsAndVariables(memory, new StringLocated(name, location)); try { final JsonValue json = Json.parse(result); return TValue.fromJson(json); @@ -428,7 +428,7 @@ public class TContext { if (memory.isEmpty() && functionsSet.size() == 0) return new StringLocated[] { located }; - final String result = applyFunctionsAndVariables(memory, located.getLocation(), located.getString()); + final String result = applyFunctionsAndVariables(memory, located); if (result == null) return null; @@ -442,7 +442,7 @@ public class TContext { private String pendingAdd = null; - public String applyFunctionsAndVariables(TMemory memory, LineLocation location, final String str) + public String applyFunctionsAndVariables(TMemory memory, final StringLocated str) throws EaterException, 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 @@ -450,15 +450,15 @@ public class TContext { // https://www.quora.com/What-is-the-most-efficient-algorithm-to-replace-all-occurrences-of-a-pattern-P-in-a-string-with-a-pattern-P // https://en.wikipedia.org/wiki/Trie if (memory.isEmpty() && functionsSet.size() == 0) - return str; + return str.getString(); final StringBuilder result = new StringBuilder(); for (int i = 0; i < str.length(); i++) { final char c = str.charAt(i); - final String presentFunction = getFunctionNameAt(str, i); + final String presentFunction = getFunctionNameAt(str.getString(), i); if (presentFunction != null) { - final String sub = str.substring(i); - final EaterFunctionCall call = new EaterFunctionCall(new StringLocated(sub, location), + final String sub = str.getString().substring(i); + final EaterFunctionCall call = new EaterFunctionCall(new StringLocated(sub, str.getLocation()), isLegacyDefine(presentFunction), isUnquoted(presentFunction)); call.analyze(this, memory); final TFunctionSignature signature = new TFunctionSignature(presentFunction, call.getValues().size(), @@ -469,27 +469,27 @@ public class TContext { if (function.getFunctionType() == TFunctionType.PROCEDURE) { this.pendingAdd = result.toString(); - executeVoid3(location, memory, sub, function, call); + executeVoid3(str, memory, function, call); i += call.getCurrentPosition(); - final String remaining = str.substring(i); + final String remaining = str.getString().substring(i); if (remaining.length() > 0) appendToLastResult(remaining); return null; } if (function.getFunctionType() == TFunctionType.LEGACY_DEFINELONG) { - this.pendingAdd = str.substring(0, i); - executeVoid3(location, memory, sub, function, call); + this.pendingAdd = str.getString().substring(0, i); + executeVoid3(str, memory, function, call); return null; } assert function.getFunctionType() == TFunctionType.RETURN_FUNCTION || function.getFunctionType() == TFunctionType.LEGACY_DEFINE; - final TValue functionReturn = function.executeReturnFunction(this, memory, location, call.getValues(), + final TValue functionReturn = function.executeReturnFunction(this, memory, str, call.getValues(), call.getNamedArguments()); result.append(functionReturn.toString()); i += call.getCurrentPosition() - 1; - } else if (new VariableManager(this, memory, location).getVarnameAt(str, i) != null) { - i = new VariableManager(this, memory, location).replaceVariables(str, i, result); + } else if (new VariableManager(this, memory, str.getLocation()).getVarnameAt(str.getString(), i) != null) { + i = new VariableManager(this, memory, str.getLocation()).replaceVariables(str.getString(), i, result); } else { result.append(c); } @@ -502,11 +502,9 @@ public class TContext { this.resultList.set(this.resultList.size() - 1, last.append(remaining)); } - private void executeVoid3(LineLocation location, TMemory memory, String s, TFunction function, - EaterFunctionCall call) throws EaterException, EaterExceptionLocated { - function.executeProcedureInternal(this, memory, call.getValues(), call.getNamedArguments()); - // function.executeProcedure(this, memory, location, s, call.getValues(), - // call.getNamedArguments()); + private void executeVoid3(StringLocated location, TMemory memory, TFunction function, EaterFunctionCall call) + throws EaterException, EaterExceptionLocated { + function.executeProcedureInternal(this, memory, location, call.getValues(), call.getNamedArguments()); } private void executeImport(TMemory memory, StringLocated s) throws EaterException, EaterExceptionLocated { @@ -514,8 +512,8 @@ public class TContext { _import.analyze(this, memory); try { - final SFile file = FileSystem.getInstance() - .getFile(applyFunctionsAndVariables(memory, s.getLocation(), _import.getLocation())); + final SFile file = FileSystem.getInstance().getFile( + applyFunctionsAndVariables(memory, new StringLocated(_import.getWhat(), s.getLocation()))); if (file.exists() && file.isDirectory() == false) { importedFiles.add(file); return; diff --git a/src/net/sourceforge/plantuml/tim/TFunction.java b/src/net/sourceforge/plantuml/tim/TFunction.java index b608b4006..d6572f378 100644 --- a/src/net/sourceforge/plantuml/tim/TFunction.java +++ b/src/net/sourceforge/plantuml/tim/TFunction.java @@ -38,8 +38,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public interface TFunction { @@ -49,11 +49,11 @@ public interface TFunction { public TFunctionType getFunctionType(); - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List args, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List args, Map named) throws EaterException, EaterExceptionLocated; - public void executeProcedureInternal(TContext context, TMemory memory, List args, Map named) - throws EaterException, EaterExceptionLocated; + public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException, EaterExceptionLocated; public boolean isUnquoted(); diff --git a/src/net/sourceforge/plantuml/tim/TFunctionImpl.java b/src/net/sourceforge/plantuml/tim/TFunctionImpl.java index 54183810b..4d1237feb 100644 --- a/src/net/sourceforge/plantuml/tim/TFunctionImpl.java +++ b/src/net/sourceforge/plantuml/tim/TFunctionImpl.java @@ -132,8 +132,8 @@ public class TFunctionImpl implements TFunction { } @Override - public void executeProcedureInternal(TContext context, TMemory memory, List args, Map named) - throws EaterException, EaterExceptionLocated { + public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException, EaterExceptionLocated { if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG) throw new IllegalStateException(); @@ -142,10 +142,10 @@ public class TFunctionImpl implements TFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, - List args, Map named) throws EaterException, EaterExceptionLocated { + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException, EaterExceptionLocated { if (functionType == TFunctionType.LEGACY_DEFINE) - return executeReturnLegacyDefine(location, context, memory, args); + 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?"); @@ -164,7 +164,7 @@ public class TFunctionImpl implements TFunction { throw new IllegalStateException(); final TMemory copy = getNewMemory(memory, args, Collections.emptyMap()); - final String tmp = context.applyFunctionsAndVariables(copy, location, legacyDefinition); + final String tmp = context.applyFunctionsAndVariables(copy, new StringLocated(legacyDefinition, location)); if (tmp == null) return TValue.fromString(""); diff --git a/src/net/sourceforge/plantuml/tim/VariableManager.java b/src/net/sourceforge/plantuml/tim/VariableManager.java index 8f3a7bd00..88332ac3d 100644 --- a/src/net/sourceforge/plantuml/tim/VariableManager.java +++ b/src/net/sourceforge/plantuml/tim/VariableManager.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.tim; 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.text.TLineType; import net.sourceforge.plantuml.tim.expression.TValue; import net.sourceforge.plantuml.utils.LineLocation; @@ -67,7 +68,7 @@ public class VariableManager { result.append(value.toJson().toString()); } else { JsonValue jsonValue = (value.toJson().isArray()) ? (JsonArray) value.toJson() - : (JsonObject) value.toJson(); + : (JsonObject) value.toJson(); i++; i = replaceJson(jsonValue, str, i, result) - 1; } @@ -111,7 +112,8 @@ public class VariableManager { inBracket.append(str.charAt(i)); i++; } - final String nbString = context.applyFunctionsAndVariables(memory, location, inBracket.toString()); + final String nbString = context.applyFunctionsAndVariables(memory, + new StringLocated(inBracket.toString(), location)); if (jsonValue instanceof JsonArray) { final int nb = Integer.parseInt(nbString); jsonValue = ((JsonArray) jsonValue).get(nb); diff --git a/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java b/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java index c5b4be109..4d19e7642 100644 --- a/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java +++ b/src/net/sourceforge/plantuml/tim/expression/ReversePolishInterpretor.java @@ -40,6 +40,7 @@ import java.util.Collections; 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; @@ -58,7 +59,7 @@ public class ReversePolishInterpretor { this(null, queue, knowledge, memory, context); } - public ReversePolishInterpretor(LineLocation location, TokenStack queue, Knowledge knowledge, TMemory memory, + public ReversePolishInterpretor(StringLocated location, TokenStack queue, Knowledge knowledge, TMemory memory, TContext context) throws EaterException, EaterExceptionLocated { final Deque stack = new ArrayDeque<>(); diff --git a/src/net/sourceforge/plantuml/tim/expression/TokenStack.java b/src/net/sourceforge/plantuml/tim/expression/TokenStack.java index 3bd091e4b..61eeebae6 100644 --- a/src/net/sourceforge/plantuml/tim/expression/TokenStack.java +++ b/src/net/sourceforge/plantuml/tim/expression/TokenStack.java @@ -42,6 +42,7 @@ import java.util.HashMap; import java.util.List; 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; @@ -210,9 +211,9 @@ public class TokenStack { return new InternalIterator(); } - public TValue getResult(LineLocation location, TContext context, TMemory memory) + public TValue getResult(StringLocated location, TContext context, TMemory memory) throws EaterException, EaterExceptionLocated { - final Knowledge knowledge = context.asKnowledge(memory, location); + final Knowledge knowledge = context.asKnowledge(memory, location.getLocation()); final TokenStack tmp = withoutSpace(); tmp.guessFunctions(); final TokenIterator it = tmp.tokenIterator(); diff --git a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java index 037c33200..84f201e6a 100644 --- a/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java +++ b/src/net/sourceforge/plantuml/tim/iterator/CodeIteratorWhile.java @@ -90,10 +90,10 @@ public class CodeIteratorWhile extends AbstractCodeIterator { continue; } else if (result.getType() == TLineType.ENDWHILE) { logs.add(result); - if (currentWhile == null) { + if (currentWhile == null) throw EaterException.located("No while related to this endwhile"); - } - final TValue value = currentWhile.conditionValue(result.getLocation(), context, memory); + + final TValue value = currentWhile.conditionValue(result, context, memory); if (value.toBoolean()) { source.jumpToCodePosition(currentWhile.getStartWhile()); } else { @@ -113,10 +113,10 @@ public class CodeIteratorWhile extends AbstractCodeIterator { final TokenStack whileExpression = condition.getWhileExpression(); final ExecutionContextWhile theWhile = ExecutionContextWhile.fromValue(whileExpression, source.getCodePosition()); - final TValue value = theWhile.conditionValue(s.getLocation(), context, memory); - if (value.toBoolean() == false) { + final TValue value = theWhile.conditionValue(s, context, memory); + if (value.toBoolean() == false) theWhile.skipMe(); - } + memory.addWhile(theWhile); } diff --git a/src/net/sourceforge/plantuml/tim/package-info.java b/src/net/sourceforge/plantuml/tim/package-info.java index d185cc4bd..7aa0e198b 100644 --- a/src/net/sourceforge/plantuml/tim/package-info.java +++ b/src/net/sourceforge/plantuml/tim/package-info.java @@ -1,7 +1,7 @@ /** - * Provides classes used to manage - * - * Preprocessing of PlantUML input. + * Provides classes used to manage + * Preprocessing + * of PlantUML input. * * @see net.sourceforge.plantuml.text.TLineType * @see net.sourceforge.plantuml.preproc diff --git a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java index 0c73b754a..6d13ce01e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysFalse.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class AlwaysFalse extends SimpleReturnFunction { @@ -56,9 +56,9 @@ public class AlwaysFalse extends SimpleReturnFunction { public boolean canCover(int nbArg, Set namedArgument) { return nbArg == 0; } - + @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 66ec893af..e9a1362b6 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/AlwaysTrue.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class AlwaysTrue extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class AlwaysTrue extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 5d9107a92..0bc47532a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/CallUserFunction.java @@ -38,6 +38,7 @@ import java.util.List; 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; @@ -45,7 +46,6 @@ import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class CallUserFunction extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class CallUserFunction extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String fname = values.get(0).toString(); final List args = values.subList(1, values.size()); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java index cdd7e139a..aa7daa6cb 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Chr extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Chr extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { try { final String value = String.valueOf(Character.toChars(values.get(0).toInt())); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Darken.java b/src/net/sourceforge/plantuml/tim/stdlib/Darken.java index e053ac6c7..4a282d150 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Darken.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Darken.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Darken extends SimpleReturnFunction { @@ -62,7 +62,7 @@ public class Darken extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String colorString = values.get(0).toString(); final int ratio = values.get(1).toInt(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java index 1c18155d9..e596ef4b7 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/DateFunction.java @@ -40,13 +40,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class DateFunction extends SimpleReturnFunction { @@ -60,7 +60,7 @@ public class DateFunction extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { if (values.size() == 0) return TValue.fromString(new Date().toString()); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java b/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java index 3dc6f7b63..668f618da 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Dec2hex.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Dec2hex extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Dec2hex extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { try { return TValue.fromString("" + Integer.toHexString(values.get(0).toInt())); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java b/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java index 1c918c4e8..a3a0b4e9e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Dirpath.java @@ -39,13 +39,13 @@ import java.util.Map; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Dirpath extends SimpleReturnFunction { @@ -65,11 +65,11 @@ public class Dirpath extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { - if (value == null) { + if (value == null) return TValue.fromString(""); - } + return TValue.fromString(value); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Eval.java b/src/net/sourceforge/plantuml/tim/stdlib/Eval.java index ee7ad6e46..d08e45363 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Eval.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Eval.java @@ -38,6 +38,7 @@ import java.util.List; 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; @@ -45,7 +46,6 @@ import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Eval extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class Eval extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String exp = values.get(0).toString(); final StringEater eater = new StringEater(exp); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Feature.java b/src/net/sourceforge/plantuml/tim/stdlib/Feature.java index f79b4ed4d..042bfee0b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Feature.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Feature.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Feature extends SimpleReturnFunction { @@ -58,15 +58,15 @@ public class Feature extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String arg = values.get(0).toString(); - if ("style".equalsIgnoreCase(arg)) { + if ("style".equalsIgnoreCase(arg)) return TValue.fromInt(1); - } - if ("theme".equalsIgnoreCase(arg)) { + + if ("theme".equalsIgnoreCase(arg)) return TValue.fromInt(1); - } + return TValue.fromInt(0); } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java b/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java index d7b68e423..f43b345a1 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/FileExists.java @@ -39,13 +39,13 @@ import java.util.Map; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class FileExists extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class FileExists extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { // ::comment when __CORE__ final String path = values.get(0).toString(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Filename.java b/src/net/sourceforge/plantuml/tim/stdlib/Filename.java index 49fd6b6c8..fd6089946 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Filename.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Filename.java @@ -39,13 +39,13 @@ import java.util.Map; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Filename extends SimpleReturnFunction { @@ -65,7 +65,7 @@ public class Filename extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 43442f82e..f72dae133 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/FunctionExists.java @@ -38,16 +38,16 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class FunctionExists extends SimpleReturnFunction { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ public TFunctionSignature getSignature() { return new TFunctionSignature("%function_exists", 1); @@ -59,7 +59,7 @@ public class FunctionExists extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 6a84fd84e..4bac0865e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetAllStdlib.java @@ -39,18 +39,18 @@ import java.util.List; import java.util.Map; import java.util.Set; -import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.json.Json; import net.sourceforge.plantuml.json.JsonArray; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetAllStdlib extends SimpleReturnFunction { @@ -64,42 +64,42 @@ public class GetAllStdlib extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { switch (values.size()) { - case 0: - final JsonArray result = new JsonArray(); - try { - for (String name : Stdlib.getAll()) { - result.add(name); - } - return TValue.fromJson(result); - } catch (IOException e) { - Logme.error(e); - return TValue.fromJson(result); + case 0: + final JsonArray result = new JsonArray(); + try { + for (String name : Stdlib.getAll()) { + result.add(name); } + return TValue.fromJson(result); + } catch (IOException e) { + Logme.error(e); + return TValue.fromJson(result); + } - case 1: - final JsonObject res = new JsonObject(); - try { - // Inspired by Stdlib.addInfoVersion - for (String name : Stdlib.getAll()) { - final Stdlib folder = Stdlib.retrieve(name); - final JsonObject object = Json.object() // - .add("name", name) // - .add("version", folder.getVersion()) // - .add("source", folder.getSource()); - res.add(name, object); - } - return TValue.fromJson(res); - } catch (IOException e) { - Logme.error(e); - return TValue.fromJson(res); + case 1: + final JsonObject res = new JsonObject(); + try { + // Inspired by Stdlib.addInfoVersion + for (String name : Stdlib.getAll()) { + final Stdlib folder = Stdlib.retrieve(name); + final JsonObject object = Json.object() // + .add("name", name) // + .add("version", folder.getVersion()) // + .add("source", folder.getSource()); + res.add(name, object); } + return TValue.fromJson(res); + } catch (IOException e) { + Logme.error(e); + return TValue.fromJson(res); + } - default: - throw EaterException.located("Error on get_all_stdlib: Too many arguments"); + default: + throw EaterException.located("Error on get_all_stdlib: Too many arguments"); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java b/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java index e0b2d0281..f26379843 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetAllTheme.java @@ -39,8 +39,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -import net.sourceforge.plantuml.log.Logme; 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; @@ -48,7 +49,6 @@ import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetAllTheme extends SimpleReturnFunction { @@ -62,7 +62,7 @@ public class GetAllTheme extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final JsonArray result = new JsonArray(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java index 244824ee3..0bd617053 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonKey.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetJsonKey extends SimpleReturnFunction { @@ -61,7 +61,7 @@ public class GetJsonKey extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final TValue data = values.get(0); if (data.isJson() == false) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java index 33d3b5b64..17a2f164a 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetJsonType.java @@ -39,13 +39,13 @@ import java.util.Map; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetJsonType extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class GetJsonType extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final TValue data = values.get(0); if (data.isString()) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java b/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java index 082921acb..c950f7c7b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetVariableValue.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class GetVariableValue extends SimpleReturnFunction { @@ -58,13 +58,13 @@ public class GetVariableValue extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String name = values.get(0).toString(); final TValue variable = memory.getVariable(name); - if (variable == null) { + if (variable == null) return TValue.fromString(""); - } + return variable; } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java b/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java index c206538cb..68e66ec23 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/GetVersion.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.version.Version; public class GetVersion extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class GetVersion extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 88fd8a638..380448942 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Getenv.java @@ -39,13 +39,13 @@ import java.util.Map; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Getenv extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class Getenv extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { // ::comment when __CORE__ final String value = getenv(values.get(0).toString()); @@ -82,7 +82,7 @@ public class Getenv extends SimpleReturnFunction { // also stop here in other deployments. if (SecurityUtils.getSecurityProfile().canWeReadThisEnvironmentVariable(name) == false) return null; - + final String env = System.getProperty(name); if (env != null) return env; diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java index 27f510248..0cc471567 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Hex2dec.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Hex2dec extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Hex2dec extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { try { return TValue.fromInt(Integer.parseInt(values.get(0).toString(), 16)); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java index cc1173882..2618bfbf6 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/HslColor.java @@ -41,13 +41,13 @@ 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class HslColor extends SimpleReturnFunction { @@ -61,7 +61,7 @@ public class HslColor extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final int h = values.get(0).toInt(); final int s = values.get(1).toInt(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java b/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java index 27e19db7a..b412cad9d 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IntVal.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; import net.sourceforge.plantuml.utils.Log; public class IntVal extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class IntVal extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String s = values.get(0).toString(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java b/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java index 5331f7b2e..64503ed11 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/InvokeProcedure.java @@ -38,6 +38,7 @@ import java.util.List; 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; @@ -46,7 +47,6 @@ import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TFunctionType; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class InvokeProcedure implements TFunction { @@ -64,20 +64,20 @@ public class InvokeProcedure implements TFunction { } @Override - public void executeProcedureInternal(TContext context, TMemory memory, List args, Map named) - throws EaterException, EaterExceptionLocated { + public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, List args, + Map named) throws EaterException, 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) { + if (func == null) throw EaterException.located("Cannot find void function " + fname); - } - func.executeProcedureInternal(context, memory, sublist, named); + + func.executeProcedureInternal(context, memory, location, sublist, named); } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java b/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java index efc4299da..d8f337bf5 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IsDark.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class IsDark extends SimpleReturnFunction { @@ -62,7 +62,7 @@ public class IsDark extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String colorString = values.get(0).toString(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java b/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java index deff7b24d..e298e1baa 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/IsLight.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class IsLight extends SimpleReturnFunction { @@ -62,7 +62,7 @@ public class IsLight extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String colorString = values.get(0).toString(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java b/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java index 85eafc540..71d6eaed8 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/JsonKeyExists.java @@ -40,13 +40,13 @@ 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class JsonKeyExists extends SimpleReturnFunction { @@ -60,7 +60,7 @@ public class JsonKeyExists extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final TValue arg0 = values.get(0); if (arg0.isJson() == false) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java b/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java index e4de200fe..ac69bf9e4 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Lighten.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Lighten extends SimpleReturnFunction { @@ -62,7 +62,7 @@ public class Lighten extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String colorString = values.get(0).toString(); final int ratio = values.get(1).toInt(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java b/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java index a5021562c..58e6a74bf 100755 --- a/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LoadJson.java @@ -49,13 +49,13 @@ import net.sourceforge.plantuml.json.ParseException; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; /** * Loads JSON data from file or URL source. @@ -108,7 +108,7 @@ public class LoadJson extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String path = values.get(0).toString(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java index 4fe2d2a14..3770e1b05 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalAnd.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalAnd extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalAnd extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == false) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java index 9b018d3c0..7d655c92f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNand.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNand extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalNand extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == false) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java index 95c4e3c6d..12b003616 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNor.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNor extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalNor extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == true) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java index ca6d5ab3a..7ffb3689e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNot.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNot extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalNot extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 e83c05b1e..a5ed319e3 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalNxor.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalNxor extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalNxor extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { int cpt = 0; for (TValue v : values) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java index 41026ac89..e78dcc546 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalOr.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalOr extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalOr extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { for (TValue v : values) if (v.toBoolean() == true) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java b/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java index 14ad07a5e..da04addf5 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/LogicalXor.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class LogicalXor extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class LogicalXor extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { int cpt = 0; for (TValue v : values) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Lower.java b/src/net/sourceforge/plantuml/tim/stdlib/Lower.java index d0dbcb731..721a521b8 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Lower.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Lower.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Lower extends SimpleReturnFunction { @@ -56,7 +56,7 @@ public class Lower extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString(values.get(0).toString().toLowerCase()); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Newline.java b/src/net/sourceforge/plantuml/tim/stdlib/Newline.java index 2f5c7abb7..d3b4b8768 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Newline.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Newline.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Newline extends SimpleReturnFunction { @@ -56,7 +56,7 @@ public class Newline extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString("\n"); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Now.java b/src/net/sourceforge/plantuml/tim/stdlib/Now.java index c90eb25d1..f827d6e9f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Now.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Now.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Now extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Now extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 bf0f7d767..8ae31e5c4 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Ord.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Ord.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Ord extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Ord extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { try { final int codePoint = values.get(0).toString().codePointAt(0); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java index a165f00a4..bf7786f5c 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/RandomFunction.java @@ -39,13 +39,13 @@ import java.util.Map; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class RandomFunction extends SimpleReturnFunction { @@ -59,25 +59,25 @@ public class RandomFunction extends SimpleReturnFunction { } private final Random random = new Random(); - + @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { switch (values.size()) { - case 0: - return TValue.fromInt(random.nextInt(2)); + case 0: + return TValue.fromInt(random.nextInt(2)); - case 1: - final Integer mx = values.get(0).toInt(); - return TValue.fromInt(random.nextInt(mx)); + case 1: + final Integer mx = values.get(0).toInt(); + return TValue.fromInt(random.nextInt(mx)); - case 2: - final Integer min = values.get(0).toInt(); - final Integer max = values.get(1).toInt(); - return TValue.fromInt(random.nextInt(max - min) + min); + case 2: + final Integer min = values.get(0).toInt(); + final Integer max = values.get(1).toInt(); + return TValue.fromInt(random.nextInt(max - min) + min); - default: - throw EaterException.located("Error on Random: Too many argument"); + default: + throw EaterException.located("Error on Random: Too many argument"); } } } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java b/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java index fa75ab946..8c31c3520 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/RetrieveProcedure.java @@ -39,6 +39,7 @@ import java.util.List; 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; @@ -46,7 +47,6 @@ import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class RetrieveProcedure extends SimpleReturnFunction { @@ -60,14 +60,14 @@ public class RetrieveProcedure extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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); final int n1 = context.getResultList().size(); - func.executeProcedureInternal(context, memory, args, Collections.emptyMap()); + func.executeProcedureInternal(context, memory, location, args, Collections.emptyMap()); final String extracted = context.extractFromResultList(n1); return TValue.fromString(extracted); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java index 6084e16d1..43521f070 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseColor.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class ReverseColor extends SimpleReturnFunction { @@ -61,7 +61,7 @@ public class ReverseColor extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String colorString = values.get(0).toString(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java index 6a42843f7..bcfaa72b9 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/ReverseHsluvColor.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class ReverseHsluvColor extends SimpleReturnFunction { @@ -61,7 +61,7 @@ public class ReverseHsluvColor extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String colorString = values.get(0).toString(); try { diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java b/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java index a35ec7786..1dd202157 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SetVariableValue.java @@ -38,6 +38,7 @@ import java.util.List; 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; @@ -45,7 +46,6 @@ import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.TVariableScope; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class SetVariableValue extends SimpleReturnFunction { @@ -59,7 +59,7 @@ public class SetVariableValue extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 f276bcbdd..c649a86a4 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SimpleReturnFunction.java @@ -37,13 +37,13 @@ package net.sourceforge.plantuml.tim.stdlib; 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.TContext; import net.sourceforge.plantuml.tim.TFunction; import net.sourceforge.plantuml.tim.TFunctionType; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public abstract class SimpleReturnFunction implements TFunction { @@ -52,8 +52,8 @@ public abstract class SimpleReturnFunction implements TFunction { } @Override - final public void executeProcedureInternal(TContext context, TMemory memory, List args, - Map named) throws EaterException { + final public void executeProcedureInternal(TContext context, TMemory memory, StringLocated location, + List args, Map named) throws EaterException { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Size.java b/src/net/sourceforge/plantuml/tim/stdlib/Size.java index 0794bca42..0bf62d6d6 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Size.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Size.java @@ -41,13 +41,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Size extends SimpleReturnFunction { @@ -61,7 +61,7 @@ public class Size extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final TValue value = values.get(0); if (value.isNumber()) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java b/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java index d9aa2fded..5e181ffca 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/SplitStr.java @@ -40,13 +40,13 @@ import java.util.Set; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class SplitStr extends SimpleReturnFunction { @@ -60,7 +60,7 @@ public class SplitStr extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final JsonArray result = new JsonArray(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java b/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java index f2b972a80..de63add20 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/StringFunction.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class StringFunction extends SimpleReturnFunction { @@ -56,7 +56,7 @@ public class StringFunction extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString(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 3e1578fba..3aeb5b609 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Strlen.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Strlen extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Strlen extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 09a5c43a9..8db94424f 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Strpos.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Strpos extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Strpos extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String full = values.get(0).toString(); final String searched = values.get(1).toString(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Substr.java b/src/net/sourceforge/plantuml/tim/stdlib/Substr.java index ba0c0e8ce..ec254565b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Substr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Substr.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Substr extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class Substr extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, EaterExceptionLocated { final String full = values.get(0).toString(); final int pos = values.get(1).toInt(); diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Upper.java b/src/net/sourceforge/plantuml/tim/stdlib/Upper.java index 98caf89ff..71ebe587e 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Upper.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Upper.java @@ -38,11 +38,11 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.sourceforge.plantuml.text.StringLocated; import net.sourceforge.plantuml.tim.TContext; import net.sourceforge.plantuml.tim.TFunctionSignature; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class Upper extends SimpleReturnFunction { @@ -56,7 +56,7 @@ public class Upper extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) { return TValue.fromString(values.get(0).toString().toUpperCase()); } diff --git a/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java b/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java index a63730447..3f06d5e62 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/VariableExists.java @@ -38,13 +38,13 @@ import java.util.List; 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; import net.sourceforge.plantuml.tim.TMemory; import net.sourceforge.plantuml.tim.expression.TValue; -import net.sourceforge.plantuml.utils.LineLocation; public class VariableExists extends SimpleReturnFunction { @@ -58,7 +58,7 @@ public class VariableExists extends SimpleReturnFunction { } @Override - public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, + public TValue executeReturnFunction(TContext context, TMemory memory, StringLocated location, List values, Map named) throws EaterException, 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 50dd4b24e..77f7aa10b 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.4beta1"; + private static final String version = "1.2024.4beta2"; public static String versionString() { return version;