CloneSet327


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
76201.000class_body
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
17623
plugins/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ExclusivePositionUpdater.java
276427
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
Clone Instance
1
Line Count
76
Source Line
23
Source File
plugins/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/ExclusivePositionUpdater.java

                                                                 {

        /** The position category. */
        private final String fCategory;

        /**
         * Creates a new updater for the given <code>category</code>.
         *
         * @param category the new category.
         */
        public ExclusivePositionUpdater(String category) {
                fCategory = category;
        }

        /*
         * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
         */
        public void update(DocumentEvent event) {

                int eventOffset = event.getOffset();
                int eventOldLength = event.getLength();
                int eventNewLength = event.getText() == null ? 0:  event.getText().length();
                int deltaLength = eventNewLength - eventOldLength;

                try {
                        Position[] positions = event.getDocument().getPositions(fCategory);

                        for (int i = 0; i != positions.length; i++) {

                                Position position = positions[i];

                                if (position.isDeleted())
                                        continue ;

                                int offset = position.getOffset();
                                int length = position.getLength();
                                int end = offset + length;

                                if (offset >= eventOffset + eventOldLength)
                                        // position comes
                                        // after change - shift
                                        position.setOffset(offset + deltaLength);
                                else if (end <= eventOffset) {
                                        // position comes way before change -
                                        // leave alone
                                     }
                                     else
                                       if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
                                        // event completely internal to the position - adjust length
                                        position.setLength(length + deltaLength);
                                       }
                                       else
                                       if (offset < eventOffset) {
                                        // event extends over end of position - adjust length
                                        int newEnd = eventOffset;
                                        position.setLength(newEnd - offset);
                                       }
                                       else
                                       if (end > eventOffset + eventOldLength) {
                                        // event extends from before position into it - adjust offset
                                        // and length
                                        // offset becomes end of event, length adjusted accordingly
                                        int newOffset = eventOffset + eventNewLength;
                                        position.setOffset(newOffset);
                                        position.setLength(end - newOffset);
                                       }
                                       else {
                                        // event consumes the position - delete it
                                        position.delete();
                                       }
                        }
                } catch (BadPositionCategoryException e) {
                        // ignore and return
                  }
        }

        /**
         * Returns the position category.
         *
         * @return the position category
         */
        public String getCategory() {
                return fCategory;
        }
                                                                 }


Clone Instance
2
Line Count
76
Source Line
427
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java

                                                                                  {

                /** The position category. */
                private final String fCategory;

                /**
                 * Creates a new updater for the given <code>category</code>.
                 *
                 * @param category the new category.
                 */
                public ExclusivePositionUpdater(String category) {
                        fCategory = category;
                }

                /*
                 * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
                 */
                public void update(DocumentEvent event) {

                        int eventOffset = event.getOffset();
                        int eventOldLength = event.getLength();
                        int eventNewLength = event.getText() == null ? 0:  event.getText().length();
                        int deltaLength = eventNewLength - eventOldLength;

                        try {
                                Position[] positions = event.getDocument().getPositions(fCategory);

                                for (int i = 0; i != positions.length; i++) {

                                        Position position = positions[i];

                                        if (position.isDeleted())
                                                continue ;

                                        int offset = position.getOffset();
                                        int length = position.getLength();
                                        int end = offset + length;

                                        if (offset >= eventOffset + eventOldLength)
                                                // position comes
                                                // after change - shift
                                                position.setOffset(offset + deltaLength);
                                        else if (end <= eventOffset) {
                                                // position comes way before change -
                                                // leave alone
                                             }
                                             else
                                               if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
                                                // event completely internal to the position - adjust length
                                                position.setLength(length + deltaLength);
                                               }
                                               else
                                               if (offset < eventOffset) {
                                                // event extends over end of position - adjust length
                                                int newEnd = eventOffset;
                                                position.setLength(newEnd - offset);
                                               }
                                               else
                                               if (end > eventOffset + eventOldLength) {
                                                // event extends from before position into it - adjust offset
                                                // and length
                                                // offset becomes end of event, length adjusted accordingly
                                                int newOffset = eventOffset + eventNewLength;
                                                position.setOffset(newOffset);
                                                position.setLength(end - newOffset);
                                               }
                                               else {
                                                // event consumes the position - delete it
                                                position.delete();
                                               }
                                }
                        } catch (BadPositionCategoryException e) {
                                // ignore and return
                          }
                }

                /**
                 * Returns the position category.
                 *
                 * @return the position category
                 */
                public String getCategory() {
                        return fCategory;
                }
                                                                                  }


Clone AbstractionParameter Count: 0Parameter Bindings

{
  /** The position category. */
  private final String fCategory;

  /**
                   * Creates a new updater for the given <code>category</code>.
                   *
                   * @param category the new category.
                   */
  /**
           * Creates a new updater for the given <code>category</code>.
           *
           * @param category the new category.
           */
  public ExclusivePositionUpdater(String category) {
    fCategory = category;
  }

  /*
                   * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
                   */
  /*
           * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
           */
  public void update(DocumentEvent event) {
    int eventOffset = event.getOffset();
    int eventOldLength = event.getLength();
    int eventNewLength = event.getText() == null ? 0: event.getText().length();
    int deltaLength = eventNewLength - eventOldLength;
    try {
      Position[] positions = event.getDocument().getPositions(fCategory);
      for (int i = 0; i != positions.length; i++) {
        Position position = positions[i];
        if (position.isDeleted())
          continue ;
        int offset = position.getOffset();
        int length = position.getLength();
        int end = offset + length;
        if (offset >= eventOffset + eventOldLength)
          // position comes
          // after change - shift
          position.setOffset(offset + deltaLength);
        else
          if (end <= eventOffset) {
          // position comes way before change -
          // leave alone
          }
          else
            if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
              // event completely internal to the position - adjust length
              position.setLength(length + deltaLength);
            }
            else
              if (offset < eventOffset) {
                // event extends over end of position - adjust length
                int newEnd = eventOffset;
                position.setLength(newEnd - offset);
              }
              else
                if (end > eventOffset + eventOldLength) {
                  // event extends from before position into it - adjust offset
                  // and length
                  // offset becomes end of event, length adjusted accordingly
                  int newOffset = eventOffset + eventNewLength;
                  position.setOffset(newOffset);
                  position.setLength(end - newOffset);
                }
                else {
                  // event consumes the position - delete it
                  position.delete();
                }
      }
    }
    catch (BadPositionCategoryException e) {
    // ignore and return
    }
  }

  /**
                   * Returns the position category.
                   *
                   * @return the position category
                   */
  /**
           * Returns the position category.
           *
           * @return the position category
           */
  public String getCategory() {
    return fCategory;
  }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
None