1 11 package org.eclipse.jdt.internal.junit.refactoring; 12 13 import org.eclipse.core.runtime.CoreException; 14 15 import org.eclipse.jdt.core.IType; 16 17 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 18 19 import org.eclipse.jdt.internal.junit.util.TestSearchEngine; 20 21 public class TypeRenameParticipant extends JUnitRenameParticipant { 22 23 private IType fType; 24 25 protected boolean initialize(Object element) { 26 fType= (IType) element; 27 return isTestOrTestSuite(); 28 } 29 30 protected boolean isTestOrTestSuite() { 31 try { 32 return TestSearchEngine.isTestOrTestSuite(fType); 33 } catch (CoreException e) { 34 return false; 35 } 36 } 37 38 public void createChangeForConfig(ChangeList list, LaunchConfigurationContainer config) throws CoreException { 39 String typeName= fType.getFullyQualifiedName('.'); 40 String mainType= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String ) null); 41 if (typeName.equals(mainType)) { 42 int index= mainType.lastIndexOf('.'); 43 String prefix; 44 if (index == -1) 45 prefix= ""; prefix= mainType.substring(0, index + 1); 47 String newValue= prefix + getNewName(); 48 list.addAttributeChange(config, IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, newValue); 49 50 list.addRenameChangeIfNeeded(config, fType.getElementName()); 51 } 52 } 53 } 54 | Popular Tags |