-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix anonymous and local class indices
The previous code would consider type parameters an indexed class
- Loading branch information
1 parent
f166031
commit da192c4
Showing
6 changed files
with
169 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
25 changes: 25 additions & 0 deletions
25
tests/data/parchment/anonymous_classes/expected/FormattedText.java
This file contains 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,25 @@ | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import java.util.Optional; | ||
|
||
public interface FormattedText { | ||
FormattedText EMPTY = new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(AtomicReference<T> named_inner1) { | ||
return Optional.empty(); | ||
} | ||
}; | ||
|
||
<T> Optional<T> visit(AtomicReference<T> p_ref); | ||
|
||
static FormattedText of(final String p_txt) { | ||
class Local { | ||
void run(int named_local1) {} | ||
} | ||
return new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(AtomicReference<T> named_inner2) { | ||
return Optional.empty(); | ||
} | ||
}; | ||
} | ||
} |
This file contains 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,10 @@ | ||
tsrg2 left right | ||
obfuscated_c$1 FormattedText$1 | ||
obfuscated_m (Ljava/util/concurrent/atomic/AtomicReference;)Ljava/util/Optional; visit | ||
0 o named_inner1 | ||
obfuscated_c$2 FormattedText$2Local | ||
obfuscated_m (I)V run | ||
0 o named_local1 | ||
obfuscated_c$3 FormattedText$3 | ||
obfuscated_m (Ljava/util/concurrent/atomic/AtomicReference;)Ljava/util/Optional; visit | ||
0 o named_inner2 |
25 changes: 25 additions & 0 deletions
25
tests/data/parchment/anonymous_classes/source/FormattedText.java
This file contains 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,25 @@ | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import java.util.Optional; | ||
|
||
public interface FormattedText { | ||
FormattedText EMPTY = new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(AtomicReference<T> p_130797_) { | ||
return Optional.empty(); | ||
} | ||
}; | ||
|
||
<T> Optional<T> visit(AtomicReference<T> p_ref); | ||
|
||
static FormattedText of(final String p_txt) { | ||
class Local { | ||
void run(int p_127434_) {} | ||
} | ||
return new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(AtomicReference<T> p_130787_) { | ||
return Optional.empty(); | ||
} | ||
}; | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
tests/data/parchment/tsrg_file/source/FormattedText.java
This file contains 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,100 @@ | ||
import com.google.common.collect.ImmutableList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import net.minecraft.util.Unit; | ||
|
||
public interface FormattedText { | ||
Optional<Unit> STOP_ITERATION = Optional.of(Unit.INSTANCE); | ||
FormattedText EMPTY = new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> p_130797_) { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> p_130799_, Style p_130800_) { | ||
return Optional.empty(); | ||
} | ||
}; | ||
|
||
<T> Optional<T> visit(FormattedText.ContentConsumer<T> p_130770_); | ||
|
||
<T> Optional<T> visit(FormattedText.StyledContentConsumer<T> p_130771_, Style p_130772_); | ||
|
||
static FormattedText of(final String p_130776_) { | ||
return new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> p_130787_) { | ||
return p_130787_.accept(p_130776_); | ||
} | ||
|
||
@Override | ||
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> p_130789_, Style p_130790_) { | ||
return p_130789_.accept(p_130790_, p_130776_); | ||
} | ||
}; | ||
} | ||
|
||
static FormattedText of(final String p_130763_, final Style p_130764_) { | ||
return new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> p_130797_) { | ||
return p_130797_.accept(p_130763_); | ||
} | ||
|
||
@Override | ||
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> p_130799_, Style p_130800_) { | ||
return p_130799_.accept(p_130764_.applyTo(p_130800_), p_130763_); | ||
} | ||
}; | ||
} | ||
|
||
static FormattedText composite(FormattedText... p_130774_) { | ||
return composite(ImmutableList.copyOf(p_130774_)); | ||
} | ||
|
||
static FormattedText composite(final List<? extends FormattedText> p_130769_) { | ||
return new FormattedText() { | ||
@Override | ||
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> p_130805_) { | ||
for (FormattedText formattedtext : p_130769_) { | ||
Optional<T> optional = formattedtext.visit(p_130805_); | ||
if (optional.isPresent()) { | ||
return optional; | ||
} | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> p_130807_, Style p_130808_) { | ||
for (FormattedText formattedtext : p_130769_) { | ||
Optional<T> optional = formattedtext.visit(p_130807_, p_130808_); | ||
if (optional.isPresent()) { | ||
return optional; | ||
} | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
}; | ||
} | ||
|
||
default String getString() { | ||
StringBuilder stringbuilder = new StringBuilder(); | ||
this.visit(p_130767_ -> { | ||
stringbuilder.append(p_130767_); | ||
return Optional.empty(); | ||
}); | ||
return stringbuilder.toString(); | ||
} | ||
|
||
public interface ContentConsumer<T> { | ||
Optional<T> accept(String p_130810_); | ||
} | ||
|
||
public interface StyledContentConsumer<T> { | ||
Optional<T> accept(Style p_130811_, String p_130812_); | ||
} | ||
} |
This file contains 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