org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext Java Examples
The following examples show how to use
org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext.
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: N4JSRenameElementProcessor.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException { RefactoringStatus status = new RefactoringStatus(); status.merge(super.checkFinalConditions(monitor, context)); if (status.hasFatalError()) { return status; } String newName = this.getNewName(); EObject targetElement = this.getTargetElement(); List<EObject> realTargetElements = TypeModelUtils.getRealElements(targetElement); realTargetElements.stream() .forEach((realTargetElement) -> status.merge(checkDuplicateName(realTargetElement, newName))); return status; }
Example #2
Source File: UseSuperTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public final RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); final RefactoringStatus status= new RefactoringStatus(); fChangeManager= new TextEditBasedChangeManager(); try { monitor.beginTask("", 200); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.UseSuperTypeProcessor_checking); fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 200), status); if (!status.hasFatalError()) { Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context); } } finally { monitor.done(); } return status; }
Example #3
Source File: TypeScriptRenameProcessor.java From typescript.java with MIT License | 6 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { RefactoringStatus status = new RefactoringStatus(); // Consume "rename" tsserver command. try { rename = tsFile.rename(offset, isFindInComments(), isFindInStrings()).get(1000, TimeUnit.MILLISECONDS); RenameInfo info = rename.getInfo(); if (!info.isCanRename()) { // Refactoring cannot be done. status.addError(info.getLocalizedErrorMessage()); } } catch (Exception e) { status.addError(e.getMessage()); } return status; }
Example #4
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context, IReorgQueries reorgQueries) throws CoreException { Assert.isNotNull(reorgQueries); ResourceChangeChecker checker= context.getChecker(ResourceChangeChecker.class); IFile[] allModifiedFiles= getAllModifiedFiles(); RefactoringModifications modifications= getModifications(); IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); for (int i= 0; i < allModifiedFiles.length; i++) { deltaFactory.change(allModifiedFiles[i]); } if (modifications != null) { modifications.buildDelta(deltaFactory); modifications.buildValidateEdits(context.getChecker(ValidateEditChecker.class)); } return new RefactoringStatus(); }
Example #5
Source File: RenameLocalVariableProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { try { pm.beginTask("", 1); //$NON-NLS-1$ RefactoringStatus result= checkNewElementName(fNewName); if (result.hasFatalError()) return result; createEdits(); if (!fIsComposite) { LocalAnalyzePackage[] localAnalyzePackages= new RenameAnalyzeUtil.LocalAnalyzePackage[] { fLocalAnalyzePackage }; result.merge(RenameAnalyzeUtil.analyzeLocalRenames(localAnalyzePackages, fChange, fCompilationUnitNode, true)); } return result; } finally { pm.done(); if (fIsComposite) { // end of life cycle for this processor fChange= null; fCompilationUnitNode= null; fTempDeclarationNode= null; } } }
Example #6
Source File: RenameCompilationUnitProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { try{ if (fWillRenameType && (!fCu.isStructureKnown())){ RefactoringStatus result1= new RefactoringStatus(); RefactoringStatus result2= new RefactoringStatus(); result2.merge(Checks.checkCompilationUnitNewName(fCu, removeFileNameExtension(getNewElementName()))); if (result2.hasFatalError()) result1.addError(Messages.format(RefactoringCoreMessages.RenameCompilationUnitRefactoring_not_parsed_1, BasicElementLabels.getFileName(fCu))); else result1.addError(Messages.format(RefactoringCoreMessages.RenameCompilationUnitRefactoring_not_parsed, BasicElementLabels.getFileName(fCu))); result1.merge(result2); } if (fWillRenameType) { return fRenameTypeProcessor.checkFinalConditions(pm, context); } else { return Checks.checkCompilationUnitNewName(fCu, removeFileNameExtension(getNewElementName())); } } finally{ pm.done(); } }
Example #7
Source File: JavaRenameProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public final RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); RefactoringStatus result= doCheckFinalConditions(pm, context); if (result.hasFatalError()) return result; IFile[] changed= getChangedFiles(); for (int i= 0; i < changed.length; i++) { deltaFactory.change(changed[i]); } fRenameModifications= computeRenameModifications(); fRenameModifications.buildDelta(deltaFactory); fRenameModifications.buildValidateEdits((ValidateEditChecker)context.getChecker(ValidateEditChecker.class)); return result; }
Example #8
Source File: RenameTypeParameterProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 5); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_checking); status.merge(Checks.checkIfCuBroken(fTypeParameter.getDeclaringMember())); monitor.worked(1); if (!status.hasFatalError()) { status.merge(checkNewElementName(getNewElementName())); monitor.worked(1); monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_searching); status.merge(createRenameChanges(new SubProgressMonitor(monitor, 2))); monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_checking); if (status.hasFatalError()) { return status; } monitor.worked(1); } } finally { monitor.done(); } return status; }
Example #9
Source File: RenameTypeParameterProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 5); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_checking); status.merge(Checks.checkIfCuBroken(fTypeParameter.getDeclaringMember())); monitor.worked(1); if (!status.hasFatalError()) { status.merge(checkNewElementName(getNewElementName())); monitor.worked(1); monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_searching); status.merge(createRenameChanges(new SubProgressMonitor(monitor, 2))); monitor.setTaskName(RefactoringCoreMessages.RenameTypeParameterRefactoring_checking); if (status.hasFatalError()) return status; monitor.worked(1); } } finally { monitor.done(); } return status; }
Example #10
Source File: JavaRenameProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override public final RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { ResourceChangeChecker checker= context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); RefactoringStatus result= doCheckFinalConditions(pm, context); if (result.hasFatalError()) { return result; } IFile[] changed= getChangedFiles(); for (int i= 0; i < changed.length; i++) { deltaFactory.change(changed[i]); } fRenameModifications= computeRenameModifications(); fRenameModifications.buildDelta(deltaFactory); fRenameModifications.buildValidateEdits(context.getChecker(ValidateEditChecker.class)); return result; }
Example #11
Source File: RenameLocalVariableProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { try { pm.beginTask("", 1); //$NON-NLS-1$ RefactoringStatus result= checkNewElementName(fNewName); if (result.hasFatalError()) { return result; } createEdits(); if (!fIsComposite) { LocalAnalyzePackage[] localAnalyzePackages= new RenameAnalyzeUtil.LocalAnalyzePackage[] { fLocalAnalyzePackage }; result.merge(RenameAnalyzeUtil.analyzeLocalRenames(localAnalyzePackages, fChange, fCompilationUnitNode, true)); } return result; } finally { pm.done(); if (fIsComposite) { // end of life cycle for this processor fChange= null; fCompilationUnitNode= null; fTempDeclarationNode= null; } } }
Example #12
Source File: RenameCompilationUnitProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { try{ if (fWillRenameType && (!fCu.isStructureKnown())){ RefactoringStatus result1= new RefactoringStatus(); RefactoringStatus result2= new RefactoringStatus(); result2.merge(Checks.checkCompilationUnitNewName(fCu, removeFileNameExtension(getNewElementName()))); if (result2.hasFatalError()) { result1.addError(Messages.format(RefactoringCoreMessages.RenameCompilationUnitRefactoring_not_parsed_1, BasicElementLabels.getFileName(fCu))); } else { result1.addError(Messages.format(RefactoringCoreMessages.RenameCompilationUnitRefactoring_not_parsed, BasicElementLabels.getFileName(fCu))); } result1.merge(result2); } if (fWillRenameType) { return fRenameTypeProcessor.checkFinalConditions(pm, context); } else { return Checks.checkCompilationUnitNewName(fCu, removeFileNameExtension(getNewElementName())); } } finally{ pm.done(); } }
Example #13
Source File: AbstractProcessorBasedRenameParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException { SubMonitor progress = SubMonitor.convert(pm).setWorkRemaining(100 * wrappedProcessors.size()); try { for (RenameProcessor wrappedProcessor : wrappedProcessors) { List<Object> targetElements = Arrays.asList(wrappedProcessor.getElements()); if (!disabledTargets.containsAll(targetElements)) { setNewName(wrappedProcessor, getNewName()); status.merge(wrappedProcessor.checkInitialConditions(progress.newChild(20))); if(!status.getRefactoringStatus().hasFatalError()) status.merge(wrappedProcessor.checkFinalConditions(progress.newChild(80), context)); } } } catch (OperationCanceledException e) { throw e; } catch (Exception ce) { status.add(ERROR, "Error checking conditions in refactoring participant: {0}. See log for details", ce, LOG); } return status.getRefactoringStatus(); }
Example #14
Source File: RenameSourceFolderProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { pm.beginTask("", 1); //$NON-NLS-1$ try{ return new RefactoringStatus(); } finally{ pm.done(); } }
Example #15
Source File: ExtractSupertypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { final RefactoringStatus status= new RefactoringStatus(); try { monitor.beginTask("", 1); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.ExtractSupertypeProcessor_checking); status.merge(checkExtractedCompilationUnit()); if (status.hasFatalError()) return status; return super.checkFinalConditions(new SubProgressMonitor(monitor, 1), context); } finally { monitor.done(); } }
Example #16
Source File: MoveStaticMembersProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { fTarget= null; try { pm.beginTask(RefactoringCoreMessages.MoveMembersRefactoring_checking, 10); RefactoringStatus result= new RefactoringStatus(); fSource.clearASTAndImportRewrites(); result.merge(checkDestinationType()); if (result.hasFatalError()) return result; result.merge(checkDestinationInsideTypeToMove()); if (result.hasFatalError()) return result; result.merge(MemberCheckUtil.checkMembersInDestinationType(fMembersToMove, fDestinationType)); if (result.hasFatalError()) return result; result.merge(checkNativeMovedMethods(new SubProgressMonitor(pm, 1))); if (result.hasFatalError()) return result; List<ICompilationUnit> modifiedCus= new ArrayList<ICompilationUnit>(); createChange(modifiedCus, result, new SubProgressMonitor(pm, 7)); IFile[] changedFiles= getAllFilesToModify(modifiedCus); ResourceChangeChecker checker= (ResourceChangeChecker)context.getChecker(ResourceChangeChecker.class); for (int i= 0; i < changedFiles.length; i++) { checker.getDeltaFactory().change(changedFiles[i]); } return result; } finally { pm.done(); } }
Example #17
Source File: TextEditCreation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * In this method, changes from the occurrences found in the current document and * other files are transformed to the objects required by the Eclipse Language Toolkit */ public void fillRefactoringChangeObject(RefactoringRequest request, CheckConditionsContext context) { for (IRefactorRenameProcess p : processes) { if (status.hasFatalError() || request.getMonitor().isCanceled()) { break; } HashSet<ASTEntry> occurrences = p.getOccurrences(); if (docOccurrences == null) { docOccurrences = occurrences; } else { docOccurrences.addAll(occurrences); } Map<Tuple<String, File>, HashSet<ASTEntry>> occurrencesInOtherFiles = p.getOccurrencesInOtherFiles(); if (fileOccurrences == null) { fileOccurrences = occurrencesInOtherFiles; } else { //iterate in a copy for (Map.Entry<Tuple<String, File>, HashSet<ASTEntry>> entry : new HashMap<Tuple<String, File>, HashSet<ASTEntry>>( occurrencesInOtherFiles).entrySet()) { HashSet<ASTEntry> set = occurrencesInOtherFiles.get(entry.getKey()); if (set == null) { occurrencesInOtherFiles.put(entry.getKey(), entry.getValue()); } else { set.addAll(entry.getValue()); } } } } createCurrModuleChange(request); createOtherFileChanges(request); }
Example #18
Source File: ExtractInterfaceProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { Assert.isNotNull(monitor); Assert.isNotNull(context); final RefactoringStatus status= new RefactoringStatus(); fChangeManager= new TextEditBasedChangeManager(); try { monitor.beginTask("", 1); //$NON-NLS-1$ monitor.setTaskName(RefactoringCoreMessages.ExtractInterfaceProcessor_checking); status.merge(Checks.checkIfCuBroken(fSubType)); if (!status.hasError()) { if (fSubType.isBinary() || fSubType.isReadOnly() || !fSubType.exists()) status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractInterfaceProcessor_no_binary, JavaStatusContext.create(fSubType))); else if (fSubType.isAnonymous()) status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractInterfaceProcessor_no_anonymous, JavaStatusContext.create(fSubType))); else if (fSubType.isAnnotation()) status.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractInterfaceProcessor_no_annotation, JavaStatusContext.create(fSubType))); else { status.merge(checkSuperType()); if (!status.hasFatalError()) { if (!status.hasFatalError()) { fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 1), status); if (!status.hasFatalError()) { Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context); } } } } } } finally { monitor.done(); } return status; }
Example #19
Source File: PyRenameEntryPoint.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Checks all the changed file resources to cooperate with a VCS. * * @throws CoreException */ private static void checkResourcesToBeChanged(Set<IResource> resources, CheckConditionsContext context, RefactoringStatus refactoringStatus) throws CoreException { Set<IFile> affectedFiles = new HashSet<>(); for (IResource resource : resources) { if (resource instanceof IFile) { IFile fileResource = (IFile) resource; affectedFiles.add(fileResource); } } ChangedFilesChecker.checkFiles(affectedFiles, context, refactoringStatus); }
Example #20
Source File: IntroduceParameterObjectProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { RefactoringStatus status= new RefactoringStatus(); IMethod method= getMethod(); // TODO: Check for availability status.merge(Checks.checkTypeName(fParameterObjectFactory.getClassName(), method)); status.merge(Checks.checkIdentifier(getParameterName(), method)); if (status.hasFatalError()) return status; status.merge(super.checkFinalConditions(pm, context)); return status; }
Example #21
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, final CheckConditionsContext context) throws CoreException, OperationCanceledException { try { monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 12); clearCaches(); final RefactoringStatus result= new RefactoringStatus(); result.merge(createWorkingCopyLayer(new SubProgressMonitor(monitor, 4))); if (result.hasFatalError()) return result; if (monitor.isCanceled()) throw new OperationCanceledException(); result.merge(checkGenericDeclaringType(new SubProgressMonitor(monitor, 1))); result.merge(checkFinalFields(new SubProgressMonitor(monitor, 1))); if (monitor.isCanceled()) throw new OperationCanceledException(); result.merge(checkAccesses(new SubProgressMonitor(monitor, 1))); result.merge(checkMembersInTypeAndAllSubtypes(new SubProgressMonitor(monitor, 2))); result.merge(checkIfSkippingOverElements(new SubProgressMonitor(monitor, 1))); if (monitor.isCanceled()) throw new OperationCanceledException(); if (!JdtFlags.isAbstract(getDestinationType()) && getAbstractMethods().length > 0) result.merge(checkConstructorCalls(getDestinationType(), new SubProgressMonitor(monitor, 1))); else monitor.worked(1); if (result.hasFatalError()) return result; fCompilationUnitRewrites= new HashMap<ICompilationUnit, CompilationUnitRewrite>(3); result.merge(checkProjectCompliance(getCompilationUnitRewrite(fCompilationUnitRewrites, getDeclaringType().getCompilationUnit()), getDestinationType(), fMembersToMove)); fChangeManager= createChangeManager(new SubProgressMonitor(monitor, 1), result); Checks.addModifiedFilesToChecker(ResourceUtil.getFiles(fChangeManager.getAllCompilationUnits()), context); return result; } finally { monitor.done(); } }
Example #22
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context, IReorgQueries reorgQueries) throws CoreException { Assert.isNotNull(reorgQueries); ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); IFile[] allModifiedFiles= getAllModifiedFiles(); RefactoringModifications modifications= getModifications(); IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); for (int i= 0; i < allModifiedFiles.length; i++) { deltaFactory.change(allModifiedFiles[i]); } if (modifications != null) { modifications.buildDelta(deltaFactory); modifications.buildValidateEdits((ValidateEditChecker) context.getChecker(ValidateEditChecker.class)); } return new RefactoringStatus(); }
Example #23
Source File: RenameJavaProjectProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { pm.beginTask("", 1); //$NON-NLS-1$ try{ if (isReadOnly()){ String message= Messages.format(RefactoringCoreMessages.RenameJavaProjectRefactoring_read_only, BasicElementLabels.getJavaElementName(fProject.getElementName())); return RefactoringStatus.createErrorStatus(message); } return new RefactoringStatus(); } finally{ pm.done(); } }
Example #24
Source File: JavaMoveProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { try { Assert.isNotNull(fReorgQueries); fWasCanceled= false; return fMovePolicy.checkFinalConditions(pm, context, fReorgQueries); } catch (OperationCanceledException e) { fWasCanceled= true; throw e; } }
Example #25
Source File: JavaCopyProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { Assert.isNotNull(fNewNameQueries, "Missing new name queries"); //$NON-NLS-1$ Assert.isNotNull(fReorgQueries, "Missing reorg queries"); //$NON-NLS-1$ pm.beginTask("", 2); //$NON-NLS-1$ return fCopyPolicy.checkFinalConditions(new SubProgressMonitor(pm, 1), context, fReorgQueries); }
Example #26
Source File: JavaDeleteProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException { pm.beginTask(RefactoringCoreMessages.DeleteRefactoring_1, 1); try{ fWasCanceled= false; RefactoringStatus result= new RefactoringStatus(); recalculateElementsToDelete(); checkDirtyCompilationUnits(result); checkDirtyResources(result); fDeleteModifications= new DeleteModifications(); fDeleteModifications.delete(fResources); fDeleteModifications.delete(fJavaElements); List<IResource> packageDeletes= fDeleteModifications.postProcess(); TextChangeManager manager= new TextChangeManager(); fDeleteChange= DeleteChangeCreator.createDeleteChange(manager, fResources, fJavaElements, getProcessorName(), packageDeletes); ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); fDeleteModifications.buildDelta(deltaFactory); IFile[] files= ResourceUtil.getFiles(manager.getAllCompilationUnits()); for (int i= 0; i < files.length; i++) { deltaFactory.change(files[i]); } return result; } catch (OperationCanceledException e) { fWasCanceled= true; throw e; } finally{ pm.done(); } }
Example #27
Source File: Checks.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addModifiedFilesToChecker(IFile[] filesToModify, CheckConditionsContext context) { ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory(); for (int i= 0; i < filesToModify.length; i++) { deltaFactory.change(filesToModify[i]); } }
Example #28
Source File: RenameElementProcessor2.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException, OperationCanceledException { RenameChange renameChange = new RenameChange(newName, renameElementContext.getTargetElementURI()); RenameContext renameContext = new RenameContext(Arrays.asList(renameChange), resourceSet, changeSerializer, status); renameStrategy.applyRename(renameContext); String name = "Rename " + originalName + " to " + newName; ChangeConverter changeConverter = changeConverterFactory.create(name, null, status); changeSerializer.applyModifications(changeConverter); change = changeConverter.getChange(); return status.getRefactoringStatus(); }
Example #29
Source File: RenameRefactoringProcessor.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException { RefactoringStatus refactoringStatus = findMatches(monitor, context); return refactoringStatus; }
Example #30
Source File: CombinedJvmJdtRenameProcessor.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, jvmElements2jdtProcessors.size() + 1); RefactoringStatus status = super.checkFinalConditions(monitor.newChild(1), context); ResourceSet resourceSet = getResourceSet(getRenameElementContext()); getRenameArguments().getRenameStrategy().applyDeclarationChange(getNewName(), resourceSet); for (Iterator<Map.Entry<URI, JavaRenameProcessor>> entryIterator = jvmElements2jdtProcessors.entrySet().iterator(); entryIterator.hasNext();) { Map.Entry<URI, JavaRenameProcessor> jvmElement2jdtRefactoring = entryIterator.next(); if (monitor.isCanceled()) { throw new OperationCanceledException(); } URI renamedJvmElementURI = getRenameArguments().getNewElementURI(jvmElement2jdtRefactoring.getKey()); EObject renamedJvmElement = resourceSet.getEObject(renamedJvmElementURI, false); if (!(renamedJvmElement instanceof JvmIdentifiableElement) || renamedJvmElement.eIsProxy()) { status.addError("Cannot find inferred JVM element after refactoring."); } else { JavaRenameProcessor jdtRefactoring = jvmElement2jdtRefactoring.getValue(); String newName = ((JvmIdentifiableElement) renamedJvmElement).getSimpleName(); if(jdtRefactoring.getCurrentElementName().equals(newName)) { entryIterator.remove(); } else { jdtRefactoring.setNewElementName(newName); status.merge(jdtRefactoring.checkFinalConditions(monitor.newChild(1), context)); } } } getRenameArguments().getRenameStrategy().revertDeclarationChange(resourceSet); return status; }