@Override public Change perform(IProgressMonitor pm) throws CoreException { try { UndoEdit redo= performEdits(); Change result= new UndoDocumentChange(getName(), fDocument, redo); return result; } catch (MalformedTreeException e) { throw Changes.asCoreException(e); } catch (BadLocationException e) { throw Changes.asCoreException(e); } }
/** * {@inheritDoc} */ public RefactoringStatus isValid(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask("", 1); //$NON-NLS-1$ boolean needsSaving= needsSaving(); RefactoringStatus result= fValidationState.isValid(needsSaving); if (needsSaving) { result.merge(Changes.validateModifiesFiles(new IFile[] { fFile})); } else { // we are reading the file. So it should be at least in sync result.merge(Changes.checkInSync(new IFile[] { fFile})); } return result; } finally { monitor.done(); } }
@Override public Change perform(IProgressMonitor pm) throws CoreException { try { UndoEdit redo= performEdits(); Change result= new UndoDocumentChange(getName(), fDocument, redo); return result; } catch (MalformedTreeException e) { throw Changes.asCoreException(e); } catch (BadLocationException e) { throw Changes.asCoreException(e); } }
@Override public RefactoringStatus isValid(IProgressMonitor monitor) throws CoreException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask("", 1); //$NON-NLS-1$ if (fValidationState == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), "TextFileChange has not been initialialized")); //$NON-NLS-1$ boolean needsSaving= needsSaving(); RefactoringStatus result= fValidationState.isValid(needsSaving); if (needsSaving) { result.merge(Changes.validateModifiesFiles(new IFile[] { fFile})); } else { // we are reading the file. So it should be at least in sync result.merge(Changes.checkInSync(new IFile[] { fFile})); } return result; } finally { monitor.done(); } }
/** * {@inheritDoc} */ public Change perform(IProgressMonitor pm) throws CoreException { try { UndoEdit redo= fUndo.apply(fDocument, TextEdit.CREATE_UNDO); Change result= new UndoDocumentChange(getName(), fDocument, redo); return result; } catch (BadLocationException e) { throw Changes.asCoreException(e); } } }
@Override public RefactoringStatus isValid(IProgressMonitor monitor) throws CoreException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask("", 1); //$NON-NLS-1$ if (fValidationState == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), "TextFileChange has not been initialialized")); //$NON-NLS-1$ boolean needsSaving= needsSaving(); RefactoringStatus result= fValidationState.isValid(needsSaving); if (needsSaving) { result.merge(Changes.validateModifiesFiles(new IFile[] { fFile})); } else { // we are reading the file. So it should be at least in sync result.merge(Changes.checkInSync(new IFile[] { fFile})); } return result; } finally { monitor.done(); } }
public static boolean set(IDocument document, ContentStamp s) throws CoreException { if (!(s instanceof ContentStampImpl)) return false; ContentStampImpl stamp= (ContentStampImpl)s; if (document instanceof IDocumentExtension4 && stamp.isDocumentStamp()) { try { ((IDocumentExtension4)document).replace(0, 0, "", stamp.getValue()); //$NON-NLS-1$ return true; } catch (BadLocationException e) { throw Changes.asCoreException(e); } } return false; } }
@Override public final RefactoringStatus isValid(IProgressMonitor monitor) throws CoreException, OperationCanceledException { if (monitor == null) monitor= new NullProgressMonitor(); monitor.beginTask("", 1); //$NON-NLS-1$ try { if (fValidationState == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), "MultiStateTextFileChange has not been initialialized")); //$NON-NLS-1$ final ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE); fDirty= buffer != null && buffer.isDirty(); final RefactoringStatus status= fValidationState.isValid(needsSaving()); if (needsSaving()) { status.merge(Changes.validateModifiesFiles(new IFile[] { fFile })); } else { // we are reading the file. So it should be at least in sync status.merge(Changes.checkInSync(new IFile[] { fFile })); } return status; } finally { monitor.done(); } }
public static boolean set(IDocument document, ContentStamp s) throws CoreException { if (!(s instanceof ContentStampImpl)) return false; ContentStampImpl stamp= (ContentStampImpl)s; if (document instanceof IDocumentExtension4 && stamp.isDocumentStamp()) { try { ((IDocumentExtension4)document).replace(0, 0, "", stamp.getValue()); //$NON-NLS-1$ return true; } catch (BadLocationException e) { throw Changes.asCoreException(e); } } return false; } }
public final RefactoringStatus isValid(final IProgressMonitor monitor) throws CoreException, OperationCanceledException { monitor.beginTask("", 1); //$NON-NLS-1$ final ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE); fDirty= buffer != null && buffer.isDirty(); final RefactoringStatus status= fValidationState.isValid(needsSaving()); if (needsSaving()) { status.merge(Changes.validateModifiesFiles(new IFile[] { fFile})); } else { // we are reading the file. So it should be at least in sync status.merge(Changes.checkInSync(new IFile[] { fFile})); } monitor.worked(1); return status; }
public static boolean set(IDocument document, ContentStamp s) throws CoreException { if (!(s instanceof ContentStampImpl)) return false; ContentStampImpl stamp= (ContentStampImpl)s; if (document instanceof IDocumentExtension4 && stamp.isDocumentStamp()) { try { ((IDocumentExtension4)document).replace(0, 0, "", stamp.getValue()); //$NON-NLS-1$ return true; } catch (BadLocationException e) { throw Changes.asCoreException(e); } } return false; } }
@Override public final RefactoringStatus isValid(IProgressMonitor monitor) throws CoreException, OperationCanceledException { if (monitor == null) monitor= new NullProgressMonitor(); monitor.beginTask("", 1); //$NON-NLS-1$ try { if (fValidationState == null) throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), "MultiStateTextFileChange has not been initialialized")); //$NON-NLS-1$ final ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE); fDirty= buffer != null && buffer.isDirty(); final RefactoringStatus status= fValidationState.isValid(needsSaving()); if (needsSaving()) { status.merge(Changes.validateModifiesFiles(new IFile[] { fFile })); } else { // we are reading the file. So it should be at least in sync status.merge(Changes.checkInSync(new IFile[] { fFile })); } return status; } finally { monitor.done(); } }
@Override public Change perform(IProgressMonitor pm) throws CoreException { pm.beginTask("", 3); //$NON-NLS-1$ IDocument document= null; try { document= acquireDocument(new SubProgressMonitor(pm, 1)); UndoEdit undo= performEdits(document); commit(document, new SubProgressMonitor(pm, 1)); return createUndoChange(undo); } catch (BadLocationException e) { throw Changes.asCoreException(e); } catch (MalformedTreeException e) { throw Changes.asCoreException(e); } finally { releaseDocument(document, new SubProgressMonitor(pm, 1)); pm.done(); } }
@Override public Change perform(IProgressMonitor pm) throws CoreException { pm.beginTask("", 3); //$NON-NLS-1$ IDocument document= null; try { document= acquireDocument(new SubProgressMonitor(pm, 1)); UndoEdit undo= performEdits(document); commit(document, new SubProgressMonitor(pm, 1)); return createUndoChange(undo); } catch (BadLocationException e) { throw Changes.asCoreException(e); } catch (MalformedTreeException e) { throw Changes.asCoreException(e); } finally { releaseDocument(document, new SubProgressMonitor(pm, 1)); pm.done(); } }
@Override public final Change perform(final IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 3); //$NON-NLS-1$ IDocument document= null; try { document= acquireDocument(new SubProgressMonitor(monitor, 1)); final LinkedList<UndoEdit> undoList= new LinkedList<>(); performChanges(document, undoList, false); if (needsSaving()) fBuffer.commit(new SubProgressMonitor(monitor, 1), false); return new MultiStateUndoChange(getName(), fFile, undoList.toArray(new UndoEdit[undoList.size()]), fContentStamp, fSaveMode); } catch (BadLocationException exception) { throw Changes.asCoreException(exception); } finally { if (document != null) { releaseDocument(document, new SubProgressMonitor(monitor, 1)); } monitor.done(); } }
@Override public final Change perform(final IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 3); //$NON-NLS-1$ IDocument document= null; try { document= acquireDocument(new SubProgressMonitor(monitor, 1)); final LinkedList<UndoEdit> undoList= new LinkedList<>(); performChanges(document, undoList, false); if (needsSaving()) fBuffer.commit(new SubProgressMonitor(monitor, 1), false); return new MultiStateUndoChange(getName(), fFile, undoList.toArray(new UndoEdit[undoList.size()]), fContentStamp, fSaveMode); } catch (BadLocationException exception) { throw Changes.asCoreException(exception); } finally { if (document != null) { releaseDocument(document, new SubProgressMonitor(monitor, 1)); } monitor.done(); } }
public final Change perform(final IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 3); //$NON-NLS-1$ IDocument document= null; DocumentRewriteSession session= null; try { document= acquireDocument(new SubProgressMonitor(monitor, 1)); if (document instanceof IDocumentExtension4) session= ((IDocumentExtension4) document).startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED); final LinkedList undoList= new LinkedList(); performChanges(document, undoList, false); if (needsSaving()) fBuffer.commit(new SubProgressMonitor(monitor, 1), false); return new MultiStateUndoChange(getName(), fFile, (UndoEdit[]) undoList.toArray(new UndoEdit[undoList.size()]), fContentStamp, fSaveMode); } catch (BadLocationException exception) { throw Changes.asCoreException(exception); } finally { if (document != null) { try { if (session != null) ((IDocumentExtension4) document).stopRewriteSession(session); } finally { releaseDocument(document, new SubProgressMonitor(monitor, 1)); } } monitor.done(); } }
throw Changes.asCoreException(exception); } finally { if (document != null) {
throw Changes.asCoreException(exception); } finally { if (document != null) {
return createUndoChange(undo); } catch (BadLocationException e) { throw Changes.asCoreException(e); } finally { if (document != null) {