Skip to content

Commit

Permalink
Fix MixinChecker accidentally skipping mixin classes where the target…
Browse files Browse the repository at this point in the history
… does not exist (Hendrix-Shen#121)

Signed-off-by: Hendrix-Shen <[email protected]>
  • Loading branch information
Hendrix-Shen authored Oct 29, 2024
1 parent c964c2d commit 5b4e21a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,14 @@ public ValueContainer<DependencyCheckResult> checkAsRequire() {
I18n.tr("magiclib.dependency.result.platform.require.fail",
this.platformType, currentPlatformType)));
case PREDICATE:
if (this.predicate == null) {
return ValueContainer.of(new DependencyCheckResult(true, I18n.tr(
"magiclib.dependency.result.predicate.target_obj_not_exist")));
}

boolean testResult = this.predicate.test(this.obj);
return ValueContainer.of(new DependencyCheckResult(testResult, I18n.tr(
"magiclib.dependency.result.predicate.message",
"magiclib.dependency.result.predicate.test_result",
this.predicate.getClass().getName(), testResult)));
}

Expand Down Expand Up @@ -232,9 +237,14 @@ public ValueContainer<DependencyCheckResult> checkAsConflict() {
return ValueContainer.of(new DependencyCheckResult(true,
I18n.tr("magiclib.dependency.result.platform.conflict.success", this.platformType)));
case PREDICATE:
if (this.predicate == null) {
return ValueContainer.of(new DependencyCheckResult(false, I18n.tr(
"magiclib.dependency.result.predicate.target_obj_not_exist")));
}

boolean testResult = this.predicate.test(this.obj);
return ValueContainer.of(new DependencyCheckResult(!testResult,
I18n.tr("magiclib.dependency.result.predicate.message",
I18n.tr("magiclib.dependency.result.predicate.test_result",
this.predicate.getClass().getName(), testResult)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean check(String targetClassName, String mixinClassName) {
ClassNode targetClassNode = MixinUtil.getClassNode(targetClassName);
ClassNode mixinClassNode = MixinUtil.getClassNode(mixinClassName);

if (targetClassNode == null || mixinClassNode == null) {
if (mixinClassNode == null) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ magiclib:
fail: Running on unexpected platform, expected %1$s, but found %2$s.
success: "Running on expected platform: %1$s."
predicate:
message: Predicate %s test result = %s
test_result: Predicate %1$s test result = %2$s
target_obj_not_exist: Predicate %1$s test target does not exist, skipped.
misc:
version_type:
beta: Public Beta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ magiclib:
fail: "运行在非预期平台, 预期: %1$s, 实际: %2$s."
success: "运行在预期平台: %1$s."
predicate:
message: 谓词 %s 测试结果 = %s
test_result: 谓词 %1$s 测试结果 = %2$s
target_obj_not_exist: 谓词 %1$s 测试目标不存在, 已跳过.
misc:
version_type:
beta: 公共测试版
Expand Down

0 comments on commit 5b4e21a

Please sign in to comment.