23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.util; |
26 package com.sun.tools.javac.util; |
27 |
27 |
28 import com.sun.tools.javac.code.Source; |
|
29 import com.sun.tools.javac.main.JavacOption; |
|
30 import com.sun.tools.javac.main.OptionName; |
|
31 import com.sun.tools.javac.main.RecognizedOptions; |
|
32 import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; |
|
33 import java.io.ByteArrayOutputStream; |
28 import java.io.ByteArrayOutputStream; |
34 import java.io.Closeable; |
29 import java.io.Closeable; |
35 import java.io.IOException; |
30 import java.io.IOException; |
36 import java.io.InputStream; |
31 import java.io.InputStream; |
37 import java.io.OutputStreamWriter; |
32 import java.io.OutputStreamWriter; |
52 import java.util.Iterator; |
47 import java.util.Iterator; |
53 import java.util.Map; |
48 import java.util.Map; |
54 import javax.tools.JavaFileObject; |
49 import javax.tools.JavaFileObject; |
55 import javax.tools.JavaFileObject.Kind; |
50 import javax.tools.JavaFileObject.Kind; |
56 |
51 |
|
52 import com.sun.tools.javac.code.Lint; |
|
53 import com.sun.tools.javac.code.Source; |
|
54 import com.sun.tools.javac.file.FSInfo; |
|
55 import com.sun.tools.javac.file.Paths; |
|
56 import com.sun.tools.javac.main.JavacOption; |
|
57 import com.sun.tools.javac.main.OptionName; |
|
58 import com.sun.tools.javac.main.RecognizedOptions; |
|
59 import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; |
|
60 |
57 /** |
61 /** |
58 * Utility methods for building a filemanager. |
62 * Utility methods for building a filemanager. |
59 * There are no references here to file-system specific objects such as |
63 * There are no references here to file-system specific objects such as |
60 * java.io.File or java.nio.file.Path. |
64 * java.io.File or java.nio.file.Path. |
61 */ |
65 */ |
62 public abstract class BaseFileManager { |
66 public abstract class BaseFileManager { |
63 protected BaseFileManager(Charset charset) { |
67 protected BaseFileManager(Charset charset) { |
64 this.charset = charset; |
68 this.charset = charset; |
65 byteBufferCache = new ByteBufferCache(); |
69 byteBufferCache = new ByteBufferCache(); |
|
70 searchPaths = createPaths(); |
66 } |
71 } |
67 |
72 |
68 /** |
73 /** |
69 * Set the context for JavacPathFileManager. |
74 * Set the context for JavacPathFileManager. |
70 */ |
75 */ |
71 protected void setContext(Context context) { |
76 public void setContext(Context context) { |
72 log = Log.instance(context); |
77 log = Log.instance(context); |
73 options = Options.instance(context); |
78 options = Options.instance(context); |
74 classLoaderClass = options.get("procloader"); |
79 classLoaderClass = options.get("procloader"); |
|
80 searchPaths.update(log, options, Lint.instance(context), FSInfo.instance(context)); |
|
81 } |
|
82 |
|
83 protected Paths createPaths() { |
|
84 return new Paths(); |
75 } |
85 } |
76 |
86 |
77 /** |
87 /** |
78 * The log to be used for error reporting. |
88 * The log to be used for error reporting. |
79 */ |
89 */ |
85 protected Charset charset; |
95 protected Charset charset; |
86 |
96 |
87 protected Options options; |
97 protected Options options; |
88 |
98 |
89 protected String classLoaderClass; |
99 protected String classLoaderClass; |
|
100 |
|
101 protected Paths searchPaths; |
90 |
102 |
91 protected Source getSource() { |
103 protected Source getSource() { |
92 String sourceName = options.get(OptionName.SOURCE); |
104 String sourceName = options.get(OptionName.SOURCE); |
93 Source source = null; |
105 Source source = null; |
94 if (sourceName != null) |
106 if (sourceName != null) |