本文整理汇总了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);
}
示例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;
}
示例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();
}
}
示例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();
}
示例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