Skip to content

Commit

Permalink
use new 'register' method, and tweak pseudoobject format
Browse files Browse the repository at this point in the history
self-registering constructor, same as most other tag things use.
Exclude DurationTag/ElementTag because there's a PR on those waiting
  • Loading branch information
mcmonkey4eva committed Nov 18, 2022
1 parent df1539c commit 61f6544
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public Object getJavaObject() {
return data;
}

public static void registerTags() {
public static void register() {

// <--[tag]
// @attribute <BinaryTag.length>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public Object getJavaObject() {
return object;
}

public static void registerTags() {
public static void register() {

// <--[tag]
// @attribute <JavaReflectedObjectTag.simple_class_name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public int parseIndex(String index, Attribute attribute, boolean strict) {
return integerIndex - 1;
}

public static void registerTags() {
public static void register() {

// <--[tag]
// @attribute <ListTag.combine>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public ListTag keys() {
return result;
}

public static void registerTags() {
public static void register() {

// <--[tag]
// @attribute <MapTag.size>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void reapplyTracker(AbstractFlagTracker tracker) {
// Nothing to do.
}

public static void registerTags() {
public static void register() {

AbstractFlagTracker.registerFlagHandlers(tagProcessor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void reapplyTracker(AbstractFlagTracker tracker) {
// Nothing to do.
}

public static void registerTags() {
public static void register() {

AbstractFlagTracker.registerFlagHandlers(tagProcessor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public boolean isUnique() {
return true;
}

public static void registerTags() {
public static void register() {

// <--[tag]
// @attribute <SecretTag.key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void reapplyTracker(AbstractFlagTracker tracker) {
// Nothing to do.
}

public static void registerTags() {
public static void register() {

AbstractFlagTracker.registerFlagHandlers(tagProcessor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ public static void patchPatchMethodMethodsField() {
}

public static void webGet(final ScriptEntry scriptEntry, final ElementTag data, Method method, String urlText, DurationTag timeout, MapTag headers, String saveFile, boolean hideFailure, boolean urlIsSecret) {
BufferedReader buffIn = null;
HttpURLConnection uc = null;
try {
long timeStart = CoreUtilities.monotonicMillis();
Expand Down Expand Up @@ -334,22 +333,5 @@ public boolean tick(float seconds) {
}
});
}
finally {
try {
if (buffIn != null) {
buffIn.close();
}
}
catch (Exception e) {
if (!hideFailure) {
if (urlIsSecret) {
Debug.echoError("WebGet encountered an exception of type '" + e.getClass().getCanonicalName() + "' but hid the exception text due to secret URL presence.");
}
else {
Debug.echoError(e);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ObjectTag getNextObjectTypeDown() {

public ObjectType<T> type = new ObjectType<>();

public abstract void registerTags();
public abstract void register();

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
Expand All @@ -60,6 +60,6 @@ public PseudoObjectTagBase() {
type.clazz = tagProcessor.type;
type.longName = DebugInternals.getClassNameOpti(getClass());
ObjectFetcher.objectsByClass.put(type.clazz, type);
registerTags();
register();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void registerCoreTags() {
new ProcedureScriptTagBase();
new StaticTagBase();
new TernaryTagBase();
UtilTagBase.register();
new UtilTagBase();
}

public static class TagBaseData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ public class UtilTagBase extends PseudoObjectTagBase<UtilTagBase> {

public static UtilTagBase instance;

public static void register() {
instance = new UtilTagBase();
public UtilTagBase() {
instance = this;
TagManager.registerStaticTagBaseHandler(UtilTagBase.class, "util", (t) -> instance);
}

@Override
public void registerTags() {

public void register() {
tagProcessor.registerTag(ElementTag.class, "random", (attribute, object) -> {
attribute.fulfill(1);

Expand Down

0 comments on commit 61f6544

Please sign in to comment.