com.google.javascript.jscomp
Class JsMessageExtractor

java.lang.Object
  extended by com.google.javascript.jscomp.JsMessageExtractor

public class JsMessageExtractor
extends Object

Extracts messages and message comments from JS code.

Uses a special prefix (e.g. MSG_) to determine which variables are messages. Here are the recognized formats: var MSG_FOO = "foo"; var MSG_FOO_HELP = "this message is used for foo"; var MSG_BAR = function(a, b) { return a + " bar " + b; } var MSG_BAR_HELP = "the bar message";

This class enforces the policy that message variable names must be unique across all JS files.


Constructor Summary
JsMessageExtractor(JsMessage.IdGenerator idGenerator, JsMessage.Style style)
           
 
Method Summary
<T extends SourceFile>
Collection<JsMessage>
extractMessages(Iterable<T> inputs)
          Extracts js messages from javascript code.
 Collection<JsMessage> extractMessages(SourceFile... inputs)
          Extracts js messages from javascript code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsMessageExtractor

public JsMessageExtractor(JsMessage.IdGenerator idGenerator,
                          JsMessage.Style style)
Method Detail

extractMessages

public Collection<JsMessage> extractMessages(SourceFile... inputs)
                                      throws IOException
Extracts js messages from javascript code.

Throws:
IOException

extractMessages

public <T extends SourceFile> Collection<JsMessage> extractMessages(Iterable<T> inputs)
                                      throws IOException
Extracts js messages from javascript code.

Parameters:
inputs - the javascript source code inputs
Returns:
the extracted messages collection
Throws:
IOException - if there is a problem reading the js code
RuntimeException - if there are problems parsing the js code or the js messages, or if two messages have the same key