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


Java CatchClause.getException方法代码示例

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


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

示例1: endVisit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public void endVisit(TryStatement node) {
	ASTNode firstSelectedNode = getFirstSelectedNode();
	if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
		if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
			invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
		} else {
			List<CatchClause> catchClauses = node.catchClauses();
			for (Iterator<CatchClause> iterator = catchClauses.iterator(); iterator.hasNext();) {
				CatchClause element = iterator.next();
				if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
					invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
				} else if (element.getException() == firstSelectedNode) {
					invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
				}
			}
		}
	}
	super.endVisit(node);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:StatementAnalyzer.java

示例2: create

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public ITypeConstraint[] create(CatchClause node) {
  SingleVariableDeclaration exception = node.getException();
  ConstraintVariable nameVariable =
      fConstraintVariableFactory.makeExpressionOrTypeVariable(exception.getName(), getContext());

  ITypeConstraint[] defines =
      fTypeConstraintFactory.createDefinesConstraint(
          nameVariable, fConstraintVariableFactory.makeTypeVariable(exception.getType()));

  ITypeBinding throwable =
      node.getAST().resolveWellKnownType("java.lang.Throwable"); // $NON-NLS-1$
  ITypeConstraint[] catchBound =
      fTypeConstraintFactory.createSubtypeConstraint(
          nameVariable, fConstraintVariableFactory.makeRawBindingVariable(throwable));

  ArrayList<ITypeConstraint> result = new ArrayList<ITypeConstraint>();
  result.addAll(Arrays.asList(defines));
  result.addAll(Arrays.asList(catchBound));
  return result.toArray(new ITypeConstraint[result.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:FullConstraintCreator.java

示例3: endVisit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public void endVisit(TryStatement node) {
  ASTNode firstSelectedNode = getFirstSelectedNode();
  if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
    if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
      invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
    } else {
      List<CatchClause> catchClauses = node.catchClauses();
      for (Iterator<CatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
        CatchClause element = iterator.next();
        if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
          invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
        } else if (element.getException() == firstSelectedNode) {
          invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
        }
      }
    }
  }
  super.endVisit(node);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:StatementAnalyzer.java

示例4: create

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public ITypeConstraint[] create(CatchClause node) {
	SingleVariableDeclaration exception= node.getException();
	ConstraintVariable nameVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(exception.getName(), getContext());

	ITypeConstraint[] defines= fTypeConstraintFactory.createDefinesConstraint(
			nameVariable,
			fConstraintVariableFactory.makeTypeVariable(exception.getType()));

	ITypeBinding throwable= node.getAST().resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
	ITypeConstraint[] catchBound= fTypeConstraintFactory.createSubtypeConstraint(
			nameVariable,
			fConstraintVariableFactory.makeRawBindingVariable(throwable));

	ArrayList<ITypeConstraint> result= new ArrayList<ITypeConstraint>();
	result.addAll(Arrays.asList(defines));
	result.addAll(Arrays.asList(catchBound));
	return result.toArray(new ITypeConstraint[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:FullConstraintCreator.java

示例5: endVisit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public void endVisit(TryStatement node) {
	ASTNode firstSelectedNode= getFirstSelectedNode();
	if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
		if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
			invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
		} else {
			List<CatchClause> catchClauses= node.catchClauses();
			for (Iterator<CatchClause> iterator= catchClauses.iterator(); iterator.hasNext();) {
				CatchClause element= iterator.next();
				if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
					invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
				} else if (element.getException() == firstSelectedNode) {
					invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
				}
			}
		}
	}
	super.endVisit(node);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:StatementAnalyzer.java

示例6: visit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public boolean visit(CatchClause node) {
	SingleVariableDeclaration param = node.getException();

	ITypeBinding type = param.resolveBinding().getType();
	if (!hasAnnotation(param.modifiers())) {
		if (!type.isPrimitive()) {
			if (type.getName().compareTo("String") != 0) {
				setParameterAnnotation(rewrite, param, "lent");
			}
		}
	}

	return super.visit(node);
}
 
开发者ID:aroog,项目名称:code,代码行数:16,代码来源:DefaultingVisitor.java

示例7: visit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public boolean visit(CatchClause node) {
	
	SingleVariableDeclaration param = node.getException();

	ITypeBinding type = param.resolveBinding().getType();
	SingleMemberAnnotation annot = hasAnnotation(param.modifiers());
	if (annot != null) {
		ListRewrite paramRewrite = rewrite.getListRewrite(param, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
		paramRewrite.remove(annot, null);
	}

	
	return super.visit(node);
}
 
开发者ID:aroog,项目名称:code,代码行数:16,代码来源:RemoveAnnotationsVisitor.java

示例8: visit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public boolean visit(CatchClause node) {
  SingleVariableDeclaration exception = node.getException();
  IVariableBinding variableBinding = exception.resolveBinding();
  VariableVariable2 cv = fTCModel.makeDeclaredVariableVariable(variableBinding, fCU);
  setConstraintVariable(exception, cv);
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:InferTypeArgumentsConstraintCreator.java

示例9: endVisit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public final void endVisit(final CatchClause node) {
	final SingleVariableDeclaration declaration= node.getException();
	if (declaration != null) {
		final ConstraintVariable2 descendant= (ConstraintVariable2) declaration.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
		if (descendant != null) {
			final ITypeBinding binding= node.getAST().resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
			if (binding != null) {
				final ConstraintVariable2 ancestor= fModel.createImmutableTypeVariable(binding);
				if (ancestor != null)
					fModel.createSubtypeConstraint(descendant, ancestor);
			}
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:SuperTypeConstraintsCreator.java

示例10: visit

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
@Override
public boolean visit(CatchClause node) {
	SingleVariableDeclaration exception= node.getException();
	IVariableBinding variableBinding= exception.resolveBinding();
	VariableVariable2 cv= fTCModel.makeDeclaredVariableVariable(variableBinding, fCU);
	setConstraintVariable(exception, cv);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:InferTypeArgumentsConstraintCreator.java

示例11: CatchClauseWrapper

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
CatchClauseWrapper(CatchClause catchClause, int indentationLevel, Applicable applicable) {
    super(indentationLevel, applicable);
    ofNullable(catchClause.getBody()).ifPresent(block -> body.addAll(block.statements()));
    exception = catchClause.getException();
    applicable.applyFeaturesToStatements(body);
}
 
开发者ID:opaluchlukasz,项目名称:junit2spock,代码行数:7,代码来源:TryStatementWrapper.java

示例12: getUnrollMultiCatchProposals

import org.eclipse.jdt.core.dom.CatchClause; //导入方法依赖的package包/类
private static boolean getUnrollMultiCatchProposals(IInvocationContext context, ASTNode covering, Collection<ICommandAccess> resultingCollections) {
	if (!JavaModelUtil.is17OrHigher(context.getCompilationUnit().getJavaProject()))
		return false;

	CatchClause catchClause= (CatchClause) ASTResolving.findAncestor(covering, ASTNode.CATCH_CLAUSE);
	if (catchClause == null) {
		return false;
	}

	Statement statement= ASTResolving.findParentStatement(covering);
	if (statement != catchClause.getParent() && statement != catchClause.getBody()) {
		return false; // selection is in a statement inside the body
	}

	Type type1= catchClause.getException().getType();
	Type selectedMultiCatchType= null;
	if (type1.isUnionType() && covering instanceof Name) {
		Name topMostName= ASTNodes.getTopMostName((Name) covering);
		ASTNode parent= topMostName.getParent();
		if (parent instanceof SimpleType || parent instanceof NameQualifiedType) {
			selectedMultiCatchType= (Type) parent;
		}
	}
	if (selectedMultiCatchType != null)
		return false;

	SingleVariableDeclaration singleVariableDeclaration= catchClause.getException();
	Type type= singleVariableDeclaration.getType();
	if (!(type instanceof UnionType))
		return false;

	if (resultingCollections == null)
		return true;

	AST ast= covering.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);

	TryStatement tryStatement= (TryStatement) catchClause.getParent();
	ListRewrite listRewrite= rewrite.getListRewrite(tryStatement, TryStatement.CATCH_CLAUSES_PROPERTY);

	UnionType unionType= (UnionType) type;
	List<Type> types= unionType.types();
	for (int i= types.size() - 1; i >= 0; i--) {
		Type type2= types.get(i);
		CatchClause newCatchClause= ast.newCatchClause();

		SingleVariableDeclaration newSingleVariableDeclaration= ast.newSingleVariableDeclaration();
		newSingleVariableDeclaration.setType((Type) rewrite.createCopyTarget(type2));
		newSingleVariableDeclaration.setName((SimpleName) rewrite.createCopyTarget(singleVariableDeclaration.getName()));
		newCatchClause.setException(newSingleVariableDeclaration);
		setCatchClauseBody(newCatchClause, rewrite, catchClause);
		listRewrite.insertAfter(newCatchClause, catchClause, null);
	}
	rewrite.remove(catchClause, null);

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


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