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


Java RefactoringContribution.createDescriptor方法代码示例

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


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

示例1: createDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入方法依赖的package包/类
/**
 * Creates a new refactoring descriptor for the specified input data.
 *
 * @param id the unique id of the refactoring
 * @param project the project name, or <code>null</code>
 * @param description a description
 * @param comment the comment, or <code>null</code>
 * @param arguments the argument map
 * @param flags the flags
 * @return the refactoring descriptor
 * @throws IllegalArgumentException if the argument map contains invalid keys/values
 */
public RefactoringDescriptor createDescriptor(
    final String id,
    final String project,
    final String description,
    final String comment,
    final Map arguments,
    final int flags)
    throws IllegalArgumentException {
  Assert.isNotNull(id);
  Assert.isNotNull(description);
  Assert.isNotNull(arguments);
  Assert.isLegal(flags >= RefactoringDescriptor.NONE);
  final RefactoringContribution contribution = getRefactoringContribution(id);
  if (contribution != null)
    return contribution.createDescriptor(id, project, description, comment, arguments, flags);
  return new DefaultRefactoringDescriptor(id, project, description, comment, arguments, flags);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RefactoringContributionManager.java

示例2: createDescriptor

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入方法依赖的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: renameVariable

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入方法依赖的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

示例4: perform

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入方法依赖的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

示例5: createRefactoringContext

import org.eclipse.ltk.core.refactoring.RefactoringContribution; //导入方法依赖的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.RefactoringContribution.createDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。