Package com.google.javascript.jscomp

# Class JsMessageExtractor

java.lang.Object
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

Constructors
Constructor
Description
`JsMessageExtractor(JsMessage.IdGenerator idGenerator, JsMessage.Style style)`
`JsMessageExtractor(JsMessage.IdGenerator idGenerator, JsMessage.Style style, CompilerOptions options)`

## Method Summary

Modifier and Type
Method
Description
`Collection<JsMessage>`
`extractMessages(SourceFile... inputs)`
Extracts JS messages from JavaScript code.
`<T extends SourceFile>
Collection<JsMessage>`
`extractMessages(Iterable<T> 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 Details

### JsMessageExtractor

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

### JsMessageExtractor

public JsMessageExtractor(JsMessage.IdGenerator idGenerator, JsMessage.Style style, CompilerOptions options)

## Method Details

### 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