Lines 14-29
Link Here
|
14 |
import java.util.Collections; |
14 |
import java.util.Collections; |
15 |
import java.util.Comparator; |
15 |
import java.util.Comparator; |
16 |
import java.util.List; |
16 |
import java.util.List; |
17 |
import java.util.Map; |
|
|
18 |
|
17 |
|
19 |
import org.eclipse.jdt.core.JavaCore; |
|
|
20 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
21 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
19 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
22 |
import org.eclipse.jdt.core.dom.ASTVisitor; |
20 |
import org.eclipse.jdt.core.dom.ASTVisitor; |
23 |
import org.eclipse.jdt.core.dom.Annotation; |
21 |
import org.eclipse.jdt.core.dom.Annotation; |
24 |
import org.eclipse.jdt.core.dom.Comment; |
22 |
import org.eclipse.jdt.core.dom.Comment; |
25 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
23 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
26 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
|
|
27 |
import org.eclipse.jdt.internal.compiler.parser.Scanner; |
24 |
import org.eclipse.jdt.internal.compiler.parser.Scanner; |
28 |
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; |
25 |
import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; |
29 |
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; |
26 |
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; |
Lines 83-101
Link Here
|
83 |
/** indent empty lines*/ |
80 |
/** indent empty lines*/ |
84 |
private final boolean indentEmptyLines; |
81 |
private final boolean indentEmptyLines; |
85 |
|
82 |
|
86 |
Scribe2(CodeFormatterVisitor2 formatter, Map settings, int offset, int length, CompilationUnit unit) { |
83 |
Scribe2(CodeFormatterVisitor2 formatter, long sourceLevel, int offset, int length, CompilationUnit unit) { |
87 |
if (settings != null) { |
84 |
this.scanner = new Scanner(true, true, false/*nls*/, sourceLevel/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); |
88 |
Object sourceLevelOption = settings.get(JavaCore.COMPILER_SOURCE); |
|
|
89 |
long sourceLevel = ClassFileConstants.JDK1_3; |
90 |
if (JavaCore.VERSION_1_4.equals(sourceLevelOption)) { |
91 |
sourceLevel = ClassFileConstants.JDK1_4; |
92 |
} else if (JavaCore.VERSION_1_5.equals(sourceLevelOption)) { |
93 |
sourceLevel = ClassFileConstants.JDK1_5; |
94 |
} |
95 |
this.scanner = new Scanner(true, true, false/*nls*/, sourceLevel/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); |
96 |
} else { |
97 |
this.scanner = new Scanner(true, true, false/*nls*/, ClassFileConstants.JDK1_3/*sourceLevel*/, null/*taskTags*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); |
98 |
} |
99 |
this.formatter = formatter; |
85 |
this.formatter = formatter; |
100 |
this.pageWidth = formatter.preferences.page_width; |
86 |
this.pageWidth = formatter.preferences.page_width; |
101 |
this.tabLength = formatter.preferences.tab_size; |
87 |
this.tabLength = formatter.preferences.tab_size; |