private static boolean hasNestedBlocks(final AstNode node) { return node.getChildByRole(Roles.EMBEDDED_STATEMENT) instanceof BlockStatement || node instanceof TryCatchStatement || node instanceof CatchClause || node instanceof SwitchSection; }
private static boolean hasNestedBlocks(final AstNode node) { return node.getChildByRole(Roles.EMBEDDED_STATEMENT) instanceof BlockStatement || node instanceof TryCatchStatement || node instanceof CatchClause || node instanceof SwitchSection; }
private static boolean hasNestedBlocks(final AstNode node) { return node.getChildByRole(Roles.EMBEDDED_STATEMENT) instanceof BlockStatement || node instanceof TryCatchStatement || node instanceof CatchClause || node instanceof SwitchSection; }
private static boolean hasNestedBlocks(final AstNode node) { return node.getChildByRole(Roles.EMBEDDED_STATEMENT) instanceof BlockStatement || node instanceof TryCatchStatement || node instanceof CatchClause || node instanceof SwitchSection; }
private static boolean hasNestedBlocks(final AstNode node) { return node.getChildByRole(Roles.EMBEDDED_STATEMENT) instanceof BlockStatement || node instanceof TryCatchStatement || node instanceof CatchClause || node instanceof SwitchSection; }
private static boolean hasNestedBlocks(final AstNode node) { return node.getChildByRole(Roles.EMBEDDED_STATEMENT) instanceof BlockStatement || node instanceof TryCatchStatement || node instanceof CatchClause || node instanceof SwitchSection; }
protected final <T extends AstNode> void setChildByRole(final Role<T> role, final T newChild) { final T oldChild = getChildByRole(role); if (oldChild.isNull()) { addChild(newChild, role); } else { oldChild.replaceWith(newChild); } }
protected final <T extends AstNode> void setChildByRole(final Role<T> role, final T newChild) { final T oldChild = getChildByRole(role); if (oldChild.isNull()) { addChild(newChild, role); } else { oldChild.replaceWith(newChild); } }
protected final <T extends AstNode> void setChildByRole(final Role<T> role, final T newChild) { final T oldChild = getChildByRole(role); if (oldChild.isNull()) { addChild(newChild, role); } else { oldChild.replaceWith(newChild); } }
private void redirectLabels(final AstNode node, final String labelName, final String nextLabel) { for (final AstNode n : node.getDescendantsAndSelf()) { if (AstNode.isUnconditionalBranch(n)) { final Identifier label = n.getChildByRole(Roles.IDENTIFIER); if (!label.isNull() && StringUtilities.equals(label.getName(), labelName)) { label.setName(nextLabel); } } } } }
private void redirectLabels(final AstNode node, final String labelName, final String nextLabel) { for (final AstNode n : node.getDescendantsAndSelf()) { if (AstNode.isUnconditionalBranch(n)) { final Identifier label = n.getChildByRole(Roles.IDENTIFIER); if (!label.isNull() && StringUtilities.equals(label.getName(), labelName)) { label.setName(nextLabel); } } } } }
private void redirectLabels(final AstNode node, final String labelName, final String nextLabel) { for (final AstNode n : node.getDescendantsAndSelf()) { if (AstNode.isUnconditionalBranch(n)) { final Identifier label = n.getChildByRole(Roles.IDENTIFIER); if (!label.isNull() && StringUtilities.equals(label.getName(), labelName)) { label.setName(nextLabel); } } } } }
@Override public final boolean matches(final INode other, final Match match) { if (other instanceof IdentifierExpression && !any(((IdentifierExpression) other).getTypeArguments())) { final INode referenced = lastOrDefault(match.get(_referencedGroupName)); return referenced instanceof AstNode && StringUtilities.equals( ((IdentifierExpression) other).getIdentifier(), ((AstNode) referenced).getChildByRole(Roles.IDENTIFIER).getName() ); } return false; } }
@Override public final boolean matches(final INode other, final Match match) { if (other instanceof IdentifierExpression && !any(((IdentifierExpression) other).getTypeArguments())) { final INode referenced = lastOrDefault(match.get(_referencedGroupName)); return referenced instanceof AstNode && StringUtilities.equals( ((IdentifierExpression) other).getIdentifier(), ((AstNode) referenced).getChildByRole(Roles.IDENTIFIER).getName() ); } return false; } }
@Override public final boolean matches(final INode other, final Match match) { if (other instanceof IdentifierExpression && !any(((IdentifierExpression) other).getTypeArguments())) { final INode referenced = lastOrDefault(match.get(_referencedGroupName)); return referenced instanceof AstNode && StringUtilities.equals( ((IdentifierExpression) other).getIdentifier(), ((AstNode) referenced).getChildByRole(Roles.IDENTIFIER).getName() ); } return false; } }
@Override public final boolean matches(final INode other, final Match match) { if (other instanceof AstNode) { final INode lastInGroup = lastOrDefault(match.get(_referencedGroupName)); if (lastInGroup instanceof VariableDeclarationStatement) { final VariableDeclarationStatement referenced = (VariableDeclarationStatement) lastInGroup; final AstNodeCollection<VariableInitializer> variables = referenced.getVariables(); return variables.hasSingleElement() && matchString( variables.firstOrNullObject().getName(), ((AstNode) other).getChildByRole(Roles.IDENTIFIER).getName() ); } } return false; } }
@Override public final boolean matches(final INode other, final Match match) { if (other instanceof AstNode) { final INode lastInGroup = lastOrDefault(match.get(_referencedGroupName)); if (lastInGroup instanceof VariableDeclarationStatement) { final VariableDeclarationStatement referenced = (VariableDeclarationStatement) lastInGroup; final AstNodeCollection<VariableInitializer> variables = referenced.getVariables(); return variables.hasSingleElement() && matchString( variables.firstOrNullObject().getName(), ((AstNode) other).getChildByRole(Roles.IDENTIFIER).getName() ); } } return false; } }
@Override public final boolean matches(final INode other, final Match match) { if (other instanceof AstNode) { final INode lastInGroup = lastOrDefault(match.get(_referencedGroupName)); if (lastInGroup instanceof VariableDeclarationStatement) { final VariableDeclarationStatement referenced = (VariableDeclarationStatement) lastInGroup; final AstNodeCollection<VariableInitializer> variables = referenced.getVariables(); return variables.hasSingleElement() && matchString( variables.firstOrNullObject().getName(), ((AstNode) other).getChildByRole(Roles.IDENTIFIER).getName() ); } } return false; } }
node.getChildByRole(Roles.IDENTIFIER).isNull()) {
node.getChildByRole(Roles.IDENTIFIER).isNull()) {