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


Java ExceptionInfo类代码示例

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


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

示例1: removeExceptionFromNodeList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void removeExceptionFromNodeList(ExceptionInfo toRemove, List<Type> list) {
  ITypeBinding typeToRemove = toRemove.getTypeBinding();
  for (Iterator<Type> iter = list.iterator(); iter.hasNext(); ) {
    Type currentExcType = iter.next();
    ITypeBinding currentType = currentExcType.resolveBinding();
    /* Maybe remove all subclasses of typeToRemove too.
     * Problem:
     * - B extends A;
     * - A.m() throws IOException, Exception;
     * - B.m() throws IOException, AWTException;
     * Removing Exception should remove AWTException,
     * but NOT remove IOException (or a subclass of JavaModelException). */
    // if (Bindings.isSuperType(typeToRemove, currentType))
    if (currentType == null) continue; // newly added or unresolvable type
    if (Bindings.equals(currentType, typeToRemove)
        || toRemove.getElement().getElementName().equals(currentType.getName())) {
      getASTRewrite().remove(currentExcType, fDescription);
      registerImportRemoveNode(currentExcType);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ChangeSignatureProcessor.java

示例2: addExceptionToNodeList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void addExceptionToNodeList(
    ExceptionInfo exceptionInfo, ListRewrite exceptionListRewrite) {
  String fullyQualified = exceptionInfo.getFullyQualifiedName();
  for (Iterator<? extends ASTNode> iter = exceptionListRewrite.getOriginalList().iterator();
      iter.hasNext(); ) {
    Type exType = (Type) iter.next();
    // XXX: existing superclasses of the added exception are redundant and could be removed
    ITypeBinding typeBinding = exType.resolveBinding();
    if (typeBinding == null) continue; // newly added or unresolvable type
    if (typeBinding.getQualifiedName().equals(fullyQualified)) return; // don't add it again
  }
  String importedType = getImportRewrite().addImport(exceptionInfo.getFullyQualifiedName());
  getImportRemover().registerAddedImport(importedType);
  ASTNode exNode = getASTRewrite().createStringPlaceholder(importedType, ASTNode.SIMPLE_TYPE);
  exceptionListRewrite.insertLast(exNode, fDescription);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:ChangeSignatureProcessor.java

示例3: createExceptionInfoList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private RefactoringStatus createExceptionInfoList() {
	if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
		fExceptionInfos= new ArrayList<ExceptionInfo>(0);
		try {
			ASTNode nameNode= NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
			if (nameNode == null || !(nameNode instanceof Name) || !(nameNode.getParent() instanceof MethodDeclaration))
				return null;
			MethodDeclaration methodDeclaration= (MethodDeclaration) nameNode.getParent();
			List<Type> exceptions= methodDeclaration.thrownExceptionTypes();
			List<ExceptionInfo> result= new ArrayList<ExceptionInfo>(exceptions.size());
			for (int i= 0; i < exceptions.size(); i++) {
				Type type= exceptions.get(i);
				ITypeBinding typeBinding= type.resolveBinding();
				if (typeBinding == null)
					return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
				IJavaElement element= typeBinding.getJavaElement();
				result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
			}
			fExceptionInfos= result;
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ChangeSignatureProcessor.java

示例4: removeExceptionFromNodeList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void removeExceptionFromNodeList(ExceptionInfo toRemove, List<Type> list) {
	ITypeBinding typeToRemove= toRemove.getTypeBinding();
	for (Iterator<Type> iter= list.iterator(); iter.hasNext();) {
		Type currentExcType= iter.next();
		ITypeBinding currentType= currentExcType.resolveBinding();
		/* Maybe remove all subclasses of typeToRemove too.
		 * Problem:
		 * - B extends A;
		 * - A.m() throws IOException, Exception;
		 * - B.m() throws IOException, AWTException;
		 * Removing Exception should remove AWTException,
		 * but NOT remove IOException (or a subclass of JavaModelException). */
		 // if (Bindings.isSuperType(typeToRemove, currentType))
		if (currentType == null)
			continue; // newly added or unresolvable type
		if (Bindings.equals(currentType, typeToRemove) || toRemove.getElement().getElementName().equals(currentType.getName())) {
			getASTRewrite().remove(currentExcType, fDescription);
			registerImportRemoveNode(currentExcType);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:ChangeSignatureProcessor.java

示例5: addExceptionToNodeList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void addExceptionToNodeList(ExceptionInfo exceptionInfo, ListRewrite exceptionListRewrite) {
	String fullyQualified= exceptionInfo.getFullyQualifiedName();
	for (Iterator<? extends ASTNode> iter= exceptionListRewrite.getOriginalList().iterator(); iter.hasNext(); ) {
		Type exType= (Type) iter.next();
		//XXX: existing superclasses of the added exception are redundant and could be removed
		ITypeBinding typeBinding= exType.resolveBinding();
		if (typeBinding == null)
			continue; // newly added or unresolvable type
		if (typeBinding.getQualifiedName().equals(fullyQualified))
			return; // don't add it again
	}
	String importedType= getImportRewrite().addImport(exceptionInfo.getFullyQualifiedName());
	getImportRemover().registerAddedImport(importedType);
	ASTNode exNode= getASTRewrite().createStringPlaceholder(importedType, ASTNode.SIMPLE_TYPE);
	exceptionListRewrite.insertLast(exNode, fDescription);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ChangeSignatureProcessor.java

示例6: createExceptionInfoList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private RefactoringStatus createExceptionInfoList() {
	if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
		fExceptionInfos= new ArrayList<ExceptionInfo>(0);
		try {
			ASTNode nameNode= NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
			if (nameNode == null || !(nameNode instanceof Name) || !(nameNode.getParent() instanceof MethodDeclaration))
				return null;
			MethodDeclaration methodDeclaration= (MethodDeclaration) nameNode.getParent();
			List<Name> exceptions= methodDeclaration.thrownExceptions();
			List<ExceptionInfo> result= new ArrayList<ExceptionInfo>(exceptions.size());
			for (int i= 0; i < exceptions.size(); i++) {
				Name name= exceptions.get(i);
				ITypeBinding typeBinding= name.resolveTypeBinding();
				if (typeBinding == null)
					return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
				IJavaElement element= typeBinding.getJavaElement();
				result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
			}
			fExceptionInfos= result;
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:26,代码来源:ChangeSignatureProcessor.java

示例7: removeExceptionFromNodeList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void removeExceptionFromNodeList(ExceptionInfo toRemove, List<Name> list) {
	ITypeBinding typeToRemove= toRemove.getTypeBinding();
	for (Iterator<Name> iter= list.iterator(); iter.hasNext(); ) {
		Name currentName= iter.next();
		ITypeBinding currentType= currentName.resolveTypeBinding();
		/* Maybe remove all subclasses of typeToRemove too.
		 * Problem:
		 * - B extends A;
		 * - A.m() throws IOException, Exception;
		 * - B.m() throws IOException, AWTException;
		 * Removing Exception should remove AWTException,
		 * but NOT remove IOException (or a subclass of JavaModelException). */
		 // if (Bindings.isSuperType(typeToRemove, currentType))
		if (currentType == null)
			continue; // newly added or unresolvable type
		if (Bindings.equals(currentType, typeToRemove) || toRemove.getElement().getElementName().equals(currentType.getName())) {
			getASTRewrite().remove(currentName, fDescription);
			registerImportRemoveNode(currentName);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:ChangeSignatureProcessor.java

示例8: addExceptionToNodeList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void addExceptionToNodeList(ExceptionInfo exceptionInfo, ListRewrite exceptionListRewrite) {
	String fullyQualified= exceptionInfo.getFullyQualifiedName();
	for (Iterator<? extends ASTNode> iter= exceptionListRewrite.getOriginalList().iterator(); iter.hasNext(); ) {
		Name exName= (Name) iter.next();
		//XXX: existing superclasses of the added exception are redundant and could be removed
		ITypeBinding typeBinding= exName.resolveTypeBinding();
		if (typeBinding == null)
			continue; // newly added or unresolvable type
		if (typeBinding.getQualifiedName().equals(fullyQualified))
			return; // don't add it again
	}
	String importedType= getImportRewrite().addImport(exceptionInfo.getFullyQualifiedName());
	getImportRemover().registerAddedImport(importedType);
	ASTNode exNode= getASTRewrite().createStringPlaceholder(importedType, ASTNode.SIMPLE_NAME);
	exceptionListRewrite.insertLast(exNode, fDescription);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:ChangeSignatureProcessor.java

示例9: areExceptionsSameAsInitial

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private boolean areExceptionsSameAsInitial() {
  for (Iterator<ExceptionInfo> iter = fExceptionInfos.iterator(); iter.hasNext(); ) {
    ExceptionInfo info = iter.next();
    if (!info.isOld()) return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:ChangeSignatureProcessor.java

示例10: createExceptionInfoList

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private RefactoringStatus createExceptionInfoList() {
  if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
    fExceptionInfos = new ArrayList<ExceptionInfo>(0);
    try {
      ASTNode nameNode = NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
      if (nameNode == null
          || !(nameNode instanceof Name)
          || !(nameNode.getParent() instanceof MethodDeclaration)) return null;
      MethodDeclaration methodDeclaration = (MethodDeclaration) nameNode.getParent();
      List<Type> exceptions = methodDeclaration.thrownExceptionTypes();
      List<ExceptionInfo> result = new ArrayList<ExceptionInfo>(exceptions.size());
      for (int i = 0; i < exceptions.size(); i++) {
        Type type = exceptions.get(i);
        ITypeBinding typeBinding = type.resolveBinding();
        if (typeBinding == null)
          return RefactoringStatus.createFatalErrorStatus(
              RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
        IJavaElement element = typeBinding.getJavaElement();
        result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
      }
      fExceptionInfos = result;
    } catch (JavaModelException e) {
      JavaPlugin.log(e);
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:ChangeSignatureProcessor.java

示例11: getMethodThrows

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private String getMethodThrows() {
  final String throwsString = " throws "; // $NON-NLS-1$
  StringBuffer buff = new StringBuffer(throwsString);
  for (Iterator<ExceptionInfo> iter = fExceptionInfos.iterator(); iter.hasNext(); ) {
    ExceptionInfo info = iter.next();
    if (!info.isDeleted()) {
      buff.append(info.getElement().getElementName());
      buff.append(", "); // $NON-NLS-1$
    }
  }
  if (buff.length() == throwsString.length()) return ""; // $NON-NLS-1$
  buff.delete(buff.length() - 2, buff.length());
  return buff.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:ChangeSignatureProcessor.java

示例12: getOldMethodThrows

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private String getOldMethodThrows() {
  final String throwsString = " throws "; // $NON-NLS-1$
  StringBuffer buff = new StringBuffer(throwsString);
  for (Iterator<ExceptionInfo> iter = fExceptionInfos.iterator(); iter.hasNext(); ) {
    ExceptionInfo info = iter.next();
    if (!info.isAdded()) {
      buff.append(info.getElement().getElementName());
      buff.append(", "); // $NON-NLS-1$
    }
  }
  if (buff.length() == throwsString.length()) return ""; // $NON-NLS-1$
  buff.delete(buff.length() - 2, buff.length());
  return buff.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:ChangeSignatureProcessor.java

示例13: changeExceptions

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private void changeExceptions() {
  for (Iterator<ExceptionInfo> iter = fExceptionInfos.iterator(); iter.hasNext(); ) {
    ExceptionInfo info = iter.next();
    if (info.isOld()) continue;
    if (info.isDeleted()) removeExceptionFromNodeList(info, fMethDecl.thrownExceptionTypes());
    else
      addExceptionToNodeList(
          info,
          getASTRewrite()
              .getListRewrite(fMethDecl, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:ChangeSignatureProcessor.java

示例14: areExceptionsSameAsInitial

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private boolean areExceptionsSameAsInitial() {
	for (Iterator<ExceptionInfo> iter= fExceptionInfos.iterator(); iter.hasNext();) {
		ExceptionInfo info= iter.next();
		if (! info.isOld())
			return false;
	}
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ChangeSignatureProcessor.java

示例15: getMethodThrows

import org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo; //导入依赖的package包/类
private String getMethodThrows() {
	final String throwsString= " throws "; //$NON-NLS-1$
	StringBuffer buff= new StringBuffer(throwsString);
	for (Iterator<ExceptionInfo> iter= fExceptionInfos.iterator(); iter.hasNext(); ) {
		ExceptionInfo info= iter.next();
		if (! info.isDeleted()) {
			buff.append(info.getElement().getElementName());
			buff.append(", "); //$NON-NLS-1$
		}
	}
	if (buff.length() == throwsString.length())
		return ""; //$NON-NLS-1$
	buff.delete(buff.length() - 2, buff.length());
	return buff.toString();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ChangeSignatureProcessor.java


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