Java Code Examples for org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor#setUpdateQualifiedNames()
The following examples show how to use
org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor#setUpdateQualifiedNames() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PairedInterfaceRenameParticipant.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override protected void configureDescriptor(RenameJavaElementDescriptor descriptor) { descriptor.setJavaElement(pairedType); descriptor.setNewName(pairedNewName); descriptor.setProject(pairedType.getJavaProject().getProject().getName()); // getFilePatterns and getMatchStrategy could return uninitialized values // if they have not been explicitly set String filePatterns = processor.getFilePatterns(); if (filePatterns != null) { descriptor.setFileNamePatterns(filePatterns); } int strategy = processor.getMatchStrategy(); if (strategy == RenameJavaElementDescriptor.STRATEGY_EXACT || strategy == RenameJavaElementDescriptor.STRATEGY_EMBEDDED || strategy == RenameJavaElementDescriptor.STRATEGY_SUFFIX) { descriptor.setMatchStrategy(strategy); } descriptor.setUpdateQualifiedNames(processor.getUpdateQualifiedNames()); descriptor.setUpdateReferences(processor.getUpdateReferences()); descriptor.setUpdateSimilarDeclarations(processor.getUpdateSimilarDeclarations()); descriptor.setUpdateTextualOccurrences(processor.getUpdateTextualMatches()); }
Example 2
Source File: RenamePackageProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private RenameJavaElementDescriptor createRefactoringDescriptor() { String project= null; IJavaProject javaProject= fPackage.getJavaProject(); if (javaProject != null) project= javaProject.getElementName(); final int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final String description= Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description_short, getElementLabel(fPackage)); final String header= Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description, new String[] { getElementLabel(fPackage), getNewElementName()}); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); if (fRenameSubpackages) comment.addSetting(RefactoringCoreMessages.RenamePackageProcessor_rename_subpackages); final RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_PACKAGE); descriptor.setProject(project); descriptor.setDescription(description); descriptor.setComment(comment.asString()); descriptor.setFlags(flags); descriptor.setJavaElement(fPackage); descriptor.setNewName(getNewElementName()); descriptor.setUpdateReferences(fUpdateReferences); descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches); descriptor.setUpdateQualifiedNames(fUpdateQualifiedNames); if (fUpdateQualifiedNames && fFilePatterns != null && !"".equals(fFilePatterns)) //$NON-NLS-1$ descriptor.setFileNamePatterns(fFilePatterns); descriptor.setUpdateHierarchy(fRenameSubpackages); return descriptor; }
Example 3
Source File: RenamePackageProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private RenameJavaElementDescriptor createRefactoringDescriptor() { String project= null; IJavaProject javaProject= fPackage.getJavaProject(); if (javaProject != null) { project= javaProject.getElementName(); } final int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE; final String description= Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description_short, getElementLabel(fPackage)); final String header= Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description, new String[] { getElementLabel(fPackage), getNewElementName()}); final JDTRefactoringDescriptorComment comment= new JDTRefactoringDescriptorComment(project, this, header); if (fRenameSubpackages) { comment.addSetting(RefactoringCoreMessages.RenamePackageProcessor_rename_subpackages); } final RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_PACKAGE); descriptor.setProject(project); descriptor.setDescription(description); descriptor.setComment(comment.asString()); descriptor.setFlags(flags); descriptor.setJavaElement(fPackage); descriptor.setNewName(getNewElementName()); descriptor.setUpdateReferences(fUpdateReferences); descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches); descriptor.setUpdateQualifiedNames(fUpdateQualifiedNames); if (fUpdateQualifiedNames && fFilePatterns != null && !"".equals(fFilePatterns)) { descriptor.setFileNamePatterns(fFilePatterns); } descriptor.setUpdateHierarchy(fRenameSubpackages); return descriptor; }
Example 4
Source File: RenameTypeProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public Change createChange(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(RefactoringCoreMessages.RenameTypeRefactoring_creating_change, 4); String project = null; IJavaProject javaProject = fType.getJavaProject(); if (javaProject != null) { project = javaProject.getElementName(); } int flags = JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE; try { if (!Flags.isPrivate(fType.getFlags())) { flags |= RefactoringDescriptor.MULTI_CHANGE; } if (fType.isAnonymous() || fType.isLocal()) { flags |= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } } catch (JavaModelException exception) { JavaLanguageServerPlugin.log(exception); } final String description = Messages.format(RefactoringCoreMessages.RenameTypeProcessor_descriptor_description_short, BasicElementLabels.getJavaElementName(fType.getElementName())); final String header = Messages.format(RefactoringCoreMessages.RenameTypeProcessor_descriptor_description, new String[] { JavaElementLabels.getElementLabel(fType, JavaElementLabels.ALL_FULLY_QUALIFIED), getNewElementLabel() }); final String comment = new JDTRefactoringDescriptorComment(project, this, header).asString(); final RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_TYPE); descriptor.setProject(project); descriptor.setDescription(description); descriptor.setComment(comment); descriptor.setFlags(flags); descriptor.setJavaElement(fType); descriptor.setNewName(getNewElementName()); descriptor.setUpdateQualifiedNames(fUpdateQualifiedNames); descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches); descriptor.setUpdateReferences(fUpdateReferences); if (fUpdateQualifiedNames && fFilePatterns != null && !"".equals(fFilePatterns)) { descriptor.setFileNamePatterns(fFilePatterns); } descriptor.setUpdateSimilarDeclarations(fUpdateSimilarElements); descriptor.setMatchStrategy(fRenamingStrategy); final DynamicValidationRefactoringChange result = new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenameTypeProcessor_change_name); if (fChangeManager.containsChangesIn(fType.getCompilationUnit())) { TextChange textChange = fChangeManager.get(fType.getCompilationUnit()); if (textChange instanceof TextFileChange) { ((TextFileChange) textChange).setSaveMode(TextFileChange.FORCE_SAVE); } } if (willRenameCU()) { IResource resource = fType.getCompilationUnit().getResource(); if (resource != null && resource.isLinked()) { result.addAll(fChangeManager.getAllChanges()); String ext = resource.getFileExtension(); String renamedResourceName; if (ext == null) { renamedResourceName = getNewElementName(); } else { renamedResourceName = getNewElementName() + '.' + ext; } result.add(new RenameResourceChange(fType.getCompilationUnit().getPath(), renamedResourceName)); } else { addTypeDeclarationUpdate(fChangeManager); addConstructorRenames(fChangeManager); result.addAll(fChangeManager.getAllChanges()); String renamedCUName = JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), getNewElementName()); result.add(new RenameCompilationUnitChange(fType.getCompilationUnit(), renamedCUName)); } } else { result.addAll(fChangeManager.getAllChanges()); } monitor.worked(1); return result; } finally { fChangeManager = null; } }
Example 5
Source File: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public Change createChange(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(RefactoringCoreMessages.RenameTypeRefactoring_creating_change, 4); String project= null; IJavaProject javaProject= fType.getJavaProject(); if (javaProject != null) project= javaProject.getElementName(); int flags= JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING | RefactoringDescriptor.STRUCTURAL_CHANGE; try { if (!Flags.isPrivate(fType.getFlags())) flags|= RefactoringDescriptor.MULTI_CHANGE; if (fType.isAnonymous() || fType.isLocal()) flags|= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT; } catch (JavaModelException exception) { JavaPlugin.log(exception); } final String description= Messages.format(RefactoringCoreMessages.RenameTypeProcessor_descriptor_description_short, BasicElementLabels.getJavaElementName(fType.getElementName())); final String header= Messages.format(RefactoringCoreMessages.RenameTypeProcessor_descriptor_description, new String[] { JavaElementLabels.getElementLabel(fType, JavaElementLabels.ALL_FULLY_QUALIFIED), getNewElementLabel()}); final String comment= new JDTRefactoringDescriptorComment(project, this, header).asString(); final RenameJavaElementDescriptor descriptor= RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_TYPE); descriptor.setProject(project); descriptor.setDescription(description); descriptor.setComment(comment); descriptor.setFlags(flags); descriptor.setJavaElement(fType); descriptor.setNewName(getNewElementName()); descriptor.setUpdateQualifiedNames(fUpdateQualifiedNames); descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches); descriptor.setUpdateReferences(fUpdateReferences); if (fUpdateQualifiedNames && fFilePatterns != null && !"".equals(fFilePatterns)) //$NON-NLS-1$ descriptor.setFileNamePatterns(fFilePatterns); descriptor.setUpdateSimilarDeclarations(fUpdateSimilarElements); descriptor.setMatchStrategy(fRenamingStrategy); final DynamicValidationRefactoringChange result= new DynamicValidationRefactoringChange(descriptor, RefactoringCoreMessages.RenameTypeProcessor_change_name); if (fChangeManager.containsChangesIn(fType.getCompilationUnit())) { TextChange textChange= fChangeManager.get(fType.getCompilationUnit()); if (textChange instanceof TextFileChange) { ((TextFileChange) textChange).setSaveMode(TextFileChange.FORCE_SAVE); } } result.addAll(fChangeManager.getAllChanges()); if (willRenameCU()) { IResource resource= fType.getCompilationUnit().getResource(); if (resource != null && resource.isLinked()) { String ext= resource.getFileExtension(); String renamedResourceName; if (ext == null) renamedResourceName= getNewElementName(); else renamedResourceName= getNewElementName() + '.' + ext; result.add(new RenameResourceChange(fType.getCompilationUnit().getPath(), renamedResourceName)); } else { String renamedCUName= JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), getNewElementName()); result.add(new RenameCompilationUnitChange(fType.getCompilationUnit(), renamedCUName)); } } monitor.worked(1); return result; } finally { fChangeManager= null; } }