use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseFunctionTypeExpression.
private ParseTree parseFunctionTypeExpression() {
SourcePosition start = getTreeStartLocation();
ParseTree typeExpression = null;
if (peekFunctionTypeExpression()) {
FormalParameterListTree formalParameterList;
formalParameterList = parseFormalParameterList(ParamContext.IMPLEMENTATION);
eat(TokenType.ARROW);
ParseTree returnType = parseType();
typeExpression = new FunctionTypeTree(getTreeLocation(start), formalParameterList, returnType);
} else {
typeExpression = parseArrayTypeExpression();
}
return typeExpression;
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseArrayTypeExpression.
private ParseTree parseArrayTypeExpression() {
SourcePosition start = getTreeStartLocation();
ParseTree typeExpression = parseParenTypeExpression();
while (!peekImplicitSemiColon() && peek(TokenType.OPEN_SQUARE)) {
eat(TokenType.OPEN_SQUARE);
eat(TokenType.CLOSE_SQUARE);
typeExpression = new ArrayTypeTree(getTreeLocation(start), typeExpression);
}
return typeExpression;
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method maybeParseGenericTypes.
private GenericTypeListTree maybeParseGenericTypes() {
if (!peek(TokenType.OPEN_ANGLE)) {
return null;
}
SourcePosition start = getTreeStartLocation();
eat(TokenType.OPEN_ANGLE);
scanner.incTypeParameterLevel();
LinkedHashMap<IdentifierToken, ParseTree> types = new LinkedHashMap<>();
do {
IdentifierToken name = eatId();
ParseTree bound = null;
if (peek(TokenType.EXTENDS)) {
eat(TokenType.EXTENDS);
bound = parseType();
}
types.put(name, bound);
if (peek(TokenType.COMMA)) {
eat(TokenType.COMMA);
}
} while (peekId());
eat(TokenType.CLOSE_ANGLE);
scanner.decTypeParameterLevel();
return new GenericTypeListTree(getTreeLocation(start), types);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseTypeReference.
private ParseTree parseTypeReference() {
SourcePosition start = getTreeStartLocation();
TypeNameTree typeName = parseTypeName();
if (!peek(TokenType.OPEN_ANGLE)) {
return typeName;
}
return parseTypeArgumentList(start, typeName);
}
use of com.google.javascript.jscomp.parsing.parser.util.SourcePosition in project closure-compiler by google.
the class Parser method parseIndexSignature.
private IndexSignatureTree parseIndexSignature() {
SourcePosition start = getTreeStartLocation();
eat(TokenType.OPEN_SQUARE);
IdentifierToken name = eatIdOrKeywordAsId();
eat(TokenType.COLON);
// must be 'string' or 'number'
ParseTree indexType = parseTypeName();
eat(TokenType.CLOSE_SQUARE);
eat(TokenType.COLON);
ParseTree declaredType = parseType();
ParseTree nameTree = new MemberVariableTree(getTreeLocation(start), name, false, false, null, indexType);
return new IndexSignatureTree(getTreeLocation(start), nameTree, declaredType);
}
Aggregations