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


Java IfStatement.getElseStatement方法代码示例

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


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

示例1: isSingleControlStatementWithoutBlock

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private boolean isSingleControlStatementWithoutBlock() {
  List<Statement> statements = fDeclaration.getBody().statements();
  int size = statements.size();
  if (size != 1) return false;
  Statement statement = statements.get(size - 1);
  int nodeType = statement.getNodeType();
  if (nodeType == ASTNode.IF_STATEMENT) {
    IfStatement ifStatement = (IfStatement) statement;
    return !(ifStatement.getThenStatement() instanceof Block)
        && !(ifStatement.getElseStatement() instanceof Block);
  } else if (nodeType == ASTNode.FOR_STATEMENT) {
    return !(((ForStatement) statement).getBody() instanceof Block);
  } else if (nodeType == ASTNode.WHILE_STATEMENT) {
    return !(((WhileStatement) statement).getBody() instanceof Block);
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:SourceProvider.java

示例2: preNext

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public boolean preNext(IfStatement curElement) {

	Statement thenStatement = curElement.getThenStatement();
	Statement elseStatement = curElement.getElseStatement();
	Expression condition = curElement.getExpression();

	if (elseStatement == null) {
		compiler.println("opt " + condition.toString());
		return true;
	} else {
		compiler.println("alt " + condition.toString());
		thenStatement.accept(compiler);
		if (elseStatement instanceof IfStatement) {
			processAltStatement((IfStatement) elseStatement);
		} else {
			compiler.println("else");
			elseStatement.accept(compiler);
		}
		return false;
	}
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:23,代码来源:OptAltFragment.java

示例3: processAltStatement

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private void processAltStatement(IfStatement statement) {
	Statement thenStatement = statement.getThenStatement();
	Statement elseStatement = statement.getElseStatement();
	Expression condition = statement.getExpression();

	compiler.println("else " + condition.toString());
	thenStatement.accept(compiler);
	if (elseStatement != null) {
		if (elseStatement instanceof IfStatement) {
			processAltStatement((IfStatement) elseStatement);
		} else {
			compiler.println("else");
			elseStatement.accept(compiler);
		}
	}
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:17,代码来源:OptAltFragment.java

示例4: isSingleControlStatementWithoutBlock

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private boolean isSingleControlStatementWithoutBlock() {
	List<Statement> statements= fDeclaration.getBody().statements();
	int size= statements.size();
	if (size != 1)
		return false;
	Statement statement= statements.get(size - 1);
	int nodeType= statement.getNodeType();
	if (nodeType == ASTNode.IF_STATEMENT) {
		IfStatement ifStatement= (IfStatement) statement;
		return !(ifStatement.getThenStatement() instanceof Block)
			&& !(ifStatement.getElseStatement() instanceof Block);
	} else if (nodeType == ASTNode.FOR_STATEMENT) {
		return !(((ForStatement)statement).getBody() instanceof Block);
	} else if (nodeType == ASTNode.WHILE_STATEMENT) {
		return !(((WhileStatement)statement).getBody() instanceof Block);
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:SourceProvider.java

示例5: getAddElseProposals

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private static boolean getAddElseProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
	if (!(node instanceof IfStatement)) {
		return false;
	}
	IfStatement ifStatement= (IfStatement) node;
	if (ifStatement.getElseStatement() != null) {
		return false;
	}

	if (resultingCollections == null) {
		return true;
	}

	AST ast= node.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);
	Block body= ast.newBlock();

	rewrite.set(ifStatement, IfStatement.ELSE_STATEMENT_PROPERTY, body, null);

	String label= CorrectionMessages.QuickAssistProcessor_addelseblock_description;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_ELSE_BLOCK, image);
	resultingCollections.add(proposal);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:QuickAssistProcessor.java

示例6: getAddElseProposals

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
private static boolean getAddElseProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
	if (!(node instanceof IfStatement)) {
		return false;
	}
	IfStatement ifStatement= (IfStatement) node;
	if (ifStatement.getElseStatement() != null) {
		return false;
	}

	if (resultingCollections == null) {
		return true;
	}

	AST ast= node.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);
	Block body= ast.newBlock();

	rewrite.set(ifStatement, IfStatement.ELSE_STATEMENT_PROPERTY, body, null);

	String label= CorrectionMessages.QuickAssistProcessor_addelseblock_description;
	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
	ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
	resultingCollections.add(proposal);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:QuickAssistProcessor.java

示例7: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
/**
 * 'if(' expression ') {' thenStatement '}' ['else {' elseStatement '}']
 */
@Override
public boolean visit(final IfStatement node)
{
  final int lineNo = lineStart(node);
  // dependence id
  final LineKind kind = node.getElseStatement() == null ? LK_IF_THEN : LK_IF_THEN_ELSE;
  // new dependence
  final IResolvedLine rd = createDependence(kind, lineNo, mdg.parent());
  // append control dependences
  appendDependences(rd, node.getExpression(), null, false);
  // recursively append "then" dependences
  appendRecursive(lineNo, rd, node.getThenStatement());
  // recursively append "else" dependences
  if (node.getElseStatement() != null)
  {
    appendRecursive(lineNo, rd, node.getElseStatement());
  }
  // do not visit children
  return false;
}
 
开发者ID:UBPL,项目名称:jive,代码行数:24,代码来源:StatementVisitor.java

示例8: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public boolean visit(IfStatement node) {
	//System.out.println("Found: " + node.getClass());
	print("if (");
	node.getExpression().accept(this);
	println(") {");
	indent++;
	node.getThenStatement().accept(this);
	indent--;
	
	if (node.getElseStatement() == null) {
		println("}");
	} else {
		if (node.getElseStatement() instanceof IfStatement) {
			print("} else ");
			node.getElseStatement().accept(this);
		} else {
			println("} else {");
			indent++;
			node.getElseStatement().accept(this);
			indent--;
			println("}");
		}
	}
	return false;
}
 
开发者ID:mrmonday,项目名称:j2d,代码行数:27,代码来源:J2dVisitor.java

示例9: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
public boolean visit(IfStatement node) {
	Statement thenStmt = node.getThenStatement();
	Statement elseStmt = node.getElseStatement();
	Expression condExpr = node.getExpression();

	String thenStr = (thenStmt.toString()).replace('\n', ' ');
	String elseStr = "";

	if (elseStmt != null) {
		elseStr = (elseStmt.toString()).replace('\n', ' ');
	}

	if (mtbStack.isEmpty()) // not part of a method
		return true;

	IMethodBinding mtb = mtbStack.peek();
	String methodStr = getQualifiedName(mtb);
	String condStr = condExpr.toString();

	condStr = edit_str(condStr);
	thenStr = edit_str(thenStr);
	elseStr = edit_str(elseStr);

	// make conditional fact
	try {
		facts.add(Fact.makeConditionalFact(condStr, thenStr, elseStr,
				methodStr));
	} catch (Exception e) {
		System.err.println("Cannot resolve conditional \""
				+ condExpr.toString() + "\"");
		System.out.println("ifStmt: " + thenStr);
		System.out.println("elseStmt: " + elseStr);
		System.err.println(e.getMessage());
	}
	return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:37,代码来源:ASTVisitorAtomicChange.java

示例10: endVisit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public void endVisit(IfStatement node) {
	if (skipNode(node)) {
		return;
	}
	Statement thenPart = node.getThenStatement();
	Statement elsePart = node.getElseStatement();
	if ((thenPart != null && fSelection.coveredBy(thenPart)) || (elsePart != null && fSelection.coveredBy(elsePart))) {
		GenericSequentialFlowInfo info = createSequential();
		setFlowInfo(node, info);
		endVisitConditional(info, node.getExpression(), new ASTNode[] { thenPart, elsePart });
	} else {
		super.endVisit(node);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:InputFlowAnalyzer.java

示例11: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
public boolean visit(IfStatement node)
{
  Statement thenStmt = node.getThenStatement();
  Statement elseStmt = node.getElseStatement();
  Expression condExpr = node.getExpression();
  
  String thenStr = thenStmt.toString().replace('\n', ' ');
  String elseStr = "";
  if (elseStmt != null) {
    elseStr = elseStmt.toString().replace('\n', ' ');
  }
  if (this.mtbStack.isEmpty()) {
    return true;
  }
  IMethodBinding mtb = (IMethodBinding)this.mtbStack.peek();
  String methodStr = getQualifiedName(mtb);
  String condStr = condExpr.toString();
  
  condStr = edit_str(condStr);
  thenStr = edit_str(thenStr);
  elseStr = edit_str(elseStr);
  try
  {
    this.facts.add(Fact.makeConditionalFact(condStr, thenStr, elseStr, 
      methodStr));
  }
  catch (Exception e)
  {
    System.err.println("Cannot resolve conditional \"" + 
      condExpr.toString() + "\"");
    System.out.println("ifStmt: " + thenStr);
    System.out.println("elseStmt: " + elseStr);
    System.err.println(e.getMessage());
  }
  return true;
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:37,代码来源:ASTVisitorAtomicChange.java

示例12: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public boolean visit(IfStatement statement) {
  handle(statement.getThenStatement(), IfStatement.THEN_STATEMENT_PROPERTY);

  Statement elseStatement = statement.getElseStatement();
  if (elseStatement != null && !(elseStatement instanceof IfStatement)) {
    handle(elseStatement, IfStatement.ELSE_STATEMENT_PROPERTY);
  }

  return super.visit(statement);
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:ControlStatementsFix.java

示例13: endVisit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public void endVisit(IfStatement node) {
  if (skipNode(node)) return;
  Statement thenPart = node.getThenStatement();
  Statement elsePart = node.getElseStatement();
  if ((thenPart != null && fSelection.coveredBy(thenPart))
      || (elsePart != null && fSelection.coveredBy(elsePart))) {
    GenericSequentialFlowInfo info = createSequential();
    setFlowInfo(node, info);
    endVisitConditional(info, node.getExpression(), new ASTNode[] {thenPart, elsePart});
  } else {
    super.endVisit(node);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:InputFlowAnalyzer.java

示例14: endVisit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public void endVisit(IfStatement node) {
	if (skipNode(node))
		return;
	Statement thenPart= node.getThenStatement();
	Statement elsePart= node.getElseStatement();
	if ((thenPart != null && fSelection.coveredBy(thenPart)) ||
			(elsePart != null && fSelection.coveredBy(elsePart))) {
		GenericSequentialFlowInfo info= createSequential();
		setFlowInfo(node, info);
		endVisitConditional(info, node.getExpression(), new ASTNode[] {thenPart, elsePart});
	} else {
		super.endVisit(node);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:InputFlowAnalyzer.java

示例15: visit

import org.eclipse.jdt.core.dom.IfStatement; //导入方法依赖的package包/类
@Override
public boolean visit(IfStatement statement) {
	handle(statement.getThenStatement(), IfStatement.THEN_STATEMENT_PROPERTY);

	Statement elseStatement= statement.getElseStatement();
	if (elseStatement != null && !(elseStatement instanceof IfStatement)) {
		handle(elseStatement, IfStatement.ELSE_STATEMENT_PROPERTY);
	}

	return super.visit(statement);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ControlStatementsFix.java


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