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


Java RefactoringCore.getRefactoringContribution方法代码示例

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


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

示例1: createRefactoring

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
/** {@inheritDoc} */
public Refactoring createRefactoring(final RefactoringStatus status) throws CoreException {
  Refactoring refactoring = null;
  final String id = getID();
  final RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(id);
  if (contribution != null) {
    if (contribution instanceof JavaRefactoringContribution) {
      JavaRefactoringContribution javaContribution = (JavaRefactoringContribution) contribution;
      refactoring = javaContribution.createRefactoring(this, status);
    } else
      JavaPlugin.log(
          new Status(
              IStatus.ERROR,
              JavaPlugin.getPluginId(),
              0,
              MessageFormat.format(
                  DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor,
                  new Object[] {id}),
              null));
  }
  return refactoring;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JavaRefactoringDescriptor.java

示例2: createDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
/**
 * Creates a {@link RefactoringDescriptor} from a
 * {@link RefactoringContribution} of the given ID.
 * 
 * @return a non-null {@link RefactoringDescriptor}
 * @throws RefactoringException if there was a problem creating the descriptor
 */
public static RefactoringDescriptor createDescriptor(String contributionId)
    throws RefactoringException {
  RefactoringContribution contribution = RefactoringCore.getRefactoringContribution(contributionId);
  if (contribution == null) {
    throw new RefactoringException(
        String.format("The refactoring contribution (%s) is not available.",
            contributionId));
  }

  RefactoringDescriptor refactoringDescriptor = contribution.createDescriptor();
  if (refactoringDescriptor == null) {
    throw new RefactoringException(
        String.format(
            "A descriptor could not be created from the refactoring contribution (%s).",
            contribution.getClass().getSimpleName()));
  }

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

示例3: getRefactoringDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
private IntroduceParameterDescriptor getRefactoringDescriptor() {
	ChangeMethodSignatureDescriptor extended= (ChangeMethodSignatureDescriptor) fChangeSignatureProcessor.createDescriptor();
	RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(IJavaRefactorings.CHANGE_METHOD_SIGNATURE);

	Map<String, String> argumentsMap= contribution.retrieveArgumentMap(extended);

	final Map<String, String> arguments= new HashMap<String, String>();
	arguments.put(ATTRIBUTE_ARGUMENT, fParameter.getNewName());
	arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_SELECTION, new Integer(fSelectionStart).toString() + " " + new Integer(fSelectionLength).toString()); //$NON-NLS-1$
	arguments.putAll(argumentsMap);
	String signature= fChangeSignatureProcessor.getMethodName();
	try {
		signature= fChangeSignatureProcessor.getOldMethodSignature();
	} catch (JavaModelException exception) {
		JavaPlugin.log(exception);
	}
	final String description= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description_short, BasicElementLabels.getJavaElementName(fChangeSignatureProcessor.getMethod().getElementName()));
	final String header= Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_descriptor_description, new String[] { BasicElementLabels.getJavaElementName(fParameter.getNewName()), signature, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))});
	final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(extended.getProject(), this, header);
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_original_pattern, JavaElementLabels.getTextLabel(fChangeSignatureProcessor.getMethod(),
			JavaElementLabels.ALL_FULLY_QUALIFIED)));
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_expression_pattern, BasicElementLabels.getJavaCodeString(ASTNodes.asString(fSelectedExpression))));
	comment.addSetting(Messages.format(RefactoringCoreMessages.IntroduceParameterRefactoring_parameter_pattern, BasicElementLabels.getJavaElementName(getAddedParameterInfo().getNewName())));
	return RefactoringSignatureDescriptorFactory.createIntroduceParameterDescriptor(extended.getProject(), description, comment.asString(), arguments, extended.getFlags());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:IntroduceParameterRefactoring.java

示例4: renameVariable

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
public static void renameVariable(String task, IJavaElement element, String new_name) {
    RefactoringStatus status = new RefactoringStatus();

    RefactoringContribution contrib = RefactoringCore
            .getRefactoringContribution(IJavaRefactorings.RENAME_LOCAL_VARIABLE);
    RenameJavaElementDescriptor rnDesc = (RenameJavaElementDescriptor) contrib.createDescriptor();
    rnDesc.setFlags(JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING);
    rnDesc.setProject(element.getJavaProject().getProject().getName());
    rnDesc.setUpdateReferences(true);
    rnDesc.setJavaElement(element);
    rnDesc.setNewName(new_name);

    Refactoring ref;
    try {
        ref = rnDesc.createRefactoring(status);
        ref.checkInitialConditions(NULL_MON);
        ref.checkFinalConditions(NULL_MON);

        Change change = ref.createChange(NULL_MON);
        change.perform(NULL_MON);
    } catch (CoreException e) {
        e.printStackTrace();
    }

}
 
开发者ID:Flamefire,项目名称:ImportSmaliVarNames,代码行数:26,代码来源:RefactoringHelper.java

示例5: executionNotification

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
@Override
public void executionNotification(RefactoringExecutionEvent event) {
	refactoringName = getRefactoringID(event);
	int refactoringEventType = event.getEventType();
	RefactoringDescriptor refactoringDescriptor = getRefactoringDescriptorFromEvent(event);
	RefactoringContribution refactoringContribution = RefactoringCore.getRefactoringContribution(refactoringName);
	Map argumentMap = refactoringContribution.retrieveArgumentMap(refactoringDescriptor);
	
	if (refactoringEventType == RefactoringExecutionEvent.ABOUT_TO_PERFORM || refactoringEventType == RefactoringExecutionEvent.ABOUT_TO_REDO) {
		isRefactoringInProgress = true;
		clientRecorder.recordRefactoring(refactoringName, argumentMap);
	}
	
	if (refactoringEventType == RefactoringExecutionEvent.ABOUT_TO_UNDO) {
		isRefactoringInProgress = true;
		clientRecorder.recordRefactoringUndo(refactoringName, argumentMap);
	}
	
	if (refactoringEventType == RefactoringExecutionEvent.PERFORMED || refactoringEventType == RefactoringExecutionEvent.REDONE || refactoringEventType == RefactoringExecutionEvent.UNDONE) {
		isRefactoringInProgress = false;
		clientRecorder.recordRefactoringEnd(refactoringName, argumentMap);
		refactoringName = "";
	}
}
 
开发者ID:ChangeOrientedProgrammingEnvironment,项目名称:eclipseRecorder,代码行数:25,代码来源:RefactoringExecutionListener.java

示例6: perform

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
@Override
public Change perform(IProgressMonitor pm) throws CoreException {

	RefactoringContribution refactoringContribution = RefactoringCore
			.getRefactoringContribution(IJavaRefactorings.MOVE);
	RefactoringDescriptor desc = refactoringContribution.createDescriptor();
	MoveDescriptor moveDes = (MoveDescriptor) desc;
	moveDes.setComment("Moving " + originalFile);
	moveDes.setDescription("Moving " + originalFile);
	IFolder dest = computeCompilationUnitDestination();
	moveDes.setDestination(JavaCore.create(dest));
	moveDes.setProject(originalFile.getProject().getName());
 
	moveDes.setMoveResources(new IFile[0], new IFolder[0],
			new ICompilationUnit[] { JavaCore.createCompilationUnitFrom(originalFile) });
	moveDes.setUpdateReferences(true);

	RefactoringStatus status = new RefactoringStatus();

	RefactoringContext context = moveDes.createRefactoringContext(status);
	PerformRefactoringOperation op = new PerformRefactoringOperation(context,
			CheckConditionsOperation.ALL_CONDITIONS);
	Job job = new WorkspaceJob("GW4E Moving Job") {
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			Display.getDefault().syncExec(() -> {
				try {
					
					op.run(monitor);
				} catch (Exception e) {
					ResourceManager.logException(e);
				}
			});
			return Status.OK_STATUS;
		}
	};
	job.setRule(originalFile.getProject()); // lock so that we serialize the
											// refactoring of the "test
											// interface" AND the "test
											// implementation"
	job.setUser(true);
	job.schedule();

	return op.getUndoChange();
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:46,代码来源:MoveCompilationUnitChange.java

示例7: createRefactoringContext

import org.eclipse.ltk.core.refactoring.RefactoringCore; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected RefactoringContext createRefactoringContext(RefactoringDescriptor descriptor, RefactoringStatus status, IProgressMonitor monitor) throws CoreException {
	Assert.isNotNull(descriptor);

	createNecessarySourceCode(monitor);

	if (descriptor instanceof JavaRefactoringDescriptor) {
		JavaRefactoringDescriptor javaDescriptor= (JavaRefactoringDescriptor) descriptor;
		RefactoringContribution contribution= RefactoringCore.getRefactoringContribution(javaDescriptor.getID());

		Map<String, String> map= contribution.retrieveArgumentMap(descriptor);
		if (fJavaProject == null) {
			status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
			return null;
		}

		String name= fJavaProject.getElementName();

		String handle= map.get(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
		if (handle != null && handle.length() > 0)
			map.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT, getTransformedHandle(name, handle));

		int count= 1;
		String attribute= JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
		while ((handle= map.get(attribute)) != null) {
			if (handle.length() > 0)
				map.put(attribute, getTransformedHandle(name, handle));
			count++;
			attribute= JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + count;
		}

		// create adapted descriptor
		try {
			descriptor= contribution.createDescriptor(descriptor.getID(), name, descriptor.getDescription(), descriptor.getComment(), map, descriptor.getFlags());
		} catch (IllegalArgumentException e) {
			status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments));
			return null;
		}
	}
	return descriptor.createRefactoringContext(status);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:BinaryRefactoringHistoryWizard.java


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