Skip to content

Commit

Permalink
Merge pull request #45 from DeepBlueRobotics/only-import-types-when-n…
Browse files Browse the repository at this point in the history
…ecessary

Only Import `wpiws.types.*` When Necessary
  • Loading branch information
CoolSpy3 committed May 29, 2024
2 parents fe36fbd + 4837463 commit 7a60199
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion asyncapi-template/filters/PropertyFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,22 @@ function isRobotOutput(prop) {
return prop.startsWith("<");
}

module.exports = { formatPropName, cap1, formatPropType, formatPropObjType, formatPropCallbackType, formatPropParser, formatPropInitialValue, isRobotInput, isRobotOutput }
function usesCustomTypes(props, schemaName) {
for (const [propName, prop] of Object.entries(props)) {
if (formatPropParser(prop, schemaName, propName) !== "null") return true;
}
return false;
}

module.exports = {
formatPropName,
cap1,
formatPropType,
formatPropObjType,
formatPropCallbackType,
formatPropParser,
formatPropInitialValue,
isRobotInput,
isRobotOutput,
usesCustomTypes
}
2 changes: 2 additions & 0 deletions asyncapi-template/template/$$schema$$.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import org.team199.wpiws.connection.ConnectionProcessor;
import org.team199.wpiws.connection.WSValue;
import org.team199.wpiws.interfaces.*;
{%- if (props | usesCustomTypes(name)) %}
import org.team199.wpiws.types.*;
{%- endif %}

/**
* Represents a simulated {{ name | lower }}
Expand Down

0 comments on commit 7a60199

Please sign in to comment.