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


Java CompilationUnitChange.setDescriptor方法代码示例

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


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

示例1: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
  pm.beginTask("", 1); // $NON-NLS-1$
  try {
    if (fFieldName.length() == 0) {
      fFieldName = getInitialFieldName();
    }

    ASTRewrite rewrite = ASTRewrite.create(fCompilationUnitNode.getAST());
    if (fInitializeIn == INITIALIZE_IN_METHOD && tempHasInitializer())
      addLocalDeclarationSplit(rewrite);
    else addLocalDeclarationRemoval(rewrite);
    if (fInitializeIn == INITIALIZE_IN_CONSTRUCTOR) addInitializersToConstructors(rewrite);
    addTempRenames(rewrite);
    addFieldDeclaration(rewrite);

    CompilationUnitChange result =
        new CompilationUnitChange(
            RefactoringCoreMessages.PromoteTempToFieldRefactoring_name, fCu);
    result.setDescriptor(new RefactoringChangeDescriptor(getRefactoringDescriptor()));
    TextEdit resultingEdits = rewrite.rewriteAST();
    TextChangeCompatibility.addTextEdit(
        result, RefactoringCoreMessages.PromoteTempToFieldRefactoring_editName, resultingEdits);
    return result;

  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:PromoteTempToFieldRefactoring.java

示例2: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
	try {
		pm.beginTask(RefactoringCoreMessages.InlineTempRefactoring_preview, 2);
		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= getVariableDeclaration().resolveBinding();
		String text= null;
		final IMethodBinding method= binding.getDeclaringMethod();
		if (method != null)
			text= BindingLabelProvider.getBindingLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED);
		else
			text= BasicElementLabels.getJavaElementName('{' + JavaElementLabels.ELLIPSIS_STRING + '}');
		final String description= Messages.format(RefactoringCoreMessages.InlineTempRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(binding.getName()));
		final String header= Messages.format(RefactoringCoreMessages.InlineTempRefactoring_descriptor_description, new String[] { BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED), text});
		final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header);
		comment.addSetting(Messages.format(RefactoringCoreMessages.InlineTempRefactoring_original_pattern, BindingLabelProvider.getBindingLabel(binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
		final InlineLocalVariableDescriptor descriptor= RefactoringSignatureDescriptorFactory.createInlineLocalVariableDescriptor(project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
		arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
		arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, String.valueOf(fSelectionStart) + ' ' + String.valueOf(fSelectionLength));

		CompilationUnitRewrite cuRewrite= new CompilationUnitRewrite(fCu, fASTRoot);

		inlineTemp(cuRewrite);
		removeTemp(cuRewrite);

		final CompilationUnitChange result= cuRewrite.createChange(RefactoringCoreMessages.InlineTempRefactoring_inline, false, new SubProgressMonitor(pm, 1));
		result.setDescriptor(new RefactoringChangeDescriptor(descriptor));
		return result;
	} finally {
		pm.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:38,代码来源:InlineTempRefactoring.java

示例3: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
   	pm.beginTask("", 1); //$NON-NLS-1$
   	try {
   		if (fFieldName.length() == 0) {
   			fFieldName= getInitialFieldName();
   		}

   		ASTRewrite rewrite= ASTRewrite.create(fCompilationUnitNode.getAST());
   		if (fInitializeIn == INITIALIZE_IN_METHOD && tempHasInitializer())
   			addLocalDeclarationSplit(rewrite);
		else
			addLocalDeclarationRemoval(rewrite);
   		if (fInitializeIn == INITIALIZE_IN_CONSTRUCTOR)
   			addInitializersToConstructors(rewrite);
  			addTempRenames(rewrite);
   		addFieldDeclaration(rewrite);

		CompilationUnitChange result= new CompilationUnitChange(RefactoringCoreMessages.PromoteTempToFieldRefactoring_name, fCu);
		result.setDescriptor(new RefactoringChangeDescriptor(getRefactoringDescriptor()));
		TextEdit resultingEdits= rewrite.rewriteAST();
		TextChangeCompatibility.addTextEdit(result, RefactoringCoreMessages.PromoteTempToFieldRefactoring_editName, resultingEdits);
		return result;

   	} finally {
   		pm.done();
   	}
   }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:PromoteTempToFieldRefactoring.java

示例4: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
  final CompilationUnitChange result = createCompilationUnitChange(pm);
  result.setDescriptor(createRefactoringDescriptor());
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:ConvertAnonymousToNestedRefactoring.java

示例5: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
  try {
    pm.beginTask(RefactoringCoreMessages.InlineTempRefactoring_preview, 2);
    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 = getVariableDeclaration().resolveBinding();
    String text = null;
    final IMethodBinding method = binding.getDeclaringMethod();
    if (method != null)
      text = BindingLabelProvider.getBindingLabel(method, JavaElementLabels.ALL_FULLY_QUALIFIED);
    else
      text = BasicElementLabels.getJavaElementName('{' + JavaElementLabels.ELLIPSIS_STRING + '}');
    final String description =
        Messages.format(
            RefactoringCoreMessages.InlineTempRefactoring_descriptor_description_short,
            BasicElementLabels.getJavaElementName(binding.getName()));
    final String header =
        Messages.format(
            RefactoringCoreMessages.InlineTempRefactoring_descriptor_description,
            new String[] {
              BindingLabelProvider.getBindingLabel(
                  binding, JavaElementLabels.ALL_FULLY_QUALIFIED),
              text
            });
    final JDTRefactoringDescriptorComment comment =
        new JDTRefactoringDescriptorComment(project, this, header);
    comment.addSetting(
        Messages.format(
            RefactoringCoreMessages.InlineTempRefactoring_original_pattern,
            BindingLabelProvider.getBindingLabel(
                binding, JavaElementLabels.ALL_FULLY_QUALIFIED)));
    final InlineLocalVariableDescriptor descriptor =
        RefactoringSignatureDescriptorFactory.createInlineLocalVariableDescriptor(
            project, description, comment.asString(), arguments, RefactoringDescriptor.NONE);
    arguments.put(
        JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
        JavaRefactoringDescriptorUtil.elementToHandle(project, fCu));
    arguments.put(
        JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION,
        String.valueOf(fSelectionStart) + ' ' + String.valueOf(fSelectionLength));

    CompilationUnitRewrite cuRewrite = new CompilationUnitRewrite(fCu, fASTRoot);

    inlineTemp(cuRewrite);
    removeTemp(cuRewrite);

    final CompilationUnitChange result =
        cuRewrite.createChange(
            RefactoringCoreMessages.InlineTempRefactoring_inline,
            false,
            new SubProgressMonitor(pm, 1));
    result.setDescriptor(new RefactoringChangeDescriptor(descriptor));
    return result;
  } finally {
    pm.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:62,代码来源:InlineTempRefactoring.java

示例6: createChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
	final CompilationUnitChange result= createCompilationUnitChange(pm);
	result.setDescriptor(createRefactoringDescriptor());
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:ConvertAnonymousToNestedRefactoring.java


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