22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package jdk.nashorn.internal.parser; |
26 package jdk.nashorn.internal.parser; |
|
27 |
|
28 import static jdk.nashorn.internal.runtime.Source.sourceFor; |
|
29 import static jdk.nashorn.internal.runtime.Source.readFully; |
27 |
30 |
28 import java.io.File; |
31 import java.io.File; |
29 import jdk.nashorn.internal.runtime.Context; |
32 import jdk.nashorn.internal.runtime.Context; |
30 import jdk.nashorn.internal.runtime.ErrorManager; |
33 import jdk.nashorn.internal.runtime.ErrorManager; |
31 import jdk.nashorn.internal.runtime.Source; |
34 import jdk.nashorn.internal.runtime.Source; |
130 if (VERBOSE) { |
133 if (VERBOSE) { |
131 log("Begin parsing " + file.getAbsolutePath()); |
134 log("Begin parsing " + file.getAbsolutePath()); |
132 } |
135 } |
133 |
136 |
134 try { |
137 try { |
135 final char[] buffer = Source.readFully(file); |
138 final char[] buffer = readFully(file); |
136 boolean excluded = false; |
139 boolean excluded = false; |
137 if (filter != null) { |
140 if (filter != null) { |
138 final String content = new String(buffer); |
141 final String content = new String(buffer); |
139 excluded = filter.exclude(file, content); |
142 excluded = filter.exclude(file, content); |
140 } |
143 } |
152 public void error(final String msg) { |
155 public void error(final String msg) { |
153 log(msg); |
156 log(msg); |
154 } |
157 } |
155 }; |
158 }; |
156 errors.setLimit(0); |
159 errors.setLimit(0); |
157 final Source source = new Source(file.getAbsolutePath(), buffer); |
160 final Source source = sourceFor(file.getAbsolutePath(), buffer); |
158 new Parser(context.getEnv(), source, errors).parse(); |
161 new Parser(context.getEnv(), source, errors).parse(); |
159 if (errors.getNumberOfErrors() > 0) { |
162 if (errors.getNumberOfErrors() > 0) { |
160 log("Parse failed: " + file.getAbsolutePath()); |
163 log("Parse failed: " + file.getAbsolutePath()); |
161 failed++; |
164 failed++; |
162 } else { |
165 } else { |