Package org.eclipse.ltk.core.refactoring

Examples of org.eclipse.ltk.core.refactoring.TextFileChange


            multiEdit.addChild(replaceEdit);
            offset += len; // to avoid overlapping
        }

        if (multiEdit.getChildrenSize() > 0) {
            TextFileChange fileChange = new TextFileChange(file.getName(), file) {
                @Override
                public Object getAdapter(Class adapter) {
                    if (adapter == TextEditChangeNode.class) {
                        return new GPDChangeNode(this, null, label);
                    }
                    return super.getAdapter(adapter);
                }
            };
            fileChange.setEdit(multiEdit);
            changes.add(fileChange);
        }
        return changes.toArray(new Change[changes.size()]);
    }
View Full Code Here


    final TextSearchRequestor collector = new TextSearchRequestor() {
      @Override
      public boolean acceptPatternMatch(final TextSearchMatchAccess matchAccess) throws CoreException {
        final IFile file = matchAccess.getFile();
        TextFileChange change = changes.get(file);
        if (change == null) {
          final TextChange textChange = getTextChange(file);
          if (textChange != null) {
            return false;
          }
          change = new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
        return true;
      }
    };

    TextSearchEngine.create().search(scope, collector, pattern, paramIProgressMonitor);
View Full Code Here

    final TextSearchRequestor collector = new TextSearchRequestor() {
      @Override
      public boolean acceptPatternMatch(final TextSearchMatchAccess matchAccess) throws CoreException {
        final IFile file = matchAccess.getFile();
        TextFileChange change = changes.get(file);
        if (change == null) {
          final TextChange textChange = getTextChange(file);
          if (textChange != null) {
            return false;
          }
          change = new TextFileChange(file.getName(), file);
          change.setEdit(new MultiTextEdit());
          changes.put(file, change);
        }
        final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
        change.addEdit(edit);
        change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
        return true;
      }
    };

    TextSearchEngine.create().search(scope, collector, pattern, paramIProgressMonitor);
View Full Code Here

        for (String pack : targets.keySet())
        {
            // create a change object for the file that contains the property
            // which the user has selected to rename
            IFile file = currentProject.getFile(pack).getRealFile();
            TextFileChange filechange = new TextFileChange( file.getName(), file );
            // a file change contains a tree of edits, first add the root of them
            MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
            filechange.setEdit( fileChangeRootEdit );
            compositeChange.add(filechange);
           
            for (Pair pair : targets.get(pack))
            {
                // edit object for the text replacement in the file, this is the only child
View Full Code Here

        ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(path);
        IDocument document = textFileBuffer.getDocument();

        TextEdit edit = cu.rewrite(document, javaProject.getOptions(true));
        TextFileChange dc = new TextFileChange(path.toString(), (IFile) cu.getJavaElement().getResource());
        dc.setTextType("java"); //$NON-NLS-1$
        dc.setEdit(edit);
        dc.setSaveMode(TextFileChange.FORCE_SAVE);

        compositeChange.add(dc);
      } catch (CoreException e) {
      }
    }
View Full Code Here

    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.reformatProductionRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
      AtgAstVisitor renameCharacterVisitor = new AtgAstVisitor() {
       
        @Override
        public boolean visit(AbstractAtgAstNode node) {
View Full Code Here

    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
      AtgAstVisitor renameTokenAtgVisitor = new AtgAstVisitor() {
       
        @Override
        public boolean visit(AbstractAtgAstNode node) {
View Full Code Here

    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
      AtgAstVisitor renameTokenAtgVisitor = new AtgAstVisitor() {
       
        @Override
        public boolean visit(AbstractAtgAstNode node) {
View Full Code Here

    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
      AtgAstVisitor renameCharacterVisitor = new AtgAstVisitor() {
       
        @Override
        public boolean visit(AbstractAtgAstNode node) {
View Full Code Here

    CompositeChange rootChange = new CompositeChange("CompositeChange");
    try {
      pm.beginTask( CoreTexts.renameRefactor_collectingChanges, 100 );
     
      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
      AtgAstVisitor renameTokenAtgVisitor = new AtgAstVisitor() {
       
        @Override
        public boolean visit(AbstractAtgAstNode node) {
View Full Code Here

TOP

Related Classes of org.eclipse.ltk.core.refactoring.TextFileChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.