CloneSet70


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
119201.000class_body_declarations[5]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
11191370
plugins/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
21191329
plugins/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe2.java
Clone Instance
1
Line Count
119
Source Line
1370
Source File
plugins/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java

        private void printRule(StringBuffer stringBuffer) {
                for (int i = 0; i < this.pageWidth; i++) {
                        if ((i % this.tabLength) == 0) {
                                stringBuffer.append('+');
                        }
                        else   {
                                stringBuffer.append('-');
                        }
                }
                stringBuffer.append(this.lineSeparator);
                for (int i = 0; i < (pageWidth / tabLength); i++) {
                        stringBuffer.append(i);
                        stringBuffer.append('\t');
                }
        }

        public void printTrailingComment() {
                try {
                        // if we have a space between two tokens we ensure it will be dumped in the formatted string
                        int currentTokenStartPosition = this.scanner.currentPosition;
                        boolean hasWhitespaces = false;
                        boolean hasComment = false;
                        boolean hasLineComment = false;
                        while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
                                switch (this.currentToken) {
                                        case TerminalTokens.TokenNameWHITESPACE:
                                                int count = 0;
                                                char[] whiteSpaces = this.scanner.getCurrentTokenSource();
                                                for (int i = 0, max = whiteSpaces.length; i < max; i++) {
                                                        switch (whiteSpaces[i]) {
                                                                case '\r':
                                                                        if ((i + 1) < max) {
                                                                                if (whiteSpaces[i + 1] == '\n') {
                                                                                        i++;
                                                                                }
                                                                        }
                                                                        count++;
                                                                        break;
                                                                case '\n':
                                                                        count++;
                                                              }
                                                }
                                                if (hasLineComment) {
                                                        if (count >= 1) {
                                                                currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
                                                                this.preserveEmptyLines(count, currentTokenStartPosition);
                                                                addDeleteEdit(currentTokenStartPosition, this.scanner.getCurrentTokenEndPosition());
                                                                this.scanner.resetTo(this.scanner.currentPosition, this.scannerEndPosition - 1);
                                                                return;
                                                        }
                                                        else   {
                                                                this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                                return;
                                                        }
                                                }
                                                else   if (count >= 1) {
                                                        if (hasComment) {
                                                                this.printNewLine(this.scanner.getCurrentTokenStartPosition());
                                                        }
                                                        this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                        return;
                                                       }
                                                       else {
                                                        hasWhitespaces = true;
                                                        currentTokenStartPosition = this.scanner.currentPosition;
                                                        addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
                                                       }
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_LINE:
                                                if (hasWhitespaces) {
                                                        space();
                                                }
                                                this.printCommentLine(this.scanner.getRawTokenSource());
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                hasLineComment = true;
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_BLOCK:
                                                if (hasWhitespaces) {
                                                        space();
                                                }
                                                this.printBlockComment(this.scanner.getRawTokenSource(), false);
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                hasComment = true;
                                                break;
                                        default:
                                                // step back one token
                                                this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                return;
                                      }
                        }
                } catch (InvalidInputException e) {
                        throw new AbortFormatting(e);
                  }
        }

        void redoAlignment(AlignmentException e) {
                if (e.relativeDepth > 0) { // if exception targets a distinct context
                        e.relativeDepth--; // record fact that current context got traversed
                        this.currentAlignment = this.currentAlignment.enclosing; // pop currentLocation
                        throw e; // rethrow
                }
                // reset scribe/scanner to restart at this given location
                this.resetAt(this.currentAlignment.location);
                this.scanner.resetTo(this.currentAlignment.location.inputOffset, this.scanner.eofPosition);
                // clean alignment chunkKind so it will think it is a new chunk again
                this.currentAlignment.chunkKind = 0;
        }

        void redoMemberAlignment(AlignmentException e) {
                // reset scribe/scanner to restart at this given location
                this.resetAt(this.memberAlignment.location);
                this.scanner.resetTo(this.memberAlignment.location.inputOffset, this.scanner.eofPosition);
                // clean alignment chunkKind so it will think it is a new chunk again
                this.memberAlignment.chunkKind = 0;
        }

        public void reset() {
                this.checkLineWrapping = true;
                this.line = 0;
                this.column = 1;
                this.editsIndex = 0;
                this.nlsTagCounter = 0;
        }


Clone Instance
2
Line Count
119
Source Line
1329
Source File
plugins/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe2.java

/*
        public void printQualifiedReference(Name name) {
                final int sourceEnd = name.getStartPosition() + name.getLength() - 1;
                int currentTokenStartPosition = this.scanner.currentPosition;
                try {
                        do {
                                this.printComment();
                                switch(this.currentToken = this.scanner.getNextToken()) {
                                        case TerminalTokens.TokenNameEOF :
                                                return;
                                        case TerminalTokens.TokenNameWHITESPACE :
                                                addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_BLOCK :
                                        case TerminalTokens.TokenNameCOMMENT_JAVADOC :
                                                this.printBlockComment(this.scanner.getRawTokenSource(), false);
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_LINE :
                                                this.printCommentLine(this.scanner.getRawTokenSource());
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        case TerminalTokens.TokenNameIdentifier :
                                        case TerminalTokens.TokenNameDOT :
                                                this.print(this.scanner.getRawTokenSource(), false);
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        default:
                                                this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                return;
                                }
                        } while (this.scanner.currentPosition <= sourceEnd);
                } catch(InvalidInputException e) {
                        throw new AbortFormatting(e);
                }
        }
*/
        private void printRule(StringBuffer stringBuffer) {
                for (int i = 0; i < this.pageWidth; i++) {
                        if ((i % this.tabLength) == 0) {
                                stringBuffer.append('+');
                        }
                        else   {
                                stringBuffer.append('-');
                        }
                }
                stringBuffer.append(this.lineSeparator);
                for (int i = 0; i < (pageWidth / tabLength); i++) {
                        stringBuffer.append(i);
                        stringBuffer.append('\t');
                }
        }

        public void printTrailingComment() {
                try {
                        // if we have a space between two tokens we ensure it will be dumped in the formatted string
                        int currentTokenStartPosition = this.scanner.currentPosition;
                        boolean hasWhitespaces = false;
                        boolean hasComment = false;
                        boolean hasLineComment = false;
                        while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
                                switch (this.currentToken) {
                                        case TerminalTokens.TokenNameWHITESPACE:
                                                int count = 0;
                                                char[] whiteSpaces = this.scanner.getCurrentTokenSource();
                                                for (int i = 0, max = whiteSpaces.length; i < max; i++) {
                                                        switch (whiteSpaces[i]) {
                                                                case '\r':
                                                                        if ((i + 1) < max) {
                                                                                if (whiteSpaces[i + 1] == '\n') {
                                                                                        i++;
                                                                                }
                                                                        }
                                                                        count++;
                                                                        break;
                                                                case '\n':
                                                                        count++;
                                                              }
                                                }
                                                if (hasLineComment) {
                                                        if (count >= 1) {
                                                                currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
                                                                this.preserveEmptyLines(count, currentTokenStartPosition);
                                                                addDeleteEdit(currentTokenStartPosition, this.scanner.getCurrentTokenEndPosition());
                                                                this.scanner.resetTo(this.scanner.currentPosition, this.scannerEndPosition - 1);
                                                                return;
                                                        }
                                                        else   {
                                                                this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                                return;
                                                        }
                                                }
                                                else   if (count >= 1) {
                                                        if (hasComment) {
                                                                this.printNewLine(this.scanner.getCurrentTokenStartPosition());
                                                        }
                                                        this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                        return;
                                                       }
                                                       else {
                                                        hasWhitespaces = true;
                                                        currentTokenStartPosition = this.scanner.currentPosition;
                                                        addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
                                                       }
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_LINE:
                                                if (hasWhitespaces) {
                                                        space();
                                                }
                                                this.printCommentLine(this.scanner.getRawTokenSource());
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                hasLineComment = true;
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_BLOCK:
                                                if (hasWhitespaces) {
                                                        space();
                                                }
                                                this.printBlockComment(this.scanner.getRawTokenSource(), false);
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                hasComment = true;
                                                break;
                                        default:
                                                // step back one token
                                                this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                return;
                                      }
                        }
                } catch (InvalidInputException e) {
                        throw new AbortFormatting(e);
                  }
        }

        void redoAlignment(AlignmentException e) {
                if (e.relativeDepth > 0) { // if exception targets a distinct context
                        e.relativeDepth--; // record fact that current context got traversed
                        this.currentAlignment = this.currentAlignment.enclosing; // pop currentLocation
                        throw e; // rethrow
                }
                // reset scribe/scanner to restart at this given location
                this.resetAt(this.currentAlignment.location);
                this.scanner.resetTo(this.currentAlignment.location.inputOffset, this.scanner.eofPosition);
                // clean alignment chunkKind so it will think it is a new chunk again
                this.currentAlignment.chunkKind = 0;
        }

        void redoMemberAlignment(AlignmentException e) {
                // reset scribe/scanner to restart at this given location
                this.resetAt(this.memberAlignment.location);
                this.scanner.resetTo(this.memberAlignment.location.inputOffset, this.scanner.eofPosition);
                // clean alignment chunkKind so it will think it is a new chunk again
                this.memberAlignment.chunkKind = 0;
        }

        public void reset() {
                this.checkLineWrapping = true;
                this.line = 0;
                this.column = 1;
                this.editsIndex = 0;
                this.nlsTagCounter = 0;
        }


Clone AbstractionParameter Count: 0Parameter Bindings

/*
        public void printQualifiedReference(Name name) {
                final int sourceEnd = name.getStartPosition() + name.getLength() - 1;
                int currentTokenStartPosition = this.scanner.currentPosition;
                try {
                        do {
                                this.printComment();
                                switch(this.currentToken = this.scanner.getNextToken()) {
                                        case TerminalTokens.TokenNameEOF :
                                                return;
                                        case TerminalTokens.TokenNameWHITESPACE :
                                                addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_BLOCK :
                                        case TerminalTokens.TokenNameCOMMENT_JAVADOC :
                                                this.printBlockComment(this.scanner.getRawTokenSource(), false);
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        case TerminalTokens.TokenNameCOMMENT_LINE :
                                                this.printCommentLine(this.scanner.getRawTokenSource());
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        case TerminalTokens.TokenNameIdentifier :
                                        case TerminalTokens.TokenNameDOT :
                                                this.print(this.scanner.getRawTokenSource(), false);
                                                currentTokenStartPosition = this.scanner.currentPosition;
                                                break;
                                        default:
                                                this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
                                                return;
                                }
                        } while (this.scanner.currentPosition <= sourceEnd);
                } catch(InvalidInputException e) {
                        throw new AbortFormatting(e);
                }
        }
*/
private void printRule(StringBuffer stringBuffer) {
  for (int i = 0; i < this.pageWidth; i++) {
    if ((i % this.tabLength) == 0) {
      stringBuffer.append('+');
    }
    else {
      stringBuffer.append('-');
    }
  }
  stringBuffer.append(this.lineSeparator);
  for (int i = 0; i < (pageWidth / tabLength); i++) {
    stringBuffer.append(i);
    stringBuffer.append('\t');
  }
}

public void printTrailingComment() {
  try {
    // if we have a space between two tokens we ensure it will be dumped in the formatted string
    int currentTokenStartPosition = this.scanner.currentPosition;
    boolean hasWhitespaces = false;
    boolean hasComment = false;
    boolean hasLineComment = false;
    while ((this.currentToken = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
      switch (this.currentToken) {
        case TerminalTokens.TokenNameWHITESPACE:
          int count = 0;
          char[] whiteSpaces = this.scanner.getCurrentTokenSource();
          for (int i = 0, max = whiteSpaces.length; i < max; i++) {
            switch (whiteSpaces[i]) {
              case '\r':
                if ((i + 1) < max) {
                  if (whiteSpaces[i + 1] == '\n') {
                    i++;
                  }
                }
                count++;
                break;
              case '\n':
                count++;
            }
          }
          if (hasLineComment) {
            if (count >= 1) {
              currentTokenStartPosition = this.scanner.getCurrentTokenStartPosition();
              this.preserveEmptyLines(count, currentTokenStartPosition);
              addDeleteEdit(currentTokenStartPosition, this.scanner.getCurrentTokenEndPosition());
              this.scanner.resetTo(this.scanner.currentPosition, this.scannerEndPosition - 1);
              return;
            }
            else {
              this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
              return;
            }
          }
          else
            if (count >= 1) {
              if (hasComment) {
                this.printNewLine(this.scanner.getCurrentTokenStartPosition());
              }
              this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
              return;
            }
            else {
              hasWhitespaces = true;
              currentTokenStartPosition = this.scanner.currentPosition;
              addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
            }
          break;
        case TerminalTokens.TokenNameCOMMENT_LINE:
          if (hasWhitespaces) {
            space();
          }
          this.printCommentLine(this.scanner.getRawTokenSource());
          currentTokenStartPosition = this.scanner.currentPosition;
          hasLineComment = true;
          break;
        case TerminalTokens.TokenNameCOMMENT_BLOCK:
          if (hasWhitespaces) {
            space();
          }
          this.printBlockComment(this.scanner.getRawTokenSource(), false);
          currentTokenStartPosition = this.scanner.currentPosition;
          hasComment = true;
          break;
        default:
          // step back one token
          this.scanner.resetTo(currentTokenStartPosition, this.scannerEndPosition - 1);
          return;
      }
    }
  }
  catch (InvalidInputException e) {
    throw new AbortFormatting(e);
  }
}

void redoAlignment(AlignmentException e) {
  if (e.relativeDepth > 0) { // if exception targets a distinct context
    e.relativeDepth--; // record fact that current context got traversed
    this.currentAlignment = this.currentAlignment.enclosing; // pop currentLocation
    throw e; // rethrow
  }
  // reset scribe/scanner to restart at this given location
  this.resetAt(this.currentAlignment.location);
  this.scanner.resetTo(this.currentAlignment.location.inputOffset, this.scanner.eofPosition);
  // clean alignment chunkKind so it will think it is a new chunk again
  this.currentAlignment.chunkKind = 0;
}

void redoMemberAlignment(AlignmentException e) {
  // reset scribe/scanner to restart at this given location
  this.resetAt(this.memberAlignment.location);
  this.scanner.resetTo(this.memberAlignment.location.inputOffset, this.scanner.eofPosition);
  // clean alignment chunkKind so it will think it is a new chunk again
  this.memberAlignment.chunkKind = 0;
}

public void reset() {
  this.checkLineWrapping = true;
  this.line = 0;
  this.column = 1;
  this.editsIndex = 0;
  this.nlsTagCounter = 0;
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
None