IDEA-169534 Decompiler overuses ternary operation

This commit is contained in:
Egor.Ushakov
2017-04-03 17:15:31 +03:00
parent 024978848c
commit e09e303e71
5 changed files with 166 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -854,6 +854,11 @@ public class SimplifyExprentsHelper {
return false;
}
// avoid flattening to 'iff' if any of the branches is an 'iff' already
if (isIff(ifex.getValue()) || isIff(elseex.getValue())) {
return false;
}
List<Exprent> data = new ArrayList<>();
data.addAll(stif.getFirst().getExprents());
@@ -880,6 +885,10 @@ public class SimplifyExprentsHelper {
return false;
}
private static boolean isIff(Exprent exp) {
return exp.type == Exprent.EXPRENT_FUNCTION && ((FunctionExprent) exp).getFuncType() == FunctionExprent.FUNCTION_IIF;
}
static {
class14Builder.parse(
"statement type:if iftype:if exprsize:-1\n" +