-
Notifications
You must be signed in to change notification settings - Fork 197
Add support for MixinExtras expressions #2274
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
Merged
Merged
Changes from all commits
Commits
Show all changes
110 commits
Select commit
Hold shift + click to select a range
5503d8f
Start on MixinExtras Expression language
Earthcomputer a9f66e6
MEExpression color settings page
Earthcomputer 3b4a2bf
MEExpression annotator
Earthcomputer 445bc57
MEExpression brace matcher and quote handler
Earthcomputer 387f06c
Switch LHS of MEExpression assignmentExpression to themselves be cert…
Earthcomputer 8e6a686
MEExpression language injection inside @Expression
Earthcomputer 4c5e544
Fix formatting and licenses
Earthcomputer baa19de
Merge branch 'dev' into mixinextras-expression
Earthcomputer 73c065a
Add MIXINEXTRAS:EXPRESSION injection point and add @Expression annota…
Earthcomputer 226a593
Merge branch 'dev' into mixinextras-expression
Earthcomputer acce47e
Fix licenser errors
Earthcomputer 2424c95
Add new ME expression features
Earthcomputer 67b8365
Implement MixinExtras expression collect visitor
Earthcomputer 25d79fa
Merge branch 'dev' into mixinextras-expression
Earthcomputer 5f5bbd5
Fix cast expressions
Earthcomputer 4f75339
Simple best-effort source matching for ME expressions
Earthcomputer 36c7ff9
Fix name expression source matching
Earthcomputer 0ff7c74
Fix MEName.isWildcard
Earthcomputer d0312b4
Fix MELitExpression source matching
Earthcomputer ff6cdbc
operationSign - operationTokenType
Earthcomputer cfe911a
Add built-in definitions
Earthcomputer 226fdaa
Update MixinExtras
Earthcomputer 35102d2
Start with ME definition references
Earthcomputer 86d8b34
Attempt to overhaul ME expression injection
Earthcomputer fd06864
Some fixes to the new injection + navigation
Earthcomputer 4e8c8cf
Merge branch 'dev' into mixinextras-expression
Earthcomputer ba6b6b5
MixinExtras: Add handler signature support for expressions. (#2244)
LlamaLad7 c5fdbd2
Partially fix ME definition renaming
Earthcomputer bdb3e9f
Attempt to get inplace rename refactoring to work (it doesn't)
Earthcomputer d8a45c8
MixinExtras: Use expression-suggested parameter names if they're pres…
LlamaLad7 69ff93f
Fix MEExpressionInjector. Rename refactoring works!
Earthcomputer 1838363
Suppress deprecation warning
Earthcomputer daffb72
ME expression `@Definition` find usages
Earthcomputer 37ef16c
Fix/expressions int like types (#2261)
LlamaLad7 8c2eea1
Add simple keyword completion to ME expressions
Earthcomputer 6b83a7c
Why didn't my local ktlint tell me about these
Earthcomputer 8665190
Store whether a declaration is a type in the ME PSI
Earthcomputer 946a2ad
Add completions for items that already have a definition
Earthcomputer 43cc4c9
Extract some ME expression matching into its own class, and cache som…
Earthcomputer df388fe
Remove some debug code
Earthcomputer e520269
First attempt at bytecode-based completion (it's broken)
Earthcomputer 02c8ba4
Bytecode-based completion fixes
Earthcomputer ee82630
Add new definition annotations below existing definition annotations,…
Earthcomputer 21cd38c
Fix cursor offset
Earthcomputer 11ecf75
Add utilities to textify various ASM nodes
Earthcomputer a603be1
Add expression variants, to allow MixinExtras to match expressions as…
Earthcomputer 2323f54
Merge two expression types into a single MENewExpression, improve ME …
Earthcomputer 6f12b1d
Add better completion tail types
Earthcomputer a6aac8c
Fix completion not working inside of constructors
Earthcomputer c5ee3d0
Add errors/warnings for unused and unresolved definitions, and highli…
Earthcomputer 373a0cf
Split MatchUtil into CompletionUtil
Earthcomputer 9d3ce10
Fold @At.target for definition completions
Earthcomputer a69e3ee
Local variable completions
Earthcomputer 24b5596
Some fixes to local variable completion
Earthcomputer 73f6b41
Fix can-be-implicit locals with inaccessible types not showing template
Earthcomputer dbeb5ef
Show field and method types in completion list
Earthcomputer 1b01e28
Add completion tests, and make some fixes to completion
Earthcomputer d782821
Fix folding on completion
Earthcomputer e43c74d
Refactor mcdev settings, move shadow setting into a project setting
Earthcomputer 166bfaf
Add setting for position of @Definition relative to @Expression
Earthcomputer d586b52
Add folding for @Definitions
Earthcomputer efb945e
Fix array literal input completion
Earthcomputer 3380ca1
Fix ktlint
Earthcomputer c5d31c0
Relax uniqueness in ME expression completions
Earthcomputer 0517103
Initial switch from @Definition.at to field and method
Earthcomputer 56e0e6e
Fix tests
Earthcomputer e81c885
Add references to @Definition.field and method
Earthcomputer c43ff4a
Add folding to @Definition.field and method
Earthcomputer a28e49e
Add comments to MEExpressionCompletionUtil to explain the completion …
Earthcomputer 3fe87de
Fix @Local.type extraction
Earthcomputer 77bcf22
Add string literal completion for ME expressions
Earthcomputer b4f511b
Fix @Local.type for source matching too
Earthcomputer 2f977ab
Fix parsing of multiple @Expression annotations in a single modifier …
Earthcomputer a04e2f6
Merge branch 'dev' into mixinextras-expression
Earthcomputer 4063f09
Format MEExpressionLexer.flex
Earthcomputer 8bb9eb1
Better handle parenthesized expressions in Java source matching
Earthcomputer 8770366
Add method reference expressions
Earthcomputer 39e8062
Fix presentable name of method reference completions
Earthcomputer 45c192a
Override matches(Handle) for method MemberDefinition
Earthcomputer cec4f29
Update MixinExtras and don't assume that instructions are part of the…
Earthcomputer 175db4f
Wrap expanded instructions in a custom type to prevent them accidenta…
Earthcomputer b85cc23
Fix IdentityHashMap with VirtualInsn keys
Earthcomputer 7255353
Update MixinExtras
Earthcomputer 87841dc
Fix completion of new expressions with new MixinExtras update
Earthcomputer d93dd13
Update MixinExtras, fixes compound instructions
Earthcomputer ab50622
New: Add support for string concat expressions in MixinExtras. (#2281)
LlamaLad7 5c1cd92
Address PR comments
Earthcomputer 7b07722
Merge remote-tracking branch 'refs/remotes/original/dev' into mixinex…
LlamaLad7 3ecde2d
MixinExtras Expressions: Migrate to Expressions library.
LlamaLad7 d8a9f83
Fix: Resolve being unable to get the descriptor for some complex types.
LlamaLad7 c88fd70
MixinExtras Expressions: Recreate `ClassInfo#getCommonSuperClassOrInt…
LlamaLad7 a316086
MixinExtras: Fix completion confidence.
LlamaLad7 b301781
Expressions: Autocomplete `method`s and `field`s using flows not inst…
LlamaLad7 a9d6263
Expressions: Autocomplete `method`s for method references.
LlamaLad7 91c75c7
Expressions: A class constant is an expression.
LlamaLad7 2d797a9
Expressions: Show instantiation desc in autocomplete.
LlamaLad7 72f389d
Expressions: Make completions always unique to stop them being filtered.
LlamaLad7 5c32ef9
Expressions: Overhaul array completions.
LlamaLad7 d139d74
Expressions: Fix super call completions.
LlamaLad7 a4769e3
Expressions: Confidently suggest completions after `::`.
LlamaLad7 95fab6f
Expressions: Add intention action to define unresolved identifiers.
LlamaLad7 e654d59
Expressions: Fix `@Local`s not properly handling compound insns.
LlamaLad7 a46940c
Refactor: Add `project` as parameter to `MEExpressionCompletionUtil.a…
LlamaLad7 8a97cb5
Merge pull request #2327 from LlamaLad7/fix/llamas-expressions-fixes-v2
Earthcomputer 75eec45
Merge branch 'refs/heads/dev' into update/llamas-expression-updates
LlamaLad7 5e2cbea
Merge pull request #2328 from LlamaLad7/update/expressions-dev-merge
Earthcomputer a7298d3
Use maven central MixinExtras library
Earthcomputer f929ae0
Merge branch 'refs/heads/dev' into mixinextras-expression
Earthcomputer 9d1ec2f
Remove reference to light service in plugin.xml
Earthcomputer ce61bcf
Use ReentrantReadWriteLock.read and write extension functions
Earthcomputer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...ata/src/main/java/com/demonwav/mcdev/mixintestdata/meExpression/MEExpressionTestData.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Minecraft Development for IntelliJ | ||
* | ||
* https://mcdev.io/ | ||
* | ||
* Copyright (C) 2024 minecraft-dev | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, version 3.0 only. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.demonwav.mcdev.mixintestdata.meExpression; | ||
|
||
import java.util.ArrayList; | ||
import java.util.stream.Stream; | ||
|
||
public class MEExpressionTestData { | ||
private static final SynchedData<Integer> STINGER_COUNT = null; | ||
private SynchedDataManager synchedData; | ||
|
||
public void complexFunction() { | ||
int one = 1; | ||
String local1 = "Hello"; | ||
String local2 = "World"; | ||
|
||
System.out.println(new StringBuilder(local1).append(", ").append(local2)); | ||
System.out.println(one); | ||
|
||
new ArrayList<>(10); | ||
|
||
InaccessibleType varOfInaccessibleType = new InaccessibleType(); | ||
acceptInaccessibleType(varOfInaccessibleType); | ||
noArgMethod(); | ||
|
||
String[] strings1 = new String[] { local1, local2 }; | ||
String[] strings2 = new String[one]; | ||
|
||
Stream.empty().map(this::nonStaticMapper).map(MEExpressionTestData::staticMapper).map(ConstructedByMethodReference::new); | ||
} | ||
|
||
private static void acceptInaccessibleType(InaccessibleType type) { | ||
} | ||
|
||
private static void noArgMethod() { | ||
} | ||
|
||
public int getStingerCount() { | ||
return (Integer) this.synchedData.get(STINGER_COUNT); | ||
} | ||
|
||
private Object nonStaticMapper(Object arg) { | ||
return arg; | ||
} | ||
|
||
private static Object staticMapper(Object arg) { | ||
return arg; | ||
} | ||
|
||
private static class InaccessibleType { | ||
|
||
} | ||
|
||
public static class SynchedDataManager { | ||
public <V> V get(SynchedData<V> data) { | ||
return null; | ||
} | ||
} | ||
|
||
public static class SynchedData<V> { | ||
} | ||
|
||
public static class ConstructedByMethodReference { | ||
public ConstructedByMethodReference(Object bar) {} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Minecraft Development for IntelliJ | ||
* | ||
* https://mcdev.io/ | ||
* | ||
* Copyright (C) 2024 minecraft-dev | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, version 3.0 only. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.demonwav.mcdev.platform.mixin.expression; | ||
|
||
import com.demonwav.mcdev.platform.mixin.expression.gen.psi.MEExpressionTypes; | ||
import com.intellij.lexer.FlexLexer; | ||
import com.intellij.psi.tree.IElementType; | ||
import com.intellij.psi.TokenType; | ||
|
||
%% | ||
|
||
%public | ||
%class MEExpressionLexer | ||
%implements FlexLexer | ||
%function advance | ||
%type IElementType | ||
Earthcomputer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
%state STRING | ||
|
||
%unicode | ||
|
||
WHITE_SPACE = [\ \n\t\r] | ||
RESERVED = assert|break|case|catch|const|continue|default|else|finally|for|goto|if|switch|synchronized|try|while|yield|_ | ||
WILDCARD = "?" | ||
NEW = new | ||
INSTANCEOF = instanceof | ||
BOOL_LIT = true|false | ||
NULL_LIT = null | ||
DO = do | ||
RETURN = return | ||
THROW = throw | ||
THIS = this | ||
SUPER = super | ||
CLASS = class | ||
IDENTIFIER = [A-Za-z_][A-Za-z0-9_]* | ||
INT_LIT = ( [0-9]+ | 0x[0-9a-fA-F]+ ) | ||
DEC_LIT = [0-9]*\.[0-9]+ | ||
PLUS = "+" | ||
MINUS = - | ||
MULT = "*" | ||
DIV = "/" | ||
MOD = % | ||
BITWISE_NOT = "~" | ||
DOT = "." | ||
COMMA = , | ||
LEFT_PAREN = "(" | ||
RIGHT_PAREN = ")" | ||
LEFT_BRACKET = "[" | ||
RIGHT_BRACKET = "]" | ||
LEFT_BRACE = "{" | ||
RIGHT_BRACE = "}" | ||
AT = @ | ||
SHL = << | ||
SHR = >> | ||
USHR = >>> | ||
LT = < | ||
LE = <= | ||
GT = > | ||
GE = >= | ||
EQ = == | ||
NE = "!=" | ||
BITWISE_AND = & | ||
BITWISE_XOR = "^" | ||
BITWISE_OR = "|" | ||
ASSIGN = = | ||
METHOD_REF = :: | ||
|
||
STRING_TERMINATOR = ' | ||
STRING_ESCAPE = \\'|\\\\ | ||
|
||
%% | ||
|
||
<YYINITIAL> { | ||
{WHITE_SPACE}+ { return TokenType.WHITE_SPACE; } | ||
{RESERVED} { return MEExpressionTypes.TOKEN_RESERVED; } | ||
{WILDCARD} { return MEExpressionTypes.TOKEN_WILDCARD; } | ||
{NEW} { return MEExpressionTypes.TOKEN_NEW; } | ||
{INSTANCEOF} { return MEExpressionTypes.TOKEN_INSTANCEOF; } | ||
{BOOL_LIT} { return MEExpressionTypes.TOKEN_BOOL_LIT; } | ||
{NULL_LIT} { return MEExpressionTypes.TOKEN_NULL_LIT; } | ||
{DO} { return MEExpressionTypes.TOKEN_DO; } | ||
{RETURN} { return MEExpressionTypes.TOKEN_RETURN; } | ||
{THROW} { return MEExpressionTypes.TOKEN_THROW; } | ||
{THIS} { return MEExpressionTypes.TOKEN_THIS; } | ||
{SUPER} { return MEExpressionTypes.TOKEN_SUPER; } | ||
{CLASS} { return MEExpressionTypes.TOKEN_CLASS; } | ||
{IDENTIFIER} { return MEExpressionTypes.TOKEN_IDENTIFIER; } | ||
{INT_LIT} { return MEExpressionTypes.TOKEN_INT_LIT; } | ||
{DEC_LIT} { return MEExpressionTypes.TOKEN_DEC_LIT; } | ||
{PLUS} { return MEExpressionTypes.TOKEN_PLUS; } | ||
{MINUS} { return MEExpressionTypes.TOKEN_MINUS; } | ||
{MULT} { return MEExpressionTypes.TOKEN_MULT; } | ||
{DIV} { return MEExpressionTypes.TOKEN_DIV; } | ||
{MOD} { return MEExpressionTypes.TOKEN_MOD; } | ||
{BITWISE_NOT} { return MEExpressionTypes.TOKEN_BITWISE_NOT; } | ||
{DOT} { return MEExpressionTypes.TOKEN_DOT; } | ||
{COMMA} { return MEExpressionTypes.TOKEN_COMMA; } | ||
{LEFT_PAREN} { return MEExpressionTypes.TOKEN_LEFT_PAREN; } | ||
{RIGHT_PAREN} { return MEExpressionTypes.TOKEN_RIGHT_PAREN; } | ||
{LEFT_BRACKET} { return MEExpressionTypes.TOKEN_LEFT_BRACKET; } | ||
{RIGHT_BRACKET} { return MEExpressionTypes.TOKEN_RIGHT_BRACKET; } | ||
{LEFT_BRACE} { return MEExpressionTypes.TOKEN_LEFT_BRACE; } | ||
{RIGHT_BRACE} { return MEExpressionTypes.TOKEN_RIGHT_BRACE; } | ||
{AT} { return MEExpressionTypes.TOKEN_AT; } | ||
{SHL} { return MEExpressionTypes.TOKEN_SHL; } | ||
{SHR} { return MEExpressionTypes.TOKEN_SHR; } | ||
{USHR} { return MEExpressionTypes.TOKEN_USHR; } | ||
{LT} { return MEExpressionTypes.TOKEN_LT; } | ||
{LE} { return MEExpressionTypes.TOKEN_LE; } | ||
{GT} { return MEExpressionTypes.TOKEN_GT; } | ||
{GE} { return MEExpressionTypes.TOKEN_GE; } | ||
{EQ} { return MEExpressionTypes.TOKEN_EQ; } | ||
{NE} { return MEExpressionTypes.TOKEN_NE; } | ||
{BITWISE_AND} { return MEExpressionTypes.TOKEN_BITWISE_AND; } | ||
{BITWISE_XOR} { return MEExpressionTypes.TOKEN_BITWISE_XOR; } | ||
{BITWISE_OR} { return MEExpressionTypes.TOKEN_BITWISE_OR; } | ||
{ASSIGN} { return MEExpressionTypes.TOKEN_ASSIGN; } | ||
{METHOD_REF} { return MEExpressionTypes.TOKEN_METHOD_REF; } | ||
{STRING_TERMINATOR} { yybegin(STRING); return MEExpressionTypes.TOKEN_STRING_TERMINATOR; } | ||
} | ||
|
||
<STRING> { | ||
{STRING_ESCAPE} { return MEExpressionTypes.TOKEN_STRING_ESCAPE; } | ||
{STRING_TERMINATOR} { yybegin(YYINITIAL); return MEExpressionTypes.TOKEN_STRING_TERMINATOR; } | ||
[^'\\]+ { return MEExpressionTypes.TOKEN_STRING; } | ||
} | ||
|
||
[^] { return TokenType.BAD_CHARACTER; } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.