Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
43 | 2 | 1 | 0.998 | class_body_declaration |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 43 | 307 | plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/IndentAction.java |
2 | 43 | 436 | 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 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(); } |
| ||||
/** * 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(); } |
| |||
[[#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 Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#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 |
1 | 2 | [[#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 |