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


Java JdtFlags.getVisibilityString方法代码示例

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


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

示例1: createRefactoringDescriptor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private RefactoringChangeDescriptor createRefactoringDescriptor() {
	final ITypeBinding binding= fAnonymousInnerClassNode.resolveBinding();
	final String[] labels= new String[] { BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED), BindingLabelProvider.getBindingLabel(binding.getDeclaringMethod(), JavaElementLabels.ALL_FULLY_QUALIFIED)};
	final Map<String, String> arguments= new HashMap<String, String>();
	final String projectName= fCu.getJavaProject().getElementName();
	final int flags= RefactoringDescriptor.STRUCTURAL_CHANGE | JavaRefactoringDescriptor.JAR_REFACTORING | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
	final String description= RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_descriptor_description_short;
	final String header= Messages.format(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_descriptor_description, labels);
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(projectName, this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_original_pattern, BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_class_name_pattern, BasicElementLabels.getJavaElementName(fClassName)));
	String visibility= JdtFlags.getVisibilityString(fVisibility);
	if (visibility.length() == 0)
		visibility= RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_default_visibility;
	comment.addSetting(Messages.format(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_visibility_pattern, visibility));
	if (fDeclareFinal && fDeclareStatic)
		comment.addSetting(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_declare_final_static);
	else if (fDeclareFinal)
		comment.addSetting(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_declare_final);
	else if (fDeclareStatic)
		comment.addSetting(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_declare_static);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(projectName, fCu));
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fClassName);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + ' ' + new Integer(fSelectionLength).toString());
	arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
	arguments.put(ATTRIBUTE_STATIC, Boolean.valueOf(fDeclareStatic).toString());
	arguments.put(ATTRIBUTE_VISIBILITY, new Integer(fVisibility).toString());

	ConvertAnonymousDescriptor descriptor= RefactoringSignatureDescriptorFactory.createConvertAnonymousDescriptor(projectName, description, comment.asString(), arguments, flags);
	return new RefactoringChangeDescriptor(descriptor);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:ConvertAnonymousToNestedRefactoring.java

示例2: getVisibilityString

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private String getVisibilityString(int visibility) {
  String visibilityString = JdtFlags.getVisibilityString(visibility);
  if ("".equals(visibilityString)) // $NON-NLS-1$
  return visibilityString;
  return visibilityString + ' ';
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:ChangeSignatureProcessor.java

示例3: createRefactoringDescriptor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private RefactoringChangeDescriptor createRefactoringDescriptor() {
  final ITypeBinding binding = fAnonymousInnerClassNode.resolveBinding();
  final String[] labels =
      new String[] {
        BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED),
        BindingLabelProvider.getBindingLabel(
            binding.getDeclaringMethod(), JavaElementLabels.ALL_FULLY_QUALIFIED)
      };
  final Map<String, String> arguments = new HashMap<String, String>();
  final String projectName = fCu.getJavaProject().getElementName();
  final int flags =
      RefactoringDescriptor.STRUCTURAL_CHANGE
          | JavaRefactoringDescriptor.JAR_REFACTORING
          | JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
  final String description =
      RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_descriptor_description_short;
  final String header =
      Messages.format(
          RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_descriptor_description,
          labels);
  final JDTRefactoringDescriptorComment comment =
      new JDTRefactoringDescriptorComment(projectName, this, header);
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_original_pattern,
          BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_class_name_pattern,
          BasicElementLabels.getJavaElementName(fClassName)));
  String visibility = JdtFlags.getVisibilityString(fVisibility);
  if (visibility.length() == 0)
    visibility = RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_default_visibility;
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_visibility_pattern,
          visibility));
  if (fDeclareFinal && fDeclareStatic)
    comment.addSetting(
        RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_declare_final_static);
  else if (fDeclareFinal)
    comment.addSetting(RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_declare_final);
  else if (fDeclareStatic)
    comment.addSetting(
        RefactoringCoreMessages.ConvertAnonymousToNestedRefactoring_declare_static);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
      JavaRefactoringDescriptorUtil.elementToHandle(projectName, fCu));
  arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fClassName);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION,
      new Integer(fSelectionStart).toString() + ' ' + new Integer(fSelectionLength).toString());
  arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
  arguments.put(ATTRIBUTE_STATIC, Boolean.valueOf(fDeclareStatic).toString());
  arguments.put(ATTRIBUTE_VISIBILITY, new Integer(fVisibility).toString());

  ConvertAnonymousDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createConvertAnonymousDescriptor(
          projectName, description, comment.asString(), arguments, flags);
  return new RefactoringChangeDescriptor(descriptor);
}
 
开发者ID:eclipse,项目名称:che,代码行数:62,代码来源:ConvertAnonymousToNestedRefactoring.java

示例4: getRefactoringDescriptor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private ConvertLocalVariableDescriptor getRefactoringDescriptor() {
  final Map<String, String> arguments = new HashMap<String, String>();
  String project = null;
  IJavaProject javaProject = fCu.getJavaProject();
  if (javaProject != null) project = javaProject.getElementName();
  final IVariableBinding binding = fTempDeclarationNode.resolveBinding();
  final String description =
      Messages.format(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_descriptor_description_short,
          BasicElementLabels.getJavaElementName(binding.getName()));
  final String header =
      Messages.format(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_descriptor_description,
          new String[] {
            BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED),
            BindingLabelProvider.getBindingLabel(
                binding.getDeclaringMethod(), JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  final JDTRefactoringDescriptorComment comment =
      new JDTRefactoringDescriptorComment(project, this, header);
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_original_pattern,
          BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_field_pattern,
          BasicElementLabels.getJavaElementName(fFieldName)));
  switch (fInitializeIn) {
    case INITIALIZE_IN_CONSTRUCTOR:
      comment.addSetting(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_initialize_constructor);
      break;
    case INITIALIZE_IN_FIELD:
      comment.addSetting(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_initialize_declaration);
      break;
    case INITIALIZE_IN_METHOD:
      comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_initialize_method);
      break;
  }
  String visibility = JdtFlags.getVisibilityString(fVisibility);
  if ("".equals(visibility)) // $NON-NLS-1$
  visibility = RefactoringCoreMessages.PromoteTempToFieldRefactoring_default_visibility;
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.PromoteTempToFieldRefactoring_visibility_pattern, visibility));
  if (fDeclareFinal && fDeclareStatic)
    comment.addSetting(
        RefactoringCoreMessages.PromoteTempToFieldRefactoring_declare_final_static);
  else if (fDeclareFinal)
    comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_declare_final);
  else if (fDeclareStatic)
    comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_declare_static);
  final ConvertLocalVariableDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createConvertLocalVariableDescriptor(
          project,
          description,
          comment.asString(),
          arguments,
          RefactoringDescriptor.STRUCTURAL_CHANGE);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
      JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
  arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fFieldName);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION,
      new Integer(fSelectionStart).toString()
          + " "
          + new Integer(fSelectionLength).toString()); // $NON-NLS-1$
  arguments.put(ATTRIBUTE_STATIC, Boolean.valueOf(fDeclareStatic).toString());
  arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
  arguments.put(ATTRIBUTE_VISIBILITY, new Integer(fVisibility).toString());
  arguments.put(ATTRIBUTE_INITIALIZE, new Integer(fInitializeIn).toString());
  return descriptor;
}
 
开发者ID:eclipse,项目名称:che,代码行数:77,代码来源:PromoteTempToFieldRefactoring.java

示例5: initialize

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private RefactoringStatus initialize(JavaRefactoringArguments arguments) {
  final String selection =
      arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION);
  if (selection != null) {
    int offset = -1;
    int length = -1;
    final StringTokenizer tokenizer = new StringTokenizer(selection);
    if (tokenizer.hasMoreTokens()) offset = Integer.valueOf(tokenizer.nextToken()).intValue();
    if (tokenizer.hasMoreTokens()) length = Integer.valueOf(tokenizer.nextToken()).intValue();
    if (offset >= 0 && length >= 0) {
      fSelectionStart = offset;
      fSelectionLength = length;
    } else
      return RefactoringStatus.createFatalErrorStatus(
          Messages.format(
              RefactoringCoreMessages.InitializableRefactoring_illegal_argument,
              new Object[] {selection, JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION}));
  } else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION));
  final String handle = arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
  if (handle != null) {
    final IJavaElement element =
        JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), handle, false);
    if (element == null
        || !element.exists()
        || element.getElementType() != IJavaElement.COMPILATION_UNIT)
      return JavaRefactoringDescriptorUtil.createInputFatalStatus(
          element, getName(), IJavaRefactorings.EXTRACT_CONSTANT);
    else fCu = (ICompilationUnit) element;
  } else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT));
  final String visibility = arguments.getAttribute(ATTRIBUTE_VISIBILITY);
  if (visibility != null && !"".equals(visibility)) { // $NON-NLS-1$
    int flag = 0;
    try {
      flag = Integer.parseInt(visibility);
    } catch (NumberFormatException exception) {
      return RefactoringStatus.createFatalErrorStatus(
          Messages.format(
              RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
              ATTRIBUTE_VISIBILITY));
    }
    fVisibility = JdtFlags.getVisibilityString(flag);
  }
  final String name = arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME);
  if (name != null && !"".equals(name)) // $NON-NLS-1$
  fConstantName = name;
  else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
  final String replace = arguments.getAttribute(ATTRIBUTE_REPLACE);
  if (replace != null) {
    fReplaceAllOccurrences = Boolean.valueOf(replace).booleanValue();
  } else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            ATTRIBUTE_REPLACE));
  final String declareFinal = arguments.getAttribute(ATTRIBUTE_QUALIFY);
  if (declareFinal != null) {
    fQualifyReferencesWithDeclaringClassName = Boolean.valueOf(declareFinal).booleanValue();
  } else
    return RefactoringStatus.createFatalErrorStatus(
        Messages.format(
            RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
            ATTRIBUTE_QUALIFY));
  return new RefactoringStatus();
}
 
开发者ID:eclipse,项目名称:che,代码行数:77,代码来源:ExtractConstantRefactoring.java

示例6: createChange

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
  final Map<String, String> arguments = new HashMap<String, String>();
  String project = null;
  IJavaProject javaProject = fField.getJavaProject();
  if (javaProject != null) project = javaProject.getElementName();
  int flags =
      JavaRefactoringDescriptor.JAR_MIGRATION
          | JavaRefactoringDescriptor.JAR_REFACTORING
          | RefactoringDescriptor.STRUCTURAL_CHANGE
          | RefactoringDescriptor.MULTI_CHANGE;
  final IType declaring = fField.getDeclaringType();
  try {
    if (declaring.isAnonymous() || declaring.isLocal())
      flags |= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
  } catch (JavaModelException exception) {
    JavaPlugin.log(exception);
  }
  final String description =
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateField_descriptor_description_short,
          BasicElementLabels.getJavaElementName(fField.getElementName()));
  final String header =
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateFieldRefactoring_descriptor_description,
          new String[] {
            JavaElementLabels.getElementLabel(fField, JavaElementLabels.ALL_FULLY_QUALIFIED),
            JavaElementLabels.getElementLabel(declaring, JavaElementLabels.ALL_FULLY_QUALIFIED)
          });
  final JDTRefactoringDescriptorComment comment =
      new JDTRefactoringDescriptorComment(project, this, header);
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateField_original_pattern,
          JavaElementLabels.getElementLabel(fField, JavaElementLabels.ALL_FULLY_QUALIFIED)));
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateField_getter_pattern,
          BasicElementLabels.getJavaElementName(fGetterName)));
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateField_setter_pattern,
          BasicElementLabels.getJavaElementName(fSetterName)));
  String visibility = JdtFlags.getVisibilityString(fVisibility);
  if ("".equals(visibility)) // $NON-NLS-1$
  visibility = RefactoringCoreMessages.SelfEncapsulateField_default_visibility;
  comment.addSetting(
      Messages.format(
          RefactoringCoreMessages.SelfEncapsulateField_visibility_pattern, visibility));
  if (fEncapsulateDeclaringClass)
    comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_use_accessors);
  else comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_do_not_use_accessors);
  if (fGenerateJavadoc)
    comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_generate_comments);
  final EncapsulateFieldDescriptor descriptor =
      RefactoringSignatureDescriptorFactory.createEncapsulateFieldDescriptor(
          project, description, comment.asString(), arguments, flags);
  arguments.put(
      JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
      JavaRefactoringDescriptorUtil.elementToHandle(project, fField));
  arguments.put(ATTRIBUTE_VISIBILITY, new Integer(fVisibility).toString());
  arguments.put(ATTRIBUTE_INSERTION, new Integer(fInsertionIndex).toString());
  arguments.put(ATTRIBUTE_SETTER, fSetterName);
  arguments.put(ATTRIBUTE_GETTER, fGetterName);
  arguments.put(ATTRIBUTE_COMMENTS, Boolean.valueOf(fGenerateJavadoc).toString());
  arguments.put(ATTRIBUTE_DECLARING, Boolean.valueOf(fEncapsulateDeclaringClass).toString());
  final DynamicValidationRefactoringChange result =
      new DynamicValidationRefactoringChange(descriptor, getName());
  TextChange[] changes = fChangeManager.getAllChanges();
  pm.beginTask(NO_NAME, changes.length);
  pm.setTaskName(RefactoringCoreMessages.SelfEncapsulateField_create_changes);
  for (int i = 0; i < changes.length; i++) {
    result.add(changes[i]);
    pm.worked(1);
  }
  pm.done();
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:79,代码来源:SelfEncapsulateFieldRefactoring.java

示例7: getVisibilityString

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private String getVisibilityString(int visibility) {
	String visibilityString= JdtFlags.getVisibilityString(visibility);
	if ("".equals(visibilityString)) //$NON-NLS-1$
		return visibilityString;
	return visibilityString + ' ';
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:ChangeSignatureProcessor.java

示例8: getRefactoringDescriptor

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private ConvertLocalVariableDescriptor getRefactoringDescriptor() {
	final Map<String, String> arguments= new HashMap<String, String>();
	String project= null;
	IJavaProject javaProject= fCu.getJavaProject();
	if (javaProject != null)
		project= javaProject.getElementName();
	final IVariableBinding binding= fTempDeclarationNode.resolveBinding();
	final String description= Messages.format(RefactoringCoreMessages.PromoteTempToFieldRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(binding.getName()));
	final String header= Messages.format(RefactoringCoreMessages.PromoteTempToFieldRefactoring_descriptor_description, new String[] { BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED), BindingLabelProvider.getBindingLabel(binding.getDeclaringMethod(), JavaElementLabels.ALL_FULLY_QUALIFIED)});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.PromoteTempToFieldRefactoring_original_pattern, BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.PromoteTempToFieldRefactoring_field_pattern, BasicElementLabels.getJavaElementName(fFieldName)));
	switch (fInitializeIn) {
		case INITIALIZE_IN_CONSTRUCTOR:
			comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_initialize_constructor);
			break;
		case INITIALIZE_IN_FIELD:
			comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_initialize_declaration);
			break;
		case INITIALIZE_IN_METHOD:
			comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_initialize_method);
			break;
	}
	String visibility= JdtFlags.getVisibilityString(fVisibility);
	if ("".equals(visibility)) //$NON-NLS-1$
		visibility= RefactoringCoreMessages.PromoteTempToFieldRefactoring_default_visibility;
	comment.addSetting(Messages.format(RefactoringCoreMessages.PromoteTempToFieldRefactoring_visibility_pattern, visibility));
	if (fDeclareFinal && fDeclareStatic)
		comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_declare_final_static);
	else if (fDeclareFinal)
		comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_declare_final);
	else if (fDeclareStatic)
		comment.addSetting(RefactoringCoreMessages.PromoteTempToFieldRefactoring_declare_static);
	final ConvertLocalVariableDescriptor descriptor= RefactoringSignatureDescriptorFactory.createConvertLocalVariableDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.STRUCTURAL_CHANGE);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, fFieldName);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
	arguments.put(ATTRIBUTE_STATIC, Boolean.valueOf(fDeclareStatic).toString());
	arguments.put(ATTRIBUTE_FINAL, Boolean.valueOf(fDeclareFinal).toString());
	arguments.put(ATTRIBUTE_VISIBILITY, new Integer(fVisibility).toString());
	arguments.put(ATTRIBUTE_INITIALIZE, new Integer(fInitializeIn).toString());
	return descriptor;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:PromoteTempToFieldRefactoring.java

示例9: initialize

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
private RefactoringStatus initialize(JavaRefactoringArguments arguments) {
	final String selection= arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION);
	if (selection != null) {
		int offset= -1;
		int length= -1;
		final StringTokenizer tokenizer= new StringTokenizer(selection);
		if (tokenizer.hasMoreTokens())
			offset= Integer.valueOf(tokenizer.nextToken()).intValue();
		if (tokenizer.hasMoreTokens())
			length= Integer.valueOf(tokenizer.nextToken()).intValue();
		if (offset >= 0 && length >= 0) {
			fSelectionStart= offset;
			fSelectionLength= length;
		} else
			return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_illegal_argument, new Object[] { selection, JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION}));
	} else
		return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION));
	final String handle= arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
	if (handle != null) {
		final IJavaElement element= JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), handle, false);
		if (element == null || !element.exists() || element.getElementType() != IJavaElement.COMPILATION_UNIT)
			return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getName(), IJavaRefactorings.EXTRACT_CONSTANT);
		else
			fCu= (ICompilationUnit) element;
	} else
		return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT));
	final String visibility= arguments.getAttribute(ATTRIBUTE_VISIBILITY);
	if (visibility != null && !"".equals(visibility)) {//$NON-NLS-1$
		int flag= 0;
		try {
			flag= Integer.parseInt(visibility);
		} catch (NumberFormatException exception) {
			return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_VISIBILITY));
		}
		fVisibility= JdtFlags.getVisibilityString(flag);
	}
	final String name= arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME);
	if (name != null && !"".equals(name)) //$NON-NLS-1$
		fConstantName= name;
	else
		return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME));
	final String replace= arguments.getAttribute(ATTRIBUTE_REPLACE);
	if (replace != null) {
		fReplaceAllOccurrences= Boolean.valueOf(replace).booleanValue();
	} else
		return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REPLACE));
	final String declareFinal= arguments.getAttribute(ATTRIBUTE_QUALIFY);
	if (declareFinal != null) {
		fQualifyReferencesWithDeclaringClassName= Boolean.valueOf(declareFinal).booleanValue();
	} else
		return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_QUALIFY));
	return new RefactoringStatus();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:54,代码来源:ExtractConstantRefactoring.java

示例10: createChange

import org.eclipse.jdt.internal.corext.util.JdtFlags; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
	final Map<String, String> arguments= new HashMap<String, String>();
	String project= null;
	IJavaProject javaProject= fField.getJavaProject();
	if (javaProject != null)
		project= javaProject.getElementName();
	int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
	final IType declaring= fField.getDeclaringType();
	try {
		if (declaring.isAnonymous() || declaring.isLocal())
			flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
	} catch (JavaModelException exception) {
		JavaPlugin.log(exception);
	}
	final String description= Messages.format(RefactoringCoreMessages.SelfEncapsulateField_descriptor_description_short, BasicElementLabels.getJavaElementName(fField.getElementName()));
	final String header= Messages.format(RefactoringCoreMessages.SelfEncapsulateFieldRefactoring_descriptor_description, new String[] { JavaElementLabels.getElementLabel(fField, JavaElementLabels.ALL_FULLY_QUALIFIED), JavaElementLabels.getElementLabel(declaring, JavaElementLabels.ALL_FULLY_QUALIFIED)});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.SelfEncapsulateField_original_pattern, JavaElementLabels.getElementLabel(fField, JavaElementLabels.ALL_FULLY_QUALIFIED)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.SelfEncapsulateField_getter_pattern, BasicElementLabels.getJavaElementName(fGetterName)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.SelfEncapsulateField_setter_pattern, BasicElementLabels.getJavaElementName(fSetterName)));
	String visibility= JdtFlags.getVisibilityString(fVisibility);
	if ("".equals(visibility)) //$NON-NLS-1$
		visibility= RefactoringCoreMessages.SelfEncapsulateField_default_visibility;
	comment.addSetting(Messages.format(RefactoringCoreMessages.SelfEncapsulateField_visibility_pattern, visibility));
	if (fEncapsulateDeclaringClass)
		comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_use_accessors);
	else
		comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_do_not_use_accessors);
	if (fGenerateJavadoc)
		comment.addSetting(RefactoringCoreMessages.SelfEncapsulateField_generate_comments);
	final EncapsulateFieldDescriptor descriptor= RefactoringSignatureDescriptorFactory.createEncapsulateFieldDescriptor(project, description, comment.asString(), arguments, flags);
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fField));
	arguments.put(ATTRIBUTE_VISIBILITY, new Integer(fVisibility).toString());
	arguments.put(ATTRIBUTE_INSERTION, new Integer(fInsertionIndex).toString());
	arguments.put(ATTRIBUTE_SETTER, fSetterName);
	arguments.put(ATTRIBUTE_GETTER, fGetterName);
	arguments.put(ATTRIBUTE_COMMENTS, Boolean.valueOf(fGenerateJavadoc).toString());
	arguments.put(ATTRIBUTE_DECLARING, Boolean.valueOf(fEncapsulateDeclaringClass).toString());
	final DynamicValidationRefactoringChange result= new DynamicValidationRefactoringChange(descriptor, getName());
	TextChange[] changes= fChangeManager.getAllChanges();
	pm.beginTask(NO_NAME, changes.length);
	pm.setTaskName(RefactoringCoreMessages.SelfEncapsulateField_create_changes);
	for (int i= 0; i < changes.length; i++) {
		result.add(changes[i]);
		pm.worked(1);
	}
	pm.done();
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:51,代码来源:SelfEncapsulateFieldRefactoring.java


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