diff --git a/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java b/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java index dc4283ddf9..46231fee59 100644 --- a/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java +++ b/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java @@ -28,6 +28,7 @@ import javax.swing.*; import net.rptools.maptool.client.AppPreferences; import net.rptools.maptool.client.MapTool; +import net.rptools.maptool.client.MapToolExpressionParser; import net.rptools.maptool.client.ui.htmlframe.HTMLDialog; import net.rptools.maptool.client.ui.htmlframe.HTMLFrame; import net.rptools.maptool.client.ui.htmlframe.HTMLOverlayManager; @@ -105,12 +106,30 @@ public Object childEvaluate( return getThemeInfo(); } else if (infoType.equalsIgnoreCase("debug")) { return getDebugInfo(); + } else if (infoType.equalsIgnoreCase("functions")) { + return getFunctionLists(); } else { throw new ParserException( I18N.getText("macro.function.getInfo.invalidArg", param.get(0).toString())); } } + private JsonObject getFunctionLists() { + UserDefinedMacroFunctions UDF = UserDefinedMacroFunctions.getInstance(); + JsonObject udfList = new JsonObject(); + for (String name : UDF.getAliases()) { + udfList.addProperty(name, UDF.getFunctionLocation(name)); + } + JsonArray fList = new JsonArray(); + MapToolExpressionParser.getMacroFunctions() + .forEach(function -> Arrays.stream(function.getAliases()).forEach(fList::add)); + + JsonObject fInfo = new JsonObject(); + fInfo.add("functions", fList); + fInfo.add("user defined functions", udfList); + return fInfo; + } + /** * Retrieves the information about the current zone/map and returns it as a JSON Object. *