public final WhileStatement transformContinueOuter(final WhileStatement loop) { final Match m = CONTINUE_OUTER_PATTERN.match(loop); if (!m.success()) { return loop; } final LabelStatement label = (LabelStatement) m.get("label").iterator().next(); label.remove(); loop.getParent().insertChildBefore(loop, label, BlockStatement.STATEMENT_ROLE); return loop; }
public final WhileStatement transformContinueOuter(final WhileStatement loop) { final Match m = CONTINUE_OUTER_PATTERN.match(loop); if (!m.success()) { return loop; } final LabelStatement label = (LabelStatement) m.get("label").iterator().next(); label.remove(); loop.getParent().insertChildBefore(loop, label, BlockStatement.STATEMENT_ROLE); return loop; }
public final WhileStatement transformContinueOuter(final WhileStatement loop) { final Match m = CONTINUE_OUTER_PATTERN.match(loop); if (!m.success()) { return loop; } final LabelStatement label = (LabelStatement) m.get("label").iterator().next(); label.remove(); loop.getParent().insertChildBefore(loop, label, BlockStatement.STATEMENT_ROLE); return loop; }
@Override public Void visitMethodDeclaration(final MethodDeclaration node, final Void p) { final MethodDefinition methodDefinition = node.getUserData(Keys.METHOD_DEFINITION); if (isSwitchMapMethod(methodDefinition)) { final Match m = SWITCH_TABLE_METHOD_BODY.match(node.getBody()); if (m.success()) { final MemberReferenceExpression fieldAccess = first(m.<MemberReferenceExpression>get("fieldAccess")); final FieldReference field = (FieldReference) fieldAccess.getUserData(Keys.MEMBER_REFERENCE); final List<MemberReferenceExpression> enumValues = toList(m.<MemberReferenceExpression>get("enumValue")); final List<PrimitiveExpression> tableValues = toList(m.<PrimitiveExpression>get("tableValue")); assert field != null && tableValues.size() == enumValues.size(); final String key = makeKey(field); SwitchMapInfo info = _switchMaps.get(key); if (info == null) { _switchMaps.put(key, info = new SwitchMapInfo(field)); } info.switchMapMethodDeclaration = node; for (int i = 0; i < enumValues.size(); i++) { final MemberReferenceExpression memberReference = enumValues.get(i); final IdentifierExpression identifier = new IdentifierExpression( Expression.MYSTERY_OFFSET, memberReference.getMemberName()); identifier.putUserData(Keys.MEMBER_REFERENCE, memberReference.getUserData(Keys.MEMBER_REFERENCE)); info.mappings.put((Integer) tableValues.get(i).getValue(), identifier); } } } return super.visitMethodDeclaration(node, p); }
@Override public Void visitMethodDeclaration(final MethodDeclaration node, final Void _) { final MethodDefinition methodDefinition = node.getUserData(Keys.METHOD_DEFINITION); if (isSwitchMapMethod(methodDefinition)) { final Match m = SWITCH_TABLE_METHOD_BODY.match(node.getBody()); if (m.success()) { final MemberReferenceExpression fieldAccess = first(m.<MemberReferenceExpression>get("fieldAccess")); final FieldReference field = (FieldReference) fieldAccess.getUserData(Keys.MEMBER_REFERENCE); final List<MemberReferenceExpression> enumValues = toList(m.<MemberReferenceExpression>get("enumValue")); final List<PrimitiveExpression> tableValues = toList(m.<PrimitiveExpression>get("tableValue")); assert field != null && tableValues.size() == enumValues.size(); final String key = makeKey(field); SwitchMapInfo info = _switchMaps.get(key); if (info == null) { _switchMaps.put(key, info = new SwitchMapInfo(field)); } info.switchMapMethodDeclaration = node; for (int i = 0; i < enumValues.size(); i++) { final MemberReferenceExpression memberReference = enumValues.get(i); final IdentifierExpression identifier = new IdentifierExpression( Expression.MYSTERY_OFFSET, memberReference.getMemberName()); identifier.putUserData(Keys.MEMBER_REFERENCE, memberReference.getUserData(Keys.MEMBER_REFERENCE)); info.mappings.put((Integer) tableValues.get(i).getValue(), identifier); } } } return super.visitMethodDeclaration(node, _); }
@Override public Void visitMethodDeclaration(final MethodDeclaration node, final Void _) { final MethodDefinition methodDefinition = node.getUserData(Keys.METHOD_DEFINITION); if (isSwitchMapMethod(methodDefinition)) { final Match m = SWITCH_TABLE_METHOD_BODY.match(node.getBody()); if (m.success()) { final MemberReferenceExpression fieldAccess = first(m.<MemberReferenceExpression>get("fieldAccess")); final FieldReference field = (FieldReference) fieldAccess.getUserData(Keys.MEMBER_REFERENCE); final List<MemberReferenceExpression> enumValues = toList(m.<MemberReferenceExpression>get("enumValue")); final List<PrimitiveExpression> tableValues = toList(m.<PrimitiveExpression>get("tableValue")); assert field != null && tableValues.size() == enumValues.size(); final String key = makeKey(field); SwitchMapInfo info = _switchMaps.get(key); if (info == null) { _switchMaps.put(key, info = new SwitchMapInfo(field)); } info.switchMapMethodDeclaration = node; for (int i = 0; i < enumValues.size(); i++) { final MemberReferenceExpression memberReference = enumValues.get(i); final IdentifierExpression identifier = new IdentifierExpression( Expression.MYSTERY_OFFSET, memberReference.getMemberName()); identifier.putUserData(Keys.MEMBER_REFERENCE, memberReference.getUserData(Keys.MEMBER_REFERENCE)); info.mappings.put((Integer) tableValues.get(i).getValue(), identifier); } } } return super.visitMethodDeclaration(node, _); }
@Override public Void visitExpressionStatement(final ExpressionStatement node, final Void data) { super.visitExpressionStatement(node, data); // // Remove `super()`-style invocations within constructors, but only if they actually // bind to a constructor. Keep calls to potentially obfuscated methods named 'super'. // if (inConstructor() && !context.getSettings().getShowSyntheticMembers()) { final Match match = EMPTY_SUPER.match(node); if (match.success()) { final AstNode target = firstOrDefault(match.<AstNode>get("target")); final MemberReference member = target.getUserData(Keys.MEMBER_REFERENCE); if (member instanceof MethodReference && ((MethodReference) member).isConstructor()) { node.remove(); } } } return null; } }
@Override public Void visitExpressionStatement(final ExpressionStatement node, final Void data) { super.visitExpressionStatement(node, data); // // Remove `super()`-style invocations within constructors, but only if they actually // bind to a constructor. Keep calls to potentially obfuscated methods named 'super'. // if (inConstructor() && !context.getSettings().getShowSyntheticMembers()) { final Match match = EMPTY_SUPER.match(node); if (match.success()) { final AstNode target = firstOrDefault(match.<AstNode>get("target")); final MemberReference member = target.getUserData(Keys.MEMBER_REFERENCE); if (member instanceof MethodReference && ((MethodReference) member).isConstructor()) { node.remove(); } } } return null; } }
@Override public Void visitExpressionStatement(final ExpressionStatement node, final Void data) { super.visitExpressionStatement(node, data); // // Remove `super()`-style invocations within constructors, but only if they actually // bind to a constructor. Keep calls to potentially obfuscated methods named 'super'. // if (inConstructor() && !context.getSettings().getShowSyntheticMembers()) { final Match match = EMPTY_SUPER.match(node); if (match.success()) { final AstNode target = first(match.<AstNode>get("target")); final MemberReference member = target.getUserData(Keys.MEMBER_REFERENCE); if (member instanceof MethodReference && ((MethodReference) member).isConstructor()) { node.remove(); } } } return null; } }
final Match m = SWITCH_INPUT.match(test); if (m.success()) { final InvocationExpression switchMapMethodCall = first(m.<InvocationExpression>get("switchMapMethodCall")); final MethodReference switchMapMethod = (MethodReference) switchMapMethodCall.getUserData(Keys.MEMBER_REFERENCE);
final Match m = SWITCH_INPUT.match(test); if (m.success()) { final InvocationExpression switchMapMethodCall = first(m.<InvocationExpression>get("switchMapMethodCall")); final MethodReference switchMapMethod = (MethodReference) switchMapMethodCall.getUserData(Keys.MEMBER_REFERENCE);
@Override public Void visitConditionalExpression(final ConditionalExpression node, final Void data) { super.visitConditionalExpression(node, data); final Match m = PATTERN.match(node); if (m.success()) { final InvocationExpression call = firstOrDefault(m.<InvocationExpression>get("methodCall")); final MemberReference method = call != null ? call.getUserData(Keys.MEMBER_REFERENCE) : null; if (method == null || !method.isEquivalentTo(_method)) { return null; } final PrimitiveExpression className = firstOrDefault(m.<PrimitiveExpression>get("class")); if (className != null && className.getValue() instanceof String) { final AstBuilder builder = context.getUserData(Keys.AST_BUILDER); final String dottedName = (String) className.getValue(); final TypeReference classType = _parser.parseTypeDescriptor(dottedName.replace('.', '/')); final ClassOfExpression replacement = new ClassOfExpression( call.getOffset(), builder.convertType(classType) ); node.replaceWith(replacement); } } return null; }
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void data) { final AstNodeCollection<Expression> arguments = node.getArguments(); if (arguments.isEmpty() || arguments.hasSingleElement()) { final Expression firstArgument; if (arguments.hasSingleElement()) { final Match m = _stringBuilderArgumentPattern.match(arguments.firstOrNullObject()); if (!m.success()) { return super.visitObjectCreationExpression(node, data); } firstArgument = firstOrDefault(m.<Expression>get("firstArgument")); } else { firstArgument = null; } final TypeReference typeReference = node.getType().toTypeReference(); if (typeReference != null && isStringBuilder(typeReference)) { convertStringBuilderToConcatenation(node, firstArgument); } } return super.visitObjectCreationExpression(node, data); }
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void data) { final AstNodeCollection<Expression> arguments = node.getArguments(); if (arguments.isEmpty() || arguments.hasSingleElement()) { final Expression firstArgument; if (arguments.hasSingleElement()) { final Match m = _stringBuilderArgumentPattern.match(arguments.firstOrNullObject()); if (!m.success()) { return super.visitObjectCreationExpression(node, data); } firstArgument = firstOrDefault(m.<Expression>get("firstArgument")); } else { firstArgument = null; } final TypeReference typeReference = node.getType().toTypeReference(); if (typeReference != null && isStringBuilder(typeReference)) { convertStringBuilderToConcatenation(node, firstArgument); } } return super.visitObjectCreationExpression(node, data); }
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void data) { final AstNodeCollection<Expression> arguments = node.getArguments(); if (arguments.isEmpty() || arguments.hasSingleElement()) { final Expression firstArgument; if (arguments.hasSingleElement()) { final Match m = _stringBuilderArgumentPattern.match(arguments.firstOrNullObject()); if (!m.success()) { return super.visitObjectCreationExpression(node, data); } firstArgument = firstOrDefault(m.<Expression>get("firstArgument")); } else { firstArgument = null; } final TypeReference typeReference = node.getType().toTypeReference(); if (typeReference != null && isStringBuilder(typeReference)) { convertStringBuilderToConcatenation(node, firstArgument); } } return super.visitObjectCreationExpression(node, data); }
if (match.success()) { final Expression target = (Expression) firstOrDefault(match.get("target")); final FieldReference reference = (FieldReference) target.getUserData(Keys.MEMBER_REFERENCE);
if (!m.success()) { return;
if (!m.success()) { return;
if (!m.success()) { return;
if (match.success()) { final AstType type = first(match.<AstType>get("type"));