org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor Java Examples
The following examples show how to use
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor.
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: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private List<RefactoringProcessor> getProcessorsOfType(List<RefactoringProcessor> processors, Class<RenameLocalVariableProcessor> type) { List<RefactoringProcessor> tmp= new ArrayList<RefactoringProcessor>(); for (Iterator<RefactoringProcessor> iter= processors.iterator(); iter.hasNext();) { RefactoringProcessor element= iter.next(); if (element.getClass().equals(type)) tmp.add(element); } return tmp; }
Example #2
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) throws CoreException { RefactoringModifications modifications= getModifications(); if (modifications != null) { return modifications.loadParticipants(status, processor, natures, shared); } else { return new RefactoringParticipant[0]; } }
Example #3
Source File: CopyModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<>(); for (int i= 0; i < fCopies.size(); i++) { result.addAll(Arrays.asList(ParticipantManager.loadCopyParticipants(status, owner, fCopies.get(i), (CopyArguments) fCopyArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #4
Source File: XtendJdtRenameParticipantProcessor.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * @return true, if the triggering refactoring targets an Xtend element. */ protected boolean isXtendRename() { JdtRenameParticipant jdtRenameParticipant = ((JvmModelJdtRenameParticipantContext) getRenameElementContext()) .getJdtRenameParticipant(); RefactoringProcessor triggeringProcessor = jdtRenameParticipant.getProcessor().getRefactoring().getProcessor(); if(triggeringProcessor instanceof RenameElementProcessor) { EClass targetElementEClass = ((RenameElementProcessor) triggeringProcessor).getRenameElementContext().getTargetElementEClass(); return targetElementEClass.getEPackage() == XtendPackage.eINSTANCE; } return false; }
Example #5
Source File: TypeScriptRenameRefactoring.java From typescript.java with MIT License | 5 votes |
/** * {@inheritDoc} */ public RefactoringStatus initialize(final RefactoringArguments arguments) { Assert.isNotNull(arguments); final RefactoringProcessor processor= getProcessor(); if (processor instanceof IScriptableRefactoring) { return ((IScriptableRefactoring) processor).initialize(arguments); } return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.ProcessorBasedRefactoring_error_unsupported_initialization, getProcessor().getIdentifier())); }
Example #6
Source File: PairedMethodRenameParticipant.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private Change createChangeForMethodRename(IMethod methodToRename) throws RefactoringException { MethodRenameChangeBuilder builder = new MethodRenameChangeBuilder( methodToRename, newMethodName, processor, methodToRename.getJavaProject().getProject().getWorkspace()); ProcessorBasedRefactoring refactoring = (ProcessorBasedRefactoring) builder.createRefactoring(); RefactoringProcessor nestedProcessor = refactoring.getProcessor(); NestedRefactoringContext.storeForProcessor( nestedProcessor, MethodRenameRefactoringContext.newNestedRefactoringContext(refactoringContext)); return builder.createChange(); }
Example #7
Source File: PairedInterfaceRenameParticipant.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private Change createChangeForInterfaceRename() throws RefactoringException { InterfaceRenameChangeBuilder builder = new InterfaceRenameChangeBuilder( typeContainer.getPairedType(), pairedNewName, processor, typeContainer.getPairedType().getJavaProject().getProject().getWorkspace()); ProcessorBasedRefactoring refactoring = (ProcessorBasedRefactoring) builder.createRefactoring(); RefactoringProcessor nestedProcessor = refactoring.getProcessor(); NestedRefactoringContext.storeForProcessor( nestedProcessor, InterfaceRenameRefactoringContext.newNestedRefactoringContext(typeContainer.getBaseType())); return builder.createChange(); }
Example #8
Source File: RenameModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>(); for (int i= 0; i < fRename.size(); i++) { result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status, owner, fRename.get(i), (RenameArguments) fRenameArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #9
Source File: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void checkCUCompleteConditions(final RefactoringStatus status, CompilationUnit currentResolvedCU, ICompilationUnit currentCU, List<RefactoringProcessor> processors) throws CoreException { // check local variable conditions List<RefactoringProcessor> locals= getProcessorsOfType(processors, RenameLocalVariableProcessor.class); if (!locals.isEmpty()) { RenameAnalyzeUtil.LocalAnalyzePackage[] analyzePackages= new RenameAnalyzeUtil.LocalAnalyzePackage[locals.size()]; TextChangeManager manager= new TextChangeManager(); int current= 0; TextChange textChange= manager.get(currentCU); textChange.setKeepPreviewEdits(true); for (Iterator<RefactoringProcessor> iterator= locals.iterator(); iterator.hasNext();) { RenameLocalVariableProcessor localProcessor= (RenameLocalVariableProcessor) iterator.next(); RenameAnalyzeUtil.LocalAnalyzePackage analyzePackage= localProcessor.getLocalAnalyzePackage(); analyzePackages[current]= analyzePackage; for (int i= 0; i < analyzePackage.fOccurenceEdits.length; i++) { TextChangeCompatibility.addTextEdit(textChange, "", analyzePackage.fOccurenceEdits[i], GroupCategorySet.NONE); //$NON-NLS-1$ } current++; } status.merge(RenameAnalyzeUtil.analyzeLocalRenames(analyzePackages, textChange, currentResolvedCU, false)); } /* * There is room for performance improvement here: One could move * shadowing analyzes out of the field and method processors and perform * it here, thus saving on working copy creation. Drawback is increased * heap consumption. */ }
Example #10
Source File: AbstractXtendRenameRefactoringTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected ProcessorBasedRefactoring createXtendRenameRefactoring(final XtextEditor editor, final int offset, String newName) { IRenameElementContext renameElementContext = createRenameElementContext(editor, offset); ProcessorBasedRefactoring renameRefactoring = renameRefactoringProvider .getRenameRefactoring(renameElementContext); RefactoringProcessor processor = renameRefactoring.getProcessor(); if (processor instanceof AbstractRenameProcessor) ((AbstractRenameProcessor) processor).setNewName(newName); else if (processor instanceof JavaRenameProcessor) ((JavaRenameProcessor) processor).setNewElementName(newName); return renameRefactoring; }
Example #11
Source File: DeleteModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>(); for (Iterator<IJavaElement> iter= fDelete.iterator(); iter.hasNext();) { result.addAll(Arrays.asList(ParticipantManager.loadDeleteParticipants(status, owner, iter.next(), new DeleteArguments(), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #12
Source File: MoveModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>(); for (int i= 0; i < fMoves.size(); i++) { result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(status, owner, fMoves.get(i), (MoveArguments) fMoveArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #13
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) throws CoreException { RefactoringModifications modifications= getModifications(); if (modifications != null) { return modifications.loadParticipants(status, processor, natures, shared); } else { return new RefactoringParticipant[0]; } }
Example #14
Source File: CopyModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<RefactoringParticipant>(); for (int i= 0; i < fCopies.size(); i++) { result.addAll(Arrays.asList(ParticipantManager.loadCopyParticipants(status, owner, fCopies.get(i), (CopyArguments) fCopyArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #15
Source File: NLSAccessorFieldRenameParticipant.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public boolean initialize(RefactoringProcessor processor, Object element, RefactoringArguments arguments) { fNewName= ((RenameArguments) arguments).getNewName(); return super.initialize(processor, element, arguments); }
Example #16
Source File: RenameTypeWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RenameTypeProcessor getRenameTypeProcessor() { RefactoringProcessor proc= ((RenameRefactoring) getRefactoring()).getProcessor(); if (proc instanceof RenameTypeProcessor) return (RenameTypeProcessor) proc; else if (proc instanceof RenameCompilationUnitProcessor) { RenameCompilationUnitProcessor rcu= (RenameCompilationUnitProcessor) proc; return rcu.getRenameTypeProcessor(); } Assert.isTrue(false); // Should never get here return null; }
Example #17
Source File: RenameTypeWizardSimilarElementsPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RenameTypeProcessor getRenameTypeProcessor() { RefactoringProcessor proc= ((RenameRefactoring) getRefactoring()).getProcessor(); if (proc instanceof RenameTypeProcessor) return (RenameTypeProcessor) proc; else if (proc instanceof RenameCompilationUnitProcessor) { RenameCompilationUnitProcessor rcu= (RenameCompilationUnitProcessor) proc; return rcu.getRenameTypeProcessor(); } Assert.isTrue(false); // Should never get here return null; }
Example #18
Source File: MoveModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<>(); for (int i= 0; i < fMoves.size(); i++) { result.addAll(Arrays.asList(ParticipantManager.loadMoveParticipants(status, owner, fMoves.get(i), (MoveArguments) fMoveArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #19
Source File: ChangeCombiningRenameRefactoring.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void setProcessor(RefactoringProcessor processor) { if(processor instanceof CombinedJvmJdtRenameProcessor) { for(JavaRenameProcessor subProcessor: ((CombinedJvmJdtRenameProcessor) processor).getSubProcessors()) { // LTK's API made RefactoringProcessor.setRefactoring package private // such that we cannot override it in CombinedJvmJdtRenameProcessor. We have to set // the processors iteratively from the refactoring side !? super.setProcessor(subProcessor); } } super.setProcessor(processor); }
Example #20
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public CompositeRefactoringProcessor getCurrent(RefactoringProcessor jdtSourceRefactoring) { if (current == null || currentJdtSourceRefactoringProcessor != jdtSourceRefactoring) { current = compositeRefactoringProvider.get(); currentJdtSourceRefactoringProcessor = jdtSourceRefactoring; } return current; }
Example #21
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public Object[] getElements() { List<Object> elements = newArrayList(); for (RefactoringProcessor processor : processors) { for (Object element : processor.getElements()) elements.add(element); } return toArray(elements, Object.class); }
Example #22
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isApplicable() throws CoreException { for (RefactoringProcessor processor : processors) { if (!processor.isApplicable()) return false; } return true; }
Example #23
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { SubMonitor monitor = SubMonitor.convert(pm, processors.size()); RefactoringStatus status = new RefactoringStatus(); for (RefactoringProcessor processor : processors) { if (pm.isCanceled()) { throw new OperationCanceledException(); } status.merge(processor.checkInitialConditions(monitor.newChild(1))); } return status; }
Example #24
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { SubMonitor monitor = SubMonitor.convert(pm, processors.size()); RefactoringStatus status = new RefactoringStatus(); for (RefactoringProcessor processor : processors) { if (pm.isCanceled()) { throw new OperationCanceledException(); } status.merge(processor.checkFinalConditions(monitor.newChild(1), context)); } return status; }
Example #25
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { SubMonitor monitor = SubMonitor.convert(pm, processors.size()); CompositeChange compositeChange = new CompositeChange(getProcessorName()); for (RefactoringProcessor processor : processors) { if (pm.isCanceled()) { throw new OperationCanceledException(); } compositeChange.add(processor.createChange(monitor.newChild(1))); } return textChangeCombiner.combineChanges(compositeChange); }
Example #26
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(final RefactoringStatus status, final SharableParticipants sharedParticipants) throws CoreException { List<RefactoringParticipant> participants = newArrayList(); for (RefactoringProcessor processor : processors) { for (RefactoringParticipant participant : processor.loadParticipants(status, sharedParticipants)) { if (!(participant instanceof JdtRenameParticipant)) participants.add(participant); } } return toArray(participants, RefactoringParticipant.class); }
Example #27
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void setNewName(String newName) { this.newName = newName; for (RefactoringProcessor processor : processors) { if (processor instanceof AbstractRenameProcessor) ((AbstractRenameProcessor) processor).setNewName(newName); } }
Example #28
Source File: CompositeRefactoringProcessor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus validateNewName(String newName) { RefactoringStatus status = new RefactoringStatus(); for (RefactoringProcessor processor : processors) { if (processor instanceof AbstractRenameProcessor) status.merge(((AbstractRenameProcessor) processor).validateNewName(newName)); } return status; }
Example #29
Source File: RenameModifications.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor owner, String[] natures, SharableParticipants shared) { List<RefactoringParticipant> result= new ArrayList<>(); for (int i= 0; i < fRename.size(); i++) { result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status, owner, fRename.get(i), (RenameArguments) fRenameArguments.get(i), fParticipantDescriptorFilter.get(i), natures, shared))); } result.addAll(Arrays.asList(getResourceModifications().getParticipants(status, owner, natures, shared))); return result.toArray(new RefactoringParticipant[result.size()]); }
Example #30
Source File: RenameTypeProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void checkCUCompleteConditions(final RefactoringStatus status, CompilationUnit currentResolvedCU, ICompilationUnit currentCU, List<RefactoringProcessor> processors) throws CoreException { // check local variable conditions List<RefactoringProcessor> locals = getProcessorsOfType(processors, RenameLocalVariableProcessor.class); if (!locals.isEmpty()) { RenameAnalyzeUtil.LocalAnalyzePackage[] analyzePackages = new RenameAnalyzeUtil.LocalAnalyzePackage[locals.size()]; TextChangeManager manager = new TextChangeManager(); int current = 0; TextChange textChange = manager.get(currentCU); textChange.setKeepPreviewEdits(true); for (Iterator<RefactoringProcessor> iterator = locals.iterator(); iterator.hasNext();) { RenameLocalVariableProcessor localProcessor = (RenameLocalVariableProcessor) iterator.next(); RenameAnalyzeUtil.LocalAnalyzePackage analyzePackage = localProcessor.getLocalAnalyzePackage(); analyzePackages[current] = analyzePackage; for (int i = 0; i < analyzePackage.fOccurenceEdits.length; i++) { TextChangeCompatibility.addTextEdit(textChange, "", analyzePackage.fOccurenceEdits[i], GroupCategorySet.NONE); //$NON-NLS-1$ } current++; } status.merge(RenameAnalyzeUtil.analyzeLocalRenames(analyzePackages, textChange, currentResolvedCU, false)); } /* * There is room for performance improvement here: One could move * shadowing analyzes out of the field and method processors and perform * it here, thus saving on working copy creation. Drawback is increased * heap consumption. */ }