Java 类org.eclipse.jdt.core.dom.ChildPropertyDescriptor 实例源码

项目:eclipse-optimus    文件:ASTArrayTypeHelper.java   
public static ChildPropertyDescriptor getArrayTypeElementPropertyDescriptor(ArrayType node) {
    List<?> propertyDescriptors = ArrayType.propertyDescriptors(node.getAST().apiLevel());
    for (Object propertyDescriptor : propertyDescriptors) {
        if (propertyDescriptor instanceof ChildPropertyDescriptor) {
            ChildPropertyDescriptor childListPropertyDescriptor = (ChildPropertyDescriptor) propertyDescriptor;
            if (DESCRIPTOR_NAME_AST4.equals(childListPropertyDescriptor.getId())) {
                if (OptimusLogger.logger.isLoggable(Level.FINE)) {
                    OptimusLogger.logger.fine(String.format(RETURNED_DESCRIPTOR_MESSAGE, DESCRIPTOR_NAME_AST4));
                }
                return childListPropertyDescriptor;
            } else if (DESCRIPTOR_NAME_AST8.equals(childListPropertyDescriptor.getId())) {
                if (OptimusLogger.logger.isLoggable(Level.FINE)) {
                    OptimusLogger.logger.fine(String.format(RETURNED_DESCRIPTOR_MESSAGE, DESCRIPTOR_NAME_AST8));
                }
                return childListPropertyDescriptor;
            }
        }
    }
    return null;
}
项目:che    文件:ControlStatementsFix.java   
private void handle(Statement body, ChildPropertyDescriptor bodyProperty) {
  if ((body.getFlags() & ASTNode.RECOVERED) != 0) return;
  Statement parent = (Statement) body.getParent();
  if ((parent.getFlags() & ASTNode.RECOVERED) != 0) return;

  if (fRemoveUnnecessaryBlocksOnlyWhenReturnOrThrow) {
    if (!(body instanceof Block)) {
      if (body.getNodeType() != ASTNode.IF_STATEMENT
          && body.getNodeType() != ASTNode.RETURN_STATEMENT
          && body.getNodeType() != ASTNode.THROW_STATEMENT) {
        fResult.add(new AddBlockOperation(bodyProperty, body, parent));
      }
    } else {
      if (RemoveBlockOperation.satisfiesCleanUpPrecondition(parent, bodyProperty, true)) {
        fResult.add(new RemoveBlockOperation(parent, bodyProperty));
      }
    }
  } else if (fFindControlStatementsWithoutBlock) {
    if (!(body instanceof Block)) {
      fResult.add(new AddBlockOperation(bodyProperty, body, parent));
    }
  } else if (fRemoveUnnecessaryBlocks) {
    if (RemoveBlockOperation.satisfiesCleanUpPrecondition(parent, bodyProperty, false)) {
      fResult.add(new RemoveBlockOperation(parent, bodyProperty));
    }
  }
}
项目:che    文件:DelegateFieldCreator.java   
@Override
protected ChildPropertyDescriptor getBodyProperty() {
  return VariableDeclarationFragment.INITIALIZER_PROPERTY;
}
项目:che    文件:SourceProvider.java   
public boolean isDangligIf() {
  List<Statement> statements = fDeclaration.getBody().statements();
  if (statements.size() != 1) return false;

  ASTNode p = statements.get(0);

  while (true) {
    if (p instanceof IfStatement) {
      return ((IfStatement) p).getElseStatement() == null;
    } else {

      ChildPropertyDescriptor childD;
      if (p instanceof WhileStatement) {
        childD = WhileStatement.BODY_PROPERTY;
      } else if (p instanceof ForStatement) {
        childD = ForStatement.BODY_PROPERTY;
      } else if (p instanceof EnhancedForStatement) {
        childD = EnhancedForStatement.BODY_PROPERTY;
      } else if (p instanceof DoStatement) {
        childD = DoStatement.BODY_PROPERTY;
      } else if (p instanceof LabeledStatement) {
        childD = LabeledStatement.BODY_PROPERTY;
      } else {
        return false;
      }
      Statement body = (Statement) p.getStructuralProperty(childD);
      if (body instanceof Block) {
        return false;
      } else {
        p = body;
      }
    }
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:SourceProvider.java   
public boolean isDangligIf() {
    List<Statement> statements= fDeclaration.getBody().statements();
    if (statements.size() != 1)
        return false;

    ASTNode p= statements.get(0);

    while (true) {
        if (p instanceof IfStatement) {
            return ((IfStatement) p).getElseStatement() == null;
        } else {

            ChildPropertyDescriptor childD;
            if (p instanceof WhileStatement) {
                childD= WhileStatement.BODY_PROPERTY;
            } else if (p instanceof ForStatement) {
                childD= ForStatement.BODY_PROPERTY;
            } else if (p instanceof EnhancedForStatement) {
                childD= EnhancedForStatement.BODY_PROPERTY;
            } else if (p instanceof DoStatement) {
                childD= DoStatement.BODY_PROPERTY;
            } else if (p instanceof LabeledStatement) {
                childD= LabeledStatement.BODY_PROPERTY;
            } else {
                return false;
            }
            Statement body= (Statement) p.getStructuralProperty(childD);
            if (body instanceof Block) {
                return false;
            } else {
                p= body;
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ControlStatementsFix.java   
private void handle(Statement body, ChildPropertyDescriptor bodyProperty) {
    if ((body.getFlags() & ASTNode.RECOVERED) != 0)
        return;
    Statement parent= (Statement)body.getParent();
    if ((parent.getFlags() & ASTNode.RECOVERED) != 0)
        return;

    if (fRemoveUnnecessaryBlocksOnlyWhenReturnOrThrow) {
        if (!(body instanceof Block)) {
            if (body.getNodeType() != ASTNode.IF_STATEMENT && body.getNodeType() != ASTNode.RETURN_STATEMENT && body.getNodeType() != ASTNode.THROW_STATEMENT) {
                fResult.add(new AddBlockOperation(bodyProperty, body, parent));
            }
        } else {
            if (RemoveBlockOperation.satisfiesCleanUpPrecondition(parent, bodyProperty, true)) {
                fResult.add(new RemoveBlockOperation(parent, bodyProperty));
            }
        }
    } else if (fFindControlStatementsWithoutBlock) {
        if (!(body instanceof Block)) {
            fResult.add(new AddBlockOperation(bodyProperty, body, parent));
        }
    } else if (fRemoveUnnecessaryBlocks) {
        if (RemoveBlockOperation.satisfiesCleanUpPrecondition(parent, bodyProperty, false)) {
            fResult.add(new RemoveBlockOperation(parent, bodyProperty));
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SourceProvider.java   
public boolean isDangligIf() {
    List<Statement> statements= fDeclaration.getBody().statements();
    if (statements.size() != 1)
        return false;

    ASTNode p= statements.get(0);

    while (true) {
        if (p instanceof IfStatement) {
            return ((IfStatement) p).getElseStatement() == null;
        } else {

            ChildPropertyDescriptor childD;
            if (p instanceof WhileStatement) {
                childD= WhileStatement.BODY_PROPERTY;
            } else if (p instanceof ForStatement) {
                childD= ForStatement.BODY_PROPERTY;
            } else if (p instanceof EnhancedForStatement) {
                childD= EnhancedForStatement.BODY_PROPERTY;
            } else if (p instanceof DoStatement) {
                childD= DoStatement.BODY_PROPERTY;
            } else if (p instanceof LabeledStatement) {
                childD= LabeledStatement.BODY_PROPERTY;
            } else {
                return false;
            }
            Statement body= (Statement) p.getStructuralProperty(childD);
            if (body instanceof Block) {
                return false;
            } else {
                p= body;
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ControlStatementsFix.java   
private void handle(Statement body, ChildPropertyDescriptor bodyProperty) {
    if ((body.getFlags() & ASTNode.RECOVERED) != 0)
        return;
    Statement parent= (Statement)body.getParent();
    if ((parent.getFlags() & ASTNode.RECOVERED) != 0)
        return;

    if (fRemoveUnnecessaryBlocksOnlyWhenReturnOrThrow) {
        if (!(body instanceof Block)) {
            if (body.getNodeType() != ASTNode.IF_STATEMENT && body.getNodeType() != ASTNode.RETURN_STATEMENT && body.getNodeType() != ASTNode.THROW_STATEMENT) {
                fResult.add(new AddBlockOperation(bodyProperty, body, parent));
            }
        } else {
            if (RemoveBlockOperation.satisfiesCleanUpPrecondition(parent, bodyProperty, true)) {
                fResult.add(new RemoveBlockOperation(parent, bodyProperty));
            }
        }
    } else if (fFindControlStatementsWithoutBlock) {
        if (!(body instanceof Block)) {
            fResult.add(new AddBlockOperation(bodyProperty, body, parent));
        }
    } else if (fRemoveUnnecessaryBlocks) {
        if (RemoveBlockOperation.satisfiesCleanUpPrecondition(parent, bodyProperty, false)) {
            fResult.add(new RemoveBlockOperation(parent, bodyProperty));
        }
    }
}
项目:eclipse-optimus    文件:ASTArrayTypeHelper.java   
public static Type getComponentType(ArrayType arrayType) {
    ChildPropertyDescriptor cpd = ASTArrayTypeHelper.getArrayTypeElementPropertyDescriptor(arrayType);
    if (cpd != null) {
        Object structuralProperty = arrayType.getStructuralProperty(cpd);
        if (structuralProperty instanceof Type) {
            return (Type) structuralProperty;
        }
    }
    return null;
}
项目:che    文件:ControlStatementsFix.java   
public AddBlockOperation(
    ChildPropertyDescriptor bodyProperty, Statement body, Statement controlStatement) {
  fBodyProperty = bodyProperty;
  fBody = body;
  fControlStatement = controlStatement;
}
项目:che    文件:ControlStatementsFix.java   
public RemoveBlockOperation(Statement controlStatement, ChildPropertyDescriptor child) {
  fStatement = controlStatement;
  fChild = child;
}
项目:che    文件:ControlStatementsFix.java   
public static boolean satisfiesCleanUpPrecondition(
    Statement controlStatement,
    ChildPropertyDescriptor childDescriptor,
    boolean onlyReturnAndThrows) {
  return satisfiesPrecondition(controlStatement, childDescriptor, onlyReturnAndThrows, true);
}
项目:che    文件:ControlStatementsFix.java   
public static boolean satisfiesQuickAssistPrecondition(
    Statement controlStatement, ChildPropertyDescriptor childDescriptor) {
  return satisfiesPrecondition(controlStatement, childDescriptor, false, false);
}
项目:che    文件:ControlStatementsFix.java   
private static boolean satisfiesPrecondition(
    Statement controlStatement,
    ChildPropertyDescriptor childDescriptor,
    boolean onlyReturnAndThrows,
    boolean cleanUpCheck) {
  Object child = controlStatement.getStructuralProperty(childDescriptor);

  if (!(child instanceof Block)) return false;

  Block block = (Block) child;
  List<Statement> list = block.statements();
  if (list.size() != 1) return false;

  ASTNode singleStatement = list.get(0);

  if (onlyReturnAndThrows)
    if (!(singleStatement instanceof ReturnStatement)
        && !(singleStatement instanceof ThrowStatement)) return false;

  if (controlStatement instanceof IfStatement) {
    // if (true) {
    //  while (true)
    //   if (false)
    //    ;
    // } else
    //   ;

    if (((IfStatement) controlStatement).getThenStatement() != child)
      return true; // can always remove blocks in else part

    IfStatement ifStatement = (IfStatement) controlStatement;
    if (ifStatement.getElseStatement() == null)
      return true; // can always remove if no else part

    return !hasUnblockedIf((Statement) singleStatement, onlyReturnAndThrows, cleanUpCheck);
  } else {
    // if (true)
    // while (true) {
    //  if (false)
    //   ;
    // }
    // else
    // ;
    if (!hasUnblockedIf((Statement) singleStatement, onlyReturnAndThrows, cleanUpCheck))
      return true;

    ASTNode currentChild = controlStatement;
    ASTNode parent = currentChild.getParent();
    while (true) {
      Statement body = null;
      if (parent instanceof IfStatement) {
        body = ((IfStatement) parent).getThenStatement();
        if (body == currentChild
            && ((IfStatement) parent).getElseStatement()
                != null) // ->currentChild is an unblocked then part
        return false;
      } else if (parent instanceof WhileStatement) {
        body = ((WhileStatement) parent).getBody();
      } else if (parent instanceof DoStatement) {
        body = ((DoStatement) parent).getBody();
      } else if (parent instanceof ForStatement) {
        body = ((ForStatement) parent).getBody();
      } else if (parent instanceof EnhancedForStatement) {
        body = ((EnhancedForStatement) parent).getBody();
      } else {
        return true;
      }
      if (body != currentChild) // ->parents child is a block
      return true;

      currentChild = parent;
      parent = currentChild.getParent();
    }
  }
}
项目:che    文件:DelegateMethodCreator.java   
@Override
protected ChildPropertyDescriptor getJavaDocProperty() {
  return MethodDeclaration.JAVADOC_PROPERTY;
}
项目:che    文件:DelegateMethodCreator.java   
@Override
protected ChildPropertyDescriptor getBodyProperty() {
  return MethodDeclaration.BODY_PROPERTY;
}
项目:che    文件:DelegateFieldCreator.java   
@Override
protected ChildPropertyDescriptor getJavaDocProperty() {
  return FieldDeclaration.JAVADOC_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion    文件:DelegateMethodCreator.java   
@Override
protected ChildPropertyDescriptor getJavaDocProperty() {
    return MethodDeclaration.JAVADOC_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion    文件:DelegateMethodCreator.java   
@Override
protected ChildPropertyDescriptor getBodyProperty() {
    return MethodDeclaration.BODY_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion    文件:DelegateFieldCreator.java   
@Override
protected ChildPropertyDescriptor getJavaDocProperty() {
    return FieldDeclaration.JAVADOC_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion    文件:DelegateFieldCreator.java   
@Override
protected ChildPropertyDescriptor getBodyProperty() {
    return VariableDeclarationFragment.INITIALIZER_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion    文件:ControlStatementsFix.java   
public AddBlockOperation(ChildPropertyDescriptor bodyProperty, Statement body, Statement controlStatement) {
    fBodyProperty= bodyProperty;
    fBody= body;
    fControlStatement= controlStatement;
}
项目:Eclipse-Postfix-Code-Completion    文件:ControlStatementsFix.java   
public RemoveBlockOperation(Statement controlStatement, ChildPropertyDescriptor child) {
    fStatement= controlStatement;
    fChild= child;
}
项目:Eclipse-Postfix-Code-Completion    文件:ControlStatementsFix.java   
public static boolean satisfiesCleanUpPrecondition(Statement controlStatement, ChildPropertyDescriptor childDescriptor, boolean onlyReturnAndThrows) {
    return satisfiesPrecondition(controlStatement, childDescriptor, onlyReturnAndThrows, true);
}
项目:Eclipse-Postfix-Code-Completion    文件:ControlStatementsFix.java   
public static boolean satisfiesQuickAssistPrecondition(Statement controlStatement, ChildPropertyDescriptor childDescriptor) {
    return satisfiesPrecondition(controlStatement, childDescriptor, false, false);
}
项目:Eclipse-Postfix-Code-Completion    文件:ControlStatementsFix.java   
private static boolean satisfiesPrecondition(Statement controlStatement, ChildPropertyDescriptor childDescriptor, boolean onlyReturnAndThrows, boolean cleanUpCheck) {
    Object child= controlStatement.getStructuralProperty(childDescriptor);

    if (!(child instanceof Block))
        return false;

    Block block= (Block)child;
    List<Statement> list= block.statements();
    if (list.size() != 1)
        return false;

    ASTNode singleStatement= list.get(0);

    if (onlyReturnAndThrows)
        if (!(singleStatement instanceof ReturnStatement) && !(singleStatement instanceof ThrowStatement))
            return false;

    if (controlStatement instanceof IfStatement) {
        // if (true) {
        //  while (true)
        //   if (false)
        //    ;
        // } else
        //   ;

        if (((IfStatement)controlStatement).getThenStatement() != child)
            return true;//can always remove blocks in else part

        IfStatement ifStatement= (IfStatement)controlStatement;
        if (ifStatement.getElseStatement() == null)
            return true;//can always remove if no else part

        return !hasUnblockedIf((Statement)singleStatement, onlyReturnAndThrows, cleanUpCheck);
    } else {
        //if (true)
        // while (true) {
        //  if (false)
        //   ;
        // }
        //else
        // ;
        if (!hasUnblockedIf((Statement)singleStatement, onlyReturnAndThrows, cleanUpCheck))
            return true;

        ASTNode currentChild= controlStatement;
        ASTNode parent= currentChild.getParent();
        while (true) {
            Statement body= null;
            if (parent instanceof IfStatement) {
                body= ((IfStatement)parent).getThenStatement();
                if (body == currentChild && ((IfStatement)parent).getElseStatement() != null)//->currentChild is an unblocked then part
                    return false;
            } else if (parent instanceof WhileStatement) {
                body= ((WhileStatement)parent).getBody();
            } else if (parent instanceof DoStatement) {
                body= ((DoStatement)parent).getBody();
            } else if (parent instanceof ForStatement) {
                body= ((ForStatement)parent).getBody();
            } else if (parent instanceof EnhancedForStatement) {
                body= ((EnhancedForStatement)parent).getBody();
            } else {
                return true;
            }
            if (body != currentChild)//->parents child is a block
                return true;

            currentChild= parent;
            parent= currentChild.getParent();
        }
    }
}
项目:ChangeScribe    文件:StereotypedType.java   
public ChildPropertyDescriptor getJavadocDescriptor() {
    return TypeDeclaration.JAVADOC_PROPERTY;
}
项目:ChangeScribe    文件:StereotypedMethod.java   
public ChildPropertyDescriptor getJavadocDescriptor() {
    return MethodDeclaration.JAVADOC_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DelegateMethodCreator.java   
@Override
protected ChildPropertyDescriptor getJavaDocProperty() {
    return MethodDeclaration.JAVADOC_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DelegateMethodCreator.java   
@Override
protected ChildPropertyDescriptor getBodyProperty() {
    return MethodDeclaration.BODY_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DelegateFieldCreator.java   
@Override
protected ChildPropertyDescriptor getJavaDocProperty() {
    return FieldDeclaration.JAVADOC_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DelegateFieldCreator.java   
@Override
protected ChildPropertyDescriptor getBodyProperty() {
    return VariableDeclarationFragment.INITIALIZER_PROPERTY;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ControlStatementsFix.java   
public AddBlockOperation(ChildPropertyDescriptor bodyProperty, Statement body, Statement controlStatement) {
    fBodyProperty= bodyProperty;
    fBody= body;
    fControlStatement= controlStatement;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ControlStatementsFix.java   
public RemoveBlockOperation(Statement controlStatement, ChildPropertyDescriptor child) {
    fStatement= controlStatement;
    fChild= child;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ControlStatementsFix.java   
public static boolean satisfiesCleanUpPrecondition(Statement controlStatement, ChildPropertyDescriptor childDescriptor, boolean onlyReturnAndThrows) {
    return satisfiesPrecondition(controlStatement, childDescriptor, onlyReturnAndThrows, true);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ControlStatementsFix.java   
public static boolean satisfiesQuickAssistPrecondition(Statement controlStatement, ChildPropertyDescriptor childDescriptor) {
    return satisfiesPrecondition(controlStatement, childDescriptor, false, false);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ControlStatementsFix.java   
private static boolean satisfiesPrecondition(Statement controlStatement, ChildPropertyDescriptor childDescriptor, boolean onlyReturnAndThrows, boolean cleanUpCheck) {
    Object child= controlStatement.getStructuralProperty(childDescriptor);

    if (!(child instanceof Block))
        return false;

    Block block= (Block)child;
    List<Statement> list= block.statements();
    if (list.size() != 1)
        return false;

    ASTNode singleStatement= list.get(0);

    if (onlyReturnAndThrows)
        if (!(singleStatement instanceof ReturnStatement) && !(singleStatement instanceof ThrowStatement))
            return false;

    if (controlStatement instanceof IfStatement) {
        // if (true) {
        //  while (true)
        //   if (false)
        //    ;
        // } else
        //   ;

        if (((IfStatement)controlStatement).getThenStatement() != child)
            return true;//can always remove blocks in else part

        IfStatement ifStatement= (IfStatement)controlStatement;
        if (ifStatement.getElseStatement() == null)
            return true;//can always remove if no else part

        return !hasUnblockedIf((Statement)singleStatement, onlyReturnAndThrows, cleanUpCheck);
    } else {
        //if (true)
        // while (true) {
        //  if (false)
        //   ;
        // }
        //else
        // ;
        if (!hasUnblockedIf((Statement)singleStatement, onlyReturnAndThrows, cleanUpCheck))
            return true;

        ASTNode currentChild= controlStatement;
        ASTNode parent= currentChild.getParent();
        while (true) {
            Statement body= null;
            if (parent instanceof IfStatement) {
                body= ((IfStatement)parent).getThenStatement();
                if (body == currentChild && ((IfStatement)parent).getElseStatement() != null)//->currentChild is an unblocked then part
                    return false;
            } else if (parent instanceof WhileStatement) {
                body= ((WhileStatement)parent).getBody();
            } else if (parent instanceof DoStatement) {
                body= ((DoStatement)parent).getBody();
            } else if (parent instanceof ForStatement) {
                body= ((ForStatement)parent).getBody();
            } else if (parent instanceof EnhancedForStatement) {
                body= ((EnhancedForStatement)parent).getBody();
            } else {
                return true;
            }
            if (body != currentChild)//->parents child is a block
                return true;

            currentChild= parent;
            parent= currentChild.getParent();
        }
    }
}
项目:eclipse-optimus    文件:EnumConstantMerger.java   
@Override
protected ChildPropertyDescriptor getJavadocPropertyDescriptor() {
    return JAVADOC_PROPERTY;
}
项目:eclipse-optimus    文件:EnumMerger.java   
@Override
protected ChildPropertyDescriptor getJavadocPropertyDescriptor() {
    return JAVADOC_PROPERTY;
}
项目:eclipse-optimus    文件:TypeMerger.java   
@Override
protected ChildPropertyDescriptor getJavadocPropertyDescriptor() {
    return JAVADOC_PROPERTY;
}