MinecraftDev icon indicating copy to clipboard operation
MinecraftDev copied to clipboard

Add support for MixinExtras expressions

Open Earthcomputer opened this issue 1 year ago • 1 comments
trafficstars

See Llama's gist for a (slightly outdated) overview of what MixinExtras expressions are. Without IDE support, ME expressions would be really inconvenient to write, more so than other mixin features.

ME expression syntax is support through a custom language in IntelliJ, through the use of language injection. To make this nicer to work with, I have slightly extended the ME expression language. Definitions are prefixed with the class keyword, and then a boolean literal for whether they are a type or not. Expressions are surrounded with do { ... }. For example:

@Definition(id = "Integer", type = Integer.class)
@Definition(id = "x", local = @Local(type = Object.class, ordinal = 0))
@Expression("(Integer) x")

would produce the following injected ME expression file:

class true Integer
class false x
do { (Integer) x }

This feature is basically done now, the only thing left is to switch away from the JitPack version of MixinExtras and use the library they'll provide for us, which will hopefully have the same interface.

Don't worry about the amount of commits, I'll squash them all on merge.

Earthcomputer avatar Mar 31 '24 08:03 Earthcomputer

I think once write actions are allowed outside of the EDT we'll have to make a general sweep of the codebase to look for cases like these where we use invokeLater for write actions.

Earthcomputer avatar Apr 14 '24 11:04 Earthcomputer