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


Java JavaElementUtil.getAllConstructors方法代码示例

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


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

示例1: createSearchPattern

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private static SearchPattern createSearchPattern(IType type) throws JavaModelException {
  SearchPattern pattern =
      SearchPattern.createPattern(
          type, IJavaSearchConstants.ALL_OCCURRENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
  IMethod[] constructors = JavaElementUtil.getAllConstructors(type);
  if (constructors.length == 0) return pattern;
  SearchPattern constructorDeclarationPattern =
      RefactoringSearchEngine.createOrPattern(constructors, IJavaSearchConstants.DECLARATIONS);
  return SearchPattern.createOrPattern(pattern, constructorDeclarationPattern);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:CreateCopyOfCompilationUnitChange.java

示例2: getParameterNamesOfAllConstructors

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private static String[] getParameterNamesOfAllConstructors(IType type) throws JavaModelException {
	IMethod[] constructors= JavaElementUtil.getAllConstructors(type);
	Set<String> result= new HashSet<String>();
	for (int i= 0; i < constructors.length; i++) {
		result.addAll(Arrays.asList(constructors[i].getParameterNames()));
	}
	return result.toArray(new String[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:MoveInnerToTopRefactoring.java

示例3: getAllSuperConstructorInvocations

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private static Collection<SearchMatch> getAllSuperConstructorInvocations(IType type) throws JavaModelException {
	IMethod[] constructors= JavaElementUtil.getAllConstructors(type);
	CompilationUnit cuNode= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(type.getCompilationUnit(), false);
	List<SearchMatch> result= new ArrayList<SearchMatch>(constructors.length);
	for (int i= 0; i < constructors.length; i++) {
		ASTNode superCall= getSuperConstructorCallNode(constructors[i], cuNode);
		if (superCall != null)
			result.add(createSearchResult(superCall, constructors[i]));
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ConstructorReferenceFinder.java

示例4: createSearchPattern

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private static SearchPattern createSearchPattern(IType type) throws JavaModelException {
	SearchPattern pattern= SearchPattern.createPattern(type, IJavaSearchConstants.ALL_OCCURRENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
	IMethod[] constructors= JavaElementUtil.getAllConstructors(type);
	if (constructors.length == 0)
		return pattern;
	SearchPattern constructorDeclarationPattern= RefactoringSearchEngine.createOrPattern(constructors, IJavaSearchConstants.DECLARATIONS);
	return SearchPattern.createOrPattern(pattern, constructorDeclarationPattern);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:CreateCopyOfCompilationUnitChange.java

示例5: getRoots

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private MethodWrapper[] getRoots(IMember[] members, boolean callers) {
	ArrayList<MethodWrapper> roots= new ArrayList<MethodWrapper>();
   	for (int i= 0; i < members.length; i++) {
		IMember member= members[i];
		if (member instanceof IType) {
			IType type= (IType) member;
			try {
				if (! type.isAnonymous()) {
					IMethod[] constructors= JavaElementUtil.getAllConstructors(type);
					if (constructors.length == 0) {
						addRoot(member, roots, callers); // IType is a stand-in for the non-existing default constructor
					} else {
						for (int j= 0; j < constructors.length; j++) {
							IMethod constructor= constructors[j];
							addRoot(constructor, roots, callers);
						}
					}
				} else {
					addRoot(member, roots, callers);
				}
			} catch (JavaModelException e) {
				JavaPlugin.log(e);
			}
		} else {
			addRoot(member, roots, callers);
		}
	}
   	return roots.toArray(new MethodWrapper[roots.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:CallHierarchy.java

示例6: createCompilationUnitRewrite

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private void createCompilationUnitRewrite(final ITypeBinding[] parameters, final CompilationUnitRewrite targetRewrite, final Map<ICompilationUnit, SearchMatch[]> typeReferences, final Map<ICompilationUnit, SearchMatch[]> constructorReferences, boolean visibilityWasAdjusted, final ICompilationUnit sourceUnit, final ICompilationUnit targetUnit, final boolean remove, final RefactoringStatus status, final IProgressMonitor monitor) throws CoreException {
	Assert.isNotNull(parameters);
	Assert.isNotNull(targetRewrite);
	Assert.isNotNull(typeReferences);
	Assert.isNotNull(constructorReferences);
	Assert.isNotNull(sourceUnit);
	Assert.isNotNull(targetUnit);
	final CompilationUnit root= targetRewrite.getRoot();
	final ASTRewrite rewrite= targetRewrite.getASTRewrite();
	if (targetUnit.equals(sourceUnit)) {
		final AbstractTypeDeclaration declaration= findTypeDeclaration(fType, root);
		final TextEditGroup qualifierGroup= fSourceRewrite.createGroupDescription(RefactoringCoreMessages.MoveInnerToTopRefactoring_change_qualifier);
		ITypeBinding binding= declaration.resolveBinding();
		if (!remove) {
			if (!JdtFlags.isStatic(fType) && fCreateInstanceField) {
				if (JavaElementUtil.getAllConstructors(fType).length == 0)
					createConstructor(declaration, rewrite);
				else
					modifyConstructors(declaration, rewrite);
				addInheritedTypeQualifications(declaration, targetRewrite, qualifierGroup);
				addEnclosingInstanceDeclaration(declaration, rewrite);
			}
			fTypeImports= new HashSet<ITypeBinding>();
			fStaticImports= new HashSet<IBinding>();
			ImportRewriteUtil.collectImports(fType.getJavaProject(), declaration, fTypeImports, fStaticImports, false);
			if (binding != null)
				fTypeImports.remove(binding);
		}
		addEnclosingInstanceTypeParameters(parameters, declaration, rewrite);
		modifyAccessToEnclosingInstance(targetRewrite, declaration, monitor);
		if (binding != null) {
			modifyInterfaceMemberModifiers(binding);
			final ITypeBinding declaring= binding.getDeclaringClass();
			if (declaring != null)
				declaration.accept(new TypeReferenceQualifier(binding, null));
		}
		final TextEditGroup groupMove= targetRewrite.createGroupDescription(RefactoringCoreMessages.MoveInnerToTopRefactoring_change_label);
		if (remove) {
			rewrite.remove(declaration, groupMove);
			targetRewrite.getImportRemover().registerRemovedNode(declaration);
		} else {
			// Bug 101017/96308: Rewrite the visibility of the element to be
			// moved and add a warning.

			// Note that this cannot be done in the MemberVisibilityAdjustor, as the private and
			// static flags must always be cleared when moving to new type.
			int newFlags= JdtFlags.clearFlag(Modifier.STATIC, declaration.getModifiers());

			if (!visibilityWasAdjusted) {
				if (Modifier.isPrivate(declaration.getModifiers()) || Modifier.isProtected(declaration.getModifiers())) {
					newFlags= JdtFlags.clearFlag(Modifier.PROTECTED | Modifier.PRIVATE, newFlags);
					final RefactoringStatusEntry entry= new RefactoringStatusEntry(RefactoringStatus.WARNING, Messages.format(RefactoringCoreMessages.MoveInnerToTopRefactoring_change_visibility_type_warning, new String[] { BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)}), JavaStatusContext.create(fSourceRewrite.getCu()));
					if (!containsStatusEntry(status, entry))
						status.addEntry(entry);
				}
			}

			ModifierRewrite.create(rewrite, declaration).setModifiers(newFlags, groupMove);
		}
	}
	ASTNode[] references= getReferenceNodesIn(root, typeReferences, targetUnit);
	for (int index= 0; index < references.length; index++)
		updateTypeReference(parameters, references[index], targetRewrite, targetUnit);
	references= getReferenceNodesIn(root, constructorReferences, targetUnit);
	for (int index= 0; index < references.length; index++)
		updateConstructorReference(parameters, references[index], targetRewrite, targetUnit);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:68,代码来源:MoveInnerToTopRefactoring.java

示例7: ConstructorReferenceFinder

import org.eclipse.jdt.internal.corext.refactoring.util.JavaElementUtil; //导入方法依赖的package包/类
private ConstructorReferenceFinder(IType type) throws JavaModelException{
	fConstructors= JavaElementUtil.getAllConstructors(type);
	fType= type;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:ConstructorReferenceFinder.java


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