@@ -1891,17 +1891,17 @@ object Parsers {
1891
1891
case VAL =>
1892
1892
val mod = atPos(in.skipToken()) { Mod .Val () }
1893
1893
val mods1 = mods.withAddedMod(mod)
1894
- patDefOrDcl(start, mods1, in.getDocComment(start) )
1894
+ patDefOrDcl(start, mods1)
1895
1895
case VAR =>
1896
1896
val mod = atPos(in.skipToken()) { Mod .Var () }
1897
1897
val mod1 = addMod(mods, mod)
1898
- patDefOrDcl(start, mod1, in.getDocComment(start) )
1898
+ patDefOrDcl(start, mod1)
1899
1899
case DEF =>
1900
- defDefOrDcl(start, posMods(start, mods), in.getDocComment(start) )
1900
+ defDefOrDcl(start, posMods(start, mods))
1901
1901
case TYPE =>
1902
- typeDefOrDcl(start, posMods(start, mods), in.getDocComment(start) )
1902
+ typeDefOrDcl(start, posMods(start, mods))
1903
1903
case CASE =>
1904
- enumCase(start, mods, in.getDocComment(start) )
1904
+ enumCase(start, mods)
1905
1905
case _ =>
1906
1906
tmplDef(start, mods)
1907
1907
}
@@ -1911,7 +1911,7 @@ object Parsers {
1911
1911
* ValDcl ::= id {`,' id} `:' Type
1912
1912
* VarDcl ::= id {`,' id} `:' Type
1913
1913
*/
1914
- def patDefOrDcl (start : Offset , mods : Modifiers , docstring : Option [ Comment ] = None ): Tree = atPos(start, nameStart) {
1914
+ def patDefOrDcl (start : Offset , mods : Modifiers ): Tree = atPos(start, nameStart) {
1915
1915
val lhs = commaSeparated(pattern2)
1916
1916
val tpt = typedOpt()
1917
1917
val rhs =
@@ -1926,7 +1926,7 @@ object Parsers {
1926
1926
} else EmptyTree
1927
1927
lhs match {
1928
1928
case (id @ Ident (name : TermName )) :: Nil => {
1929
- ValDef (name, tpt, rhs).withMods(mods).setComment(docstring )
1929
+ ValDef (name, tpt, rhs).withMods(mods).setComment(in.getDocComment(start) )
1930
1930
} case _ =>
1931
1931
PatDef (mods, lhs, tpt, rhs)
1932
1932
}
@@ -1937,7 +1937,7 @@ object Parsers {
1937
1937
* DefDcl ::= DefSig `:' Type
1938
1938
* DefSig ::= id [DefTypeParamClause] ParamClauses
1939
1939
*/
1940
- def defDefOrDcl (start : Offset , mods : Modifiers , docstring : Option [ Comment ] = None ): Tree = atPos(start, nameStart) {
1940
+ def defDefOrDcl (start : Offset , mods : Modifiers ): Tree = atPos(start, nameStart) {
1941
1941
def scala2ProcedureSyntax (resultTypeStr : String ) = {
1942
1942
val toInsert =
1943
1943
if (in.token == LBRACE ) s " $resultTypeStr = "
@@ -1980,7 +1980,7 @@ object Parsers {
1980
1980
accept(EQUALS )
1981
1981
expr()
1982
1982
}
1983
- DefDef (name, tparams, vparamss, tpt, rhs).withMods(mods1).setComment(docstring )
1983
+ DefDef (name, tparams, vparamss, tpt, rhs).withMods(mods1).setComment(in.getDocComment(start) )
1984
1984
}
1985
1985
}
1986
1986
@@ -2014,17 +2014,17 @@ object Parsers {
2014
2014
/** TypeDef ::= type id [TypeParamClause] `=' Type
2015
2015
* TypeDcl ::= type id [TypeParamClause] TypeBounds
2016
2016
*/
2017
- def typeDefOrDcl (start : Offset , mods : Modifiers , docstring : Option [ Comment ] = None ): Tree = {
2017
+ def typeDefOrDcl (start : Offset , mods : Modifiers ): Tree = {
2018
2018
newLinesOpt()
2019
2019
atPos(start, nameStart) {
2020
2020
val name = ident().toTypeName
2021
2021
val tparams = typeParamClauseOpt(ParamOwner .Type )
2022
2022
in.token match {
2023
2023
case EQUALS =>
2024
2024
in.nextToken()
2025
- TypeDef (name, lambdaAbstract(tparams, typ())).withMods(mods).setComment(docstring )
2025
+ TypeDef (name, lambdaAbstract(tparams, typ())).withMods(mods).setComment(in.getDocComment(start) )
2026
2026
case SUPERTYPE | SUBTYPE | SEMI | NEWLINE | NEWLINES | COMMA | RBRACE | EOF =>
2027
- TypeDef (name, lambdaAbstract(tparams, typeBounds())).withMods(mods).setComment(docstring )
2027
+ TypeDef (name, lambdaAbstract(tparams, typeBounds())).withMods(mods).setComment(in.getDocComment(start) )
2028
2028
case _ =>
2029
2029
syntaxErrorOrIncomplete(" `=', `>:', or `<:' expected" )
2030
2030
EmptyTree
@@ -2037,23 +2037,22 @@ object Parsers {
2037
2037
* | `enum' EnumDef
2038
2038
*/
2039
2039
def tmplDef (start : Int , mods : Modifiers ): Tree = {
2040
- val docstring = in.getDocComment(start)
2041
2040
in.token match {
2042
2041
case TRAIT =>
2043
- classDef(start, posMods(start, addFlag(mods, Trait )), docstring )
2042
+ classDef(start, posMods(start, addFlag(mods, Trait )))
2044
2043
case CLASS =>
2045
- classDef(start, posMods(start, mods), docstring )
2044
+ classDef(start, posMods(start, mods))
2046
2045
case CASECLASS =>
2047
- classDef(start, posMods(start, mods | Case ), docstring )
2046
+ classDef(start, posMods(start, mods | Case ))
2048
2047
case OBJECT =>
2049
- objectDef(start, posMods(start, mods | Module ), docstring )
2048
+ objectDef(start, posMods(start, mods | Module ))
2050
2049
case CASEOBJECT =>
2051
- objectDef(start, posMods(start, mods | Case | Module ), docstring )
2050
+ objectDef(start, posMods(start, mods | Case | Module ))
2052
2051
case ENUM =>
2053
2052
val mods1 = addMod(mods, atPos(in.skipToken()) { Mod .Enum () })
2054
2053
in.token match {
2055
2054
case CLASS | TRAIT | OBJECT => tmplDef(start, mods1)
2056
- case _ => enumDef(start, mods, docstring )
2055
+ case _ => enumDef(start, mods)
2057
2056
}
2058
2057
case _ =>
2059
2058
syntaxErrorOrIncomplete(" expected start of definition" )
@@ -2063,14 +2062,14 @@ object Parsers {
2063
2062
2064
2063
/** ClassDef ::= id ClassConstr TemplateOpt
2065
2064
*/
2066
- def classDef (start : Offset , mods : Modifiers , docstring : Option [ Comment ] ): TypeDef = atPos(start, nameStart) {
2067
- classDefRest(start, mods, docstring, ident().toTypeName)
2065
+ def classDef (start : Offset , mods : Modifiers ): TypeDef = atPos(start, nameStart) {
2066
+ classDefRest(start, mods, ident().toTypeName)
2068
2067
}
2069
2068
2070
- def classDefRest (start : Offset , mods : Modifiers , docstring : Option [ Comment ], name : TypeName ): TypeDef = {
2069
+ def classDefRest (start : Offset , mods : Modifiers , name : TypeName ): TypeDef = {
2071
2070
val constr = classConstr(name, isCaseClass = mods is Case )
2072
2071
val templ = templateOpt(constr)
2073
- TypeDef (name, templ).withMods(mods).setComment(docstring )
2072
+ TypeDef (name, templ).withMods(mods).setComment(in.getDocComment(start) )
2074
2073
}
2075
2074
2076
2075
/** ClassConstr ::= [ClsTypeParamClause] [ConstrMods] ClsParamClauses
@@ -2095,19 +2094,19 @@ object Parsers {
2095
2094
2096
2095
/** ObjectDef ::= id TemplateOpt
2097
2096
*/
2098
- def objectDef (start : Offset , mods : Modifiers , docstring : Option [ Comment ] = None ): ModuleDef = atPos(start, nameStart) {
2099
- objectDefRest(start, mods, docstring, ident())
2097
+ def objectDef (start : Offset , mods : Modifiers ): ModuleDef = atPos(start, nameStart) {
2098
+ objectDefRest(start, mods, ident())
2100
2099
}
2101
2100
2102
- def objectDefRest (start : Offset , mods : Modifiers , docstring : Option [ Comment ] = None , name : TermName ): ModuleDef = {
2101
+ def objectDefRest (start : Offset , mods : Modifiers , name : TermName ): ModuleDef = {
2103
2102
val template = templateOpt(emptyConstructor)
2104
- ModuleDef (name, template).withMods(mods).setComment(docstring )
2103
+ ModuleDef (name, template).withMods(mods).setComment(in.getDocComment(start) )
2105
2104
}
2106
2105
2107
2106
/** id ClassConstr [`extends' [ConstrApps]]
2108
2107
* [nl] ‘{’ EnumCaseStats ‘}’
2109
2108
*/
2110
- def enumDef (start : Offset , mods : Modifiers , docstring : Option [ Comment ] = None ): EnumDef = atPos(start, nameStart) {
2109
+ def enumDef (start : Offset , mods : Modifiers ): EnumDef = atPos(start, nameStart) {
2111
2110
val name = ident().toTypeName
2112
2111
val constr = classConstr(name)
2113
2112
val parents =
@@ -2134,23 +2133,19 @@ object Parsers {
2134
2133
}
2135
2134
2136
2135
/** EnumCaseStat = {Annotation [nl]} {Modifier} EnumCase */
2137
- def enumCaseStat (): MemberDef = {
2138
- val start = in.offset
2139
- val docstring = in.getDocComment(start)
2140
- val mods = defAnnotsMods(modifierTokens)
2141
- enumCase(start, mods, docstring)
2142
- }
2136
+ def enumCaseStat (): MemberDef =
2137
+ enumCase(in.offset, defAnnotsMods(modifierTokens))
2143
2138
2144
2139
/** EnumCase = `case' (EnumClassDef | ObjectDef) */
2145
- def enumCase (start : Offset , mods : Modifiers , docstring : Option [ Comment ] ): MemberDef = {
2140
+ def enumCase (start : Offset , mods : Modifiers ): MemberDef = {
2146
2141
val mods1 = mods.withAddedMod(atPos(in.offset)(Mod .EnumCase ())) | Case
2147
2142
accept(CASE )
2148
2143
atPos(start, nameStart) {
2149
2144
val name = ident()
2150
2145
if (in.token == LBRACKET || in.token == LPAREN )
2151
- classDefRest(start, mods1, docstring, name.toTypeName)
2146
+ classDefRest(start, mods1, name.toTypeName)
2152
2147
else
2153
- objectDefRest(start, mods1, docstring, name)
2148
+ objectDefRest(start, mods1, name)
2154
2149
}
2155
2150
}
2156
2151
@@ -2377,8 +2372,7 @@ object Parsers {
2377
2372
if (in.token == PACKAGE ) {
2378
2373
in.nextToken()
2379
2374
if (in.token == OBJECT ) {
2380
- val docstring = in.getDocComment(start)
2381
- ts += objectDef(start, atPos(start, in.skipToken()) { Modifiers (Package ) }, docstring)
2375
+ ts += objectDef(start, atPos(start, in.skipToken()) { Modifiers (Package ) })
2382
2376
if (in.token != EOF ) {
2383
2377
acceptStatSep()
2384
2378
ts ++= topStatSeq()
0 commit comments