当前位置: 首页>>代码示例>>Java>>正文


Java DoStatement.BODY_PROPERTY属性代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.DoStatement.BODY_PROPERTY属性的典型用法代码示例。如果您正苦于以下问题:Java DoStatement.BODY_PROPERTY属性的具体用法?Java DoStatement.BODY_PROPERTY怎么用?Java DoStatement.BODY_PROPERTY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.core.dom.DoStatement的用法示例。


在下文中一共展示了DoStatement.BODY_PROPERTY属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isControlStatementBody

/**
 * Returns true if a node at a given location is a body of a control statement. Such body nodes are
 * interesting as when replacing them, it has to be evaluates if a Block is needed instead.
 * E.g. <code> if (x) do(); -> if (x) { do1(); do2() } </code>
 *
 * @param locationInParent Location of the body node
 * @return Returns true if the location is a body node location of a control statement.
 */
public static boolean isControlStatementBody(StructuralPropertyDescriptor locationInParent) {
	return locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
			|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
			|| locationInParent == ForStatement.BODY_PROPERTY
			|| locationInParent == EnhancedForStatement.BODY_PROPERTY
			|| locationInParent == WhileStatement.BODY_PROPERTY
			|| locationInParent == DoStatement.BODY_PROPERTY;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:ASTNodes.java

示例2: isDangligIf

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;
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:SourceProvider.java

示例3: insertAt

private void insertAt(ASTNode target, Statement declaration) {
  ASTRewrite rewrite = fCURewrite.getASTRewrite();
  TextEditGroup groupDescription =
      fCURewrite.createGroupDescription(
          RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable);

  ASTNode parent = target.getParent();
  StructuralPropertyDescriptor locationInParent = target.getLocationInParent();
  while (locationInParent != Block.STATEMENTS_PROPERTY
      && locationInParent != SwitchStatement.STATEMENTS_PROPERTY) {
    if (locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
        || locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
        || locationInParent == ForStatement.BODY_PROPERTY
        || locationInParent == EnhancedForStatement.BODY_PROPERTY
        || locationInParent == DoStatement.BODY_PROPERTY
        || locationInParent == WhileStatement.BODY_PROPERTY) {
      // create intermediate block if target was the body property of a control statement:
      Block replacement = rewrite.getAST().newBlock();
      ListRewrite replacementRewrite =
          rewrite.getListRewrite(replacement, Block.STATEMENTS_PROPERTY);
      replacementRewrite.insertFirst(declaration, null);
      replacementRewrite.insertLast(rewrite.createMoveTarget(target), null);
      rewrite.replace(target, replacement, groupDescription);
      return;
    }
    target = parent;
    parent = parent.getParent();
    locationInParent = target.getLocationInParent();
  }
  ListRewrite listRewrite =
      rewrite.getListRewrite(parent, (ChildListPropertyDescriptor) locationInParent);
  listRewrite.insertBefore(declaration, target, groupDescription);
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:ExtractTempRefactoring.java

示例4: isDangligIf

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;
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:SourceProvider.java

示例5: insertAt

private void insertAt(ASTNode target, Statement declaration) {
	ASTRewrite rewrite= fCURewrite.getASTRewrite();
	TextEditGroup groupDescription= fCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable);

	ASTNode parent= target.getParent();
	StructuralPropertyDescriptor locationInParent= target.getLocationInParent();
	while (locationInParent != Block.STATEMENTS_PROPERTY && locationInParent != SwitchStatement.STATEMENTS_PROPERTY) {
		if (locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
				|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
				|| locationInParent == ForStatement.BODY_PROPERTY
				|| locationInParent == EnhancedForStatement.BODY_PROPERTY
				|| locationInParent == DoStatement.BODY_PROPERTY
				|| locationInParent == WhileStatement.BODY_PROPERTY) {
			// create intermediate block if target was the body property of a control statement:
			Block replacement= rewrite.getAST().newBlock();
			ListRewrite replacementRewrite= rewrite.getListRewrite(replacement, Block.STATEMENTS_PROPERTY);
			replacementRewrite.insertFirst(declaration, null);
			replacementRewrite.insertLast(rewrite.createMoveTarget(target), null);
			rewrite.replace(target, replacement, groupDescription);
			return;
		}
		target= parent;
		parent= parent.getParent();
		locationInParent= target.getLocationInParent();
	}
	ListRewrite listRewrite= rewrite.getListRewrite(parent, (ChildListPropertyDescriptor)locationInParent);
	listRewrite.insertBefore(declaration, target, groupDescription);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:ExtractTempRefactoring.java

示例6: isControlStatementBody

/**
 * Returns true if a node at a given location is a body of a control statement. Such body nodes are
 * interesting as when replacing them, it has to be evaluates if a Block is needed instead.
 * E.g. <code> if (x) do(); -> if (x) { do1(); do2() } </code>
 *
 * @param locationInParent Location of the body node
 * @return Returns true if the location is a body node location of a control statement.
 */
public static boolean isControlStatementBody(StructuralPropertyDescriptor locationInParent) {
	return locationInParent == IfStatement.THEN_STATEMENT_PROPERTY
		|| locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY
		|| locationInParent == ForStatement.BODY_PROPERTY
		|| locationInParent == EnhancedForStatement.BODY_PROPERTY
		|| locationInParent == WhileStatement.BODY_PROPERTY
		|| locationInParent == DoStatement.BODY_PROPERTY;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ASTNodes.java


注:本文中的org.eclipse.jdt.core.dom.DoStatement.BODY_PROPERTY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。