JavaParser

class JavaParser(source: SourceFile)(using `x$2`: Context) extends ParserCommon
class Object
trait Matchable
class Any

Value members

Concrete methods

def accept(token: Int): Int

Consume one token of the specified type, or signal an error if it is not there.

Consume one token of the specified type, or signal an error if it is not there.

Returns

The offset at the start of the token to accept

def addCompanionObject(statics: List[Tree], cdef: TypeDef): List[Tree]

Annotation ::= TypeName [( [AnnotationArgument {, AnnotationArgument}] )] AnnotationArgument ::= ElementValuePair | ELementValue ElementValuePair ::= Identifier = ElementValue ElementValue ::= ConstExpressionSubset | ElementValueArrayInitializer | Annotation ElementValueArrayInitializer ::= { [ElementValue {, ElementValue}] [,] } ConstExpressionSubset ::= Literal | QualifiedName | ClassLiteral

Annotation ::= TypeName [( [AnnotationArgument {, AnnotationArgument}] )] AnnotationArgument ::= ElementValuePair | ELementValue ElementValuePair ::= Identifier = ElementValue ElementValue ::= ConstExpressionSubset | ElementValueArrayInitializer | Annotation ElementValueArrayInitializer ::= { [ElementValue {, ElementValue}] [,] } ConstExpressionSubset ::= Literal | QualifiedName | ClassLiteral

We support only subset of const expressions expected in this context by java. If we encounter expression that we cannot parse, we do not raise parsing error, but instead we skip entire annotation silently.

def annotationDecl(start: Offset, mods: Modifiers): List[Tree]
def basicType(): Tree
def bound(): Tree
def classDecl(start: Offset, mods: Modifiers): List[Tree]

CompilationUnit ::= [package QualId semi] TopStatSeq

CompilationUnit ::= [package QualId semi] TopStatSeq

Convert (qual)ident to type identifier

Convert (qual)ident to type identifier

Translate names in Select/Ident nodes to type names.

Translate names in Select/Ident nodes to type names.

def enumConst(enumType: Tree): ValDef
def enumDecl(start: Offset, mods: Modifiers): List[Tree]
def fieldDecls(start: Offset, firstNameOffset: Offset, mods: Modifiers, tpt: Tree, name: Name): List[Tree]

Parse a sequence of field declarations, separated by commas. This one is tricky because a comma might also appear in an initializer. Since we don't parse initializers we don't know what the comma signifies. We solve this with a second list buffer maybe which contains potential variable definitions. Once we have reached the end of the statement, we know whether these potential definitions are real or not.

Parse a sequence of field declarations, separated by commas. This one is tricky because a comma might also appear in an initializer. Since we don't parse initializers we don't know what the comma signifies. We solve this with a second list buffer maybe which contains potential variable definitions. Once we have reached the end of the statement, we know whether these potential definitions are real or not.

def ident(): Name
def interfaceDecl(start: Offset, mods: Modifiers): List[Tree]
def javaDot(name: Name): Tree
def javaLangDot(name: Name): Tree
def makeCompanionObject(cdef: TypeDef, statics: List[Tree]): Tree
def makeConstructor(formals: List[Tree], tparams: List[TypeDef], flags: FlagSet): DefDef
def makeParam(name: TermName, tpt: Tree): ValDef
def makeSyntheticParam(count: Int, tpt: Tree): ValDef
def makeTemplate(parents: List[Tree], stats: List[Tree], tparams: List[TypeDef], needsDummyConstr: Boolean): Template
def memberDecl(start: Offset, mods: Modifiers, parentToken: Int, parentTParams: List[TypeDef]): List[Tree]
def modifiers(inInterface: Boolean): Modifiers
def optThrows(): Unit
def parse(): Tree

This is the general parse entry point. Overridden by ScriptParser

This is the general parse entry point. Overridden by ScriptParser

def qualId(): RefTree
def repsep[T <: Tree](p: () => T, sep: Int): List[T]
def skipAhead(): Unit

skip parent or brace enclosed sequence of things

skip parent or brace enclosed sequence of things

def skipTo(tokens: Int*): Unit
def syntaxError(msg: String, skipIt: Boolean): Unit
def syntaxError(offset: Int, msg: String, skipIt: Boolean): Unit
def termDecl(start: Offset, mods: Modifiers, parentToken: Int, parentTParams: List[TypeDef]): List[Tree]
def typ(): Tree
def typeArgs(t: Tree): Tree
def typeBody(leadingToken: Int, parentName: Name, parentTParams: List[TypeDef]): (List[Tree], List[Tree])
def typeBodyDecls(parentToken: Int, parentName: Name, parentTParams: List[TypeDef]): (List[Tree], List[Tree])
def typeDecl(start: Offset, mods: Modifiers): List[Tree]
def typeParam(flags: FlagSet): TypeDef
def varDecl(mods: Modifiers, tpt: Tree, name: TermName): ValDef

Inherited methods

def atSpan[T <: Positioned](start: Offset)(t: T): T
Inherited from
ParserCommon
def atSpan[T <: Positioned](start: Offset, point: Offset)(t: T): T

If the last read offset is strictly greater than start, assign tree the span from start to last read offset, with given point. If the last offset is less than or equal to start, the tree t did not consume any source for its construction. In this case, don't assign a span yet, but wait for its span to be determined by setChildSpans when the parent node is positioned.

If the last read offset is strictly greater than start, assign tree the span from start to last read offset, with given point. If the last offset is less than or equal to start, the tree t did not consume any source for its construction. In this case, don't assign a span yet, but wait for its span to be determined by setChildSpans when the parent node is positioned.

Inherited from
ParserCommon
def atSpan[T <: Positioned](start: Offset, point: Offset, end: Offset)(t: T): T
Inherited from
ParserCommon
def atSpan[T <: Positioned](span: Span)(t: T): T

Positions tree. If t does not have a span yet, set its span to the given one.

Positions tree. If t does not have a span yet, set its span to the given one.

Inherited from
ParserCommon
Inherited from
ParserCommon

in.offset, except if this is at a new line, in which case lastOffset is preferred.

in.offset, except if this is at a new line, in which case lastOffset is preferred.

Inherited from
ParserCommon
Inherited from
ParserCommon
Inherited from
ParserCommon
Inherited from
ParserCommon
def syntaxError(msg: Message, span: Span): Unit

Unconditionally issue an error at given span, without updating lastErrorOffset.

Unconditionally issue an error at given span, without updating lastErrorOffset.

Inherited from
ParserCommon
def syntaxError(msg: Message, offset: Int): Unit

Issue an error at given offset if beyond last error offset and update lastErrorOffset.

Issue an error at given offset if beyond last error offset and update lastErrorOffset.

Inherited from
ParserCommon
Inherited from
ParserCommon

Concrete fields

Inherited fields

protected var lastErrorOffset: Int

The offset where the last syntax error was reported, or if a skip to a safepoint occurred afterwards, the offset of the safe point.

The offset where the last syntax error was reported, or if a skip to a safepoint occurred afterwards, the offset of the safe point.

Inherited from
ParserCommon