CloneSet175


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
122220.988compilation_unit
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
112211
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/TextChangeManager.java
212211
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/TextEditBasedChangeManager.java
Clone Instance
1
Line Count
122
Source Line
11
Source File
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/TextChangeManager.java

/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.internal.corext.refactoring.util;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.eclipse.jdt.core.ICompilationUnit;

import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange;
import org.eclipse.ltk.core.refactoring.TextChange;

/**
 * A <code>TextChangeManager</code> manages associations between <code>ICompilationUnit</code>
 * or <code>IFile</code> and <code>TextChange</code> objects.
 */
public class TextChangeManager {

        private Map 
                   /*<ICompilationUnit, TextChange>*/
                                                      fMap = new HashMap(10);

        private final boolean fKeepExecutedTextEdits;

        public TextChangeManager() {
                this(false);
        }

        public TextChangeManager(boolean keepExecutedTextEdits) {
                fKeepExecutedTextEdits = keepExecutedTextEdits;
        }

        /**
         * Adds an association between the given compilation unit and the passed
         * change to this manager.
         * 
         * @param cu the compilation unit (key)
         * @param change the change associated with the compilation unit
         */
        public void manage(ICompilationUnit cu, TextChange change) {
                fMap.put(cu, change);
        }

        /**
         * Returns the <code>TextChange</code> associated with the given compilation unit.
         * If the manager does not already manage an association it creates a one.
         * 
         * @param cu the compilation unit for which the text buffer change is requested
         * @return the text change associated with the given compilation unit. 
         */
        public TextChange get(ICompilationUnit cu) {
                TextChange result = (TextChange) fMap.get(cu);
                if (result == null) {
                        result = new CompilationUnitChange(cu.getElementName(), cu);
                        result.setKeepPreviewEdits(fKeepExecutedTextEdits);
                        fMap.put(cu, result);
                }
                return result;
        }

        /**
         * Removes the <tt>TextChange</tt> managed under the given key
         * <code>unit<code>.
         * 
         * @param unit the key determining the <tt>TextChange</tt> to be removed.
         * @return the removed <tt>TextChange</tt>.
         */
        public TextChange remove(ICompilationUnit unit) {
                return (TextChange) fMap.remove(unit);
        }

        /**
         * Returns all text changes managed by this instance.
         * 
         * @return all text changes managed by this instance
         */
        public TextChange[] getAllChanges() {
                Set cuSet = fMap.keySet();
                ICompilationUnit[] cus = (ICompilationUnit[]) cuSet.toArray(new ICompilationUnit[cuSet.size()]);
                // sort by cu name:
                Arrays.sort(cus, new Comparator() {
                        public int compare(Object o1, Object o2) {
                                String name1 = ((ICompilationUnit) o1).getElementName();
                                String name2 = ((ICompilationUnit) o2).getElementName();
                                return name1.compareTo(name2);
                        }
                                 } );

                TextChange[] textChanges = new TextChange[cus.length];
                for (int i = 0; i < cus.length; i++) {
                        textChanges[i] = (TextChange) fMap.get(cus[i]);
                }
                return textChanges;
        }

        /**
         * Returns all compilation units managed by this instance.
         * 
         * @return all compilation units managed by this instance
         */
        public ICompilationUnit[] getAllCompilationUnits() {
                return (ICompilationUnit[]) fMap.keySet().toArray(new ICompilationUnit[fMap.keySet().size()]);
        }

        /**
         * Clears all associations between resources and text changes.
         */
        public void clear() {
                fMap.clear();
        }

        /**
         * Returns if any text changes are managed for the specified compilation unit.
         * 
         * @param cu the compilation unit
         * @return <code>true</code> if any text changes are managed for the specified compilation unit and <code>false</code> otherwise
         */
        public boolean containsChangesIn(ICompilationUnit cu) {
                return fMap.containsKey(cu);
        }
}




Clone Instance
2
Line Count
122
Source Line
11
Source File
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/TextEditBasedChangeManager.java

/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.internal.corext.refactoring.util;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.eclipse.jdt.core.ICompilationUnit;

import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange;
import org.eclipse.ltk.core.refactoring.TextEditBasedChange;

/**
 * A <code>TextChangeManager</code> manages associations between <code>ICompilationUnit</code>
 * or <code>IFile</code> and <code>TextEditBasedChange</code> objects.
 */
public class TextEditBasedChangeManager {

        private Map 
                   /*<ICompilationUnit, TextEditBasedChange>*/
                                                               fMap = new HashMap(10);

        private final boolean fKeepExecutedTextEdits;

        public TextEditBasedChangeManager() {
                this(false);
        }

        public TextEditBasedChangeManager(boolean keepExecutedTextEdits) {
                fKeepExecutedTextEdits = keepExecutedTextEdits;
        }

        /**
         * Adds an association between the given compilation unit and the passed
         * change to this manager.
         * 
         * @param cu the compilation unit (key)
         * @param change the change associated with the compilation unit
         */
        public void manage(ICompilationUnit cu, TextEditBasedChange change) {
                fMap.put(cu, change);
        }

        /**
         * Returns the <code>TextEditBasedChange</code> associated with the given compilation unit.
         * If the manager does not already manage an association it creates a one.
         * 
         * @param cu the compilation unit for which the text buffer change is requested
         * @return the text change associated with the given compilation unit. 
         */
        public TextEditBasedChange get(ICompilationUnit cu) {
                TextEditBasedChange result = (TextEditBasedChange) fMap.get(cu);
                if (result == null) {
                        result = new CompilationUnitChange(cu.getElementName(), cu);
                        result.setKeepPreviewEdits(fKeepExecutedTextEdits);
                        fMap.put(cu, result);
                }
                return result;
        }

        /**
         * Removes the <tt>TextEditBasedChange</tt> managed under the given key
         * <code>unit<code>.
         * 
         * @param unit the key determining the <tt>TextEditBasedChange</tt> to be removed.
         * @return the removed <tt>TextEditBasedChange</tt>.
         */
        public TextEditBasedChange remove(ICompilationUnit unit) {
                return (TextEditBasedChange) fMap.remove(unit);
        }

        /**
         * Returns all text changes managed by this instance.
         * 
         * @return all text changes managed by this instance
         */
        public TextEditBasedChange[] getAllChanges() {
                Set cuSet = fMap.keySet();
                ICompilationUnit[] cus = (ICompilationUnit[]) cuSet.toArray(new ICompilationUnit[cuSet.size()]);
                // sort by cu name:
                Arrays.sort(cus, new Comparator() {
                        public int compare(Object o1, Object o2) {
                                String name1 = ((ICompilationUnit) o1).getElementName();
                                String name2 = ((ICompilationUnit) o2).getElementName();
                                return name1.compareTo(name2);
                        }
                                 } );

                TextEditBasedChange[] textChanges = new TextEditBasedChange[cus.length];
                for (int i = 0; i < cus.length; i++) {
                        textChanges[i] = (TextEditBasedChange) fMap.get(cus[i]);
                }
                return textChanges;
        }

        /**
         * Returns all compilation units managed by this instance.
         * 
         * @return all compilation units managed by this instance
         */
        public ICompilationUnit[] getAllCompilationUnits() {
                return (ICompilationUnit[]) fMap.keySet().toArray(new ICompilationUnit[fMap.keySet().size()]);
        }

        /**
         * Clears all associations between resources and text changes.
         */
        public void clear() {
                fMap.clear();
        }

        /**
         * Returns if any text changes are managed for the specified compilation unit.
         * 
         * @param cu the compilation unit
         * @return <code>true</code> if any text changes are managed for the specified compilation unit and <code>false</code> otherwise
         */
        public boolean containsChangesIn(ICompilationUnit cu) {
                return fMap.containsKey(cu);
        }
}




Clone AbstractionParameter Count: 2Parameter Bindings

/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jdt.internal.corext.refactoring.util;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange;
import org.eclipse.ltk.core.refactoring. [[#variablea5c71e80]];

/**
 * A <code>TextChangeManager</code> manages associations between <code>ICompilationUnit</code>
 * or <code>IFile</code> and <code>TextChange</code> objects.
 */
/**
 * A <code>TextChangeManager</code> manages associations between <code>ICompilationUnit</code>
 * or <code>IFile</code> and <code>TextEditBasedChange</code> objects.
 */
public class [[#variableb8648680]]{
  private Map 
             /*<ICompilationUnit, TextChange>*/
             /*<ICompilationUnit, TextEditBasedChange>*/
             fMap = new HashMap(10);

  private final boolean fKeepExecutedTextEdits;

  public [[#variableb8648680]]() {
    this(false);
  }

  public [[#variableb8648680]](boolean keepExecutedTextEdits) {
    fKeepExecutedTextEdits = keepExecutedTextEdits;
  }

  /**
           * Adds an association between the given compilation unit and the passed
           * change to this manager.
           * 
           * @param cu the compilation unit (key)
           * @param change the change associated with the compilation unit
           */
  public void manage(ICompilationUnit cu, [[#variablea5c71e80]] change) {
    fMap.put(cu, change);
  }

  /**
           * Returns the <code>TextChange</code> associated with the given compilation unit.
           * If the manager does not already manage an association it creates a one.
           * 
           * @param cu the compilation unit for which the text buffer change is requested
           * @return the text change associated with the given compilation unit. 
           */
  /**
           * Returns the <code>TextEditBasedChange</code> associated with the given compilation unit.
           * If the manager does not already manage an association it creates a one.
           * 
           * @param cu the compilation unit for which the text buffer change is requested
           * @return the text change associated with the given compilation unit. 
           */
  public [[#variablea5c71e80]] get(ICompilationUnit cu) {
     [[#variablea5c71e80]] result = ( [[#variablea5c71e80]]) fMap.get(cu);
    if (result == null) {
      result = new CompilationUnitChange(cu.getElementName(), cu);
      result.setKeepPreviewEdits(fKeepExecutedTextEdits);
      fMap.put(cu, result);
    }
    return result;
  }

  /**
           * Removes the <tt>TextChange</tt> managed under the given key
           * <code>unit<code>.
           * 
           * @param unit the key determining the <tt>TextChange</tt> to be removed.
           * @return the removed <tt>TextChange</tt>.
           */
  /**
           * Removes the <tt>TextEditBasedChange</tt> managed under the given key
           * <code>unit<code>.
           * 
           * @param unit the key determining the <tt>TextEditBasedChange</tt> to be removed.
           * @return the removed <tt>TextEditBasedChange</tt>.
           */
  public [[#variablea5c71e80]] remove(ICompilationUnit unit) {
    return ( [[#variablea5c71e80]]) fMap.remove(unit);
  }

  /**
           * Returns all text changes managed by this instance.
           * 
           * @return all text changes managed by this instance
           */
  public [[#variablea5c71e80]][] getAllChanges() {
    Set cuSet = fMap.keySet();
    ICompilationUnit[] cus = (ICompilationUnit[]) cuSet.toArray(new ICompilationUnit[cuSet.size()]);
    // sort by cu name:
    Arrays.sort(cus, new Comparator() {
                       public int compare(Object o1, Object o2) {
                         String name1 = ((ICompilationUnit) o1).getElementName();
                         String name2 = ((ICompilationUnit) o2).getElementName();
                         return name1.compareTo(name2);
                       }
                     } );
     [[#variablea5c71e80]][] textChanges = new [[#variablea5c71e80]][cus.length];
    for (int i = 0; i < cus.length; i++) {
      textChanges[i] = ( [[#variablea5c71e80]]) fMap.get(cus[i]);
    }
    return textChanges;
  }

  /**
           * Returns all compilation units managed by this instance.
           * 
           * @return all compilation units managed by this instance
           */
  public ICompilationUnit[] getAllCompilationUnits() {
    return (ICompilationUnit[]) fMap.keySet().toArray(new ICompilationUnit[fMap.keySet().size()]);
  }

  /**
           * Clears all associations between resources and text changes.
           */
  public void clear() {
    fMap.clear();
  }

  /**
           * Returns if any text changes are managed for the specified compilation unit.
           * 
           * @param cu the compilation unit
           * @return <code>true</code> if any text changes are managed for the specified compilation unit and <code>false</code> otherwise
           */
  public boolean containsChangesIn(ICompilationUnit cu) {
    return fMap.containsKey(cu);
  }
}


 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#a5c71e80]]
TextChange 
12[[#a5c71e80]]
TextEditBasedChange 
21[[#b8648680]]
TextChangeManager 
22[[#b8648680]]
TextEditBasedChangeManager