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


Java JdtFlags.getVisibilityCode方法代码示例

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


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

示例1: ChangeSignatureProcessor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * Creates a new change signature refactoring.
 *
 * @param method the method, or <code>null</code> if invoked by scripting framework
 * @throws JavaModelException if something's wrong with the given method
 */
public ChangeSignatureProcessor(IMethod method) throws JavaModelException {
  fMethod = method;
  fOldVarargIndex = -1;
  fDelegateUpdating = false;
  fDelegateDeprecation = true;
  if (fMethod != null) {
    fParameterInfos = createParameterInfoList(method);
    // fExceptionInfos is created in checkInitialConditions
    fReturnTypeInfo =
        new ReturnTypeInfo(Signature.toString(Signature.getReturnType(fMethod.getSignature())));
    fMethodName = fMethod.getElementName();
    fVisibility = JdtFlags.getVisibilityCode(fMethod);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ChangeSignatureProcessor.java

示例2: protectConstructor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * Creates and adds the necessary change to make the constructor method protected.
 *
 * @param unitAST
 * @param unitRewriter
 * @param declGD
 * @return false iff the constructor didn't exist (i.e. was implicit)
 */
private boolean protectConstructor(
    CompilationUnit unitAST, ASTRewrite unitRewriter, TextEditGroup declGD) {
  MethodDeclaration constructor =
      (MethodDeclaration) unitAST.findDeclaringNode(fCtorBinding.getKey());

  // No need to rewrite the modifiers if the visibility is what we already want it to be.
  if (constructor == null || (JdtFlags.getVisibilityCode(constructor)) == fConstructorVisibility)
    return false;
  ModifierRewrite.create(unitRewriter, constructor).setVisibility(fConstructorVisibility, declGD);
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:IntroduceFactoryRefactoring.java

示例3: getMostVisibleConstructor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private IMethod getMostVisibleConstructor() throws JavaModelException {
	Assert.isTrue(fConstructors.length > 0);
	IMethod candidate= fConstructors[0];
	int visibility= JdtFlags.getVisibilityCode(fConstructors[0]);
	for (int i= 1; i < fConstructors.length; i++) {
		IMethod constructor= fConstructors[i];
		if (JdtFlags.isHigherVisibility(JdtFlags.getVisibilityCode(constructor), visibility))
			candidate= constructor;
	}
	return candidate;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ConstructorReferenceFinder.java

示例4: isVisibleFrom

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private static boolean isVisibleFrom(IType newMemberDeclaringType, IType accessingType) throws JavaModelException {
	int memberVisibility= JdtFlags.getVisibilityCode(newMemberDeclaringType);

	IType declaringType= newMemberDeclaringType.getDeclaringType();
	while (declaringType != null) { //get lowest visibility in all parent types of newMemberDeclaringType
		memberVisibility= JdtFlags.getLowerVisibility(
				memberVisibility, JdtFlags.getVisibilityCode(declaringType));
		declaringType= declaringType.getDeclaringType();
	}

	switch (memberVisibility) {
		case Modifier.PRIVATE :
			return isEqualOrEnclosedType(accessingType, newMemberDeclaringType);

		case Modifier.NONE :
			return JavaModelUtil.isSamePackage(accessingType.getPackageFragment(), newMemberDeclaringType.getPackageFragment());

		case Modifier.PROTECTED :
			return JavaModelUtil.isSamePackage(accessingType.getPackageFragment(), newMemberDeclaringType.getPackageFragment())
					|| accessingType.newSupertypeHierarchy(null).contains(newMemberDeclaringType);

		case Modifier.PUBLIC :
			return true;

		default:
			Assert.isTrue(false);
			return false;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:MoveStaticMembersProcessor.java

示例5: ChangeSignatureProcessor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * Creates a new change signature refactoring.
 * @param method the method, or <code>null</code> if invoked by scripting framework
 * @throws JavaModelException if something's wrong with the given method
 */
public ChangeSignatureProcessor(IMethod method) throws JavaModelException {
	fMethod= method;
	fOldVarargIndex= -1;
	fDelegateUpdating= false;
	fDelegateDeprecation= true;
	if (fMethod != null) {
		fParameterInfos= createParameterInfoList(method);
		// fExceptionInfos is created in checkInitialConditions
		fReturnTypeInfo= new ReturnTypeInfo(Signature.toString(Signature.getReturnType(fMethod.getSignature())));
		fMethodName= fMethod.getElementName();
		fVisibility= JdtFlags.getVisibilityCode(fMethod);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:ChangeSignatureProcessor.java

示例6: createRefactoringDescriptor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private ExtractConstantDescriptor createRefactoringDescriptor() {
	final Map<String, String> arguments= new HashMap<String, String>();
	String project= null;
	IJavaProject javaProject= fCu.getJavaProject();
	if (javaProject != null)
		project= javaProject.getElementName();
	int flags= JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
	if (JdtFlags.getVisibilityCode(fVisibility) != Modifier.PRIVATE)
		flags|= RefactoringDescriptor.STRUCTURAL_CHANGE;

	final String expression= ASTNodes.asString(fSelectedExpression.getAssociatedExpression());
	final String description= Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fConstantName));
	final String header= Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fConstantName), BasicElementLabels.getJavaCodeString(expression)});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_constant_name_pattern, BasicElementLabels.getJavaElementName(fConstantName)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_constant_expression_pattern, BasicElementLabels.getJavaCodeString(expression)));
	String visibility= fVisibility;
	if ("".equals(visibility)) //$NON-NLS-1$
		visibility= RefactoringCoreMessages.ExtractConstantRefactoring_default_visibility;
	comment.addSetting(Messages.format(RefactoringCoreMessages.ExtractConstantRefactoring_visibility_pattern, visibility));
	if (fReplaceAllOccurrences)
		comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_replace_occurrences);
	if (fQualifyReferencesWithDeclaringClassName)
		comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_qualify_references);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fConstantName);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
	arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
	arguments.put(ATTRIBUTE_QUALIFY, Boolean.valueOf(fQualifyReferencesWithDeclaringClassName).toString());
	arguments.put(ATTRIBUTE_VISIBILITY, new Integer(JdtFlags.getVisibilityCode(fVisibility)).toString());

	ExtractConstantDescriptor descriptor= RefactoringSignatureDescriptorFactory.createExtractConstantDescriptor(project, description, comment.asString(), arguments, flags);
	return descriptor;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:ExtractConstantRefactoring.java

示例7: protectConstructor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
/**
 * Creates and adds the necessary change to make the constructor method protected.
 * @param unitAST
 * @param unitRewriter
 * @param declGD
 * @return false iff the constructor didn't exist (i.e. was implicit)
 */
private boolean protectConstructor(CompilationUnit unitAST, ASTRewrite unitRewriter, TextEditGroup declGD) {
	MethodDeclaration constructor= (MethodDeclaration) unitAST.findDeclaringNode(fCtorBinding.getKey());

	// No need to rewrite the modifiers if the visibility is what we already want it to be.
	if (constructor == null || (JdtFlags.getVisibilityCode(constructor)) == fConstructorVisibility)
		return false;
	ModifierRewrite.create(unitRewriter, constructor).setVisibility(fConstructorVisibility, declGD);
	return true;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:IntroduceFactoryRefactoring.java

示例8: isVisibilitySameAsInitial

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private boolean isVisibilitySameAsInitial() throws JavaModelException {
  return fVisibility == JdtFlags.getVisibilityCode(fMethod);
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:ChangeSignatureProcessor.java

示例9: createRefactoringDescriptor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private ExtractConstantDescriptor createRefactoringDescriptor() {
  final Map<String, String> arguments = new HashMap<String, String>();
  String project = null;
  IJavaProject javaProject = fCu.getJavaProject();
  if (javaProject != null) project = javaProject.getElementName();
  int flags =
      JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
  if (JdtFlags.getVisibilityCode(fVisibility) != Modifier.PRIVATE)
    flags |= RefactoringDescriptor.STRUCTURAL_CHANGE;

  final String expression = ASTNodes.asString(fSelectedExpression.getAssociatedExpression());
  final String description =
      Messages.format(
          RefactoringCoreMessages.ExtractConstantRefactoring_descriptor_description_short,
          BasicElementLabels.getJavaElementName(fConstantName));
  final String header =
      Messages.format(
          RefactoringCoreMessages.ExtractConstantRefactoring_descriptor_description,
          new String[] {
            BasicElementLabels.getJavaElementName(fConstantName),
            BasicElementLabels.getJavaCodeString(expression)
          });
  final JDTRefactoringDescriptorComment comment =
      new JDTRefactoringDescriptorComment(project, this, header);
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ExtractConstantRefactoring_constant_name_pattern,
          BasicElementLabels.getJavaElementName(fConstantName)));
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ExtractConstantRefactoring_constant_expression_pattern,
          BasicElementLabels.getJavaCodeString(expression)));
  String visibility = fVisibility;
  if ("".equals(visibility)) // $NON-NLS-1$
  visibility = RefactoringCoreMessages.ExtractConstantRefactoring_default_visibility;
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ExtractConstantRefactoring_visibility_pattern, visibility));
  if (fReplaceAllOccurrences)
    comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_replace_occurrences);
  if (fQualifyReferencesWithDeclaringClassName)
    comment.addSetting(RefactoringCoreMessages.ExtractConstantRefactoring_qualify_references);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
      JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
  arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fConstantName);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION,
      new Integer(fSelectionStart).toString()
          + " "
          + new Integer(fSelectionLength).toString()); // $NON-NLS-1$
  arguments.put(ATTRIBUTE_REPLACE, Boolean.valueOf(fReplaceAllOccurrences).toString());
  arguments.put(
      ATTRIBUTE_QUALIFY, Boolean.valueOf(fQualifyReferencesWithDeclaringClassName).toString());
  arguments.put(
      ATTRIBUTE_VISIBILITY, new Integer(JdtFlags.getVisibilityCode(fVisibility)).toString());

  ExtractConstantDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createExtractConstantDescriptor(
          project, description, comment.asString(), arguments, flags);
  return descriptor;
}
 
开发者ID:eclipse,项目名称:che,代码行数:63,代码来源:ExtractConstantRefactoring.java

示例10: isVisibilitySameAsInitial

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private boolean isVisibilitySameAsInitial() throws JavaModelException {
	return fVisibility == JdtFlags.getVisibilityCode(fMethod);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:ChangeSignatureProcessor.java


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