Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added info type "functions" #4548

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
Loading