Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright (C) 2008 Google Inc. | 1 // Copyright (C) 2008 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 if (passed && MessageLevel.LOG.compareTo(msg.getMessageLevel()) >= 0) { | 206 if (passed && MessageLevel.LOG.compareTo(msg.getMessageLevel()) >= 0) { |
207 continue; | 207 continue; |
208 } | 208 } |
209 String snippet = snippetProducer.getSnippet(msg); | 209 String snippet = snippetProducer.getSnippet(msg); |
210 if (!"".equals(snippet)) { snippet = "\n" + snippet; } | 210 if (!"".equals(snippet)) { snippet = "\n" + snippet; } |
211 logger.println(msg.getMessageLevel() + " : " + msg.format(mc) + snippet); | 211 logger.println(msg.getMessageLevel() + " : " + msg.format(mc) + snippet); |
212 } | 212 } |
213 | 213 |
214 // Write the output | 214 // Write the output |
215 if (passed) { | 215 if (passed) { |
216 // Write out as HTML if the output file has the right extension. | 216 // Write out as HTML if the output file has the right extension. |
Jasvir
2009/05/22 04:50:51
I don't think we should switch on the extension.
MikeSamuel
2009/05/22 20:42:54
Any reasons why not? Switching on the output exte
ihab.awad
2009/05/29 05:11:04
Leaving as-is for this CL. To revisit discussion l
| |
217 boolean asXml = output.getName().endsWith(".xhtml"); | 217 boolean asXml = output.getName().endsWith(".xhtml"); |
218 boolean emitMarkup = asXml || output.getName().endsWith(".html"); | 218 boolean emitMarkup = asXml || output.getName().endsWith(".html"); |
219 | 219 |
220 StringBuilder jsOut = new StringBuilder(); | 220 StringBuilder jsOut = new StringBuilder(); |
221 TokenConsumer renderer; | 221 TokenConsumer renderer; |
222 String rendererType = (String) options.get("renderer"); | 222 String rendererType = (String) options.get("renderer"); |
223 if ("pretty".equals(rendererType)) { | 223 if ("pretty".equals(rendererType)) { |
224 renderer = new JsPrettyPrinter(new Concatenator(jsOut)); | 224 renderer = new JsPrettyPrinter(new Concatenator(jsOut)); |
225 } else if ("minify".equals(rendererType)) { | 225 } else if ("minify".equals(rendererType)) { |
226 renderer = new JsMinimalPrinter(new Concatenator(jsOut)); | 226 renderer = new JsMinimalPrinter(new Concatenator(jsOut)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 originalSources.put(is, content); | 285 originalSources.put(is, content); |
286 } | 286 } |
287 return content; | 287 return content; |
288 } | 288 } |
289 | 289 |
290 private AncestorChain<?> parseInput(InputSource is, MessageQueue mq) | 290 private AncestorChain<?> parseInput(InputSource is, MessageQueue mq) |
291 throws IOException { | 291 throws IOException { |
292 CharProducer cp = CharProducer.Factory.create( | 292 CharProducer cp = CharProducer.Factory.create( |
293 new StringReader(getSourceContent(is)), is); | 293 new StringReader(getSourceContent(is)), is); |
294 try { | 294 try { |
295 return new AncestorChain<ParseTreeNode>( | 295 return AncestorChain.instance(PluginCompilerMain.parseInput(is, cp, mq)); |
296 PluginCompilerMain.parseInput(is, cp, mq)); | |
297 } catch (ParseException ex) { | 296 } catch (ParseException ex) { |
298 ex.toMessageQueue(mq); | 297 ex.toMessageQueue(mq); |
299 return null; | 298 return null; |
300 } | 299 } |
301 } | 300 } |
302 | 301 |
303 /** | 302 /** |
304 * Minifies inputs to output writing any messages to logger, returning true | 303 * Minifies inputs to output writing any messages to logger, returning true |
305 * iff the task passes. | 304 * iff the task passes. |
306 */ | 305 */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 } | 347 } |
349 } | 348 } |
350 outputWriter.close(); | 349 outputWriter.close(); |
351 return true; | 350 return true; |
352 } catch (IOException ex) { | 351 } catch (IOException ex) { |
353 logger.println("Innocent transform failed: " + ex); | 352 logger.println("Innocent transform failed: " + ex); |
354 return false; | 353 return false; |
355 } | 354 } |
356 } | 355 } |
357 } | 356 } |
LEFT | RIGHT |