Skip to content

Support for custom arithmetic operators#8065

Merged
Absolutionism merged 8 commits intoSkriptLang:dev/featurefrom
Pesekjak:feature/arithmetic-part2
Sep 17, 2025
Merged

Support for custom arithmetic operators#8065
Absolutionism merged 8 commits intoSkriptLang:dev/featurefrom
Pesekjak:feature/arithmetic-part2

Conversation

@Pesekjak
Copy link
Contributor

@Pesekjak Pesekjak commented Jul 21, 2025

Problem

Currently, Skript's operator set is fixed and defined within an enum class. This PR expands on the arithmetic rework and adds the necessary API (and documentation) for the developers to register their own operators.
This PR also fixes the issue with operations caching system. If no suitable operation is found, that information is now stored in the cache.

This could be considered a breaking change because OperationInfo and DifferenceInfo are now record classes. The design choice makes sense and should be fine. As far as I know, no addons currently use these classes. All other API stays the same.
The old methods are deprecated in favor of the record component access methods.

Solution

Operator is now a record class that accepts custom sign (which could also be a String). After the arithmetic operations are registered, the arithmetic expression patterns are generated with all the operator signs.

Testing Completed

built-in tests
src/test/skript/tests/misc/custom operators.sk


Completes: none
Related: none

@Pesekjak Pesekjak requested review from a team and UnderscoreTud as code owners July 21, 2025 16:57
@Pesekjak Pesekjak requested review from erenkarakal and removed request for a team July 21, 2025 16:57
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Jul 21, 2025
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see some junit tests if possible ( oh i see 'working on it')

Also oopsk uses operationinfo iirc

@sovdeeth sovdeeth added feature Pull request adding a new feature. breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) labels Jul 21, 2025
@sovdeeth sovdeeth moved this to In Review in 2.13 Releases Jul 21, 2025
@sovdeeth sovdeeth changed the base branch from master to dev/feature July 21, 2025 17:31
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arithmetic simplification appears to have broken, maybe related to order of ops?

@Pesekjak Pesekjak requested a review from sovdeeth July 21, 2025 19:40
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great work. Thanks for adding lots of javadocs too 🙂

@skriptlang-automation skriptlang-automation bot added needs reviews A PR that needs additional reviews and removed needs reviews A PR that needs additional reviews labels Jul 25, 2025
@Pesekjak Pesekjak removed the breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) label Jul 25, 2025
@Pesekjak Pesekjak requested a review from APickledWalrus July 26, 2025 08:32
Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, great work!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that old issue should be resolved from the sorting that happens from the method. I think if there isn't a reason within this class for it to be sorted then keeping it unsorted should be preferred

@github-project-automation github-project-automation bot moved this from In Review to Awaiting Merge in 2.13 Releases Jul 30, 2025
@skriptlang-automation skriptlang-automation bot added feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. and removed needs reviews A PR that needs additional reviews labels Jul 30, 2025
@Absolutionism Absolutionism merged commit 7753091 into SkriptLang:dev/feature Sep 17, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done - Awaiting Release in 2.13 Releases Sep 17, 2025
@skriptlang-automation skriptlang-automation bot added completed The issue has been fully resolved and the change will be in the next Skript update. and removed feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. labels Sep 17, 2025
@sovdeeth sovdeeth moved this from Done - Awaiting Release to Done - Released in 2.13 Releases Oct 15, 2025
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
* javadocs and refactoring of the arithmetics api

* added support for the registration of custom operators

* preserve the registration order of operators for the pattern generation

* added test for custom operators

* styling, added back the removed methods from old API of DifferenceInfo and OperationInfo

* added cache for converted operation info and small improvements

* switched back to regular hash map for storing registered operations,
expanded compare for operators
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
* javadocs and refactoring of the arithmetics api

* added support for the registration of custom operators

* preserve the registration order of operators for the pattern generation

* added test for custom operators

* styling, added back the removed methods from old API of DifferenceInfo and OperationInfo

* added cache for converted operation info and small improvements

* switched back to regular hash map for storing registered operations,
expanded compare for operators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

completed The issue has been fully resolved and the change will be in the next Skript update. feature Pull request adding a new feature.

Projects

No open projects
Status: Done - Released

Development

Successfully merging this pull request may close these issues.

4 participants

Comments