class IRFactory
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
IRFactory.TransformDispatcher |
Modifier and Type | Field and Description |
---|---|
private static com.google.common.collect.ImmutableSet<java.lang.String> |
ALLOWED_DIRECTIVES |
(package private) static java.lang.String |
BINARY_NUMBER_LITERAL_WARNING |
private Config |
config |
private Comment |
currentComment |
private boolean |
currentFileIsExterns |
(package private) static java.lang.String |
DUPLICATE_LABEL |
(package private) static java.lang.String |
DUPLICATE_PARAMETER |
private ErrorReporter |
errorReporter |
private static com.google.common.collect.ImmutableSet<java.lang.String> |
ES5_RESERVED_KEYWORDS |
private static com.google.common.collect.ImmutableSet<java.lang.String> |
ES5_STRICT_RESERVED_KEYWORDS |
private FeatureSet |
features |
(package private) JSDocInfoBuilder |
fileLevelJsDocBuilder |
(package private) JSDocInfo |
fileOverviewInfo |
(package private) static java.lang.String |
GETTER_ERROR_MESSAGE |
private boolean |
hasJsDocTypeAnnotations |
(package private) static java.lang.String |
INVALID_ES3_PROP_NAME |
(package private) static java.lang.String |
INVALID_ES5_STRICT_OCTAL |
(package private) static java.lang.String |
INVALID_OCTAL_DIGIT |
private java.util.List<java.lang.Integer> |
newlines |
private com.google.common.collect.UnmodifiableIterator<Comment> |
nextCommentIter |
(package private) static Config |
NULL_CONFIG |
(package private) static ErrorReporter |
NULL_REPORTER |
(package private) static java.lang.String |
OCTAL_NUMBER_LITERAL_WARNING |
(package private) static java.lang.String |
OCTAL_STRING_LITERAL_WARNING |
private java.util.Set<Comment> |
parsedComments |
private java.util.Set<java.lang.String> |
reservedKeywords |
private Node |
resultNode |
(package private) static java.lang.String |
SETTER_ERROR_MESSAGE |
private StaticSourceFile |
sourceFile |
private java.lang.String |
sourceName |
private java.lang.String |
sourceString |
(package private) static java.lang.String |
STRING_CONTINUATION_ERROR |
(package private) static java.lang.String |
STRING_CONTINUATION_WARNING |
(package private) static java.lang.String |
SUSPICIOUS_COMMENT_WARNING |
private Node |
templateNode |
private IRFactory.TransformDispatcher |
transformDispatcher |
(package private) static java.lang.String |
UNDEFINED_LABEL |
(package private) static java.lang.String |
UNEXPECTED_CONTINUE |
(package private) static java.lang.String |
UNEXPECTED_LABLED_CONTINUE |
(package private) static java.lang.String |
UNEXPECTED_RETURN |
(package private) static java.lang.String |
UNLABELED_BREAK |
private static com.google.common.collect.ImmutableSet<java.lang.String> |
USE_STRICT_ONLY |
Modifier | Constructor and Description |
---|---|
private |
IRFactory(java.lang.String sourceString,
StaticSourceFile sourceFile,
Config config,
ErrorReporter errorReporter,
com.google.common.collect.ImmutableList<Comment> comments) |
Modifier and Type | Method and Description |
---|---|
private static int |
binarydigit(char c) |
private static int |
charno(ParseTree node) |
private static int |
charno(SourcePosition location) |
private Node |
cloneProps(Node n)
Clone the properties from the template node recursively, skips nodes that
have properties already.
|
private JsDocInfoParser |
createJsDocInfoParser(Comment node)
Creates a JsDocInfoParser and parses the JsDoc string.
|
private Node |
createTemplateNode() |
(package private) static FeatureSet |
detectFeatures(ProgramTree tree,
StaticSourceFile sourceFile,
java.lang.String sourceString) |
private static ParseTree |
findNearestNode(ParseTree tree) |
(package private) FeatureSet |
getFeatures() |
private Comment |
getJsDoc(ParseTree tree) |
private Comment |
getJsDoc(SourceRange location) |
private Comment |
getJsDoc(Token token) |
(package private) Node |
getResultNode() |
private static java.lang.String |
getStringValue(double value) |
private void |
handleBlockComment(Comment comment)
Check to see if the given block comment looks like it should be JSDoc.
|
private JSDocInfo |
handleInlineJsDoc(ParseTree node) |
private JSDocInfo |
handleInlineJsDoc(SourceRange location) |
private JSDocInfo |
handleInlineJsDoc(Token token) |
private JSDocInfo |
handleJsDoc(Comment comment) |
private JSDocInfo |
handleJsDoc(ParseTree node) |
private JSDocInfo |
handleJsDoc(Token token) |
private void |
handlePossibleFileOverviewJsDoc(Comment comment) |
private boolean |
handlePossibleFileOverviewJsDoc(JsDocInfoParser jsDocParser) |
private static int |
hexdigit(char c) |
private boolean |
inStrictContext() |
private static boolean |
isBreakTarget(Node n) |
private static boolean |
isContinueTarget(Node n) |
(package private) boolean |
isEs5OrBetterMode() |
(package private) boolean |
isEs6Mode() |
private static boolean |
isOctalDigit(char c) |
private Node |
justTransform(ParseTree node) |
private static boolean |
labelsMatch(Node label,
Node labelName) |
private static int |
lineno(ParseTree node) |
private static int |
lineno(SourcePosition location) |
private Node |
maybeInjectCastNode(ParseTree node,
JSDocInfo info,
Node irNode) |
private void |
maybeSetLength(Node node,
SourcePosition start,
SourcePosition end) |
private void |
maybeSetLengthFrom(Node node,
Node ref) |
private Node |
newNode(int type) |
private Node |
newNode(int type,
Node child1) |
private Node |
newNode(int type,
Node child1,
Node child2) |
private Node |
newNode(int type,
Node child1,
Node child2,
Node child3) |
private Node |
newNumberNode(java.lang.Double value) |
private Node |
newStringNode(int type,
java.lang.String value) |
private Node |
newStringNode(java.lang.String value) |
(package private) double |
normalizeNumber(LiteralToken token) |
private java.lang.String |
normalizeRegex(LiteralToken token) |
private java.lang.String |
normalizeString(LiteralToken token,
boolean templateLiteral) |
private static int |
octaldigit(char c) |
private JSDocInfo |
parseInlineTypeDoc(Comment node)
Parses inline type info.
|
private JSDocInfo |
recordJsDoc(SourceRange location,
JSDocInfo info) |
private void |
recordTypeSyntax(SourceRange location) |
private void |
setFileOverviewJsDoc(Node irNode) |
private void |
setSourceInfo(Node node,
Node ref) |
private void |
setSourceInfo(Node irNode,
ParseTree node) |
private void |
setSourceInfo(Node node,
SourcePosition start,
SourcePosition end) |
private void |
setSourceInfo(Node irNode,
Token token) |
private boolean |
shouldAttachJSDocHere(ParseTree tree) |
private Node |
transform(ParseTree tree) |
private static int |
transformBinaryTokenType(TokenType token) |
private Node |
transformBlock(ParseTree node) |
private static int |
transformBooleanTokenType(TokenType token) |
private Node |
transformNodeWithInlineJsDoc(ParseTree node)
Names and destructuring patterns, in parameters or variable declarations are special,
because they can have inline type docs attached.
|
private Node |
transformNumberAsString(LiteralToken token) |
private static int |
transformPostfixTokenType(TokenType token) |
static IRFactory |
transformTree(ProgramTree tree,
StaticSourceFile sourceFile,
java.lang.String sourceString,
Config config,
ErrorReporter errorReporter) |
private static int |
transformUnaryTokenType(TokenType token) |
private void |
validate(Node n) |
private void |
validateAll(Node n) |
private void |
validateBreakContinue(Node n) |
private void |
validateLabel(Node n) |
private void |
validateParameters(Node n) |
private void |
validateReturn(Node n) |
static final java.lang.String GETTER_ERROR_MESSAGE
static final java.lang.String SETTER_ERROR_MESSAGE
static final java.lang.String SUSPICIOUS_COMMENT_WARNING
static final java.lang.String INVALID_ES3_PROP_NAME
static final java.lang.String INVALID_ES5_STRICT_OCTAL
static final java.lang.String INVALID_OCTAL_DIGIT
static final java.lang.String STRING_CONTINUATION_ERROR
static final java.lang.String STRING_CONTINUATION_WARNING
static final java.lang.String BINARY_NUMBER_LITERAL_WARNING
static final java.lang.String OCTAL_NUMBER_LITERAL_WARNING
static final java.lang.String OCTAL_STRING_LITERAL_WARNING
static final java.lang.String DUPLICATE_PARAMETER
static final java.lang.String DUPLICATE_LABEL
static final java.lang.String UNLABELED_BREAK
static final java.lang.String UNEXPECTED_CONTINUE
static final java.lang.String UNEXPECTED_LABLED_CONTINUE
static final java.lang.String UNEXPECTED_RETURN
static final java.lang.String UNDEFINED_LABEL
private final java.lang.String sourceString
private final java.util.List<java.lang.Integer> newlines
private final StaticSourceFile sourceFile
private final java.lang.String sourceName
private final Config config
private final ErrorReporter errorReporter
private final IRFactory.TransformDispatcher transformDispatcher
private static final com.google.common.collect.ImmutableSet<java.lang.String> USE_STRICT_ONLY
private static final com.google.common.collect.ImmutableSet<java.lang.String> ALLOWED_DIRECTIVES
private static final com.google.common.collect.ImmutableSet<java.lang.String> ES5_RESERVED_KEYWORDS
private static final com.google.common.collect.ImmutableSet<java.lang.String> ES5_STRICT_RESERVED_KEYWORDS
private final java.util.Set<java.lang.String> reservedKeywords
private final java.util.Set<Comment> parsedComments
JSDocInfoBuilder fileLevelJsDocBuilder
JSDocInfo fileOverviewInfo
private final Node templateNode
private final com.google.common.collect.UnmodifiableIterator<Comment> nextCommentIter
private Comment currentComment
private boolean currentFileIsExterns
private boolean hasJsDocTypeAnnotations
private FeatureSet features
private Node resultNode
static final Config NULL_CONFIG
static final ErrorReporter NULL_REPORTER
private IRFactory(java.lang.String sourceString, StaticSourceFile sourceFile, Config config, ErrorReporter errorReporter, com.google.common.collect.ImmutableList<Comment> comments)
private Node createTemplateNode()
public static IRFactory transformTree(ProgramTree tree, StaticSourceFile sourceFile, java.lang.String sourceString, Config config, ErrorReporter errorReporter)
static FeatureSet detectFeatures(ProgramTree tree, StaticSourceFile sourceFile, java.lang.String sourceString)
Node getResultNode()
FeatureSet getFeatures()
private void validateAll(Node n)
private void validate(Node n)
private void validateBreakContinue(Node n)
private void validateReturn(Node n)
private static boolean isBreakTarget(Node n)
private static boolean isContinueTarget(Node n)
private void validateParameters(Node n)
private JSDocInfo recordJsDoc(SourceRange location, JSDocInfo info)
private void recordTypeSyntax(SourceRange location)
private void validateLabel(Node n)
private void setFileOverviewJsDoc(Node irNode)
private void handleBlockComment(Comment comment)
private boolean handlePossibleFileOverviewJsDoc(JsDocInfoParser jsDocParser)
private void handlePossibleFileOverviewJsDoc(Comment comment)
private Comment getJsDoc(SourceRange location)
private boolean shouldAttachJSDocHere(ParseTree tree)
private Node transformNodeWithInlineJsDoc(ParseTree node)
function f(/** string */ x) {}annotates 'x' as a string.
private JSDocInfo handleInlineJsDoc(SourceRange location)
private Node transformNumberAsString(LiteralToken token)
private static java.lang.String getStringValue(double value)
private static int lineno(ParseTree node)
private static int charno(ParseTree node)
private static int lineno(SourcePosition location)
private static int charno(SourcePosition location)
private void setSourceInfo(Node node, SourcePosition start, SourcePosition end)
private JsDocInfoParser createJsDocInfoParser(Comment node)
node
- The JsDoc Comment node to parse.private void maybeSetLength(Node node, SourcePosition start, SourcePosition end)
private java.lang.String normalizeRegex(LiteralToken token)
private java.lang.String normalizeString(LiteralToken token, boolean templateLiteral)
boolean isEs6Mode()
boolean isEs5OrBetterMode()
private boolean inStrictContext()
double normalizeNumber(LiteralToken token)
private static int binarydigit(char c)
private static boolean isOctalDigit(char c)
private static int octaldigit(char c)
private static int hexdigit(char c)
private static int transformBooleanTokenType(TokenType token)
private static int transformPostfixTokenType(TokenType token)
private static int transformUnaryTokenType(TokenType token)
private static int transformBinaryTokenType(TokenType token)
private Node newNode(int type)
private Node newStringNode(java.lang.String value)
private Node newStringNode(int type, java.lang.String value)
private Node newNumberNode(java.lang.Double value)