CloneSet212


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
43210.998class_body_declaration
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
143307
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/IndentAction.java
243436
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/IndentUtil.java
Clone Instance
1
Line Count
43
Source Line
307
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/IndentAction.java

        /**
         * Computes and returns the indentation for a javadoc line. The line
         * must be inside a javadoc comment.
         * 
         * @param document the document
         * @param line the line in document
         * @param scanner the scanner
         * @param partition the javadoc partition
         * @return the indent, or <code>null</code> if not computable
         * @throws BadLocationException
         * @since 3.1
         */
        private String computeJavadocIndent(IDocument document, int line, JavaHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
                if (line == 0) // impossible - the first line is never inside a javadoc comment
                        return null;

                // don't make any assumptions if the line does not start with \s*\* - it might be
                // commented out code, for which we don't want to change the indent
                final IRegion lineInfo = document.getLineInformation(line);
                final int lineStart = lineInfo.getOffset();
                final int lineLength = lineInfo.getLength();
                final int lineEnd = lineStart + lineLength;
                int nonWS = scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
                if (nonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
                        if (nonWS == JavaHeuristicScanner.NOT_FOUND)
                                return document.get(lineStart, lineLength);
                        return document.get(lineStart, nonWS - lineStart);
                }

                // take the indent from the previous line and reuse
                IRegion previousLine = document.getLineInformation(line - 1);
                int previousLineStart = previousLine.getOffset();
                int previousLineLength = previousLine.getLength();
                int previousLineEnd = previousLineStart + previousLineLength;

                StringBuffer buf = new StringBuffer();
                int previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
                if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
                        // align with the comment start if the previous line is not an asterisked line
                        previousLine = document.getLineInformationOfOffset(partition.getOffset());
                        previousLineStart = previousLine.getOffset();
                        previousLineLength = previousLine.getLength();
                        previousLineEnd = previousLineStart + previousLineLength;
                        previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
                        if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND)
                                previousLineNonWS = previousLineEnd;

                        // add the initial space 
                        // TODO this may be controlled by a formatter preference in the future
                        buf.append(' ');
                }

                String indentation = document.get(previousLineStart, previousLineNonWS - previousLineStart);
                buf.insert(0, indentation);
                return buf.toString();
        }


Clone Instance
2
Line Count
43
Source Line
436
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/IndentUtil.java

        /**
         * Computes and returns the indentation for a javadoc line. The line
         * must be inside a javadoc comment.
         * 
         * @param document the document
         * @param line the line in document
         * @param scanner the scanner
         * @param partition the comment partition
         * @return the indent, or <code>null</code> if not computable
         * @throws BadLocationException
         */
        private static String computeJavadocIndent(IDocument document, int line, JavaHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
                if (line == 0) // impossible - the first line is never inside a javadoc comment
                        return null;

                // don't make any assumptions if the line does not start with \s*\* - it might be
                // commented out code, for which we don't want to change the indent
                final IRegion lineInfo = document.getLineInformation(line);
                final int lineStart = lineInfo.getOffset();
                final int lineLength = lineInfo.getLength();
                final int lineEnd = lineStart + lineLength;
                int nonWS = scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
                if (nonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
                        if (nonWS == JavaHeuristicScanner.NOT_FOUND)
                                return document.get(lineStart, lineLength);
                        return document.get(lineStart, nonWS - lineStart);
                }

                // take the indent from the previous line and reuse
                IRegion previousLine = document.getLineInformation(line - 1);
                int previousLineStart = previousLine.getOffset();
                int previousLineLength = previousLine.getLength();
                int previousLineEnd = previousLineStart + previousLineLength;

                StringBuffer buf = new StringBuffer();
                int previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
                if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
                        // align with the comment start if the previous line is not an asterix line
                        previousLine = document.getLineInformationOfOffset(partition.getOffset());
                        previousLineStart = previousLine.getOffset();
                        previousLineLength = previousLine.getLength();
                        previousLineEnd = previousLineStart + previousLineLength;
                        previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
                        if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND)
                                previousLineNonWS = previousLineEnd;

                        // add the initial space 
                        // TODO this may be controlled by a formatter preference in the future
                        buf.append(' ');
                }

                String indentation = document.get(previousLineStart, previousLineNonWS - previousLineStart);
                buf.insert(0, indentation);
                return buf.toString();
        }


Clone AbstractionParameter Count: 1Parameter Bindings

 [[#variable56be5740]]String computeJavadocIndent(IDocument document, int line, JavaHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
  if (line == 0) // impossible - the first line is never inside a javadoc comment
    return null;
  // don't make any assumptions if the line does not start with \s*\* - it might be
  // commented out code, for which we don't want to change the indent
  final IRegion lineInfo = document.getLineInformation(line);
  final int lineStart = lineInfo.getOffset();
  final int lineLength = lineInfo.getLength();
  final int lineEnd = lineStart + lineLength;
  int nonWS = scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
  if (nonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
    if (nonWS == JavaHeuristicScanner.NOT_FOUND)
      return document.get(lineStart, lineLength);
    return document.get(lineStart, nonWS - lineStart);
  }
  // take the indent from the previous line and reuse
  IRegion previousLine = document.getLineInformation(line - 1);
  int previousLineStart = previousLine.getOffset();
  int previousLineLength = previousLine.getLength();
  int previousLineEnd = previousLineStart + previousLineLength;
  StringBuffer buf = new StringBuffer();
  int previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
  if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
    // align with the comment start if the previous line is not an asterisked line
    // align with the comment start if the previous line is not an asterix line
    previousLine = document.getLineInformationOfOffset(partition.getOffset());
    previousLineStart = previousLine.getOffset();
    previousLineLength = previousLine.getLength();
    previousLineEnd = previousLineStart + previousLineLength;
    previousLineNonWS = scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
    if (previousLineNonWS == JavaHeuristicScanner.NOT_FOUND)
      previousLineNonWS = previousLineEnd;
    // add the initial space 
    // TODO this may be controlled by a formatter preference in the future
    buf.append(' ');
  }
  String indentation = document.get(previousLineStart, previousLineNonWS - previousLineStart);
  buf.insert(0, indentation);
  return buf.toString();
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#56be5740]]
/**
 * Computes and returns the indentation for a javadoc line. The line
 * must be inside a javadoc comment.
 * 
 * @param document the document
 * @param line the line in document
 * @param scanner the scanner
 * @param partition the javadoc partition
 * @return the indent, or <code>null</code> if not computable
 * @throws BadLocationException
 * @since 3.1
 */
private 
12[[#56be5740]]
/**
 * Computes and returns the indentation for a javadoc line. The line
 * must be inside a javadoc comment.
 * 
 * @param document the document
 * @param line the line in document
 * @param scanner the scanner
 * @param partition the comment partition
 * @return the indent, or <code>null</code> if not computable
 * @throws BadLocationException
 */
private static