|
Lines 14-25
Link Here
|
| 14 |
import java.io.StringReader; |
14 |
import java.io.StringReader; |
| 15 |
import java.util.Arrays; |
15 |
import java.util.Arrays; |
| 16 |
import java.util.Comparator; |
16 |
import java.util.Comparator; |
|
|
17 |
import java.util.Map; |
| 17 |
|
18 |
|
|
|
19 |
import org.eclipse.jdt.core.JavaCore; |
| 18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
20 |
import org.eclipse.jdt.core.compiler.CharOperation; |
| 19 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
21 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
| 20 |
import org.eclipse.jdt.core.formatter.CodeFormatter; |
22 |
import org.eclipse.jdt.core.formatter.CodeFormatter; |
| 21 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
23 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
| 22 |
import org.eclipse.jdt.internal.compiler.ast.Annotation; |
24 |
import org.eclipse.jdt.internal.compiler.ast.Annotation; |
|
|
25 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
| 26 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
| 23 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
27 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
| 24 |
import org.eclipse.jdt.internal.compiler.parser.Parser; |
28 |
import org.eclipse.jdt.internal.compiler.parser.Parser; |
| 25 |
import org.eclipse.jdt.internal.compiler.parser.Scanner; |
29 |
import org.eclipse.jdt.internal.compiler.parser.Scanner; |
|
Lines 1858-1864
Link Here
|
| 1858 |
// 3 - format snippet (@see JavaDocRegion#formatCodeSnippet) |
1862 |
// 3 - format snippet (@see JavaDocRegion#formatCodeSnippet) |
| 1859 |
// include comments in case of line comments are present in the snippet |
1863 |
// include comments in case of line comments are present in the snippet |
| 1860 |
String formattedSnippet = convertedSnippet; |
1864 |
String formattedSnippet = convertedSnippet; |
| 1861 |
TextEdit edit= CommentFormatterUtil.format2(CodeFormatter.K_UNKNOWN | CodeFormatter.F_INCLUDE_COMMENTS, convertedSnippet, 0, this.lineSeparator, this.formatter.preferences.getMap()); |
1865 |
Map options = this.formatter.preferences.getMap(); |
|
|
1866 |
if (this.scanner.sourceLevel > ClassFileConstants.JDK1_3) { |
| 1867 |
options.put(JavaCore.COMPILER_SOURCE, CompilerOptions.versionFromJdkLevel(this.scanner.sourceLevel)); |
| 1868 |
} |
| 1869 |
TextEdit edit= CommentFormatterUtil.format2(CodeFormatter.K_UNKNOWN | CodeFormatter.F_INCLUDE_COMMENTS, convertedSnippet, 0, this.lineSeparator, options); |
| 1862 |
if (edit == null) { |
1870 |
if (edit == null) { |
| 1863 |
// 3.a - not a valid code to format, keep initial buffer |
1871 |
// 3.a - not a valid code to format, keep initial buffer |
| 1864 |
formattedSnippet = inputBuffer.toString(); |
1872 |
formattedSnippet = inputBuffer.toString(); |