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


Java MoveRefactoring类代码示例

本文整理汇总了Java中org.eclipse.ltk.core.refactoring.participants.MoveRefactoring的典型用法代码示例。如果您正苦于以下问题:Java MoveRefactoring类的具体用法?Java MoveRefactoring怎么用?Java MoveRefactoring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MoveRefactoring类属于org.eclipse.ltk.core.refactoring.participants包,在下文中一共展示了MoveRefactoring类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMoveRefactoringSession

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
/**
 * Create move refactoring session.
 *
 * @param javaElements the java elements
 * @return the ID of the refactoring session
 */
public String createMoveRefactoringSession(IJavaElement[] javaElements)
    throws JavaModelException, RefactoringException {
  IReorgPolicy.IMovePolicy policy =
      ReorgPolicyFactory.createMovePolicy(new IResource[0], javaElements);
  if (policy.canEnable()) {
    JavaMoveProcessor processor = new JavaMoveProcessor(policy);
    // TODO this may overwrite existing sources.
    processor.setReorgQueries(new NullReorgQueries());
    processor.setCreateTargetQueries(() -> null);
    Refactoring refactoring = new MoveRefactoring(processor);
    MoveRefactoringSession session = new MoveRefactoringSession(refactoring, processor);
    final String id = String.format("move-%s", sessionId.getAndIncrement());
    sessions.put(id, session);
    return id;
  } else {
    throw new RefactoringException("Can't create move refactoring session.");
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RefactoringManager.java

示例2: run

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
public boolean run(Shell parent) throws InterruptedException, InvocationTargetException {
	Refactoring ref= new MoveRefactoring(fMoveProcessor);
	if (fMoveProcessor.hasAllInputSet()) {
		IRunnableContext context= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(parent));
		fMoveProcessor.setReorgQueries(new ReorgQueries(parent));
		new RefactoringExecutionHelper(ref, RefactoringCore.getConditionCheckingFailedSeverity(), fMoveProcessor.getSaveMode(), parent, context).perform(false, false);
		return true;
	} else {
		RefactoringWizard wizard= new ReorgMoveWizard(fMoveProcessor, ref);
		/*
		 * We want to get the shell from the refactoring dialog but it's not known at this point,
		 * so we pass the wizard and then, once the dialog is open, we will have access to its shell.
		 */
		fMoveProcessor.setCreateTargetQueries(new CreateTargetQueries(wizard));
		fMoveProcessor.setReorgQueries(new ReorgQueries(wizard));
		return new RefactoringStarter().activate(wizard, parent, RefactoringMessages.OpenRefactoringWizardAction_refactoring, fMoveProcessor.getSaveMode());
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ReorgMoveStarter.java

示例3: createRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
	JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));

	MoveStaticMembersProcessor processor= new MoveStaticMembersProcessor(arguments, status);
	return new MoveRefactoring(processor);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:MoveStaticMembersRefactoringContribution.java

示例4: createRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
	JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
	MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(arguments, status);
	return new MoveRefactoring(processor);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:MoveMethodRefactoringContribution.java

示例5: createRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws CoreException {
	JavaRefactoringArguments arguments= new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
	JavaMoveProcessor processor= new JavaMoveProcessor(arguments, status);
	return new MoveRefactoring(processor);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:MoveRefactoringContribution.java

示例6: startMoveRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
public static void startMoveRefactoring(final IResource[] resources, final IJavaElement[] elements, final Shell shell) throws JavaModelException {
	IMovePolicy policy= ReorgPolicyFactory.createMovePolicy(resources, elements);
	if (policy.canEnable()) {
		JavaMoveProcessor processor= new JavaMoveProcessor(policy);
		Refactoring refactoring= new MoveRefactoring(processor);
		RefactoringWizard wizard= new ReorgMoveWizard(processor, refactoring);
		processor.setCreateTargetQueries(new CreateTargetQueries(wizard));
		processor.setReorgQueries(new ReorgQueries(wizard));
		new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, processor.getSaveMode());
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:RefactoringExecutionStarter.java

示例7: startMoveStaticMembersRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
public static void startMoveStaticMembersRefactoring(final IMember[] members, final Shell shell) throws JavaModelException {
	if (!RefactoringAvailabilityTester.isMoveStaticAvailable(members))
		return;
	final Set<IMember> set= new HashSet<IMember>();
	set.addAll(Arrays.asList(members));
	final IMember[] elements= set.toArray(new IMember[set.size()]);
	IJavaProject project= null;
	if (elements.length > 0)
		project= elements[0].getJavaProject();
	MoveStaticMembersProcessor processor= new MoveStaticMembersProcessor(elements, JavaPreferencesSettings.getCodeGenerationSettings(project));
	Refactoring refactoring= new MoveRefactoring(processor);
	MoveMembersWizard wizard= new MoveMembersWizard(processor, refactoring);
	new RefactoringStarter().activate(wizard, shell, RefactoringMessages.OpenRefactoringWizardAction_refactoring, RefactoringSaveHelper.SAVE_REFACTORING);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:15,代码来源:RefactoringExecutionStarter.java

示例8: createRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
public Refactoring createRefactoring(RefactoringStatus status) throws CoreException {
  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

  IPath destinationPath = getDestinationPath();
  if (destinationPath == null) {
    status.addFatalError(
        RefactoringCoreMessages.MoveResourcesDescriptor_error_destination_not_set);
    return null;
  }

  IResource destination = root.findMember(destinationPath);
  if (!(destination instanceof IFolder || destination instanceof IProject)
      || !destination.exists()) {
    status.addFatalError(
        Messages.format(
            RefactoringCoreMessages.MoveResourcesDescriptor_error_destination_not_exists,
            BasicElementLabels.getPathLabel(destinationPath, false)));
    return null;
  }

  IPath[] paths = getResourcePathsToMove();
  if (paths == null) {
    status.addFatalError(RefactoringCoreMessages.MoveResourcesDescriptor_error_moved_not_set);
    return null;
  }

  IResource[] resources = new IResource[paths.length];
  for (int i = 0; i < paths.length; i++) {
    IPath path = paths[i];
    if (path == null) {
      status.addFatalError(
          RefactoringCoreMessages.MoveResourcesDescriptor_error_moved_contains_null);
      return null;
    }
    IResource resource = root.findMember(path);
    if (resource == null || !resource.exists()) {
      status.addFatalError(
          Messages.format(
              RefactoringCoreMessages.MoveResourcesDescriptor_error_moved_not_exists,
              BasicElementLabels.getPathLabel(path, false)));
      return null;
    }
    if (!(resource instanceof IFile || resource instanceof IFolder)) {
      status.addFatalError(
          Messages.format(
              RefactoringCoreMessages.MoveResourcesDescriptor_error_moved_not_file_or_folder,
              BasicElementLabels.getPathLabel(path, false)));
      return null;
    }
    resources[i] = resource;
  }

  MoveResourcesProcessor processor = new MoveResourcesProcessor(resources);
  processor.setDestination((IContainer) destination);
  processor.setUpdateReferences(isUpdateReferences());

  return new MoveRefactoring(processor);
}
 
开发者ID:eclipse,项目名称:che,代码行数:59,代码来源:MoveResourcesDescriptor.java

示例9: startMoveMethodRefactoring

import org.eclipse.ltk.core.refactoring.participants.MoveRefactoring; //导入依赖的package包/类
public static void startMoveMethodRefactoring(final IMethod method, final Shell shell) {
	MoveInstanceMethodProcessor processor= new MoveInstanceMethodProcessor(method, JavaPreferencesSettings.getCodeGenerationSettings(method.getJavaProject()));
	Refactoring refactoring= new MoveRefactoring(processor);
	MoveInstanceMethodWizard wizard= new MoveInstanceMethodWizard(processor, refactoring);
	new RefactoringStarter().activate(wizard, shell, RefactoringMessages.MoveInstanceMethodAction_dialog_title, RefactoringSaveHelper.SAVE_REFACTORING);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:RefactoringExecutionStarter.java


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