本文整理汇总了Java中org.eclipse.ltk.core.refactoring.participants.RenameRefactoring类的典型用法代码示例。如果您正苦于以下问题:Java RenameRefactoring类的具体用法?Java RenameRefactoring怎么用?Java RenameRefactoring使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RenameRefactoring类属于org.eclipse.ltk.core.refactoring.participants包,在下文中一共展示了RenameRefactoring类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: helper1
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper1(
String parameterName,
String newParameterName,
String typeName,
String methodName,
String[] methodSignature,
boolean references)
throws Exception {
IType declaringType = getType(createCUfromTestFile(getPackageP(), "A"), typeName);
IMethod[] declaringMethods =
getMethods(declaringType, new String[] {methodName}, new String[][] {methodSignature});
RenameTypeParameterProcessor processor =
new RenameTypeParameterProcessor(declaringMethods[0].getTypeParameter(parameterName));
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName(newParameterName);
processor.setUpdateReferences(references);
RefactoringStatus result = performRefactoring(refactoring);
assertNotNull("precondition was supposed to fail", result);
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:RenameTypeParameterTest.java
示例2: test18
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
@Test
public void test18() throws Exception {
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuC = createCUfromTestFile(getPackageP(), "C");
IType classB = getType(cu, "B");
RenameMethodProcessor processor =
new RenameNonVirtualMethodProcessor(classB.getMethod("m", new String[] {"I"}));
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName("kk");
assertEquals("was supposed to pass", null, performRefactoring(refactoring));
assertEqualLines(
"invalid renaming A", getFileContents(getOutputTestFileName("A")), cu.getSource());
assertEqualLines(
"invalid renaming C", getFileContents(getOutputTestFileName("C")), cuC.getSource());
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:RenamePrivateMethodTest.java
示例3: createRenameRefactoring
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
/**
* Create rename refactoring. It can create two rename refactoring types. First is linked mode
* rename refactoring, second is classic rename refactoring with wizard.
*
* @param element element to rename
* @param cu compilation unit which element belongs. null if element is IPackageFragment.
* @param offset cursor position inside editor, used only for linked mode
* @param lightweight if true try to create linked mode refactoring
* @return rename refactoring session
* @throws CoreException when impossible to create RenameSupport
* @throws RefactoringException when we don't support renaming provided element
*/
public RenameRefactoringSession createRenameRefactoring(
IJavaElement element, ICompilationUnit cu, int offset, boolean lightweight)
throws CoreException, RefactoringException {
// package fragments are always renamed with wizard
RenameRefactoringSession session = DtoFactory.newDto(RenameRefactoringSession.class);
String id = String.format("rename-%s", sessionId.getAndIncrement());
session.setSessionId(id);
session.setOldName(element.getElementName());
session.setWizardType(getWizardType(element));
if (lightweight && !(element instanceof IPackageFragment)) {
RenameLinkedModeRefactoringSession refactoringSession =
new RenameLinkedModeRefactoringSession(element, cu, offset);
LinkedModeModel model = refactoringSession.getModel();
if (model != null) {
session.setLinkedModeModel(model);
}
sessions.put(id, refactoringSession);
return session;
} else {
RenameSupport renameSupport =
createRenameSupport(element, null, RenameSupport.UPDATE_REFERENCES);
if (renameSupport != null && renameSupport.preCheck().isOK()) {
RenameRefactoring refactoring = renameSupport.getfRefactoring();
RenameSession renameSession = new RenameSession(refactoring);
sessions.put(id, renameSession);
return session;
}
throw new RefactoringException(
"Can't create refactoring session for element: " + element.getElementName());
}
}
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:RefactoringManager.java
示例4: checkMappedSimilarElementsExist
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void checkMappedSimilarElementsExist(Refactoring ref) {
RenameTypeProcessor rtp = (RenameTypeProcessor) ((RenameRefactoring) ref).getProcessor();
IJavaElementMapper mapper = (IJavaElementMapper) rtp.getAdapter(IJavaElementMapper.class);
IJavaElement[] similarElements = rtp.getSimilarElements();
if (similarElements == null) return;
for (int i = 0; i < similarElements.length; i++) {
IJavaElement element = similarElements[i];
if (!(element instanceof ILocalVariable)) {
IJavaElement newElement = mapper.getRefactoredJavaElement(element);
TestCase.assertTrue(newElement.exists());
Assert.assertFalse(element.exists());
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:RenameTypeTest.java
示例5: checkMappers
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void checkMappers(
Refactoring refactoring, IType type, String newCUName, IJavaElement[] someClassMembers) {
RenameTypeProcessor rtp =
(RenameTypeProcessor) ((RenameRefactoring) refactoring).getProcessor();
ICompilationUnit newUnit =
(ICompilationUnit) rtp.getRefactoredJavaElement(type.getCompilationUnit());
TestCase.assertTrue(newUnit.exists());
TestCase.assertTrue(newUnit.getElementName().equals(newCUName));
IFile newFile = (IFile) rtp.getRefactoredResource(type.getResource());
TestCase.assertTrue(newFile.exists());
TestCase.assertTrue(newFile.getName().equals(newCUName));
if ((type.getParent().getElementType() == IJavaElement.COMPILATION_UNIT)
&& type.getCompilationUnit().getElementName().equals(type.getElementName() + ".java")) {
Assert.assertFalse(type.getCompilationUnit().exists());
Assert.assertFalse(type.getResource().exists());
}
IPackageFragment oldPackage = (IPackageFragment) type.getCompilationUnit().getParent();
IPackageFragment newPackage = (IPackageFragment) rtp.getRefactoredJavaElement(oldPackage);
Assert.assertEquals(oldPackage, newPackage);
for (int i = 0; i < someClassMembers.length; i++) {
IMember member = (IMember) someClassMembers[i];
IJavaElement refactoredMember = rtp.getRefactoredJavaElement(member);
if (member instanceof IMethod && member.getElementName().equals(type.getElementName()))
continue; // constructor
TestCase.assertTrue(refactoredMember.exists());
Assert.assertEquals(member.getElementName(), refactoredMember.getElementName());
Assert.assertFalse(refactoredMember.equals(member));
}
}
开发者ID:eclipse,项目名称:che,代码行数:35,代码来源:RenameTypeTest.java
示例6: helper1_not_available
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper1_not_available(String methodName, String[] signatures) throws Exception {
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType interfaceI = getType(cu, "I");
RenameProcessor processor =
new RenameVirtualMethodProcessor(interfaceI.getMethod(methodName, signatures));
RenameRefactoring ref = new RenameRefactoring(processor);
assertTrue(!ref.isApplicable());
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:RenameMethodInInterfaceTest.java
示例7: helper1_not_available
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper1_not_available(String methodName, String[] signatures) throws Exception {
IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
RenameMethodProcessor processor =
new RenameVirtualMethodProcessor(classA.getMethod(methodName, signatures));
RenameRefactoring ref = new RenameRefactoring(processor);
assertTrue(!ref.isApplicable());
}
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RenameVirtualMethodInClassTest.java
示例8: helper1_0
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper1_0(String methodName, String newMethodName, String[] signatures)
throws Exception {
IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
RenameMethodProcessor processor =
new RenameVirtualMethodProcessor(classA.getMethod(methodName, signatures));
RenameRefactoring ref = new RenameRefactoring(processor);
processor.setNewElementName(newMethodName);
RefactoringStatus result = performRefactoring(ref);
assertNotNull("precondition was supposed to fail", result);
}
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:RenameVirtualMethodInClassTest.java
示例9: testPackageRenameWithResource1
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
@Test
public void testPackageRenameWithResource1() throws Exception {
IPackageFragment fragment = getRoot().createPackageFragment("org.test", true, null);
StringBuffer buf = new StringBuffer();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append(" org.test.MyClass me;\n");
buf.append("}\n");
fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
IFile file = ((IFolder) getRoot().getResource()).getFile("x.properties");
byte[] content = "This is about 'org.test' and more".getBytes();
file.create(new ByteArrayInputStream(content), true, null);
file.refreshLocal(IResource.DEPTH_ONE, null);
RenameJavaElementDescriptor descriptor =
RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
IJavaRefactorings.RENAME_PACKAGE);
descriptor.setJavaElement(fragment);
descriptor.setNewName("org.test2");
descriptor.setUpdateReferences(true);
descriptor.setUpdateQualifiedNames(true);
descriptor.setFileNamePatterns("*.properties");
Refactoring refactoring = createRefactoring(descriptor);
RefactoringStatus status = performRefactoring(refactoring);
if (status != null) assertTrue(status.toString(), status.isOK());
RefactoringProcessor processor = ((RenameRefactoring) refactoring).getProcessor();
IResourceMapper rm = (IResourceMapper) processor.getAdapter(IResourceMapper.class);
IJavaElementMapper jm = (IJavaElementMapper) processor.getAdapter(IJavaElementMapper.class);
checkMappingUnchanged(jm, rm, new Object[] {getRoot().getJavaProject(), getRoot(), file});
IFile newFile = ((IContainer) getRoot().getResource()).getFile(new Path("x.properties"));
assertEquals("This is about 'org.test2' and more", getContents(newFile));
checkMappingChanged(
jm, rm, new Object[][] {{fragment, getRoot().getPackageFragment("org.test2")}});
}
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:RenamePackageTest.java
示例10: testPackageRenameWithResource2
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
@Test
public void testPackageRenameWithResource2() throws Exception {
IPackageFragment fragment = getRoot().createPackageFragment("org.test", true, null);
StringBuffer buf = new StringBuffer();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
IFile file = ((IFolder) fragment.getResource()).getFile("x.properties");
byte[] content = "This is about 'org.test' and more".getBytes();
file.create(new ByteArrayInputStream(content), true, null);
file.refreshLocal(IResource.DEPTH_ONE, null);
RenameJavaElementDescriptor descriptor =
RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(
IJavaRefactorings.RENAME_PACKAGE);
descriptor.setJavaElement(fragment);
descriptor.setNewName("org.test2");
descriptor.setUpdateReferences(true);
descriptor.setUpdateHierarchy(true);
descriptor.setUpdateQualifiedNames(true);
descriptor.setFileNamePatterns("*.properties");
Refactoring refactoring = createRefactoring(descriptor);
RefactoringStatus status = performRefactoring(refactoring);
if (status != null) assertTrue(status.toString(), status.isOK());
RefactoringProcessor processor = ((RenameRefactoring) refactoring).getProcessor();
IResourceMapper rm = (IResourceMapper) processor.getAdapter(IResourceMapper.class);
IJavaElementMapper jm = (IJavaElementMapper) processor.getAdapter(IJavaElementMapper.class);
checkMappingUnchanged(jm, rm, new Object[] {getRoot().getJavaProject(), getRoot()});
IPackageFragment newFragment = getRoot().getPackageFragment("org.test2");
IFile newFile = ((IContainer) newFragment.getResource()).getFile(new Path("x.properties"));
assertEquals("This is about 'org.test2' and more", getContents(newFile));
checkMappingChanged(jm, rm, new Object[][] {{file, newFile}});
}
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:RenamePackageTest.java
示例11: test2
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
@Test
public void test2() throws Exception {
fIsPreDeltaTest = true;
RenamePackageProcessor processor =
helper2(new String[] {"r", "fred"}, new String[][] {{"A"}, {"A"}}, "p1");
// test that participants are correctly informed after '< Back':
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=280068
performUndo();
ParticipantTesting.reset();
String secondName = "pipapo";
processor.setNewElementName(secondName);
String[] renameHandles =
ParticipantTesting.createHandles(
new Object[] {processor.getPackage(), processor.getPackage().getResource()});
RenameRefactoring refactoring = (RenameRefactoring) processor.getRefactoring();
refactoring.checkFinalConditions(new NullProgressMonitor());
refactoring.createChange(new NullProgressMonitor());
ParticipantTesting.testRename(
renameHandles,
new RenameArguments[] {
new RenameArguments(secondName, true), new RenameArguments(secondName, true)
});
}
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:RenamePackageTest.java
示例12: helper2
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper2(
String parameterName, String newParameterName, String typeName, boolean references)
throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType declaringType = getType(cu, typeName);
ITypeParameter typeParameter = declaringType.getTypeParameter(parameterName);
RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(typeParameter);
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName(newParameterName);
processor.setUpdateReferences(references);
RefactoringStatus result = performRefactoring(refactoring);
assertEquals("was supposed to pass", null, result);
assertEqualLines(
"invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:RenameTypeParameterTest.java
示例13: helper1_0
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper1_0(String methodName, String newMethodName, String[] signatures)
throws Exception {
IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
RenameMethodProcessor processor =
new RenameNonVirtualMethodProcessor(classA.getMethod(methodName, signatures));
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName(newMethodName);
RefactoringStatus result = performRefactoring(refactoring);
assertNotNull("precondition was supposed to fail", result);
}
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:RenamePrivateMethodTest.java
示例14: helper2_0
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private void helper2_0(
String methodName,
String newMethodName,
String[] signatures,
boolean updateReferences,
boolean createDelegate)
throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType classA = getType(cu, "A");
IMethod method = classA.getMethod(methodName, signatures);
String[] handles = ParticipantTesting.createHandles(method);
RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(method);
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setUpdateReferences(updateReferences);
processor.setNewElementName(newMethodName);
processor.setDelegateUpdating(createDelegate);
assertEquals("was supposed to pass", null, performRefactoring(refactoring));
assertEqualLines(
"invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
ParticipantTesting.testRename(
handles, new RenameArguments[] {new RenameArguments(newMethodName, updateReferences)});
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
// assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
// assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size());
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:RenamePrivateMethodTest.java
示例15: RenameSupport
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
private RenameSupport(RenameJavaElementDescriptor descriptor) throws CoreException {
RefactoringStatus refactoringStatus = new RefactoringStatus();
fRefactoring = (RenameRefactoring) descriptor.createRefactoring(refactoringStatus);
if (refactoringStatus.hasFatalError()) {
fPreCheckStatus = refactoringStatus;
} else {
preCheck();
refactoringStatus.merge(fPreCheckStatus);
fPreCheckStatus = refactoringStatus;
}
}
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:RenameSupport.java
示例16: createRefactoring
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Refactoring createRefactoring(
JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments =
new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenamePackageProcessor processor = new RenamePackageProcessor(arguments, status);
return new RenameRefactoring(processor);
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:RenamePackageRefactoringContribution.java
示例17: createRefactoring
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Refactoring createRefactoring(
JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments =
new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(arguments, status);
return new RenameRefactoring(processor);
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:RenameTypeParameterRefactoringContribution.java
示例18: createRefactoring
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Refactoring createRefactoring(
JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments =
new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameLocalVariableProcessor processor = new RenameLocalVariableProcessor(arguments, status);
return new RenameRefactoring(processor);
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:RenameLocalVariableRefactoringContribution.java
示例19: createRefactoring
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Refactoring createRefactoring(
JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments =
new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameTypeProcessor processor = new RenameTypeProcessor(arguments, status);
return new RenameRefactoring(processor);
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:RenameTypeRefactoringContribution.java
示例20: createRefactoring
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Refactoring createRefactoring(
JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments =
new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameFieldProcessor processor = new RenameFieldProcessor(arguments, status);
return new RenameRefactoring(processor);
}
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:RenameFieldRefactoringContribution.java
注:本文中的org.eclipse.ltk.core.refactoring.participants.RenameRefactoring类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论