Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
200 | 2 | 4 | 0.967 | class_body_declarations[15] |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 200 | 109 | plugins/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java |
2 | 198 | 109 | plugins/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe2.java |
| ||||
private final void addDeleteEdit(int start, int end) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(start, end - start + 1, EMPTY_STRING); } public final void addInsertEdit(int insertPosition, String insertedString) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(insertPosition, 0, insertedString); } private final void addOptimizedReplaceEdit(int offset, int length, String replacement) { if (this.editsIndex > 0) { // try to merge last two edits final OptimizedReplaceEdit previous = this.edits[this.editsIndex - 1]; final int previousOffset = previous.offset; final int previousLength = previous.length; final int endOffsetOfPreviousEdit = previousOffset + previousLength; final int replacementLength = replacement.length(); final String previousReplacement = previous.replacement; final int previousReplacementLength = previousReplacement.length(); if (previousOffset == offset && previousLength == length && (replacementLength == 0 || previousReplacementLength == 0)) { if (this.currentAlignment != null) { final Location location = this.currentAlignment.location; if (location.editsIndex == this.editsIndex) { location.editsIndex--; location.textEdit = previous; } } this.editsIndex--; return; } if (endOffsetOfPreviousEdit == offset) { if (length != 0) { if (replacementLength != 0) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement + replacement); } else if (previousLength + length == previousReplacementLength) { // check the characters. If they are identical, we can get rid of the previous edit boolean canBeRemoved = true; loop: for (int i = previousOffset; i < previousOffset + previousReplacementLength; i++) { if (scanner.source[i] != previousReplacement.charAt(i - previousOffset)) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousReplacementLength, previousReplacement); canBeRemoved = false; break loop; } } if (canBeRemoved) { if (this.currentAlignment != null) { final Location location = this.currentAlignment.location; if (location.editsIndex == this.editsIndex) { location.editsIndex--; location.textEdit = previous; } } this.editsIndex--; } } else { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement); } } else { if (replacementLength != 0) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength, previousReplacement + replacement); } } } else { this.edits[this.editsIndex++ ] = new OptimizedReplaceEdit(offset, length, replacement); } } else { this.edits[this.editsIndex++ ] = new OptimizedReplaceEdit(offset, length, replacement); } } public final void addReplaceEdit(int start, int end, String replacement) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(start, end - start + 1, replacement); } public void alignFragment(Alignment alignment, int fragmentIndex) { alignment.fragmentIndex = fragmentIndex; alignment.checkColumn(); alignment.performFragmentEffect(); } public void checkNLSTag(int sourceStart) { if (hasNLSTag(sourceStart)) { this.nlsTagCounter++; } } public void consumeNextToken() { printComment(); try { this.currentToken = this.scanner.getNextToken(); addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); } catch (InvalidInputException e) { throw new AbortFormatting(e); } } public Alignment createAlignment(String name, int mode, int count, int sourceRestart) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); } public Alignment createAlignment(String name, int mode, int count, int sourceRestart, boolean adjust) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust); } public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart) { return createAlignment(name, mode, tieBreakRule, count, sourceRestart, this.formatter.preferences.continuation_indentation, false); } public Alignment createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust); } public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust) { Alignment alignment = new Alignment(name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent); // adjust break indentation if (adjust && this.memberAlignment != null) { Alignment current = this.memberAlignment; while (current.enclosing != null) { current = current.enclosing; } if ((current.mode& Alignment.M_MULTICOLUMN) != 0) { final int indentSize = this.indentationSize; switch (current.chunkKind) { case Alignment.CHUNK_METHOD: case Alignment.CHUNK_TYPE: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = this.indentationLevel + indentSize; } else { alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize; } alignment.update(); break; case Alignment.CHUNK_FIELD: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize; } else { alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize; } alignment.update(); break; } } else { switch (current.mode& Alignment.SPLIT_MASK) { case Alignment.M_COMPACT_SPLIT: case Alignment.M_COMPACT_FIRST_BREAK_SPLIT: case Alignment.M_NEXT_PER_LINE_SPLIT: case Alignment.M_NEXT_SHIFTED_SPLIT: case Alignment.M_ONE_PER_LINE_SPLIT: final int indentSize = this.indentationSize; switch (current.chunkKind) { case Alignment.CHUNK_METHOD: case Alignment.CHUNK_TYPE: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = this.indentationLevel + indentSize; } else { alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize; } alignment.update(); break; case Alignment.CHUNK_FIELD: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize; } else { alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize; } alignment.update(); break; } break; } } } return alignment; } public Alignment createMemberAlignment(String name, int mode, int count, int sourceRestart) { Alignment mAlignment = createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); mAlignment.breakIndentationLevel = this.indentationLevel; return mAlignment; } public void enterAlignment(Alignment alignment) { alignment.enclosing = this.currentAlignment; alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart; this.currentAlignment = alignment; } public void enterMemberAlignment(Alignment alignment) { alignment.enclosing = this.memberAlignment; alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart; this.memberAlignment = alignment; } |
| ||||
private final void addDeleteEdit(int start, int end) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(start, end - start + 1, EMPTY_STRING); } public final void addInsertEdit(int insertPosition, String insertedString) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(insertPosition, 0, insertedString); } private final void addOptimizedReplaceEdit(int offset, int length, String replacement) { if (this.editsIndex > 0) { // try to merge last two edits final OptimizedReplaceEdit previous = this.edits[this.editsIndex - 1]; final int previousOffset = previous.offset; final int previousLength = previous.length; final int endOffsetOfPreviousEdit = previousOffset + previousLength; final int replacementLength = replacement.length(); final String previousReplacement = previous.replacement; final int previousReplacementLength = previousReplacement.length(); if (previousOffset == offset && previousLength == length && (replacementLength == 0 || previousReplacementLength == 0)) { if (this.currentAlignment != null) { final Location2 location = this.currentAlignment.location; if (location.editsIndex == this.editsIndex) { location.editsIndex--; location.textEdit = previous; } } this.editsIndex--; return; } if (endOffsetOfPreviousEdit == offset) { if (length != 0) { if (replacementLength != 0) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement + replacement); } else if (previousLength + length == previousReplacementLength) { // check the characters. If they are identical, we can get rid of the previous edit boolean canBeRemoved = true; loop: for (int i = previousOffset; i < previousOffset + previousReplacementLength; i++) { if (scanner.source[i] != previousReplacement.charAt(i - previousOffset)) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousReplacementLength, previousReplacement); canBeRemoved = false; break loop; } } if (canBeRemoved) { if (this.currentAlignment != null) { final Location2 location = this.currentAlignment.location; if (location.editsIndex == this.editsIndex) { location.editsIndex--; location.textEdit = previous; } } this.editsIndex--; } } else { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement); } } else { if (replacementLength != 0) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength, previousReplacement + replacement); } } } else { this.edits[this.editsIndex++ ] = new OptimizedReplaceEdit(offset, length, replacement); } } else { this.edits[this.editsIndex++ ] = new OptimizedReplaceEdit(offset, length, replacement); } } public final void addReplaceEdit(int start, int end, String replacement) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(start, end - start + 1, replacement); } public void alignFragment(Alignment2 alignment, int fragmentIndex) { alignment.fragmentIndex = fragmentIndex; alignment.checkColumn(); alignment.performFragmentEffect(); } public void checkNLSTag(int sourceStart) { if (hasNLSTag(sourceStart)) { this.nlsTagCounter++; } } public void consumeNextToken() { printComment(); try { this.currentToken = this.scanner.getNextToken(); addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); } catch (InvalidInputException e) { throw new AbortFormatting(e); } } public Alignment2 createAlignment(String name, int mode, int count, int sourceRestart) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); } public Alignment2 createAlignment(String name, int mode, int count, int sourceRestart, boolean adjust) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust); } public Alignment2 createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart) { return createAlignment(name, mode, tieBreakRule, count, sourceRestart, this.formatter.preferences.continuation_indentation, false); } public Alignment2 createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust); } public Alignment2 createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust) { Alignment2 alignment = new Alignment2(name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent); // adjust break indentation if (adjust && this.memberAlignment != null) { Alignment2 current = this.memberAlignment; while (current.enclosing != null) { current = current.enclosing; } if ((current.mode& Alignment.M_MULTICOLUMN) != 0) { final int indentSize = this.indentationSize; switch (current.chunkKind) { case Alignment.CHUNK_METHOD: case Alignment.CHUNK_TYPE: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = this.indentationLevel + indentSize; } else { alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize; } alignment.update(); break; case Alignment.CHUNK_FIELD: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize; } else { alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize; } alignment.update(); break; } } else { switch (current.mode& Alignment.SPLIT_MASK) { case Alignment.M_COMPACT_SPLIT: case Alignment.M_COMPACT_FIRST_BREAK_SPLIT: case Alignment.M_NEXT_PER_LINE_SPLIT: case Alignment.M_NEXT_SHIFTED_SPLIT: case Alignment.M_ONE_PER_LINE_SPLIT: final int indentSize = this.indentationSize; switch (current.chunkKind) { case Alignment.CHUNK_METHOD: case Alignment.CHUNK_TYPE: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = this.indentationLevel + indentSize; } else { alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize; } alignment.update(); break; case Alignment.CHUNK_FIELD: if ((mode& Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize; } else { alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize; } alignment.update(); break; } break; } } } return alignment; } public Alignment2 createMemberAlignment(String name, int mode, int count, int sourceRestart) { Alignment2 mAlignment = createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); mAlignment.breakIndentationLevel = this.indentationLevel; return mAlignment; } public void enterAlignment(Alignment2 alignment) { alignment.enclosing = this.currentAlignment; this.currentAlignment = alignment; } public void enterMemberAlignment(Alignment2 alignment) { alignment.enclosing = this.memberAlignment; this.memberAlignment = alignment; } |
| |||
private final void addDeleteEdit(int start, int end) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(start, end - start + 1, EMPTY_STRING); } public final void addInsertEdit(int insertPosition, String insertedString) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(insertPosition, 0, insertedString); } private final void addOptimizedReplaceEdit(int offset, int length, String replacement) { if (this.editsIndex > 0) { // try to merge last two edits final OptimizedReplaceEdit previous = this.edits[this.editsIndex - 1]; final int previousOffset = previous.offset; final int previousLength = previous.length; final int endOffsetOfPreviousEdit = previousOffset + previousLength; final int replacementLength = replacement.length(); final String previousReplacement = previous.replacement; final int previousReplacementLength = previousReplacement.length(); if (previousOffset == offset && previousLength == length && (replacementLength == 0 || previousReplacementLength == 0)) { if (this.currentAlignment != null) { final [[#variableb95b18c0]] location = this.currentAlignment.location; if (location.editsIndex == this.editsIndex) { location.editsIndex--; location.textEdit = previous; } } this.editsIndex--; return; } if (endOffsetOfPreviousEdit == offset) { if (length != 0) { if (replacementLength != 0) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement + replacement); } else if (previousLength + length == previousReplacementLength) { // check the characters. If they are identical, we can get rid of the previous edit boolean canBeRemoved = true; loop: for (int i = previousOffset; i < previousOffset + previousReplacementLength; i++) { if (scanner.source[i] != previousReplacement.charAt(i - previousOffset)) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousReplacementLength, previousReplacement); canBeRemoved = false; break loop; } } if (canBeRemoved) { if (this.currentAlignment != null) { final [[#variableb95b18c0]] location = this.currentAlignment.location; if (location.editsIndex == this.editsIndex) { location.editsIndex--; location.textEdit = previous; } } this.editsIndex--; } } else { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength + length, previousReplacement); } } else { if (replacementLength != 0) { this.edits[this.editsIndex - 1] = new OptimizedReplaceEdit(previousOffset, previousLength, previousReplacement + replacement); } } } else { this.edits[this.editsIndex++ ] = new OptimizedReplaceEdit(offset, length, replacement); } } else { this.edits[this.editsIndex++ ] = new OptimizedReplaceEdit(offset, length, replacement); } } public final void addReplaceEdit(int start, int end, String replacement) { if (this.edits.length == this.editsIndex) { // resize resize(); } addOptimizedReplaceEdit(start, end - start + 1, replacement); } public void alignFragment( [[#variableb95b1880]] alignment, int fragmentIndex) { alignment.fragmentIndex = fragmentIndex; alignment.checkColumn(); alignment.performFragmentEffect(); } public void checkNLSTag(int sourceStart) { if (hasNLSTag(sourceStart)) { this.nlsTagCounter++; } } public void consumeNextToken() { printComment(); try { this.currentToken = this.scanner.getNextToken(); addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition()); } catch (InvalidInputException e) { throw new AbortFormatting(e); } } public [[#variableb95b1880]] createAlignment(String name, int mode, int count, int sourceRestart) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); } public [[#variableb95b1880]] createAlignment(String name, int mode, int count, int sourceRestart, boolean adjust) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust); } public [[#variableb95b1880]] createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart) { return createAlignment(name, mode, tieBreakRule, count, sourceRestart, this.formatter.preferences.continuation_indentation, false); } public [[#variableb95b1880]] createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent, boolean adjust) { return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust); } public [[#variableb95b1880]] createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart, int continuationIndent, boolean adjust) { [[#variableb95b1880]] alignment = new [[#variableb95b1880]](name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent); // adjust break indentation if (adjust && this.memberAlignment != null) { [[#variableb95b1880]] current = this.memberAlignment; while (current.enclosing != null) { current = current.enclosing; } if ((current.mode&Alignment.M_MULTICOLUMN) != 0) { final int indentSize = this.indentationSize; switch (current.chunkKind) { case Alignment.CHUNK_METHOD: case Alignment.CHUNK_TYPE: if ((mode&Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = this.indentationLevel + indentSize; } else { alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize; } alignment.update(); break; case Alignment.CHUNK_FIELD: if ((mode&Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize; } else { alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize; } alignment.update(); break; } } else { switch (current.mode&Alignment.SPLIT_MASK) { case Alignment.M_COMPACT_SPLIT: case Alignment.M_COMPACT_FIRST_BREAK_SPLIT: case Alignment.M_NEXT_PER_LINE_SPLIT: case Alignment.M_NEXT_SHIFTED_SPLIT: case Alignment.M_ONE_PER_LINE_SPLIT: final int indentSize = this.indentationSize; switch (current.chunkKind) { case Alignment.CHUNK_METHOD: case Alignment.CHUNK_TYPE: if ((mode&Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = this.indentationLevel + indentSize; } else { alignment.breakIndentationLevel = this.indentationLevel + continuationIndent * indentSize; } alignment.update(); break; case Alignment.CHUNK_FIELD: if ((mode&Alignment.M_INDENT_BY_ONE) != 0) { alignment.breakIndentationLevel = current.originalIndentationLevel + indentSize; } else { alignment.breakIndentationLevel = current.originalIndentationLevel + continuationIndent * indentSize; } alignment.update(); break; } break; } } } return alignment; } public [[#variableb95b1880]] createMemberAlignment(String name, int mode, int count, int sourceRestart) { [[#variableb95b1880]] mAlignment = createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart); mAlignment.breakIndentationLevel = this.indentationLevel; return mAlignment; } public void enterAlignment( [[#variableb95b1880]] alignment) { [[#variableb95b17e0]] } public void enterMemberAlignment( [[#variableb95b1880]] alignment) { [[#variableb95b1760]] } |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#b95b18c0]] | Location |
1 | 2 | [[#b95b18c0]] | Location2 |
2 | 1 | [[#b95b1880]] | Alignment |
2 | 2 | [[#b95b1880]] | Alignment2 |
3 | 1 | [[#b95b17e0]] | alignment.enclosing = this.currentAlignment; alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart; this.currentAlignment = alignment; |
3 | 2 | [[#b95b17e0]] | alignment.enclosing = this.currentAlignment; this.currentAlignment = alignment; |
4 | 1 | [[#b95b1760]] | alignment.enclosing = this.memberAlignment; alignment.location.lastLocalDeclarationSourceStart = this.formatter.lastLocalDeclarationSourceStart; this.memberAlignment = alignment; |
4 | 2 | [[#b95b1760]] | alignment.enclosing = this.memberAlignment; this.memberAlignment = alignment; |