Search in sources :

Example 36 with TextFileChange

use of org.eclipse.ltk.core.refactoring.TextFileChange in project jbosstools-hibernate by jbosstools.

the class HibernateJPARefactoring method createChange.

@Override
public Change createChange(IProgressMonitor pm) {
    // $NON-NLS-1$
    final CompositeChange cc = new CompositeChange("");
    for (int i = 0; i < changes.size(); i++) {
        ChangeStructure cs = changes.get(i);
        final String change_name = cs.path.toString();
        TextFileChange change = new TextFileChange(change_name, (IFile) cs.icu.getResource());
        change.setSaveMode(TextFileChange.LEAVE_DIRTY);
        change.setEdit(cs.textEdit);
        cs.change = change;
        cc.add(change);
    }
    cc.markAsSynthetic();
    return cc;
}
Also used : CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) ChangeStructure(org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure)

Example 37 with TextFileChange

use of org.eclipse.ltk.core.refactoring.TextFileChange in project erlide_eclipse by erlang.

the class ChangedFile method createChanges.

/**
 * Creates <code>Change</code> objects from the original and the modified source.
 *
 * @return the created <code>Change</code> object which typically instance of
 *         <code>TextFileChange</code>
 * @throws IOException
 *             if an exception occurs while accessing the source file
 */
public Change createChanges(final IFile file) throws IOException {
    IFile eclipseRep;
    if (file == null) {
        eclipseRep = findEclipseRepresentation(oldPath);
    } else {
        eclipseRep = file;
    }
    final TextFileChange change = new TextFileChange(oldPath, eclipseRep);
    // change.setSaveMode(TextFileChange.FORCE_SAVE);
    final File tf = new File(oldPath);
    final List<TextEdit> edits = ChangesetMaker.createEdits(tf, newFileContent);
    final MultiTextEdit multiEdit = new MultiTextEdit();
    if (!edits.isEmpty()) {
        for (final TextEdit edit : edits) {
            multiEdit.addChild(edit);
        }
        change.setEdit(multiEdit);
        return change;
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) File(java.io.File) IFile(org.eclipse.core.resources.IFile) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit)

Aggregations

TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)37 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)18 TextChange (org.eclipse.ltk.core.refactoring.TextChange)12 IFile (org.eclipse.core.resources.IFile)11 CoreException (org.eclipse.core.runtime.CoreException)11 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)10 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)10 TextEdit (org.eclipse.text.edits.TextEdit)9 InsertEdit (org.eclipse.text.edits.InsertEdit)8 Module (org.eclipse.titan.designer.AST.Module)8 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)6 ArrayList (java.util.ArrayList)5 IDocument (org.eclipse.jface.text.IDocument)5 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ITextFileBufferManager (org.eclipse.core.filebuffers.ITextFileBufferManager)3 IProject (org.eclipse.core.resources.IProject)3