@@ -20,7 +20,12 @@ import java.io.StringReader
2020
2121import com .github .javaparser ._
2222import com .github .javaparser .ast .`type` .Type
23- import com .github .javaparser .ast .body .{BodyDeclaration , ConstructorDeclaration , FieldDeclaration , MethodDeclaration }
23+ import com .github .javaparser .ast .body .{
24+ BodyDeclaration ,
25+ ConstructorDeclaration ,
26+ FieldDeclaration ,
27+ MethodDeclaration
28+ }
2429import com .github .javaparser .ast .expr .{Expression , Name , NameExpr , SimpleName }
2530import com .github .javaparser .ast .stmt .Statement
2631import com .github .javaparser .ast .{CompilationUnit , ImportDeclaration , Node }
@@ -31,7 +36,8 @@ import scala.collection.immutable._
3136import scala .jdk .CollectionConverters ._
3237
3338/** A Java fragment. */
34- class Java private (elements : Seq [Java ], text : String ) extends BufferedContent [Java ](elements, text) {
39+ class Java private (elements : Seq [Java ], text : String )
40+ extends BufferedContent [Java ](elements, text) {
3541 def this (text : String ) = this (Nil , Formats .safe(text))
3642 def this (elements : Seq [Java ]) = this (elements, " " )
3743
@@ -44,7 +50,8 @@ class Java private(elements: Seq[Java], text: String) extends BufferedContent[Ja
4450 def compilationUnit (): CompilationUnit = StaticJavaParser .parse(fullText)
4551
4652 /** Parses an import declaration. */
47- def importDeclaration (): ImportDeclaration = StaticJavaParser .parseImport(fullText)
53+ def importDeclaration (): ImportDeclaration =
54+ StaticJavaParser .parseImport(fullText)
4855
4956 /** Parses this element as a single statement. */
5057 def statement (): Statement = StaticJavaParser .parseStatement(fullText)
@@ -54,7 +61,8 @@ class Java private(elements: Seq[Java], text: String) extends BufferedContent[Ja
5461 StaticJavaParser .parseBlock(s " { $fullText } " ).getStatements.asScala.to(Seq )
5562
5663 /** Parses this element as an expression. */
57- def expression [T <: Expression ](): T = StaticJavaParser .parseExpression[T ](fullText)
64+ def expression [T <: Expression ](): T =
65+ StaticJavaParser .parseExpression[T ](fullText)
5866
5967 /** Parses this element as a (potentially qualified) name. */
6068 def name (): Name = StaticJavaParser .parseName(fullText)
@@ -65,12 +73,22 @@ class Java private(elements: Seq[Java], text: String) extends BufferedContent[Ja
6573 /** Parses this element as a (unqualified) name expression. */
6674 def nameExpression (): NameExpr = expression()
6775
68- /** Parses this element as a class body declaration (e.g. a method or a field). */
69- def classBodyDeclaration (): BodyDeclaration [? ] = StaticJavaParser .parseBodyDeclaration(fullText)
76+ /** Parses this element as a class body declaration (e.g. a method or a
77+ * field).
78+ */
79+ def classBodyDeclaration (): BodyDeclaration [? ] =
80+ StaticJavaParser .parseBodyDeclaration(fullText)
7081
7182 /** Parses this element as multiple class body declarations. */
7283 def classBodyDeclarations (): Seq [BodyDeclaration [? ]] =
73- StaticJavaParser .parse(s " class C { $fullText } " ).getTypes.asScala.head.getMembers.asScala.to(Seq )
84+ StaticJavaParser
85+ .parse(s " class C { $fullText } " )
86+ .getTypes
87+ .asScala
88+ .head
89+ .getMembers
90+ .asScala
91+ .to(Seq )
7492
7593 /** Parses this element as multiple field declarations. */
7694 def fieldDeclarations (): Seq [FieldDeclaration ] =
@@ -84,19 +102,25 @@ class Java private(elements: Seq[Java], text: String) extends BufferedContent[Ja
84102 def constructors (): Seq [ConstructorDeclaration ] =
85103 classBodyDeclarations().map(_.asInstanceOf [ConstructorDeclaration ])
86104
87- /** Parses this element as an interface body declaration (e.g. a method signature). */
88- def interfaceBodyDeclaration (): BodyDeclaration [? ] = StaticJavaParser .parseBodyDeclaration(fullText)
105+ /** Parses this element as an interface body declaration (e.g. a method
106+ * signature).
107+ */
108+ def interfaceBodyDeclaration (): BodyDeclaration [? ] =
109+ StaticJavaParser .parseBodyDeclaration(fullText)
89110
90111 /** Parses this element as a type (e.g. the in X foo = (X)bar). */
91112 def tpe (): Type = StaticJavaParser .parseType(fullText)
92113}
93114
94115/** Helper for Java utility methods. */
95116object Java {
117+
96118 /** Creates a Java fragment with initial content specified. */
97119 def apply (text : String ): Java = new Java (text)
98120
99- /** Creates a Java fragment with initial content from the given `text` separated by `separator`. */
121+ /** Creates a Java fragment with initial content from the given `text`
122+ * separated by `separator`.
123+ */
100124 def apply (text : Seq [String ], separator : String = " ;" ): Java = {
101125 apply(text.mkString(separator))
102126 }
@@ -105,19 +129,22 @@ object Java {
105129 def apply (node : Node ): Java = Java (node.toString)
106130
107131 /** Creates a Java fragment with initial content from the asts `nodes`. */
108- def apply (nodes : Seq [Node ]): Java = new Java (Seq ((nodes map apply)* ))
132+ def apply (nodes : Seq [Node ]): Java = new Java (Seq ((nodes. map( apply) )* ))
109133}
110134
111135object JavaFormat extends Format [Java ] {
136+
112137 /** Integrates `text` without performing any escaping process.
113138 *
114- * @param text Text to integrate
139+ * @param text
140+ * Text to integrate
115141 */
116142 def raw (text : String ): Java = Java (text)
117143
118144 /** Escapes `text` using Java String rules.
119145 *
120- * @param text Text to integrate
146+ * @param text
147+ * Text to integrate
121148 */
122149 def escape (text : String ): Java = Java (StringEscapeUtils .escapeJava(text))
123150
0 commit comments