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


Java ThrowStatement类代码示例

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


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

示例1: locationNeedsParentheses

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
	if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
		// e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ...
		return false;
	}
	if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
			|| locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
			|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY
			|| locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
			|| locationInParent == ForStatement.EXPRESSION_PROPERTY
			|| locationInParent == WhileStatement.EXPRESSION_PROPERTY
			|| locationInParent == DoStatement.EXPRESSION_PROPERTY
			|| locationInParent == AssertStatement.EXPRESSION_PROPERTY
			|| locationInParent == AssertStatement.MESSAGE_PROPERTY
			|| locationInParent == IfStatement.EXPRESSION_PROPERTY
			|| locationInParent == SwitchStatement.EXPRESSION_PROPERTY
			|| locationInParent == SwitchCase.EXPRESSION_PROPERTY
			|| locationInParent == ArrayAccess.INDEX_PROPERTY
			|| locationInParent == ThrowStatement.EXPRESSION_PROPERTY
			|| locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
			|| locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:NecessaryParenthesesChecker.java

示例2: locationNeedsParentheses

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) {
  if (locationInParent instanceof ChildListPropertyDescriptor
      && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
    // e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation
    // ...
    return false;
  }
  if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY
      || locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY
      || locationInParent == ReturnStatement.EXPRESSION_PROPERTY
      || locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY
      || locationInParent == ForStatement.EXPRESSION_PROPERTY
      || locationInParent == WhileStatement.EXPRESSION_PROPERTY
      || locationInParent == DoStatement.EXPRESSION_PROPERTY
      || locationInParent == AssertStatement.EXPRESSION_PROPERTY
      || locationInParent == AssertStatement.MESSAGE_PROPERTY
      || locationInParent == IfStatement.EXPRESSION_PROPERTY
      || locationInParent == SwitchStatement.EXPRESSION_PROPERTY
      || locationInParent == SwitchCase.EXPRESSION_PROPERTY
      || locationInParent == ArrayAccess.INDEX_PROPERTY
      || locationInParent == ThrowStatement.EXPRESSION_PROPERTY
      || locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY
      || locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
    return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:NecessaryParenthesesChecker.java

示例3: endVisit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void endVisit(ClassInstanceCreation instanceCreation) {
	if (instanceCreation.getParent() instanceof ThrowStatement) {
		logger.warn("Ignoring throw statements!");
		return;
	}
	List<?> paramTypes = Arrays.asList(instanceCreation.resolveConstructorBinding().getParameterTypes());
	List<?> paramValues = instanceCreation.arguments();
	Constructor<?> constructor = retrieveConstructor(instanceCreation.getType(),
	                                                 paramTypes, paramValues);
	List<VariableReference> params = convertParams(instanceCreation.arguments(),
	                                               paramTypes);
	VariableReference retVal = retrieveVariableReference(instanceCreation, null);
	retVal.setOriginalCode(instanceCreation.toString());
	ConstructorStatement statement = new ValidConstructorStatement(
	        testCase.getReference(), constructor, retVal, params);
	testCase.addStatement(statement);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:20,代码来源:TestExtractingVisitor.java

示例4: endVisit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public void endVisit(ThrowStatement node) {
	if (skipNode(node)) {
		return;
	}
	ThrowFlowInfo info = createThrow();
	setFlowInfo(node, info);
	Expression expression = node.getExpression();
	info.merge(getFlowInfo(expression), fFlowContext);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:FlowAnalyzer.java

示例5: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
	ITypeBinding exception = node.getExpression().resolveTypeBinding();
	if (exception == null) {
		return true;
	}

	addException(exception, node.getAST());
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:ExceptionAnalyzer.java

示例6: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
	ITypeBinding exception = node.getExpression().resolveTypeBinding();
	if (!isSelected(node) || exception == null || Bindings.isRuntimeException(exception)) {
		return true;
	}

	addException(exception, node.getAST());
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:ExceptionAnalyzer.java

示例7: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
  ITypeBinding exception = node.getExpression().resolveTypeBinding();
  if (exception == null) // Safety net for null bindings when compiling fails.
  return true;

  addException(exception, node.getAST());
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:ExceptionAnalyzer.java

示例8: create

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public ITypeConstraint[] create(ThrowStatement node) {
  ConstraintVariable nameVariable =
      fConstraintVariableFactory.makeExpressionOrTypeVariable(node.getExpression(), getContext());
  ITypeBinding throwable =
      node.getAST().resolveWellKnownType("java.lang.Throwable"); // $NON-NLS-1$
  return fTypeConstraintFactory.createSubtypeConstraint(
      nameVariable, fConstraintVariableFactory.makeRawBindingVariable(throwable));
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:FullConstraintCreator.java

示例9: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
  ITypeBinding exception = node.getExpression().resolveTypeBinding();
  if (!isSelected(node)
      || exception == null
      || Bindings.isRuntimeException(
          exception)) // Safety net for null bindings when compiling fails.
  return true;

  addException(exception, node.getAST());
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:ExceptionAnalyzer.java

示例10: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
	ITypeBinding thrownExceptionType = node.getExpression().resolveTypeBinding();
	try {
		handleException(node, thrownExceptionType);
	} catch (JavaModelException e) {
		throw new RuntimeException(e);
	}

	return super.visit(node);
}
 
开发者ID:mdarefin,项目名称:Convert-For-Each-Loop-to-Lambda-Expression-Eclipse-Plugin,代码行数:12,代码来源:EnhancedForStatementVisitor.java

示例11: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
	ITypeBinding binding = node.getExpression().resolveTypeBinding();
	if (binding != null) {
		ThrownException thrownException = new ThrownException();
		Type thrownType = importer.ensureTypeFromTypeBinding(binding);
		thrownException.setExceptionClass((com.feenk.jdt2famix.model.famix.Class) thrownType);
		thrownException.setDefiningMethod((Method) importer.topOfContainerStack());
		importer.repository().add(thrownException);
	}
	return true;
}
 
开发者ID:feenkcom,项目名称:jdt2famix,代码行数:13,代码来源:AstVisitor.java

示例12: endVisit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public void endVisit(ThrowStatement node) {
	if (skipNode(node))
		return;
	ThrowFlowInfo info= createThrow();
	setFlowInfo(node, info);
	Expression expression= node.getExpression();
	info.merge(getFlowInfo(expression), fFlowContext);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:FlowAnalyzer.java

示例13: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
	ITypeBinding exception= node.getExpression().resolveTypeBinding();
	if (exception == null)		// Safety net for null bindings when compiling fails.
		return true;

	addException(exception, node.getAST());
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ExceptionAnalyzer.java

示例14: create

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public ITypeConstraint[] create(ThrowStatement node) {
	ConstraintVariable nameVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(node.getExpression(), getContext());
	ITypeBinding throwable= node.getAST().resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
	return fTypeConstraintFactory.createSubtypeConstraint(
			nameVariable,
			fConstraintVariableFactory.makeRawBindingVariable(throwable));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:FullConstraintCreator.java

示例15: visit

import org.eclipse.jdt.core.dom.ThrowStatement; //导入依赖的package包/类
@Override
public boolean visit(ThrowStatement node) {
	ITypeBinding exception= node.getExpression().resolveTypeBinding();
	if (!isSelected(node) || exception == null || Bindings.isRuntimeException(exception)) // Safety net for null bindings when compiling fails.
		return true;

	addException(exception, node.getAST());
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:ExceptionAnalyzer.java


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