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


Java CompilationUnitChange.setKeepPreviewEdits方法代码示例

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


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

示例1: cloneCompilationUnitChangeWithDifferentCu

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
/**
 * Destructively clones a {@link CompilationUnitChange} where the cloned
 * change will have a different compilation unit. This does not update text
 * regions or anything more than setting the change properties and moving text
 * edits from the old to new change.
 * 
 * @param originalChange the original change, this change's internal state
 *          will likely become invalid (its text edits will be moved to the
 *          new change)
 * @param cu the compilation unit to be used for the new
 *          {@link CompilationUnitChange}
 * @return the cloned {@link CompilationUnitChange}
 */
public static CompilationUnitChange cloneCompilationUnitChangeWithDifferentCu(
    TextFileChange originalChange, ICompilationUnit cu) {
  CompilationUnitChange newChange = new CompilationUnitChange(
      originalChange.getName(), cu);

  newChange.setEdit(originalChange.getEdit());
  newChange.setEnabledShallow(originalChange.isEnabled());
  newChange.setKeepPreviewEdits(originalChange.getKeepPreviewEdits());
  newChange.setSaveMode(originalChange.getSaveMode());
  newChange.setTextType(originalChange.getTextType());

  // Copy the changes over
  TextEditUtilities.moveTextEditGroupsIntoChange(
      originalChange.getChangeGroups(), newChange);

  return newChange;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:31,代码来源:ChangeUtilities.java

示例2: addDeclarationUpdate

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
private void addDeclarationUpdate(TextChangeManager manager) throws CoreException {

    if (getDelegateUpdating()) {
      // create the delegate
      CompilationUnitRewrite rewrite = new CompilationUnitRewrite(getDeclaringCU());
      rewrite.setResolveBindings(true);
      MethodDeclaration methodDeclaration =
          ASTNodeSearchUtil.getMethodDeclarationNode(getMethod(), rewrite.getRoot());
      DelegateMethodCreator creator = new DelegateMethodCreator();
      creator.setDeclaration(methodDeclaration);
      creator.setDeclareDeprecated(getDeprecateDelegates());
      creator.setSourceRewrite(rewrite);
      creator.setCopy(true);
      creator.setNewElementName(getNewElementName());
      creator.prepareDelegate();
      creator.createEdit();
      CompilationUnitChange cuChange = rewrite.createChange(true);
      if (cuChange != null) {
        cuChange.setKeepPreviewEdits(true);
        manager.manage(getDeclaringCU(), cuChange);
      }
    }

    String editName = RefactoringCoreMessages.RenameMethodRefactoring_update_declaration;
    ISourceRange nameRange = getMethod().getNameRange();
    ReplaceEdit replaceEdit =
        new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName());
    addTextEdit(manager.get(getDeclaringCU()), editName, replaceEdit);
  }
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RenameNonVirtualMethodProcessor.java

示例3: createPreChange

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
@Override
public Change createPreChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
	CompilationUnitChange change = new CompilationUnitChange(cu.getElementName(), cu);
	change.setKeepPreviewEdits(true);
	change.setEdit(new MultiTextEdit());

	// parse javadocs and update references
	for (ImageReference reference : UmletPluginUtils.collectUxfImgRefs(cu)) {
		SourceString srcValue = reference.srcAttr.value;
		if (UmletPluginUtils.isAbsoluteImageRef(srcValue.getValue())) {
			continue;
		}
		IPackageFragment destinationPackage;
		{
			Object destination = getArguments().getDestination();
			if (!(destination instanceof IPackageFragment)) {
				continue;
			}
			destinationPackage = (IPackageFragment) destination;
		}
		IPath parentPath = UmletPluginUtils.getCompilationUnitParentPath(cu);
		IPath imgPath = parentPath.append(new Path(srcValue.getValue()));
		IPath destinationPath = UmletPluginUtils.getPackageFragmentRootRelativePath(cu.getJavaProject(), destinationPackage.getCorrespondingResource());
		String newPath = UmletPluginUtils.calculateImageRef(destinationPath, imgPath);
		change.addEdit(new ReplaceEdit(srcValue.start, srcValue.length(), newPath));
	}

	return change;
}
 
开发者ID:umlet,项目名称:umlet,代码行数:30,代码来源:MoveClassParticipant.java

示例4: createEdits

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
private void createEdits() {
	TextEdit declarationEdit= createRenameEdit(fTempDeclarationNode.getName().getStartPosition());
	TextEdit[] allRenameEdits= getAllRenameEdits(declarationEdit);

	TextEdit[] allUnparentedRenameEdits= new TextEdit[allRenameEdits.length];
	TextEdit unparentedDeclarationEdit= null;

	fChange= new CompilationUnitChange(RefactoringCoreMessages.RenameTempRefactoring_rename, fCu);
	MultiTextEdit rootEdit= new MultiTextEdit();
	fChange.setEdit(rootEdit);
	fChange.setKeepPreviewEdits(true);

	for (int i= 0; i < allRenameEdits.length; i++) {
		if (fIsComposite) {
			// Add a copy of the text edit (text edit may only have one
			// parent) to keep problem reporting code clean
			TextChangeCompatibility.addTextEdit(fChangeManager.get(fCu), RefactoringCoreMessages.RenameTempRefactoring_changeName, allRenameEdits[i].copy(), fCategorySet);

			// Add a separate copy for problem reporting
			allUnparentedRenameEdits[i]= allRenameEdits[i].copy();
			if (allRenameEdits[i].equals(declarationEdit))
				unparentedDeclarationEdit= allUnparentedRenameEdits[i];
		}
		rootEdit.addChild(allRenameEdits[i]);
		fChange.addTextEditGroup(new TextEditGroup(RefactoringCoreMessages.RenameTempRefactoring_changeName, allRenameEdits[i]));
	}

	// store information for analysis
	if (fIsComposite) {
		fLocalAnalyzePackage= new RenameAnalyzeUtil.LocalAnalyzePackage(unparentedDeclarationEdit, allUnparentedRenameEdits);
	} else
		fLocalAnalyzePackage= new RenameAnalyzeUtil.LocalAnalyzePackage(declarationEdit, allRenameEdits);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:RenameLocalVariableProcessor.java

示例5: addDeclarationUpdate

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
private void addDeclarationUpdate(TextChangeManager manager) throws CoreException {

		if (getDelegateUpdating()) {
			// create the delegate
			CompilationUnitRewrite rewrite= new CompilationUnitRewrite(getDeclaringCU());
			rewrite.setResolveBindings(true);
			MethodDeclaration methodDeclaration= ASTNodeSearchUtil.getMethodDeclarationNode(getMethod(), rewrite.getRoot());
			DelegateMethodCreator creator= new DelegateMethodCreator();
			creator.setDeclaration(methodDeclaration);
			creator.setDeclareDeprecated(getDeprecateDelegates());
			creator.setSourceRewrite(rewrite);
			creator.setCopy(true);
			creator.setNewElementName(getNewElementName());
			creator.prepareDelegate();
			creator.createEdit();
			CompilationUnitChange cuChange= rewrite.createChange(true);
			if (cuChange != null) {
				cuChange.setKeepPreviewEdits(true);
				manager.manage(getDeclaringCU(), cuChange);
			}
		}

		String editName= RefactoringCoreMessages.RenameMethodRefactoring_update_declaration;
		ISourceRange nameRange= getMethod().getNameRange();
		ReplaceEdit replaceEdit= new ReplaceEdit(nameRange.getOffset(), nameRange.getLength(), getNewElementName());
		addTextEdit(manager.get(getDeclaringCU()), editName, replaceEdit);
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:RenameNonVirtualMethodProcessor.java

示例6: createEdits

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
private void createEdits() {
  TextEdit declarationEdit = createRenameEdit(fTempDeclarationNode.getName().getStartPosition());
  TextEdit[] allRenameEdits = getAllRenameEdits(declarationEdit);

  TextEdit[] allUnparentedRenameEdits = new TextEdit[allRenameEdits.length];
  TextEdit unparentedDeclarationEdit = null;

  fChange = new CompilationUnitChange(RefactoringCoreMessages.RenameTempRefactoring_rename, fCu);
  MultiTextEdit rootEdit = new MultiTextEdit();
  fChange.setEdit(rootEdit);
  fChange.setKeepPreviewEdits(true);

  for (int i = 0; i < allRenameEdits.length; i++) {
    if (fIsComposite) {
      // Add a copy of the text edit (text edit may only have one
      // parent) to keep problem reporting code clean
      TextChangeCompatibility.addTextEdit(
          fChangeManager.get(fCu),
          RefactoringCoreMessages.RenameTempRefactoring_changeName,
          allRenameEdits[i].copy(),
          fCategorySet);

      // Add a separate copy for problem reporting
      allUnparentedRenameEdits[i] = allRenameEdits[i].copy();
      if (allRenameEdits[i].equals(declarationEdit))
        unparentedDeclarationEdit = allUnparentedRenameEdits[i];
    }
    rootEdit.addChild(allRenameEdits[i]);
    fChange.addTextEditGroup(
        new TextEditGroup(
            RefactoringCoreMessages.RenameTempRefactoring_changeName, allRenameEdits[i]));
  }

  // store information for analysis
  if (fIsComposite) {
    fLocalAnalyzePackage =
        new RenameAnalyzeUtil.LocalAnalyzePackage(
            unparentedDeclarationEdit, allUnparentedRenameEdits);
  } else
    fLocalAnalyzePackage =
        new RenameAnalyzeUtil.LocalAnalyzePackage(declarationEdit, allRenameEdits);
}
 
开发者ID:eclipse,项目名称:che,代码行数:43,代码来源:RenameLocalVariableProcessor.java

示例7: addDelegates

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
private RefactoringStatus addDelegates() throws JavaModelException, CoreException {

    RefactoringStatus status = new RefactoringStatus();
    CompilationUnitRewrite rewrite = new CompilationUnitRewrite(fField.getCompilationUnit());
    rewrite.setResolveBindings(true);

    // add delegate for the field
    if (RefactoringAvailabilityTester.isDelegateCreationAvailable(fField)) {
      FieldDeclaration fieldDeclaration =
          ASTNodeSearchUtil.getFieldDeclarationNode(fField, rewrite.getRoot());
      if (fieldDeclaration.fragments().size() > 1) {
        status.addWarning(
            Messages.format(
                RefactoringCoreMessages
                    .DelegateCreator_cannot_create_field_delegate_more_than_one_fragment,
                BasicElementLabels.getJavaElementName(fField.getElementName())),
            JavaStatusContext.create(fField));
      } else if (((VariableDeclarationFragment) fieldDeclaration.fragments().get(0))
              .getInitializer()
          == null) {
        status.addWarning(
            Messages.format(
                RefactoringCoreMessages.DelegateCreator_cannot_create_field_delegate_no_initializer,
                BasicElementLabels.getJavaElementName(fField.getElementName())),
            JavaStatusContext.create(fField));
      } else {
        DelegateFieldCreator creator = new DelegateFieldCreator();
        creator.setDeclareDeprecated(fDelegateDeprecation);
        creator.setDeclaration(fieldDeclaration);
        creator.setNewElementName(getNewElementName());
        creator.setSourceRewrite(rewrite);
        creator.prepareDelegate();
        creator.createEdit();
      }
    }

    // add delegates for getter and setter methods
    // there may be getters even if the field is static final
    if (getGetter() != null && fRenameGetter)
      addMethodDelegate(getGetter(), getNewGetterName(), rewrite);
    if (getSetter() != null && fRenameSetter)
      addMethodDelegate(getSetter(), getNewSetterName(), rewrite);

    final CompilationUnitChange change = rewrite.createChange(true);
    if (change != null) {
      change.setKeepPreviewEdits(true);
      fChangeManager.manage(fField.getCompilationUnit(), change);
    }

    return status;
  }
 
开发者ID:eclipse,项目名称:che,代码行数:52,代码来源:RenameFieldProcessor.java

示例8: addDelegates

import org.eclipse.jdt.core.refactoring.CompilationUnitChange; //导入方法依赖的package包/类
private RefactoringStatus addDelegates() throws JavaModelException, CoreException {

		RefactoringStatus status= new RefactoringStatus();
		CompilationUnitRewrite rewrite= new CompilationUnitRewrite(fField.getCompilationUnit());
		rewrite.setResolveBindings(true);

		// add delegate for the field
		if (RefactoringAvailabilityTester.isDelegateCreationAvailable(fField)) {
			FieldDeclaration fieldDeclaration= ASTNodeSearchUtil.getFieldDeclarationNode(fField, rewrite.getRoot());
			if (fieldDeclaration.fragments().size() > 1) {
				status.addWarning(Messages.format(RefactoringCoreMessages.DelegateCreator_cannot_create_field_delegate_more_than_one_fragment, BasicElementLabels.getJavaElementName(fField.getElementName())),
						JavaStatusContext.create(fField));
			} else if (((VariableDeclarationFragment) fieldDeclaration.fragments().get(0)).getInitializer() == null) {
				status.addWarning(Messages.format(RefactoringCoreMessages.DelegateCreator_cannot_create_field_delegate_no_initializer, BasicElementLabels.getJavaElementName(fField.getElementName())),
						JavaStatusContext.create(fField));
			} else {
				DelegateFieldCreator creator= new DelegateFieldCreator();
				creator.setDeclareDeprecated(fDelegateDeprecation);
				creator.setDeclaration(fieldDeclaration);
				creator.setNewElementName(getNewElementName());
				creator.setSourceRewrite(rewrite);
				creator.prepareDelegate();
				creator.createEdit();
			}
		}

		// add delegates for getter and setter methods
		// there may be getters even if the field is static final
		if (getGetter() != null && fRenameGetter)
			addMethodDelegate(getGetter(), getNewGetterName(), rewrite);
		if (getSetter() != null && fRenameSetter)
			addMethodDelegate(getSetter(), getNewSetterName(), rewrite);

		final CompilationUnitChange change= rewrite.createChange(true);
		if (change != null) {
			change.setKeepPreviewEdits(true);
			fChangeManager.manage(fField.getCompilationUnit(), change);
		}

		return status;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:RenameFieldProcessor.java


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