productIterator () { throw new RuntimeException(); }
24 | public boolean canEqual (Object x$1) { throw new RuntimeException(); }
25 | public int hashCode () { throw new RuntimeException(); }
26 | public java.lang.String toString () { throw new RuntimeException(); }
27 | }
28 | public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () ;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/scala/com/typesafe/genjavadoc/util/CompilerSpec.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 | package util
3 |
4 | import java.io.InputStreamReader
5 | import java.io.BufferedReader
6 | import java.io.File
7 |
8 | import org.junit.Test
9 | import org.junit.Assert._
10 |
11 | /** Utility trait for testing compiler behaviour. */
12 | trait CompilerSpec {
13 |
14 | /** Sources to compile. */
15 | def sources: Seq[String]
16 |
17 | /** Root directory that contains expected Java output. */
18 | def expectedPath: String
19 |
20 | /** Extra plugin arguments. */
21 | def extraSettings: Seq[String] = Seq.empty
22 |
23 | @Test def compileSourcesAndGenerateExpectedOutput(): Unit = {
24 | val doc = IO.tempDir("java")
25 | val docPath = doc.getAbsolutePath
26 | val defaultSettings = Seq(s"out=$docPath", "suppressSynthetic=false")
27 | val scalac = new GenJavadocCompiler((defaultSettings ++ extraSettings).map{ kv =>
28 | s"genjavadoc:$kv"
29 | })
30 |
31 | scalac.compile(sources)
32 | assertFalse("Scala compiler reported errors", scalac.reporter.hasErrors)
33 |
34 | lines(run(".", "diff", "-wurN",
35 | "-I", "^ *//", // comment lines
36 | "-I", "^ *private java\\.lang\\.Object readResolve", // since Scala 2.12.0-M3, these methods are emitted in a later compiler phase
37 | expectedPath, docPath)) foreach println
38 | }
39 |
40 | private def run(dir: String, cmd: String*): Process = {
41 | new ProcessBuilder(cmd: _*).directory(new File(dir)).redirectErrorStream(true).start()
42 | }
43 |
44 | private def lines(proc: Process) = {
45 | val b = new BufferedReader(new InputStreamReader(proc.getInputStream()))
46 | Iterator.continually(b.readLine).takeWhile(
47 | _ != null || { proc.waitFor(); assert(proc.exitValue == 0); false }
48 | )
49 | }
50 |
51 |
52 | }
53 | object CompilerSpec {
54 | def traverseDirectory(dir: File): Seq[File] = {
55 | dir.listFiles.toSeq.flatMap { file: File =>
56 | if (file.isFile) Seq(file)
57 | else if (file.isDirectory) traverseDirectory(file)
58 | else Seq.empty
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/resources/expected_output/basic/akka/rk/buh/is/it/EWMA.java:
--------------------------------------------------------------------------------
1 | package akka.rk.buh.is.it;
2 | /**
3 | * The exponentially weighted moving average (EWMA) approach captures short-term
4 | * movements in volatility for a conditional volatility forecasting model. By virtue
5 | * of its alpha, or decay factor, this provides a statistical streaming data model
6 | * that is exponentially biased towards newer entries.
7 | *
8 | * http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
9 | *
10 | * An EWMA only needs the most recent forecast value to be kept, as opposed to a standard
11 | * moving average model.
12 | *
13 | * param: alpha decay factor, sets how quickly the exponential weighting decays for past data compared to new data,
14 | * see http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
15 | *
16 | * param: value the current exponentially weighted moving average, e.g. Y(n - 1), or,
17 | * the sampled value resulting from the previous smoothing iteration.
18 | * This value is always used as the previous EWMA to calculate the new EWMA.
19 | *
20 | */
21 | public final class EWMA implements scala.Product, scala.Serializable {
22 | // not preceding
23 | static public akka.rk.buh.is.it.EWMA apply (double value, double alpha) { throw new RuntimeException(); }
24 | static public scala.Option> unapply (akka.rk.buh.is.it.EWMA x$0) { throw new RuntimeException(); }
25 | public double value () { throw new RuntimeException(); }
26 | public double alpha () { throw new RuntimeException(); }
27 | // not preceding
28 | public EWMA (double value, double alpha) { throw new RuntimeException(); }
29 | /**
30 | * Calculates the exponentially weighted moving average for a given monitored data set.
31 | *
32 | * @param xn the new data point
33 | * @return a new EWMA with the updated value
34 | */
35 | public akka.rk.buh.is.it.EWMA $colon$plus (double xn) { throw new RuntimeException(); }
36 | // not preceding
37 | public akka.rk.buh.is.it.EWMA copy (double value, double alpha) { throw new RuntimeException(); }
38 | // not preceding
39 | public double copy$default$1 () { throw new RuntimeException(); }
40 | public double copy$default$2 () { throw new RuntimeException(); }
41 | // not preceding
42 | public java.lang.String productPrefix () { throw new RuntimeException(); }
43 | public int productArity () { throw new RuntimeException(); }
44 | public Object productElement (int x$1) { throw new RuntimeException(); }
45 | public scala.collection.Iterator productIterator () { throw new RuntimeException(); }
46 | public boolean canEqual (Object x$1) { throw new RuntimeException(); }
47 | public int hashCode () { throw new RuntimeException(); }
48 | public java.lang.String toString () { throw new RuntimeException(); }
49 | public boolean equals (Object x$1) { throw new RuntimeException(); }
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/resources/expected_output/basic/akka/rk/buh/is/it/Blarb.java:
--------------------------------------------------------------------------------
1 | package akka.rk.buh.is.it;
2 | // no position
3 | /**
4 | * I am an object. I have no class.
5 | */
6 | public class Blarb {
7 | // no position
8 | static public class A$ implements akka.rk.buh.is.it.Blarb.Fuz, scala.Product, scala.Serializable {
9 | /**
10 | * Static reference to the singleton instance of this Scala object.
11 | */
12 | public static final A$ MODULE$ = null;
13 | public A$ () { throw new RuntimeException(); }
14 | public java.lang.String productPrefix () { throw new RuntimeException(); }
15 | public int productArity () { throw new RuntimeException(); }
16 | public Object productElement (int x$1) { throw new RuntimeException(); }
17 | public scala.collection.Iterator productIterator () { throw new RuntimeException(); }
18 | public boolean canEqual (Object x$1) { throw new RuntimeException(); }
19 | public int hashCode () { throw new RuntimeException(); }
20 | public java.lang.String toString () { throw new RuntimeException(); }
21 | private java.lang.Object readResolve () { throw new RuntimeException(); }
22 | }
23 | static public class B implements akka.rk.buh.is.it.Blarb.Fuz, scala.Product, scala.Serializable {
24 | public java.lang.String x () { throw new RuntimeException(); }
25 | // not preceding
26 | public B (java.lang.String x) { throw new RuntimeException(); }
27 | public akka.rk.buh.is.it.Blarb.B copy (java.lang.String x) { throw new RuntimeException(); }
28 | public java.lang.String copy$default$1 () { throw new RuntimeException(); }
29 | // not preceding
30 | public java.lang.String productPrefix () { throw new RuntimeException(); }
31 | public int productArity () { throw new RuntimeException(); }
32 | public Object productElement (int x$1) { throw new RuntimeException(); }
33 | public scala.collection.Iterator productIterator () { throw new RuntimeException(); }
34 | public boolean canEqual (Object x$1) { throw new RuntimeException(); }
35 | public int hashCode () { throw new RuntimeException(); }
36 | public java.lang.String toString () { throw new RuntimeException(); }
37 | public boolean equals (Object x$1) { throw new RuntimeException(); }
38 | }
39 | // no position
40 | static public class B$ extends scala.runtime.AbstractFunction1 implements scala.Serializable {
41 | /**
42 | * Static reference to the singleton instance of this Scala object.
43 | */
44 | public static final B$ MODULE$ = null;
45 | public B$ () { throw new RuntimeException(); }
46 | public final java.lang.String toString () { throw new RuntimeException(); }
47 | public akka.rk.buh.is.it.Blarb.B apply (java.lang.String x) { throw new RuntimeException(); }
48 | public scala.Option unapply (akka.rk.buh.is.it.Blarb.B x$0) { throw new RuntimeException(); }
49 | private java.lang.Object readResolve () { throw new RuntimeException(); }
50 | }
51 | static public interface Fuz {
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/resources/expected_output/basic/akka/rk/buh/is/it/CompressionProtocol.java:
--------------------------------------------------------------------------------
1 | package akka.rk.buh.is.it;
2 | public class CompressionProtocol {
3 | static public class Events$ {
4 | /**
5 | * Static reference to the singleton instance of this Scala object.
6 | */
7 | public static final Events$ MODULE$ = null;
8 | public final class HeavyHitterDetected implements akka.rk.buh.is.it.CompressionProtocol.Events.Event, scala.Product, scala.Serializable {
9 | static public akka.rk.buh.is.it.CompressionProtocol.Events.HeavyHitterDetected apply (Object key, int id, long count) { throw new RuntimeException(); }
10 | static public scala.Option> unapply (akka.rk.buh.is.it.CompressionProtocol.Events.HeavyHitterDetected x$0) { throw new RuntimeException(); }
11 | public Object key () { throw new RuntimeException(); }
12 | public int id () { throw new RuntimeException(); }
13 | public long count () { throw new RuntimeException(); }
14 | // not preceding
15 | public HeavyHitterDetected (Object key, int id, long count) { throw new RuntimeException(); }
16 | public akka.rk.buh.is.it.CompressionProtocol.Events.HeavyHitterDetected copy (Object key, int id, long count) { throw new RuntimeException(); }
17 | // not preceding
18 | public Object copy$default$1 () { throw new RuntimeException(); }
19 | public int copy$default$2 () { throw new RuntimeException(); }
20 | public long copy$default$3 () { throw new RuntimeException(); }
21 | // not preceding
22 | public java.lang.String productPrefix () { throw new RuntimeException(); }
23 | public int productArity () { throw new RuntimeException(); }
24 | public Object productElement (int x$1) { throw new RuntimeException(); }
25 | public scala.collection.Iterator productIterator () { throw new RuntimeException(); }
26 | public boolean canEqual (Object x$1) { throw new RuntimeException(); }
27 | public int hashCode () { throw new RuntimeException(); }
28 | public java.lang.String toString () { throw new RuntimeException(); }
29 | public boolean equals (Object x$1) { throw new RuntimeException(); }
30 | }
31 | public class HeavyHitterDetected$ extends scala.runtime.AbstractFunction3 implements scala.Serializable {
32 | /**
33 | * Static reference to the singleton instance of this Scala object.
34 | */
35 | public static final HeavyHitterDetected$ MODULE$ = null;
36 | public HeavyHitterDetected$ () { throw new RuntimeException(); }
37 | public final java.lang.String toString () { throw new RuntimeException(); }
38 | public akka.rk.buh.is.it.CompressionProtocol.Events.HeavyHitterDetected apply (Object key, int id, long count) { throw new RuntimeException(); }
39 | public scala.Option> unapply (akka.rk.buh.is.it.CompressionProtocol.Events.HeavyHitterDetected x$0) { throw new RuntimeException(); }
40 | private java.lang.Object readResolve () { throw new RuntimeException(); }
41 | }
42 | public interface Event {
43 | }
44 | public Events$ () { throw new RuntimeException(); }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.10.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.11.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.12.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.13.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.14.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.15.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.16.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.17.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/scala/com/typesafe/genjavadoc/BaseComments.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import scala.collection.immutable.TreeMap
4 | import scala.annotation.tailrec
5 |
6 | trait BaseComments { this: TransformCake =>
7 | import global._
8 |
9 | def unit: CompilationUnit
10 |
11 | private val replacements = Seq(
12 | "{{{" -> "",
13 | "}}}" -> " ",
14 | "“" -> "“",
15 | "”" -> "”",
16 | "‘" -> "‘",
17 | "’" -> "’",
18 | "&" -> "&",
19 | "
" -> "
",
20 | "=>" -> "=>",
21 | "[[" -> "{@link ",
22 | "]]" -> "}")
23 | private val EmptyLine = """(?:/\*\*(?:.*\*/)?|\s+(?:\*/|\*?))\s*""".r
24 | private val See = """(.*@see )\[\[([^]]+)]]\s*""".r
25 | private val HttpLink = "^https?://.*".r
26 |
27 | case class Comment(pos: Position, text: Seq[String])
28 | object Comment {
29 | def apply(pos: Position, text: String) = {
30 | val ll = text.replaceAll("\n[ \t]*", "\n ").split("\n")
31 | .map {
32 | case See(prefix, link) =>
33 | if (HttpLink.findFirstIn(link).isDefined)
34 | s"""$prefix """
35 | else
36 | s"$prefix$link"
37 | case x => x
38 | }
39 | .map(line => replacements.foldLeft(line) { case (l, (from, to)) => l.replace(from, to) })
40 | val (_, _, _, l2) = ll.foldLeft((false, false, true, List.empty[String])) {
41 | // insert line upon transition to empty, collapse contiguous empty lines
42 | case ((pre, code, empty, lines), line @ EmptyLine()) =>
43 | val nl =
44 | if (pre || line.contains("/**") || line.contains("*/")) line :: lines
45 | else if (!pre && !empty) " *
" :: (lines.head + (if (code) "" else "")) :: lines.tail
46 | else lines
47 | (pre, false, true, nl)
48 | case ((pre, code, empty, lines), line) =>
49 | val (nc, nl) = if (pre) (code, line) else codeLine(code, line)
50 | val np = if (line contains "
") true else if (line contains " ") false else pre
51 | val nl2 = if (pre && np) preLine(nl) else nl
52 | (np, nc, false, nl2 :: lines)
53 | }
54 | new Comment(pos, l2.reverse map htmlEntity)
55 | }
56 | private def preLine(line: String): String =
57 | line.replace("@", "@").replace("<", "<").replace(">", ">")
58 | @tailrec private def codeLine(code: Boolean, line: String): (Boolean, String) = {
59 | val next = replace(line, "`", if (code) "" else "")
60 | if (next eq line) (code, line)
61 | else codeLine(!code, next)
62 | }
63 | private def replace(str: String, from: String, to: String): String = {
64 | str.indexOf(from) match {
65 | case -1 => str
66 | case n => str.substring(0, n) + to + str.substring(n + from.length)
67 | }
68 | }
69 | private def htmlEntity(str: String): String = {
70 | str flatMap (ch => if (ch > 127) f"${ch}%04x;" else "" + ch)
71 | }
72 | }
73 |
74 | implicit val positionOrdering: Ordering[Position] = Ordering.by(_.point)
75 | var comments = TreeMap[Int, Comment]()
76 |
77 | // This is overriden in the Scala Version Specific Comments.scala
78 | protected def parseComments(): Unit
79 |
80 | parseComments()
81 |
82 | val positions = comments.keySet
83 |
84 | def between(p1: Position, p2: Position) = unit.source.content.slice(p1.start, p2.start).filterNot(_ == '\n').mkString
85 |
86 | object Scaladoc extends (Comment => Boolean) {
87 | def apply(c: Comment): Boolean = c.text.head.startsWith("/**")
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.18.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 | --- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
73 | +++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
74 | @@ -12,8 +12,6 @@
75 | public void alreadyDeprecatedInComment () { throw new RuntimeException(); }
76 | /**
77 | * buh!
78 | - *
79 | - * @deprecated
80 | */
81 | public void javaDeprecatedThingie () { throw new RuntimeException(); }
82 | /**
83 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.19.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 | --- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
73 | +++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
74 | @@ -12,8 +12,6 @@
75 | public void alreadyDeprecatedInComment () { throw new RuntimeException(); }
76 | /**
77 | * buh!
78 | - *
79 | - * @deprecated
80 | */
81 | public void javaDeprecatedThingie () { throw new RuntimeException(); }
82 | /**
83 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.20.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 | --- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
73 | +++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
74 | @@ -12,8 +12,6 @@
75 | public void alreadyDeprecatedInComment () { throw new RuntimeException(); }
76 | /**
77 | * buh!
78 | - *
79 | - * @deprecated
80 | */
81 | public void javaDeprecatedThingie () { throw new RuntimeException(); }
82 | /**
83 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.21.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 | --- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
73 | +++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
74 | @@ -12,8 +12,6 @@
75 | public void alreadyDeprecatedInComment () { throw new RuntimeException(); }
76 | /**
77 | * buh!
78 | - *
79 | - * @deprecated
80 | */
81 | public void javaDeprecatedThingie () { throw new RuntimeException(); }
82 | /**
83 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.22.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
51 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
52 | @@ -2,5 +2,6 @@
53 | public interface Inbox {
54 | public interface InboxExtension {
55 | public int DSLInboxQueueSize () ;
56 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
57 | }
58 | }
59 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
60 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
61 | @@ -5,7 +5,9 @@
62 | * Static reference to the singleton instance of this Scala object.
63 | */
64 | public static final JournalPolicies$ MODULE$ = null;
65 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
66 | public JournalPolicies$ () { throw new RuntimeException(); }
67 | }
68 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
69 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
70 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
71 | }
72 | --- target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
73 | +++ target/expected_output/basic/akka/rk/buh/is/it/DontTouchThis.java
74 | @@ -12,8 +12,6 @@
75 | public void alreadyDeprecatedInComment () { throw new RuntimeException(); }
76 | /**
77 | * buh!
78 | - *
79 | - * @deprecated
80 | */
81 | public void javaDeprecatedThingie () { throw new RuntimeException(); }
82 | /**
83 |
--------------------------------------------------------------------------------
/src/main/scala/com/typesafe/genjavadoc/Plugin.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import scala.tools.nsc
4 | import nsc.Global
5 | import nsc.plugins.Plugin
6 | import nsc.plugins.PluginComponent
7 | import nsc.transform.Transform
8 | import java.io.File
9 | import java.util.Properties
10 |
11 |
12 | object GenJavadocPlugin {
13 |
14 | val javaKeywords = Set("abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue",
15 | "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if",
16 | "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private",
17 | "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this",
18 | "throw", "throws", "transient", "try", "void", "volatile", "while")
19 |
20 | private val defaultFilterString = "$$"
21 |
22 | def stringToFilter(s: String): Set[String] = s.split(",").toSet
23 |
24 | val defaultFilteredStrings = stringToFilter(defaultFilterString)
25 | }
26 |
27 | class GenJavadocPlugin(val global: Global) extends Plugin {
28 | import GenJavadocPlugin._
29 |
30 | val name = "genjavadoc"
31 | val description = ""
32 | val components: List[PluginComponent] =
33 | if (global.settings.isScaladoc) List.empty
34 | else List(MyComponent)
35 |
36 | override def init(options: List[String], error: String => Unit): Boolean = {
37 | myOptions = new Properties()
38 | options foreach { str =>
39 | str.indexOf('=') match {
40 | case -1 => myOptions.setProperty(str, "true")
41 | case n => myOptions.setProperty(str.substring(0, n), str.substring(n + 1))
42 | }
43 | }
44 | true
45 | }
46 |
47 | private var myOptions: Properties = _
48 |
49 | lazy val outputBase = new File(myOptions.getProperty("out", "."))
50 | lazy val suppressSynthetic = java.lang.Boolean.parseBoolean(myOptions.getProperty("suppressSynthetic", "true"))
51 | lazy val filteredStrings: Set[String] = stringToFilter(myOptions.getProperty("filter", defaultFilterString))
52 | lazy val fabricateParams = java.lang.Boolean.parseBoolean(myOptions.getProperty("fabricateParams", "true"))
53 | lazy val strictVisibility = java.lang.Boolean.parseBoolean(myOptions.getProperty("strictVisibility", "false"))
54 | lazy val allowedAnnotations: Set[String] = stringToFilter(myOptions.getProperty("annotations", ""))
55 |
56 | private object MyComponent extends PluginComponent with Transform {
57 |
58 | import global._
59 |
60 | type GT = GenJavadocPlugin.this.global.type
61 |
62 | override val global: GT = GenJavadocPlugin.this.global
63 |
64 | private[this] val Version = s"""(\\d+)\\.(\\d+)\\.(\\d+).*""".r
65 | private[this] val (min, pat) = nsc.Properties.versionNumberString match {
66 | case Version("2", b, c) => (b.toInt, c.toInt)
67 | case v =>
68 | reporter.warning(NoPosition, s"Unexpected Scala version in GenJavadoc: $v")
69 | (-1, -1)
70 | }
71 |
72 | override val runsAfter: List[String] = List(if (min <= 11) "uncurry" else "fields")
73 |
74 | // This used to be `Nil`. In 2.12.9 and earlier, and also 2.13.0, the phase assembly algorithm
75 | // would in fact place the genjavadoc phase much later than `fields`, after `specialize`
76 | // (see https://github.com/scala/scala-dev/issues/647#issuecomment-525650681).
77 | //
78 | // This was never intended, so we tried adding `runsBefore tailcalls`. However, because the
79 | // compiler's own phase have ambiguous ordering, the 2.12.9 / 2.13.0 algorithm changed the order
80 | // of other phases (see https://github.com/lightbend/genjavadoc/pull/191#issuecomment-532185154).
81 | //
82 | // In 2.12.10 and 2.13.1, the algorithm was updated (scala/scala#8393), and setting
83 | // `runsBefore tailcalls` is now possible. The order of the compiler's own phases is made
84 | // unambiguous in scala/scala#8426 and 8427.
85 | override val runsBefore: List[String] =
86 | if (min == 12 && pat >= 10 || min == 13 && pat >= 1 || min > 13) List("tailcalls")
87 | else Nil
88 |
89 | val phaseName = "GenJavadoc"
90 |
91 | def newTransformer(unit: CompilationUnit) = new GenJavadocTransformer(unit)
92 |
93 | class GenJavadocTransformer(val unit: CompilationUnit) extends Transformer with TransformCake {
94 |
95 | override lazy val global: GT = MyComponent.this.global
96 | override val outputBase: File = GenJavadocPlugin.this.outputBase
97 | override val suppressSynthetic: Boolean = GenJavadocPlugin.this.suppressSynthetic
98 | override val fabricateParams: Boolean = GenJavadocPlugin.this.fabricateParams
99 | override val strictVisibility: Boolean = GenJavadocPlugin.this.strictVisibility
100 |
101 | override def superTransformUnit(unit: CompilationUnit) = super.transformUnit(unit)
102 | override def superTransform(tree: Tree) = super.transform(tree)
103 | override def transform(tree: Tree) = newTransform(tree)
104 | override def transformUnit(unit: CompilationUnit) = newTransformUnit(unit)
105 | override def javaKeywords = GenJavadocPlugin.javaKeywords
106 | override def filteredStrings = GenJavadocPlugin.this.filteredStrings
107 |
108 | override def allowedAnnotations: Set[String] = GenJavadocPlugin.this.allowedAnnotations
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.5.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/Identify.java
51 | +++ target/expected_output/basic/akka/actor/Identify.java
52 | @@ -2,6 +2,30 @@
53 | public final class Identify implements scala.Product, scala.Serializable {
54 | static public akka.actor.Identify apply (Object messageId) { throw new RuntimeException(); }
55 | static public scala.Option unapply (akka.actor.Identify x$0) { throw new RuntimeException(); }
56 | + static public boolean apply$mcZD$sp (double v1) { throw new RuntimeException(); }
57 | + static public double apply$mcDD$sp (double v1) { throw new RuntimeException(); }
58 | + static public float apply$mcFD$sp (double v1) { throw new RuntimeException(); }
59 | + static public int apply$mcID$sp (double v1) { throw new RuntimeException(); }
60 | + static public long apply$mcJD$sp (double v1) { throw new RuntimeException(); }
61 | + static public void apply$mcVD$sp (double v1) { throw new RuntimeException(); }
62 | + static public boolean apply$mcZF$sp (float v1) { throw new RuntimeException(); }
63 | + static public double apply$mcDF$sp (float v1) { throw new RuntimeException(); }
64 | + static public float apply$mcFF$sp (float v1) { throw new RuntimeException(); }
65 | + static public int apply$mcIF$sp (float v1) { throw new RuntimeException(); }
66 | + static public long apply$mcJF$sp (float v1) { throw new RuntimeException(); }
67 | + static public void apply$mcVF$sp (float v1) { throw new RuntimeException(); }
68 | + static public boolean apply$mcZI$sp (int v1) { throw new RuntimeException(); }
69 | + static public double apply$mcDI$sp (int v1) { throw new RuntimeException(); }
70 | + static public float apply$mcFI$sp (int v1) { throw new RuntimeException(); }
71 | + static public int apply$mcII$sp (int v1) { throw new RuntimeException(); }
72 | + static public long apply$mcJI$sp (int v1) { throw new RuntimeException(); }
73 | + static public void apply$mcVI$sp (int v1) { throw new RuntimeException(); }
74 | + static public boolean apply$mcZJ$sp (long v1) { throw new RuntimeException(); }
75 | + static public double apply$mcDJ$sp (long v1) { throw new RuntimeException(); }
76 | + static public float apply$mcFJ$sp (long v1) { throw new RuntimeException(); }
77 | + static public int apply$mcIJ$sp (long v1) { throw new RuntimeException(); }
78 | + static public long apply$mcJJ$sp (long v1) { throw new RuntimeException(); }
79 | + static public void apply$mcVJ$sp (long v1) { throw new RuntimeException(); }
80 | public Object messageId () { throw new RuntimeException(); }
81 | // not preceding
82 | public Identify (Object messageId) { throw new RuntimeException(); }
83 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
84 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
85 | @@ -2,5 +2,6 @@
86 | public interface Inbox {
87 | public interface InboxExtension {
88 | public int DSLInboxQueueSize () ;
89 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
90 | }
91 | }
92 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
93 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
94 | @@ -5,7 +5,9 @@
95 | * Static reference to the singleton instance of this Scala object.
96 | */
97 | public static final JournalPolicies$ MODULE$ = null;
98 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
99 | public JournalPolicies$ () { throw new RuntimeException(); }
100 | }
101 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
102 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
103 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
104 | }
105 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.6.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/Identify.java
51 | +++ target/expected_output/basic/akka/actor/Identify.java
52 | @@ -2,6 +2,30 @@
53 | public final class Identify implements scala.Product, scala.Serializable {
54 | static public akka.actor.Identify apply (Object messageId) { throw new RuntimeException(); }
55 | static public scala.Option unapply (akka.actor.Identify x$0) { throw new RuntimeException(); }
56 | + static public boolean apply$mcZD$sp (double v1) { throw new RuntimeException(); }
57 | + static public double apply$mcDD$sp (double v1) { throw new RuntimeException(); }
58 | + static public float apply$mcFD$sp (double v1) { throw new RuntimeException(); }
59 | + static public int apply$mcID$sp (double v1) { throw new RuntimeException(); }
60 | + static public long apply$mcJD$sp (double v1) { throw new RuntimeException(); }
61 | + static public void apply$mcVD$sp (double v1) { throw new RuntimeException(); }
62 | + static public boolean apply$mcZF$sp (float v1) { throw new RuntimeException(); }
63 | + static public double apply$mcDF$sp (float v1) { throw new RuntimeException(); }
64 | + static public float apply$mcFF$sp (float v1) { throw new RuntimeException(); }
65 | + static public int apply$mcIF$sp (float v1) { throw new RuntimeException(); }
66 | + static public long apply$mcJF$sp (float v1) { throw new RuntimeException(); }
67 | + static public void apply$mcVF$sp (float v1) { throw new RuntimeException(); }
68 | + static public boolean apply$mcZI$sp (int v1) { throw new RuntimeException(); }
69 | + static public double apply$mcDI$sp (int v1) { throw new RuntimeException(); }
70 | + static public float apply$mcFI$sp (int v1) { throw new RuntimeException(); }
71 | + static public int apply$mcII$sp (int v1) { throw new RuntimeException(); }
72 | + static public long apply$mcJI$sp (int v1) { throw new RuntimeException(); }
73 | + static public void apply$mcVI$sp (int v1) { throw new RuntimeException(); }
74 | + static public boolean apply$mcZJ$sp (long v1) { throw new RuntimeException(); }
75 | + static public double apply$mcDJ$sp (long v1) { throw new RuntimeException(); }
76 | + static public float apply$mcFJ$sp (long v1) { throw new RuntimeException(); }
77 | + static public int apply$mcIJ$sp (long v1) { throw new RuntimeException(); }
78 | + static public long apply$mcJJ$sp (long v1) { throw new RuntimeException(); }
79 | + static public void apply$mcVJ$sp (long v1) { throw new RuntimeException(); }
80 | public Object messageId () { throw new RuntimeException(); }
81 | // not preceding
82 | public Identify (Object messageId) { throw new RuntimeException(); }
83 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
84 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
85 | @@ -2,5 +2,6 @@
86 | public interface Inbox {
87 | public interface InboxExtension {
88 | public int DSLInboxQueueSize () ;
89 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
90 | }
91 | }
92 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
93 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
94 | @@ -5,7 +5,9 @@
95 | * Static reference to the singleton instance of this Scala object.
96 | */
97 | public static final JournalPolicies$ MODULE$ = null;
98 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
99 | public JournalPolicies$ () { throw new RuntimeException(); }
100 | }
101 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
102 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
103 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
104 | }
105 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.7.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/Identify.java
51 | +++ target/expected_output/basic/akka/actor/Identify.java
52 | @@ -2,6 +2,30 @@
53 | public final class Identify implements scala.Product, scala.Serializable {
54 | static public akka.actor.Identify apply (Object messageId) { throw new RuntimeException(); }
55 | static public scala.Option unapply (akka.actor.Identify x$0) { throw new RuntimeException(); }
56 | + static public boolean apply$mcZD$sp (double v1) { throw new RuntimeException(); }
57 | + static public double apply$mcDD$sp (double v1) { throw new RuntimeException(); }
58 | + static public float apply$mcFD$sp (double v1) { throw new RuntimeException(); }
59 | + static public int apply$mcID$sp (double v1) { throw new RuntimeException(); }
60 | + static public long apply$mcJD$sp (double v1) { throw new RuntimeException(); }
61 | + static public void apply$mcVD$sp (double v1) { throw new RuntimeException(); }
62 | + static public boolean apply$mcZF$sp (float v1) { throw new RuntimeException(); }
63 | + static public double apply$mcDF$sp (float v1) { throw new RuntimeException(); }
64 | + static public float apply$mcFF$sp (float v1) { throw new RuntimeException(); }
65 | + static public int apply$mcIF$sp (float v1) { throw new RuntimeException(); }
66 | + static public long apply$mcJF$sp (float v1) { throw new RuntimeException(); }
67 | + static public void apply$mcVF$sp (float v1) { throw new RuntimeException(); }
68 | + static public boolean apply$mcZI$sp (int v1) { throw new RuntimeException(); }
69 | + static public double apply$mcDI$sp (int v1) { throw new RuntimeException(); }
70 | + static public float apply$mcFI$sp (int v1) { throw new RuntimeException(); }
71 | + static public int apply$mcII$sp (int v1) { throw new RuntimeException(); }
72 | + static public long apply$mcJI$sp (int v1) { throw new RuntimeException(); }
73 | + static public void apply$mcVI$sp (int v1) { throw new RuntimeException(); }
74 | + static public boolean apply$mcZJ$sp (long v1) { throw new RuntimeException(); }
75 | + static public double apply$mcDJ$sp (long v1) { throw new RuntimeException(); }
76 | + static public float apply$mcFJ$sp (long v1) { throw new RuntimeException(); }
77 | + static public int apply$mcIJ$sp (long v1) { throw new RuntimeException(); }
78 | + static public long apply$mcJJ$sp (long v1) { throw new RuntimeException(); }
79 | + static public void apply$mcVJ$sp (long v1) { throw new RuntimeException(); }
80 | public Object messageId () { throw new RuntimeException(); }
81 | // not preceding
82 | public Identify (Object messageId) { throw new RuntimeException(); }
83 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
84 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
85 | @@ -2,5 +2,6 @@
86 | public interface Inbox {
87 | public interface InboxExtension {
88 | public int DSLInboxQueueSize () ;
89 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
90 | }
91 | }
92 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
93 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
94 | @@ -5,7 +5,9 @@
95 | * Static reference to the singleton instance of this Scala object.
96 | */
97 | public static final JournalPolicies$ MODULE$ = null;
98 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
99 | public JournalPolicies$ () { throw new RuntimeException(); }
100 | }
101 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
102 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
103 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
104 | }
105 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.8.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/Identify.java
51 | +++ target/expected_output/basic/akka/actor/Identify.java
52 | @@ -2,6 +2,30 @@
53 | public final class Identify implements scala.Product, scala.Serializable {
54 | static public akka.actor.Identify apply (Object messageId) { throw new RuntimeException(); }
55 | static public scala.Option unapply (akka.actor.Identify x$0) { throw new RuntimeException(); }
56 | + static public boolean apply$mcZD$sp (double v1) { throw new RuntimeException(); }
57 | + static public double apply$mcDD$sp (double v1) { throw new RuntimeException(); }
58 | + static public float apply$mcFD$sp (double v1) { throw new RuntimeException(); }
59 | + static public int apply$mcID$sp (double v1) { throw new RuntimeException(); }
60 | + static public long apply$mcJD$sp (double v1) { throw new RuntimeException(); }
61 | + static public void apply$mcVD$sp (double v1) { throw new RuntimeException(); }
62 | + static public boolean apply$mcZF$sp (float v1) { throw new RuntimeException(); }
63 | + static public double apply$mcDF$sp (float v1) { throw new RuntimeException(); }
64 | + static public float apply$mcFF$sp (float v1) { throw new RuntimeException(); }
65 | + static public int apply$mcIF$sp (float v1) { throw new RuntimeException(); }
66 | + static public long apply$mcJF$sp (float v1) { throw new RuntimeException(); }
67 | + static public void apply$mcVF$sp (float v1) { throw new RuntimeException(); }
68 | + static public boolean apply$mcZI$sp (int v1) { throw new RuntimeException(); }
69 | + static public double apply$mcDI$sp (int v1) { throw new RuntimeException(); }
70 | + static public float apply$mcFI$sp (int v1) { throw new RuntimeException(); }
71 | + static public int apply$mcII$sp (int v1) { throw new RuntimeException(); }
72 | + static public long apply$mcJI$sp (int v1) { throw new RuntimeException(); }
73 | + static public void apply$mcVI$sp (int v1) { throw new RuntimeException(); }
74 | + static public boolean apply$mcZJ$sp (long v1) { throw new RuntimeException(); }
75 | + static public double apply$mcDJ$sp (long v1) { throw new RuntimeException(); }
76 | + static public float apply$mcFJ$sp (long v1) { throw new RuntimeException(); }
77 | + static public int apply$mcIJ$sp (long v1) { throw new RuntimeException(); }
78 | + static public long apply$mcJJ$sp (long v1) { throw new RuntimeException(); }
79 | + static public void apply$mcVJ$sp (long v1) { throw new RuntimeException(); }
80 | public Object messageId () { throw new RuntimeException(); }
81 | // not preceding
82 | public Identify (Object messageId) { throw new RuntimeException(); }
83 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
84 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
85 | @@ -2,5 +2,6 @@
86 | public interface Inbox {
87 | public interface InboxExtension {
88 | public int DSLInboxQueueSize () ;
89 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
90 | }
91 | }
92 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
93 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
94 | @@ -5,7 +5,9 @@
95 | * Static reference to the singleton instance of this Scala object.
96 | */
97 | public static final JournalPolicies$ MODULE$ = null;
98 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
99 | public JournalPolicies$ () { throw new RuntimeException(); }
100 | }
101 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
102 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
103 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
104 | }
105 |
--------------------------------------------------------------------------------
/src/test/resources/patches/2.12.9.patch:
--------------------------------------------------------------------------------
1 | --- target/expected_output/basic/akka/rk/buh/is/it/A.java
2 | +++ target/expected_output/basic/akka/rk/buh/is/it/A.java
3 | @@ -48,13 +48,13 @@
4 | public class NonStatic {
5 | public NonStatic () { throw new RuntimeException(); }
6 | }
7 | + public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
8 | public D$ () { throw new RuntimeException(); }
9 | /**
10 | * def A.D.math
11 | * @return (undocumented)
12 | */
13 | public long math () { throw new RuntimeException(); }
14 | - public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
15 | }
16 | /**
17 | * class A.B
18 | @@ -103,8 +103,8 @@
19 | * class A.C
20 | */
21 | static public class C1 {
22 | - public C1 () { throw new RuntimeException(); }
23 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
24 | + public C1 () { throw new RuntimeException(); }
25 | }
26 | /**
27 | * object C1
28 | @@ -142,6 +142,11 @@
29 | static public java.lang.String stattic () { throw new RuntimeException(); }
30 | static public java.lang.Object x () { throw new RuntimeException(); }
31 | /**
32 | + * Accessor for nested Scala object
33 | + * @return (undocumented)
34 | + */
35 | + public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
36 | + /**
37 | * varargs
38 | * @param s (undocumented)
39 | * @return (undocumented)
40 | @@ -214,9 +219,4 @@
41 | */
42 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
43 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
44 | - /**
45 | - * Accessor for nested Scala object
46 | - * @return (undocumented)
47 | - */
48 | - public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
49 | }
50 | --- target/expected_output/basic/akka/actor/Identify.java
51 | +++ target/expected_output/basic/akka/actor/Identify.java
52 | @@ -2,6 +2,30 @@
53 | public final class Identify implements scala.Product, scala.Serializable {
54 | static public akka.actor.Identify apply (Object messageId) { throw new RuntimeException(); }
55 | static public scala.Option unapply (akka.actor.Identify x$0) { throw new RuntimeException(); }
56 | + static public boolean apply$mcZD$sp (double v1) { throw new RuntimeException(); }
57 | + static public double apply$mcDD$sp (double v1) { throw new RuntimeException(); }
58 | + static public float apply$mcFD$sp (double v1) { throw new RuntimeException(); }
59 | + static public int apply$mcID$sp (double v1) { throw new RuntimeException(); }
60 | + static public long apply$mcJD$sp (double v1) { throw new RuntimeException(); }
61 | + static public void apply$mcVD$sp (double v1) { throw new RuntimeException(); }
62 | + static public boolean apply$mcZF$sp (float v1) { throw new RuntimeException(); }
63 | + static public double apply$mcDF$sp (float v1) { throw new RuntimeException(); }
64 | + static public float apply$mcFF$sp (float v1) { throw new RuntimeException(); }
65 | + static public int apply$mcIF$sp (float v1) { throw new RuntimeException(); }
66 | + static public long apply$mcJF$sp (float v1) { throw new RuntimeException(); }
67 | + static public void apply$mcVF$sp (float v1) { throw new RuntimeException(); }
68 | + static public boolean apply$mcZI$sp (int v1) { throw new RuntimeException(); }
69 | + static public double apply$mcDI$sp (int v1) { throw new RuntimeException(); }
70 | + static public float apply$mcFI$sp (int v1) { throw new RuntimeException(); }
71 | + static public int apply$mcII$sp (int v1) { throw new RuntimeException(); }
72 | + static public long apply$mcJI$sp (int v1) { throw new RuntimeException(); }
73 | + static public void apply$mcVI$sp (int v1) { throw new RuntimeException(); }
74 | + static public boolean apply$mcZJ$sp (long v1) { throw new RuntimeException(); }
75 | + static public double apply$mcDJ$sp (long v1) { throw new RuntimeException(); }
76 | + static public float apply$mcFJ$sp (long v1) { throw new RuntimeException(); }
77 | + static public int apply$mcIJ$sp (long v1) { throw new RuntimeException(); }
78 | + static public long apply$mcJJ$sp (long v1) { throw new RuntimeException(); }
79 | + static public void apply$mcVJ$sp (long v1) { throw new RuntimeException(); }
80 | public Object messageId () { throw new RuntimeException(); }
81 | // not preceding
82 | public Identify (Object messageId) { throw new RuntimeException(); }
83 | --- target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:52.473679518 +0100
84 | +++ target/expected_output/basic/akka/actor/dsl/Inbox.java 2018-12-13 15:51:51.473673128 +0100
85 | @@ -2,5 +2,6 @@
86 | public interface Inbox {
87 | public interface InboxExtension {
88 | public int DSLInboxQueueSize () ;
89 | + public void akka$actor$dsl$Inbox$InboxExtension$_setter_$DSLInboxQueueSize_$eq (int x$1) ;
90 | }
91 | }
92 | --- target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
93 | +++ target/expected_output/basic/akka/persistence/testkit/EventStorage.java 2020-03-23 16:04:03.313049968 +0100
94 | @@ -5,7 +5,9 @@
95 | * Static reference to the singleton instance of this Scala object.
96 | */
97 | public static final JournalPolicies$ MODULE$ = null;
98 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ PassAll () { throw new RuntimeException(); }
99 | public JournalPolicies$ () { throw new RuntimeException(); }
100 | }
101 | - public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll$ DefaultPolicy () ;
102 | + public void akka$persistence$testkit$EventStorage$_setter_$DefaultPolicy_$eq (akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll x$1) ;
103 | + public akka.persistence.testkit.ProcessingPolicy.DefaultPolicies.PassAll DefaultPolicy () ;
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/scala/com/typesafe/genjavadoc/BasicTransform.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import scala.reflect.internal.Flags
4 | import scala.reflect.internal.util.Position
5 |
6 | trait BasicTransform { this: TransformCake =>
7 | import global._
8 |
9 | private def skippedName(name: String): Boolean = {
10 | val startsWithNumber = "^\\d".r
11 | (this.filteredStrings.exists(s => name.contains(s))
12 | || this.javaKeywords.contains(name)
13 | || startsWithNumber.findFirstIn(name).isDefined
14 | || name.equals("$init$"))
15 | }
16 |
17 | def suppressSynthetic: Boolean
18 |
19 | def newTransformUnit(unit: CompilationUnit): Unit = {
20 | superTransformUnit(unit)
21 | for (c <- flattenObjects(classes.flatMap(liftInnerClassesWithSameName).flatMap(withoutPrivates))) {
22 | val out = file(c.file)
23 | try {
24 | if (c.pckg != "") out.println(s"package ${c.pckg};")
25 | write(out, c)
26 | } finally {
27 | out.close()
28 | }
29 | }
30 | }
31 |
32 | private var visited: List[Tree] = Nil
33 | private var keep = true
34 | private def noKeep(code: => Tree): Tree = {
35 | val old = keep
36 | keep = false
37 | try code finally keep = old
38 | }
39 |
40 | private var pos: Position = Position.offset(unit.source, 0)
41 |
42 | private var templateMaxPos: Position = pos
43 | private var prevTemplateMaxPos: Position = pos
44 |
45 | import positionOrdering._
46 | private def advancePos(p: Position) =
47 | if (p.isDefined && p > templateMaxPos) templateMaxPos = p
48 |
49 | def newTransform(tree: Tree): Tree = {
50 | def commentText(tp: Position, endPos: Option[Position]) = {
51 | val ret = if (tp.isDefined) {
52 | val old = pos
53 | pos = max(tp, prevTemplateMaxPos)
54 | if (old <= pos) {
55 | (positions.from(old.point) intersect positions.to(pos.point)).toSeq.map(comments).filter(Scaladoc).lastOption match {
56 | case Some(c) => c.text // :+ s"// found in '${between(old, pos)}'"
57 | case None =>
58 | // s"// empty '${between(old, pos)}' (${pos.lineContent}:${pos.column})" ::
59 | Nil
60 | }
61 | } else Seq("// not preceding") ++ visited.reverse.map(t => "// " + global.showRaw(t))
62 | } else Seq("// no position")
63 | advancePos(tp)
64 | endPos foreach { p =>
65 | advancePos(p)
66 | pos = max(p, prevTemplateMaxPos)
67 | }
68 | visited = Nil
69 | ret
70 | }
71 |
72 | def track(t: Tree) = {
73 | if (!keep && tree.pos.isDefined) {
74 | visited ::= tree
75 | pos = tree.pos
76 | }
77 | tree
78 | }
79 |
80 | def endPos(t: Tree) = {
81 | val traverser = new CollectTreeTraverser({
82 | case t if t.pos.isDefined => t.pos
83 | })
84 | traverser.traverse(t)
85 | if (traverser.results.isEmpty) None else Some(traverser.results.max)
86 | }
87 |
88 | tree match {
89 | case c: ClassDef if keep =>
90 | withClass(c, commentText(c.pos, None)) {
91 | superTransform(tree)
92 | }
93 | case d: DefDef if keep =>
94 | val text =
95 | if (d.mods.hasModuleFlag) { // accessor for an object
96 | // the accessor occurs out of order; we must not advance the position
97 | Nil
98 | } else {
99 | val (lookat, end) =
100 | if (d.name == nme.CONSTRUCTOR) {
101 | if (clazz.get.constructor) (d.symbol.enclClass.pos, None)
102 | else (d.pos, endPos(d.rhs))
103 | } else (d.pos, endPos(d.rhs))
104 | // must be called for keeping the “current” position right
105 | commentText(lookat, end)
106 | }
107 | val name = d.name.toString
108 | if (!skippedName(name)) {
109 | if (d.mods.hasFlag(Flags.VARARGS)) addVarargsMethod(d, text)
110 | else if (!(suppressSynthetic && (d.mods.isSynthetic || d.name == nme.MIXIN_CONSTRUCTOR || name.contains('$'))))
111 | addMethod(d, text)
112 | }
113 | tree
114 | case _: ValDef => { track(tree) }
115 | case _: PackageDef => { track(tree); superTransform(tree) }
116 | case _: Template => { track(tree); superTransform(tree) }
117 | case _: TypeTree => { track(tree) }
118 | case _ => { track(tree); noKeep(superTransform(tree)) }
119 | }
120 | }
121 |
122 | // list of top-level classes in this unit
123 | private var classes = Vector.empty[ClassInfo]
124 |
125 | // the current class, any level
126 | private var clazz: Option[ClassInfo] = None
127 |
128 | private def withClass(c: ImplDef, comment: Seq[String])(block: => Tree): Tree = {
129 | val deprecation = deprecationInfo(c)
130 | val commentWithDeprecation = deprecation match {
131 | case Some(deprec) => deprec.appendToComment(comment)
132 | case _ => comment
133 | }
134 |
135 | val old = clazz
136 | clazz = Some(ClassInfo(c, commentWithDeprecation, old.isEmpty))
137 | val ret = block
138 | clazz =
139 | old match {
140 | case None =>
141 | classes :+= clazz.get
142 | None
143 | case Some(oc) =>
144 | Some(oc.addMember(clazz.get))
145 | }
146 | pos = templateMaxPos
147 | prevTemplateMaxPos = templateMaxPos
148 | ret
149 | }
150 |
151 | private def addMethod(d: DefDef, comment: Seq[String]): Unit = {
152 | clazz = clazz map (c => c.addMember(MethodInfo(d, c.interface, comment, hasVararg = false, deprecation = deprecationInfo(d))))
153 | }
154 |
155 | private def addVarargsMethod(d: DefDef, comment: Seq[String]): Unit = {
156 | clazz = clazz map (c => c.addMember(MethodInfo(d, c.interface, comment, hasVararg = true, deprecation = deprecationInfo(d))))
157 | }
158 |
159 | private def deprecationInfo(d: DefDef): Option[DeprecationInfo] = deprecationInfo(d.symbol)
160 | private def deprecationInfo(d: ImplDef): Option[DeprecationInfo] = deprecationInfo(d.symbol)
161 | private def deprecationInfo(symbol: Symbol): Option[DeprecationInfo] =
162 | if (symbol.isDeprecated) {
163 | // symbol either has `DeprecatedAttr` or `JavaDeprecatedAttr`
164 | val deprec = symbol.getAnnotation(definitions.DeprecatedAttr)
165 | Some(DeprecationInfo(deprec.flatMap(_.stringArg(0)).getOrElse(""), deprec.flatMap(_.stringArg(1)).getOrElse("")))
166 | } else None
167 |
168 | }
169 |
--------------------------------------------------------------------------------
/src/test/scala/com/typesafe/genjavadoc/SignatureSpec.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import java.net.URLClassLoader
4 | import java.lang.reflect.Modifier
5 |
6 | import org.junit.Test
7 | import org.junit.Assert._
8 |
9 | import util._
10 |
11 | object SignatureSpec {
12 | // this should match up against the definition in GenJavadocPlugin
13 | val javaKeywords = Set("abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue",
14 | "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if",
15 | "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private",
16 | "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this",
17 | "throw", "throws", "transient", "try", "void", "volatile", "while")
18 |
19 | val defaultFilteredStrings = Set(
20 | // this should match up against the definition in GenJavadocPlugin
21 | // with the addition of "$lzycompute", which is special
22 | "$$", "$lzycompute",
23 | // see https://github.com/lightbend/genjavadoc/issues/143
24 | "productElementName",
25 | // because of https://github.com/scala/scala/pull/10002
26 | "productIterator"
27 | )
28 |
29 | // they can't start with numbers either
30 | val startsWithNumber = "^\\d".r
31 |
32 | val expectedClasses = Seq(
33 | "AtTheRoot",
34 | "akka.Main",
35 | "akka.rk.buh.is.it.A",
36 | "akka.rk.buh.is.it.A$",
37 | "akka.rk.buh.is.it.Blarb",
38 | "akka.rk.buh.is.it.Blarb$",
39 | "akka.rk.buh.is.it.X",
40 | "akka.rk.buh.is.it.Y",
41 | "akka.rk.buh.is.it.Z",
42 | "akka.rk.buh.is.it.PPrivate",
43 | "akka.rk.buh.is.it.PPrivate$",
44 | "akka.rk.buh.is.it.Private",
45 | "akka.rk.buh.is.it.Private$",
46 | "akka.rk.buh.is.it.PProtected",
47 | "akka.rk.buh.is.it.PProtected$",
48 | "akka.rk.buh.is.it.PTrait",
49 | "akka.rk.buh.is.it.AnAbstractTypeRef"
50 | )
51 |
52 | }
53 |
54 | class SignatureSpec {
55 |
56 | import SignatureSpec._
57 |
58 | @Test def `the generated java files contain the same methods and classes as the original Scala files`(): Unit = {
59 | val doc = IO.tempDir("java")
60 | val docPath = doc.getAbsolutePath
61 |
62 | val scalac = new GenJavadocCompiler(Seq(
63 | s"genjavadoc:out=$docPath",
64 | "genjavadoc:suppressSynthetic=false"
65 | ))
66 |
67 | val javaSources = expectedClasses.map{cls =>
68 | docPath + "/" + cls.replace(".", "/") + ".java"
69 | }
70 | val javac = new JavaCompiler
71 |
72 | scalac.compile(BasicSpec.sources)
73 | javac.compile(javaSources)
74 |
75 | val scalaCL = new URLClassLoader(Array(scalac.target.getAbsoluteFile.toURI.toURL), classOf[List[_]].getClassLoader)
76 | val javaCL = new URLClassLoader(Array(javac.target.getAbsoluteFile.toURI.toURL), classOf[List[_]].getClassLoader)
77 |
78 | val accProtLvl = Map(1 -> 1, 2 -> 3, 4 -> 2)
79 |
80 | /*
81 | * This translation is necessary for the evil hack that allows things
82 | * nested in nested objects to be accepted by Javadoc: while the emitted
83 | * Java code compiles, the name mangling of javac and scalac differs for
84 | * such nestings, which means that it is impossible to express the Scalac
85 | * generated byte-code in valid Java source. To make things compile
86 | * nonetheless we just accept that the types here are nonsense, but they
87 | * are not usable from Java anyway.
88 | */
89 | val exception = "(akka.rk.buh.is.it.A\\$[C1D]+\\$)\\$"
90 | val replacement = "$1"
91 |
92 | def check(jn: String): Unit = {
93 | val jc: Class[_] = javaCL.loadClass(jn)
94 | val sc: Class[_] = scalaCL.loadClass(jn.replaceAll(exception, replacement))
95 |
96 | def matchJava(s: Set[String], j: Set[String]) = {
97 | val msg = s"Scala: \n" +
98 | s" ${s.mkString("\n ")} \n" +
99 | s"did not match Java: \n" +
100 | s" ${j.mkString("\n ")}\n" +
101 | s"(in $jc)"
102 | assertEquals(msg, s, j)
103 | }
104 |
105 | val jm = getMethods(jc)
106 | val sm = getMethods(sc).filter(!_.startsWith("private"))
107 | printIfNotEmpty(sm -- jm, "missing methods:")
108 | printIfNotEmpty(jm -- sm, "extraneous methods:")
109 | matchJava(sm, jm)
110 |
111 | // akka.rk.buh.is.it.A$C1$C1$ is a special case, generated because Java
112 | // doesn't allow an inner class with the same name as its enclosing
113 | // class, so we exclude it here:
114 | val jsub = getClasses(jc, filter = false) - "akka.rk.buh.is.it.A$C1$C1$"
115 | val ssub = getClasses(sc, filter = true) - "akka.rk.buh.is.it.A$C1$C1$" - "akka.rk.buh.is.it.A$NoComment$" // private class is not converted
116 | printIfNotEmpty(ssub.keySet -- jsub.keySet, "missing classes:")
117 | printIfNotEmpty(jsub.keySet -- ssub.keySet, "extraneous classes:")
118 | matchJava(ssub.keySet, jsub.keySet)
119 |
120 | for (n <- ssub.keys) {
121 | val js = jsub(n)
122 | val ss = ssub(n)
123 |
124 | def beEqual[T](u: T, t: T) = assertEquals(s"$u was not equal $t (in $n)", t, u)
125 | def beAtLeast(u: Int, t: Int) = assertTrue(s"$u was < $t (in $n)", u >= t)
126 |
127 | beEqual(js.getModifiers & ~15, ss.getModifiers & ~15)
128 | beAtLeast(ss.getModifiers & 8, js.getModifiers & 8) // older Scala versions (2.10) were more STATIC ...
129 | beAtLeast(accProtLvl(js.getModifiers & 7), accProtLvl(ss.getModifiers & 7))
130 | beEqual(js.getInterfaces.toList.map(_.getName), ss.getInterfaces.toList.map(_.getName))
131 | beEqual(js.isInterface, ss.isInterface)
132 | if (!js.isInterface())
133 | beEqual(js.getSuperclass.getName, ss.getSuperclass.getName)
134 | check(js.getName)
135 | }
136 | }
137 |
138 | def printIfNotEmpty(s: Set[String], msg: String): Unit = if (s.nonEmpty) {
139 | println(msg)
140 | s.toList.sorted foreach println
141 | }
142 |
143 | def getMethods(c: Class[_]): Set[String] = {
144 | c.getDeclaredMethods.filterNot(x =>
145 | defaultFilteredStrings.exists(s => x.getName.contains(s))
146 | || javaKeywords.contains(x.getName)
147 | || x.getName == "$init$" // These synthetic methods show up in 2.12.0-M4+ even though they are not in the generated Java sources
148 | || Modifier.isStatic(x.getModifiers) && x.getName.endsWith("$") // These synthetic static methods appear since 2.12.0-M5+ as companions to default methods
149 | || startsWithNumber.findFirstIn(x.getName).isDefined)
150 | .map(_.toGenericString)
151 | .map(_.replace("default ", "abstract ")) // Scala 2.12.0-M4+ creates default methods for trait method implementations. We treat them as abstract for now.
152 | .map(_.replaceAll(exception, replacement))
153 | .toSet
154 | }
155 |
156 | def getClasses(c: Class[_], filter: Boolean): Map[String, Class[_]] = {
157 | c.getDeclaredClasses.collect {
158 | case x if (!filter || !(x.getName contains "anon")) => x.getName.replaceAll(exception, replacement) -> x
159 | }.toMap
160 | }
161 |
162 |
163 | for (className <- expectedClasses) {
164 | check(className)
165 | }
166 | }
167 |
168 | }
169 |
--------------------------------------------------------------------------------
/src/test/resources/expected_output/basic/akka/rk/buh/is/it/A.java:
--------------------------------------------------------------------------------
1 | package akka.rk.buh.is.it;
2 | /**
3 | * class A
4 | *
5 | * with a second paragraph
6 | *
7 | * and a third one with
8 | * a break in some code.
9 | *
10 | * Some problematic things: & > =>
11 | *
12 | *
13 | *
14 | *
15 | * and some code<with angle brackets>
16 | *
17 | *
18 | * and an illegal tag:
19 | * param: x buh
20 | *
21 | * @see Blarb
22 | * @see
23 | * @see
24 | */
25 | public class A {
26 | /**
27 | * class A.D
28 | */
29 | public class D extends akka.rk.buh.is.it.A.B {
30 | /** val i */
31 | public int i () { throw new RuntimeException(); }
32 | // not preceding
33 | public D () { throw new RuntimeException(); }
34 | }
35 | /**
36 | * object A.D
37 | */
38 | public class D$ implements scala.Serializable {
39 | /**
40 | * And a nested object.
41 | */
42 | public class E$ {
43 | public E$ () { throw new RuntimeException(); }
44 | }
45 | /**
46 | * A nested non-static class.
47 | */
48 | public class NonStatic {
49 | public NonStatic () { throw new RuntimeException(); }
50 | }
51 | public D$ () { throw new RuntimeException(); }
52 | /**
53 | * def A.D.math
54 | * @return (undocumented)
55 | */
56 | public long math () { throw new RuntimeException(); }
57 | public akka.rk.buh.is.it.A.D$.E$ E () { throw new RuntimeException(); }
58 | }
59 | /**
60 | * class A.B
61 | */
62 | public class B implements akka.rk.buh.is.it.X {
63 | // not preceding
64 | public B () { throw new RuntimeException(); }
65 | /**
66 | * secondary constructor
67 | * @param stest (undocumented)
68 | */
69 | public B (java.lang.String stest) { throw new RuntimeException(); }
70 | /**
71 | * def b(args: java.lang.String*): Unit
72 | * @param args (undocumented)
73 | */
74 | public void b (java.lang.String... args) { throw new RuntimeException(); }
75 | /**
76 | * def b(args: java.lang.String*): Unit
77 | * @param args (undocumented)
78 | */
79 | public void b (scala.collection.Seq args) { throw new RuntimeException(); }
80 | public java.lang.String d (java.lang.String a, akka.rk.buh.is.it.X b) { throw new RuntimeException(); }
81 | }
82 | public class C implements akka.rk.buh.is.it.X {
83 | // not preceding
84 | public C () { throw new RuntimeException(); }
85 | public int i () { throw new RuntimeException(); }
86 | }
87 | /** tailrecced */
88 | public final class TR {
89 | public TR () { throw new RuntimeException(); }
90 | public void tr (java.lang.String r) { throw new RuntimeException(); }
91 | }
92 | /**
93 | * object A.C.C1
94 | */
95 | static public class C1$C1$ {
96 | /**
97 | * Static reference to the singleton instance of this Scala object.
98 | */
99 | public static final C1$C1$ MODULE$ = null;
100 | public C1$C1$ () { throw new RuntimeException(); }
101 | }
102 | /**
103 | * class A.C
104 | */
105 | static public class C1 {
106 | public C1 () { throw new RuntimeException(); }
107 | public akka.rk.buh.is.it.A.C1$C1$ C1 () { throw new RuntimeException(); }
108 | }
109 | /**
110 | * object C1
111 | */
112 | static public class C1$ {
113 | /**
114 | * And another nested object.
115 | */
116 | static public class EE$ {
117 | /**
118 | * Static reference to the singleton instance of this Scala object.
119 | */
120 | public static final EE$ MODULE$ = null;
121 | public EE$ () { throw new RuntimeException(); }
122 | }
123 | /**
124 | * Static reference to the singleton instance of this Scala object.
125 | */
126 | public static final C1$ MODULE$ = null;
127 | public C1$ () { throw new RuntimeException(); }
128 | /**
129 | * A.C1.method
130 | */
131 | public void method () { throw new RuntimeException(); }
132 | }
133 | /**
134 | * def IAmStatic: Int
135 | * @return (undocumented)
136 | */
137 | static public int IAmStatic () { throw new RuntimeException(); }
138 | /**
139 | * val stattic: java.lang.String
140 | * @return (undocumented)
141 | */
142 | static public java.lang.String stattic () { throw new RuntimeException(); }
143 | static public java.lang.Object x () { throw new RuntimeException(); }
144 | /**
145 | * varargs
146 | * @param s (undocumented)
147 | * @return (undocumented)
148 | */
149 | public int hello (java.lang.String... s) { throw new RuntimeException(); }
150 | // not preceding
151 | public A () { throw new RuntimeException(); }
152 | /**
153 | * def p(x: Array[Int]): Predef.type
154 | *
155 | * @param x an Array
156 | * @return (undocumented)
157 | */
158 | public scala.Predef$ p (int[] x) { throw new RuntimeException(); }
159 | /**
160 | * def params[T <: B](b: T): T
161 | * @param b (undocumented)
162 | * @return (undocumented)
163 | */
164 | public scala.collection.immutable.List params (T b) { throw new RuntimeException(); }
165 | /**
166 | * def map
167 | * @return (undocumented)
168 | */
169 | public scala.collection.immutable.Map map () { throw new RuntimeException(); }
170 | /**
171 | * scala.Nothing should be converted to scala.runtime.Nothing$.
172 | * @param msg (undocumented)
173 | * @return (undocumented)
174 | */
175 | public scala.runtime.Nothing$ nothing (java.lang.String msg) { throw new RuntimeException(); }
176 | /**
177 | * Unitparam
178 | * @param unit (undocumented)
179 | * @return (undocumented)
180 | */
181 | public int unitParam (scala.runtime.BoxedUnit unit) { throw new RuntimeException(); }
182 | /**
183 | * mangledNames
184 | * @param default_ (undocumented)
185 | * @param goto_ (undocumented)
186 | * @param interface_ (undocumented)
187 | * @return (undocumented)
188 | */
189 | public int mangledNames (java.lang.String default_, java.lang.String goto_, java.lang.String interface_) { throw new RuntimeException(); }
190 | /**
191 | * blarb
192 | * @return (undocumented)
193 | */
194 | public akka.rk.buh.is.it.Blarb.Fuz blarb () { throw new RuntimeException(); }
195 | /**
196 | * refined
197 | * @return (undocumented)
198 | */
199 | public akka.rk.buh.is.it.Z refined () { throw new RuntimeException(); }
200 | /**
201 | * poly
202 | * @return (undocumented)
203 | */
204 | public > int poly () { throw new RuntimeException(); }
205 | /**
206 | * varargs
207 | * @param s (undocumented)
208 | * @return (undocumented)
209 | */
210 | public int hello (scala.collection.Seq s) { throw new RuntimeException(); }
211 | /**
212 | * throws
213 | * @return (undocumented)
214 | */
215 | public int testthrows () throws java.lang.IllegalArgumentException, java.lang.NullPointerException { throw new RuntimeException(); }
216 | public scala.runtime.Null$ getNull () { throw new RuntimeException(); }
217 | /**
218 | * Accessor for nested Scala object
219 | * @return (undocumented)
220 | */
221 | public akka.rk.buh.is.it.A.D$ D () { throw new RuntimeException(); }
222 | }
223 |
--------------------------------------------------------------------------------
/src/main/scala/com/typesafe/genjavadoc/JavaSig.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import scala.reflect.internal.ClassfileConstants
4 |
5 | trait JavaSig extends NeedsJavaSig { this: TransformCake =>
6 | import global._
7 | import definitions._
8 |
9 | def js(sym0: Symbol, info: Type, voidOK: Boolean = true, debug: Boolean = false): String = {
10 | val isTraitSignature = sym0.enclClass.isTrait
11 |
12 | def removeThis(in: Type): Type = {
13 | // println("transforming " + in)
14 | in match {
15 | case ThisType(parent) if !parent.hasPackageFlag => removeThis(parent.tpe)
16 | case SingleType(parent, name) => typeRef(removeThis(parent), name, Nil)
17 | case TypeRef(pre, sym, args) => typeRef(removeThis(pre), sym, args)
18 | case x => x
19 | }
20 | }
21 |
22 | def superSig(parents: List[Type]) = {
23 | val ps = (
24 | if (isTraitSignature) {
25 | // java is unthrilled about seeing interfaces inherit from classes
26 | val ok = parents filter (p => p.typeSymbol.isTrait || p.typeSymbol.isInterface)
27 | // traits should always list Object.
28 | if (ok.isEmpty || ok.head.typeSymbol != ObjectClass) ObjectClass.tpe :: ok
29 | else ok
30 | } else parents)
31 | (ps map boxedSig).mkString
32 | }
33 | def boxedSig(tp: Type) = tp match {
34 | case PolyType(tparams, restpe) => jsig(restpe, primitiveOK = false)
35 | case _ => jsig(tp, primitiveOK = false)
36 | }
37 | def boundsSig(bounds: List[Type]) = {
38 | bounds.headOption map (" extends " + boxedSig(_)) getOrElse ""
39 | }
40 | def paramSig(tsym: Symbol) = tsym.name.toString + boundsSig(hiBounds(tsym.info.bounds))
41 | def polyParamSig(tparams: List[Symbol]) = (
42 | if (tparams.isEmpty) ""
43 | else tparams map paramSig mkString ("<", ", ", ">"))
44 |
45 | // Anything which could conceivably be a module (i.e. isn't known to be
46 | // a type parameter or similar) must go through here or the signature is
47 | // likely to end up with Foo.Empty where it needs Foo.Empty$.
48 | /*
49 | * Unfortunately sym.fullName is not accurate wrt. the location of objects
50 | * in non-static scopes, hence we need to manually traverse the parent list
51 | * and apply the moduleSuffix in these cases.
52 | */
53 | def fullNameInSig(sym: Symbol): String = {
54 | var staticScope = true
55 | def rec(s: Symbol, innermost: Boolean): String =
56 | if (s.isPackageClass) s.fullName
57 | else {
58 | val parent = rec(s.effectiveOwner.enclClass, false)
59 | staticScope &&= s.needsModuleSuffix
60 |
61 | val infix =
62 | if (s.effectiveOwner.enclClass.name == s.name) "$"
63 | else "."
64 | if (innermost || !staticScope) parent + infix + s.name + s.moduleSuffix
65 | else parent + infix + s.name
66 | }
67 | rec(sym, true)
68 | }
69 |
70 | def jsig(tp0: Type, existentiallyBound: List[Symbol] = Nil, toplevel: Boolean = false, primitiveOK: Boolean = true): String = {
71 | val tp = tp0.dealias
72 | if (debug) println(s"JSIG: $tp")
73 | tp match {
74 | case st: SubType =>
75 | jsig(st.supertype, existentiallyBound, toplevel, primitiveOK)
76 | case ExistentialType(tparams, tpe) =>
77 | jsig(tpe, tparams, toplevel, primitiveOK)
78 | case TypeRef(pre, sym, args) =>
79 | def argSig(tp: Type) =
80 | if (existentiallyBound contains tp.typeSymbol) {
81 | val bounds = tp.typeSymbol.info.bounds
82 | if (!(AnyRefClass.tpe <:< bounds.hi)) "? extends " + boxedSig(bounds.hi)
83 | else if (!(bounds.lo <:< NullClass.tpe)) "? super " + boxedSig(bounds.lo)
84 | else "?"
85 | } else {
86 | boxedSig(tp)
87 | }
88 |
89 | // If args isEmpty, Array is being used as a type constructor
90 | if (sym == ArrayClass && args.nonEmpty) {
91 | if (unboundedGenericArrayLevel(tp) == 1) jsig(ObjectClass.tpe)
92 | else (args map (jsig(_))).mkString + "[]"
93 | } else if (isTypeParameterInSig(sym, sym0)) {
94 | assert(!sym.isAliasType, "Unexpected alias type: " + sym)
95 | sym.name.toString
96 | } else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass)
97 | jsig(ObjectClass.tpe)
98 | else if (sym == UnitClass)
99 | jsig(BoxedUnitClass.tpe)
100 | else if (sym == NothingClass)
101 | jsig(RuntimeNothingClass.tpe)
102 | else if (sym == NullClass)
103 | jsig(RuntimeNullClass.tpe)
104 | else if (isPrimitiveValueClass(sym)) {
105 | if (!primitiveOK) jsig(ObjectClass.tpe)
106 | else if (sym == UnitClass) jsig(BoxedUnitClass.tpe)
107 | else toJava(tp)
108 | } else if (sym.isClass || sym.isModule) {
109 | val preRebound = pre.baseType(sym.owner) // #2585
110 | val name =
111 | if (needsJavaSig(preRebound)) {
112 | val s = jsig(preRebound, existentiallyBound)
113 | s + "." + sym.javaSimpleName
114 | } else fullNameInSig(sym)
115 | val generics =
116 | if (args.isEmpty) "" else
117 | "<" + (args map argSig).mkString(", ") + ">"
118 | name + generics
119 | } else jsig(erasure.erasure(sym0)(tp), existentiallyBound, toplevel, primitiveOK)
120 | case PolyType(tparams, restpe) =>
121 | assert(tparams.nonEmpty, s"expected non-empty type parameters in $tp")
122 | if (toplevel) polyParamSig(tparams) else ""
123 |
124 | case MethodType(params, restpe) =>
125 | "(" + (params map (_.tpe) map (jsig(_))).mkString + ")" +
126 | (if (restpe.typeSymbol == UnitClass || sym0.isConstructor) ClassfileConstants.VOID_TAG.toString else jsig(restpe))
127 |
128 | case RefinedType(parent :: _, decls) =>
129 | boxedSig(parent)
130 | case ClassInfoType(parents, _, _) =>
131 | superSig(parents)
132 | case at: AnnotatedType =>
133 | jsig(at.underlying, existentiallyBound, toplevel, primitiveOK)
134 | case BoundedWildcardType(bounds) =>
135 | println("something's wrong: " + sym0 + ":" + sym0.tpe + " has a bounded wildcard type")
136 | jsig(bounds.hi, existentiallyBound, toplevel, primitiveOK)
137 | case _ =>
138 | val etp = erasure.erasure(sym0)(tp)
139 | if (etp eq tp) throw new UnknownSig
140 | else jsig(etp)
141 | }
142 | }
143 | def toJava(info0: Type): String = {
144 | if (debug) println(s"JSIG toJava: $info0")
145 | val info = info0.dealiasWiden
146 | info.typeSymbol match {
147 | case UnitClass => if (voidOK) "void" else "scala.runtime.BoxedUnit"
148 | case NothingClass => "scala.runtime.Nothing$"
149 | case BooleanClass => "boolean"
150 | case ByteClass => "byte"
151 | case ShortClass => "short"
152 | case CharClass => "char"
153 | case IntClass => "int"
154 | case LongClass => "long"
155 | case FloatClass => "float"
156 | case DoubleClass => "double"
157 | case ArrayClass => jsig(info)
158 | case AnyClass => "Object"
159 | case _ =>
160 | info match {
161 | case r @ RefinedType(head :: tail, _) =>
162 | fullNameInSig(head.typeSymbol)
163 | case TypeRef(pre, sym, _) if sym.isAbstractType =>
164 | fullNameInSig(pre.typeSymbol)
165 | case TypeRef(pre, sym, _) if sym.isValueParameter =>
166 | fullNameInSig(info0.memberType(sym).typeSymbol)
167 | case _ =>
168 | fullNameInSig(info0.typeSymbol)
169 | }
170 | }
171 | }
172 | val _info = removeThis(info)
173 | if (debug) println(s"JSIG entry: ${_info}")
174 | val result =
175 | if (needsJavaSig(info)) {
176 | try jsig(_info, toplevel = true)
177 | catch { case ex: UnknownSig => toJava(_info) }
178 | } else toJava(_info)
179 | if (result == "scala.Null") "scala.runtime.Null$"
180 | else if (result == "scala.Nothing") "scala.runtime.Nothing$"
181 | else result
182 | }
183 |
184 | private def hiBounds(bounds: TypeBounds): List[Type] = bounds.hi.normalize match {
185 | case RefinedType(parents, _) => parents map (_.normalize)
186 | case tp => tp :: Nil
187 | }
188 |
189 | import erasure.GenericArray
190 |
191 | private def unboundedGenericArrayLevel(tp: Type): Int = tp match {
192 | case GenericArray(level, core) if !(core <:< AnyRefClass.tpe) => level
193 | case _ => 0
194 | }
195 |
196 | private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol) = (
197 | !sym.isHigherOrderTypeParameter &&
198 | sym.isTypeParameterOrSkolem && (
199 | (initialSymbol.enclClassChain.exists(sym isNestedIn _)) ||
200 | (initialSymbol.isMethod && initialSymbol.typeParams.contains(sym))))
201 |
202 | class UnknownSig extends Exception
203 |
204 | }
205 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This project’s goal is the creation of real Javadoc for Scala projects. While Scaladoc—the native API documentation format of Scala—has several benefits over Javadoc, Java programmers are very much used to having access to API documentation in a syntax matching their programming language of choice. Another motivating factor may be that javadoc-JARs are supported within IDE, e.g. showing tooltip help texts.
2 |
3 | ## How to Use It
4 |
5 | GenJavadoc is a Scala compiler plugin which emits structurally equivalent Java code for all Scala sources of a project, keeping the Scaladoc comments (with a few format adaptions). Integration into an SBT build is quite simple:
6 |
7 | ~~~ scala
8 | lazy val Javadoc = config("genjavadoc") extend Compile
9 |
10 | lazy val javadocSettings = inConfig(Javadoc)(Defaults.configSettings) ++ Seq(
11 | addCompilerPlugin("com.typesafe.genjavadoc" %% "genjavadoc-plugin" % "0.18" cross CrossVersion.full),
12 | scalacOptions += s"-P:genjavadoc:out=${target.value}/java",
13 | Compile / packageDoc := (Javadoc / packageDoc).value,
14 | Javadoc / sources :=
15 | (target.value / "java" ** "*.java").get ++
16 | (Compile / sources).value.filter(_.getName.endsWith(".java")),
17 | Javadoc / javacOptions := Seq(),
18 | Javadoc / packageDoc / artifactName := ((sv, mod, art) =>
19 | "" + mod.name + "_" + sv.binary + "-" + mod.revision + "-javadoc.jar")
20 | )
21 | ~~~
22 |
23 | To make it work, you must add the config and the settings to your
24 | project. One way to do this is to place the following line in your
25 | `build.sbt` file:
26 |
27 | ~~~ scala
28 | lazy val root = project.in(file(".")).configs(Javadoc).settings(javadocSettings: _*)
29 | ~~~
30 |
31 | Adding `javadocSettings` to a `Project` this way will replace the
32 | packaging of the API docs to use the Javadoc instead of the Scaladoc
33 | (i.e. the `XY-javadoc.jar` will then contain Javadoc). The Scaladoc
34 | can still be generated using the normal `doc` task, whereas the
35 | Javadoc can now be generated using `genjavadoc:doc`.
36 |
37 | GenJavadoc can also be integrated into a Maven build (inspired by [this answer on StackOverflow](http://stackoverflow.com/questions/12301620/how-to-generate-an-aggregated-scaladoc-for-a-maven-site/16288487#16288487)):
38 |
39 | ~~~ xml
40 |
41 | javadoc
42 |
43 |
44 |
45 | net.alchim31.maven
46 | scala-maven-plugin
47 |
48 |
49 | doc
50 | generate-sources
51 |
52 | compile
53 |
54 |
55 |
56 |
57 |
58 | -P:genjavadoc:out=${project.build.directory}/genjavadoc
59 |
60 |
61 |
62 | com.typesafe.genjavadoc
63 | genjavadoc-plugin_${scala.binary.full.version}
64 | 0.11
65 |
66 |
67 |
68 |
69 |
70 | org.codehaus.mojo
71 | build-helper-maven-plugin
72 |
73 |
74 | generate-sources
75 |
76 | add-source
77 |
78 |
79 |
80 | ${project.build.directory}/genjavadoc
81 |
82 |
83 |
84 |
85 |
86 |
87 | org.apache.maven.plugins
88 | maven-javadoc-plugin
89 | 2.9
90 |
91 | 64m
92 | 2g
93 | ${project.build.directory}
94 | true
95 |
96 |
97 |
98 |
99 |
100 | ~~~
101 |
102 | You can integrate genjavadoc with gradle build:
103 |
104 | ~~~ groovy
105 | apply plugin: 'scala'
106 |
107 | configurations {
108 | scalaCompilerPlugin
109 | }
110 |
111 | dependencies {
112 | // ...
113 | scalaCompilerPlugin "com.typesafe.genjavadoc:genjavadoc-plugin_${scalaFullVersion}:0.13"
114 |
115 | }
116 |
117 | tasks.withType(ScalaCompile) {
118 | scalaCompileOptions.with {
119 | additionalParameters = [
120 | "-Xplugin:" + configurations.scalaCompilerPlugin.asPath,
121 | "-P:genjavadoc:out=$buildDir/generated/java".toString()
122 | ]
123 | }
124 | }
125 |
126 | tasks.withType(Javadoc) {
127 | dependsOn("compileScala")
128 | source = [sourceSets.main.allJava, "$buildDir/generated/java"]
129 | }
130 | ~~~
131 |
132 | ### Translation of Scaladoc comments
133 |
134 | Comments found within the Scala sources are transferred to the corresponding Java sources including some modifications. These are necessary since Scaladoc supports different mark-up elements than Javadoc. The modifications are:
135 |
136 | * `{{{ ... }}}` is translated to ` ... `, where within the pre-formatted text the following are represented by their HTML entities: `@`, `<`, `>`
137 | * typographic quotes (double as well as single) are translated to `”` and friends
138 | * `@see [[ ... ]]` is translated to `@see ...`, but only if on a line on its own
139 | * `[[ ... ]]` is translated to `{@link ... }`
140 | * `` tokens are placed between paragraphs, collapsing empty lines beforehand
141 | * words between backticks are placed between ` ... ` instead
142 |
143 | ### Additional transformations
144 |
145 | Some additional transformations are applied in order to make the generated Javadoc more useful:
146 |
147 | * if a Scala method or class was marked `@scala.annotation.deprecated` an equivalent Javadoc `@deprecated` comment line will be inserted to the resulting Javadoc comment.
148 |
149 | ## How it Works
150 |
151 | Scaladoc generation is done by a special variant of the Scala compiler, which can in principle emit different output, but the syntax parsed by the Scaladoc code is the Scala one: the compiler phases which adapt the AST to be more Java-like (to emit JVM byte-code in the end) are not run. On the other hand source comments cannot easily be associated with method signatures parsed from class files, and generating corresponding Java code to be fed into the `javadoc` tool is also no small task.
152 |
153 | The approach taken here is to use the Scala compiler’s support as far as possible and then generate mostly valid Java code corresponding to the AST—but only the class and method structur without implementations. Since the Javadoc shall contain generic type information, and shall also not be confused by artifacts of Scala’s encoding of traits and other things, the AST must be inspected before the “erasure” phase; due to Java’s flat method parameter lists the other bound on where to hook into the transformation is that it should be after the “uncurry” phase (which transforms `def f(x: Int)(s: String)` into `def f(x: int, s: String)`). Luckily there is a gap between those two phases which is just wide enough to squeeze some code in.
154 |
155 | One drawback of this choice is that the flattening of classes and companion objects or the mixing-in of method implementations from traits into derived classes happens much later in the transformation pipeline, meaning that the compiler plugin has to do that transformation itself; for this it has the advantage that it does not need to be 100% Scala-correct since the goal is just to document method signatures, not to implement all the intricacies of access widening and so on.
156 |
157 | ## Known Limitations
158 |
159 | * Many Scaladoc tags and features are simply not supported by the javadoc tool and genjavadoc does not reimplement them:
160 |
161 | * `@note`, `@example`, `@group` etc. do not work and are errors in Javadoc 8, so they cannot be used
162 | * links to methods that use the overload disambiguation syntax will not work
163 |
164 | * Classes and objects nested inside nested objects are emitted by Scalac in such a form that there is no valid Java syntax to produce the same binary names. This is due to differences in name mangling (where javac inserts more dollar signs than scalac does). This means that while Javadoc is generated for these (in order to guarantee that Javadoc will find all the types it needs) the precise names are neither correct nor usable in practice.
165 |
166 | * The Java code produced by genjavadoc is 'just correct enough' to be understood by javadoc. It is not a goal of this project to emit correct Java code. On recent version of the JDK you will have to pass the `--ignore-source-errors` flag to make the javadoc tool accept our output.
167 |
168 | ## Reporting Bugs
169 |
170 | If you find errors in the generation process or have suggestions on how to improve the quality of the emitted Javadoc, please report issues on this GitHub repo’s issue tracker.
171 |
172 | ### Sponsored by Lightbend
173 |
174 | Originally responsible: Dr. Roland Kuhn ([@rkuhn](https://github.com/rkuhn))
175 |
176 | Community maintenance is overseen by Lightbend staff.
177 |
178 | Pull requests are very welcome. Thanks in advance!
179 |
--------------------------------------------------------------------------------
/src/main/scala/com/typesafe/genjavadoc/Output.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import java.io.PrintStream
4 | import java.io.File
5 |
6 | trait Output { this: TransformCake =>
7 |
8 | private val Tparam = "(.*@tparam )(\\S+)( .*)".r
9 |
10 | def outputBase: File
11 |
12 | def write(out: Out, c: ClassInfo): Unit = {
13 | // TODO @param should be transformed to constructor comments
14 | c.comment foreach {line =>
15 | val replaced = line.replace("@param", "param: ") match {
16 | case Tparam(_, param, desc) =>
17 | s" * @param <$param> $desc"
18 | case x => x
19 | }
20 | out(replaced)
21 | }
22 | out(s"${c.sig} {")
23 | out.indent()
24 | for (m <- c.members)
25 | m match {
26 | case clazz: ClassInfo => write(out, clazz)
27 | case method: MethodInfo => write(out, method)
28 | }
29 | out.outdent()
30 | out("}")
31 | }
32 |
33 | def write(out: Out, m: MethodInfo): Unit = {
34 | m.comment foreach (out(_))
35 | out(m.sig)
36 | }
37 |
38 | trait Out {
39 | var ind = 0
40 |
41 | def println(s: String): Unit
42 | def apply(s: String): Unit = { println(" " * ind + s) }
43 | def indent(): Unit = { ind += 2 }
44 | def outdent(): Unit = { ind -= 2 }
45 | def close(): Unit
46 | }
47 |
48 | def file(name: String): Out = {
49 | val f = new File(outputBase, name)
50 | f.getParentFile.mkdirs
51 | val w = new PrintStream(f, "UTF-8")
52 | new Out {
53 | def println(s: String): Unit = { w.println(s) }
54 | def close(): Unit = { w.close() }
55 | }
56 | }
57 |
58 | /**
59 | * Private methods and classes are not visible in the javadoc,
60 | * so they can be removed wholesale.
61 | */
62 | def withoutPrivates(c: ClassInfo): Option[ClassInfo] = {
63 | def templWithoutPrivates(t: Templ): Option[Templ] = {
64 | if (t.access.contains("private")) None
65 | else t match {
66 | case c: ClassInfo =>
67 | Some(c.copy(members = c.members.flatMap(templWithoutPrivates)))
68 | case other =>
69 | Some(other)
70 | }
71 | }
72 |
73 | if (c.access.contains("private")) None
74 | else Some(c.copy(members = c.members.flatMap(templWithoutPrivates)))
75 | }
76 |
77 | /**
78 | * Lift nested interfaces with the same name as their parent class to the parent
79 | * level, as Java does not allow this, mangling their name accordingly
80 | *
81 | * Also applied recursively to members
82 | */
83 | def liftInnerClassesWithSameName(c: ClassInfo): Seq[ClassInfo] = {
84 | c.members.find {
85 | case member: ClassInfo => member.name == c.name
86 | case _ => false
87 | } match {
88 | case Some(nestedClass: ClassInfo) =>
89 | Seq(
90 | c.copy(members = c.classMembers.filterNot(_ == nestedClass).flatMap(liftInnerClassesWithSameName) ++ c.methodMembers),
91 | nestedClass.copy(
92 | name = s"${nestedClass.name}$$${nestedClass.name}",
93 | static = false,
94 | members = nestedClass.members.map {
95 | case member: MethodInfo if member.name == nestedClass.name =>
96 | member.copy(name = s"${nestedClass.name}$$${nestedClass.name}")
97 | case member =>
98 | member
99 | }
100 | )
101 | )
102 | case _ =>
103 | Seq(c.copy(members = c.classMembers.flatMap(liftInnerClassesWithSameName) ++ c.methodMembers))
104 | }
105 | }
106 |
107 | /**
108 | * This method is supposed to do the transformation of `object` into
109 | *
110 | * - a class with $ appended to the name
111 | * - including a MODULE$ static field
112 | * - and static forwarders in the original class
113 | *
114 | * The first two parts are to be applied recursively to nested objects.
115 | */
116 | def flattenObjects(c: Vector[ClassInfo], forwarders: Boolean = true, staticScope: Boolean = true): Vector[ClassInfo] = {
117 | val (obj: Vector[ClassInfo], cls: Vector[ClassInfo]) = c collect PreFilter partition (_.module)
118 | val classes = cls.map(c => c.name -> c).toMap
119 | val objects = obj.map(o => o.name -> o).toMap
120 | val pairs = obj.map(o => Some(o) -> (classes get o.name)) ++
121 | cls.filterNot(c => objects contains c.name).map(c => None -> Some(c))
122 | pairs flatMap { p =>
123 | p match {
124 | case (Some(o), Some(c)) => merge(o, c, forwarders, staticScope)
125 | case (Some(o), None) if forwarders => merge(o, fabricateCompanion(o), forwarders, staticScope)
126 | case (Some(o), None) => Vector(mangleModule(o, addMODULE = forwarders, pruneClasses = false))
127 | case (None, Some(c)) => Vector(c.copy(members = flattenObjects(c.classMembers) ++ c.methodMembers.sortBy(_.name)))
128 | case (None, None) => ???
129 | }
130 | }
131 | }
132 |
133 | // goes from object to companion class (not the other way around)
134 | private def fabricateCompanion(obj: ClassInfo): ClassInfo = {
135 | val com = obj.members.foldLeft(obj.comment)((c, mem) => mem match {
136 | case x: MethodInfo if x.name == obj.name => c ++ x.comment
137 | case _ => c
138 | })
139 | val sig = (n: String, a: String) => obj.pattern(n, a).replaceAll(" extends.*", "").replaceAll(" implements.*", "")
140 | obj.copy(comment = com, module = false, members = Vector.empty, pattern = sig)
141 | }
142 |
143 | val PreFilter: PartialFunction[ClassInfo, ClassInfo] = {
144 | case c if c.name != "package" =>
145 | val nm = c.members filterNot (this.javaKeywords contains _.name)
146 | if (nm == c.members) c
147 | else c.copy(members = nm)
148 | }
149 |
150 | private def mangleModule(obj: ClassInfo, addMODULE: Boolean, pruneClasses: Boolean): ClassInfo = {
151 | val moduleInstance =
152 | if (addMODULE || (obj.module && obj.static))
153 | Some(MethodInfo("public", x => x, "public static final", s"${obj.name}$$ MODULE$$ = null;",
154 | Seq("/**", " * Static reference to the singleton instance of this Scala object.", " */")))
155 | else None
156 |
157 | val members = moduleInstance ++: (
158 | if (pruneClasses) obj.methodMembers
159 | else flattenObjects(obj.classMembers) ++ obj.methodMembers
160 | )
161 |
162 | val (com: Seq[String], moduleMembers: Vector[Templ]) = members.foldLeft((obj.comment, Vector.empty[Templ]))((p, mem) => mem match {
163 | case x: MethodInfo if x.name == obj.name => (p._1 ++ x.comment, p._2 :+ x.copy(name = x.name + '$', comment = Seq()))
164 | case x => (p._1, p._2 :+ x)
165 | })
166 | obj.copy(name = obj.name + '$', comment = com, members = moduleMembers)
167 | }
168 |
169 | private def merge(obj: ClassInfo, cls: ClassInfo, forwarders: Boolean, staticScope: Boolean): Vector[ClassInfo] = {
170 | val classes = cls.members collect { case c: ClassInfo => c }
171 | val methods = cls.members collect {
172 | case m: MethodInfo =>
173 | if (m.ret.endsWith("$") && classes.exists(_.name == m.name))
174 | m.copy(comment = Seq("/**", " * Accessor for nested Scala object", " * @return (undocumented)", " */"))
175 | else m
176 | }
177 | val staticClasses = obj.members collect {
178 | case c: ClassInfo =>
179 | c.copy(
180 | access = if (cls.interface && c.access == "private") "" else c.access,
181 | pattern = if (staticScope) (n, a) => "static " + c.pattern(n, a) else c.pattern,
182 | static = staticScope)
183 | }
184 | val staticMethods =
185 | if (!forwarders || cls.interface) Vector.empty
186 | else {
187 | val direct = obj.members.collect {
188 | case m: MethodInfo if !(m.name == obj.name) && !cls.members.exists(_.name == m.name) =>
189 | m.copy(pattern = n => "static " + m.pattern(n))
190 | }
191 | val exclude = (direct.iterator ++ methods.iterator).map(_.name).toSet ++ this.javaKeywords ++ excludedForwarders
192 | direct ++ inheritedMethods(obj.sym, exclude)
193 | }
194 | val nestedClasses = flattenObjects(classes, forwarders = false, staticScope = false)
195 | val nestedStaticClasses = flattenObjects(staticClasses, forwarders = false, staticScope = staticScope)
196 | if (forwarders) {
197 | val base = cls.copy(members = nestedClasses ++ nestedStaticClasses ++ staticMethods ++ methods)
198 | val mod = mangleModule(obj, addMODULE = forwarders, pruneClasses = true)
199 | Vector(base, mod)
200 | } else {
201 | val base = cls.copy(members = nestedClasses ++ staticMethods ++ methods)
202 | val mod = mangleModule(obj, addMODULE = forwarders, pruneClasses = true)
203 | Vector(base, mod.copy(members = nestedStaticClasses ++ mod.members))
204 | }
205 | }
206 |
207 | private val excludedForwarders =
208 | // For case classes, there is a generated companion object that
209 | // implements `AbstractFunctionN`, but static forwarders are not created
210 | // on the class for the methods on the companion object inherited from
211 | // that:
212 | Seq("curried", "tupled", "compose", "andThen")
213 |
214 | private def inheritedMethods(sym: global.Symbol, exclude: Set[String]): Seq[MethodInfo] = {
215 | import global._
216 | sym.ancestors.reverse
217 | .filter(s => s.name != tpnme.Object && s.name != tpnme.Any)
218 | .flatMap(_.info.nonPrivateDecls)
219 | .collect { case m: MethodSymbol if !m.isConstructor && !exclude.contains(m.name.toString) => m }
220 | .foldLeft(Vector.empty[Symbol])((s, m) => s.filterNot(m.allOverriddenSymbols.contains) :+ m)
221 | .map(MethodInfo(_))
222 | }
223 |
224 | }
225 |
--------------------------------------------------------------------------------
/src/main/scala/com/typesafe/genjavadoc/AST.scala:
--------------------------------------------------------------------------------
1 | package com.typesafe.genjavadoc
2 |
3 | import scala.annotation.tailrec
4 |
5 | trait AST { this: TransformCake =>
6 |
7 | import global._
8 |
9 | def strictVisibility: Boolean
10 |
11 | trait Templ {
12 | def name: String
13 | def sig: String
14 | def access: String
15 | }
16 |
17 | case class ClassInfo(
18 | sym: Symbol,
19 | name: String,
20 | access: String,
21 | pattern: (String, String) => String,
22 | module: Boolean,
23 | comment: Seq[String],
24 | pckg: String,
25 | filepattern: String => String,
26 | members: Vector[Templ],
27 | interface: Boolean,
28 | static: Boolean,
29 | var firstConstructor: Boolean) extends Templ {
30 |
31 | def sig: String = {
32 | s"$addAnnotations${pattern(name, access)}"
33 | }
34 |
35 | def file = filepattern(name)
36 |
37 | private def addAnnotations: String = {
38 | val annotations = sym.annotations
39 | .filter(a => allowedAnnotations.contains(a.symbol.fullName('.')))
40 | .map { a => s"@${a.symbol.fullName('.')}" }
41 | .mkString(System.lineSeparator())
42 | if (!annotations.isEmpty) {
43 | annotations + System.lineSeparator()
44 | } else {
45 | annotations
46 | }
47 | }
48 |
49 | def addMember(t: Templ) = copy(members = members :+ t)
50 |
51 | def constructor: Boolean = {
52 | val ret = firstConstructor
53 | firstConstructor = false
54 | ret
55 | }
56 |
57 | def classMembers = members.collect { case classInfo: ClassInfo => classInfo }
58 | def methodMembers = members.collect { case methodInfo: MethodInfo => methodInfo }
59 |
60 | override def toString =
61 | s"ClassInfo($name, ${pattern("XXXXX", "AAAAA")}, module=$module, pckg=$pckg, ${filepattern("FFFFFF")}, interface=$interface, static=$static)" +
62 | comment.mkString("\n ", "\n ", "\n ") + members.mkString("\n ")
63 | }
64 | object ClassInfo {
65 | def apply(c: ImplDef, comment: Seq[String], topLevel: Boolean): ClassInfo = {
66 | c match {
67 | case cd@ClassDef(mods, _, tparams, impl) =>
68 | val name = c.name.toString
69 | val acc = access(mods, topLevel)
70 | val fl = flags(mods)
71 | val kind = if (mods.isInterface || mods.isTrait) "interface" else "class"
72 | val tp = c.symbol.owner.thisType.memberInfo(c.symbol) match {
73 | case p @ PolyType(params, _) => js(c.symbol, p)
74 | case _ => ""
75 | }
76 | val parent = {
77 | val p = impl.parents.head
78 | if (p.isEmpty || p.symbol == definitions.ObjectClass || mods.isTrait) ""
79 | else {
80 | s" extends ${js(c.symbol, p.tpe)}"
81 | }
82 | }
83 | val intf = impl.parents.tail map (i => js(c.symbol, i.tpe)) mkString (", ")
84 | val interfaces = if (!intf.isEmpty) (if (mods.isInterface || mods.isTrait) " extends " else " implements ") + intf else ""
85 | val sig = (n: String, a: String) => s"$a $fl $kind $n$tp$parent$interfaces"
86 | val packageName = c.symbol.enclosingPackage.fullName('/')
87 | val file =
88 | if (packageName == "") (n: String) => s"$n.java"
89 | else (n: String) => s"$packageName/$n.java"
90 | val pckg = c.symbol.enclosingPackage.fullName
91 | ClassInfo(c.symbol, name, acc, sig, mods.hasModuleFlag, comment, pckg, file, Vector.empty, kind == "interface", false, true)
92 | }
93 | }
94 | }
95 |
96 | def fabricateParams: Boolean
97 |
98 | case class DeprecationInfo(msg: String, since: String) {
99 | def render = {
100 | val rMsg = if (msg.isEmpty) "" else s" ${msg.stripSuffix(".")}."
101 | val rSince = if (since.isEmpty) "" else s" Since ${since.stripSuffix(".")}."
102 | s" * @deprecated$rMsg$rSince"
103 | }
104 |
105 | def appendToComment(comment: Seq[String]): Seq[String] = comment.toVector match {
106 | case init :+ " */" =>
107 | init ++ List(" *", render, " */")
108 | case c =>
109 | c ++ List("/**", render, "*/")
110 | }
111 | }
112 |
113 | case class MethodInfo(access: String, pattern: String => String, ret: String, name: String, comment: Seq[String], d: Option[DefDef] = None) extends Templ {
114 | def sig: String = {
115 | s"$addAnnotations${pattern(s"$ret $name")}"
116 | }
117 |
118 | private def addAnnotations: String = d match {
119 | case Some(definition) => {
120 | val annotations = definition.symbol.annotations
121 | .filter(a => allowedAnnotations.contains(a.symbol.fullName('.')))
122 | .map { a => s"@${a.symbol.fullName('.')}" }
123 | .mkString(System.lineSeparator())
124 | if (!annotations.isEmpty) {
125 | annotations + System.lineSeparator()
126 | } else {
127 | annotations
128 | }
129 | }
130 | case None => ""
131 | }
132 | }
133 |
134 | object MethodInfo {
135 | def apply(d: DefDef, interface: Boolean, comment: Seq[String], hasVararg: Boolean, deprecation: Option[DeprecationInfo]): MethodInfo = {
136 | val acc = methodAccess(d.symbol, interface) + methodFlags(d.mods, interface)
137 | val (ret, name) =
138 | if (d.name == nme.CONSTRUCTOR) {
139 | ("", d.symbol.enclClass.name.toString)
140 | } else (js(d.symbol, d.tpt.tpe), d.name.toString)
141 | val tp = d.symbol.owner.thisType.memberInfo(d.symbol) match {
142 | case p @ PolyType(params, _) => js(d.symbol, p)
143 | case _ => ""
144 | }
145 | @tailrec def rec(l: List[ValDef], acc: Vector[String] = Vector.empty): Seq[String] = l match {
146 | case x :: Nil if hasVararg => acc :+ s"${js(d.symbol, x.tpt.tpe, voidOK = false).dropRight(2)}... ${mangleMethodName(x)}"
147 | case x :: xs => rec(xs, acc :+ s"${js(d.symbol, x.tpt.tpe, voidOK = false)} ${mangleMethodName(x)}")
148 | case Nil => acc
149 | }
150 | val args = rec(d.vparamss.head) mkString ("(", ", ", ")")
151 |
152 | val throwsAnnotations = d.symbol.annotations.collect {
153 | case ThrownException(exc) => (exc: Any) match {
154 | case s: Symbol => s.fullName
155 | case t: Type => t.typeSymbol.fullName // 2.12.0-M4+ has a Type instead of a TypeSymbol in ThrownException
156 | }
157 | }
158 | val throws = if (throwsAnnotations.isEmpty) "" else "throws " + throwsAnnotations.mkString(", ")
159 |
160 | val impl = if (d.mods.isDeferred || interface) ";" else "{ throw new RuntimeException(); }"
161 | val pattern = (n: String) => s"$acc $tp $n $args $throws $impl"
162 | def hasParam(n: String) = comment.find(_.contains(s"@param $n")).isDefined
163 |
164 | val commentWithParams =
165 | if (fabricateParams && comment.size > 1 && comment.head.startsWith("/**")) {
166 | val p = d.vparamss.head.map(mangleMethodName).filterNot(hasParam)
167 | val rev = comment.toList.reverse
168 | val r = if (ret == "void" || ret == "" || comment.find(_.contains("@return")).isDefined) Nil else " * @return (undocumented)" :: Nil
169 | rev.tail reverse_::: p.map(n => s" * @param $n (undocumented)") ::: r ::: rev.head :: Nil
170 | } else comment
171 | val commentWithParamsAndDeprec =
172 | if (comment.exists(_ contains "* @deprecated ")) commentWithParams // skip adding deprecated javadoc if already there
173 | else deprecation match {
174 | case Some(deprec) => deprec.appendToComment(commentWithParams)
175 | case _ => commentWithParams
176 | }
177 | MethodInfo(acc, pattern, ret, name, commentWithParamsAndDeprec, Some(d))
178 | }
179 |
180 | /**
181 | * This is used only for creating the static forwarders for methods that
182 | * are inherited by the Scala object in question, hence `interface=false`
183 | * and the addition of `static`.
184 | */
185 | def apply(sym: Symbol): MethodInfo = {
186 | val varargs = sym match {
187 | case m: MethodSymbol => m.isVarargsMethod
188 | case _ => false
189 | }
190 | val d = DefDef(sym, EmptyTree)
191 | val m = MethodInfo(d, false, Nil, varargs, None)
192 | m.copy(pattern = n => "static " + m.pattern(n))
193 | }
194 | }
195 |
196 | private def mangleMethodName(p: ValDef): String = {
197 | if (this.javaKeywords contains p.name.toString) s"${p.name}_" else p.name.toString
198 | }
199 |
200 | private def access(m: Modifiers, topLevel: Boolean): String = {
201 | if (m.isPublic || m.isTrait) "public"
202 | else if (m.isProtected && !topLevel) "protected"
203 | else if (m.isPrivate && !topLevel) {
204 | if (m.isInterface || m.hasStaticFlag) "" else "private"
205 | }
206 | else if (strictVisibility && m.privateWithin != tpnme.EMPTY) ""
207 | else "public" // this is the case for top level classes
208 | }
209 |
210 | private def methodAccess(sym: Symbol, interface: Boolean): String = {
211 | if (sym.isPublic) "public"
212 | else if (sym.isProtected && !interface) "protected"
213 | else if (sym.isPrivate && !interface) "private"
214 | else if (strictVisibility && sym.privateWithin != NoSymbol) ""
215 | else "public" // this is the case for interfaces
216 | }
217 |
218 | private def flags(m: Modifiers): String = {
219 | var f: List[String] = Nil
220 | if (m.isFinal) f ::= "final"
221 | if (m.hasAbstractFlag && !(m.isInterface || m.isTrait)) f ::= "abstract"
222 | f mkString " "
223 | }
224 |
225 | private def methodFlags(m: Modifiers, interface: Boolean): String = {
226 | var f: List[String] = Nil
227 | if (m.isFinal && !interface) f ::= "final"
228 | if (m.isDeferred && !interface) f ::= "abstract"
229 | (if (f.nonEmpty) " " else "") + f.mkString(" ")
230 | }
231 |
232 | }
233 |
--------------------------------------------------------------------------------
/src/test/resources/input/basic/test.scala:
--------------------------------------------------------------------------------
1 | package akka.rk
2 | package buh.is.it
3 |
4 | import scala.annotation.varargs
5 | import scala.concurrent.duration.FiniteDuration
6 |
7 | object Status {
8 | sealed trait Status extends Serializable
9 | }
10 |
11 | /**
12 | * @tparam A I am a type parameter description
13 | */
14 | trait Y[A] {
15 | // def pi = 3.14
16 | }
17 | trait X extends Serializable with Y[A]
18 |
19 | abstract class Z {
20 | def pi: Double
21 | }
22 |
23 | /**
24 | * I am an object. I have no class.
25 | */
26 | object Blarb {
27 | sealed trait Fuz
28 | case object A extends Fuz
29 | case class B(x: String) extends Fuz
30 | }
31 |
32 | /**
33 | * class A
34 | *
35 | * with a `second` paragraph
36 | *
37 | * and a third one `with
38 | * a break` in some code.
39 | *
40 | * Some problematic things: & > =>
41 | *
42 | *
43 | *
44 | * {{{
45 | * and some code
46 | * }}}
47 | *
48 | * and an illegal tag:
49 | * @param x buh
50 | *
51 | * @see [[Blarb]]
52 | * @see [[http://some.url.here]]
53 | * @see [[https://some.other.url.here]]
54 | */
55 | class A {
56 | /**
57 | * def p(x: Array[Int]): Predef.type
58 | *
59 | * @param x an Array
60 | */
61 | def p(x: Array[Int]) = Predef
62 |
63 | /**
64 | * def params[T <: B](b: T): T
65 | */
66 | def params[T >: D <: B](b: T): List[T] = b :: Nil
67 |
68 | /**
69 | * def map
70 | */
71 | def map = Map(1 -> "1")
72 |
73 | def default = 0 // this shall not be emitted
74 | def goto = 0 // this shall not be emitted
75 | def interface = 0 // this shall not be emitted
76 | def switch = 0 // this shall not be emitted
77 |
78 | val `public` = 0 // this shall not be emitted
79 | val `private` = 0 // this shall not be emitted
80 | val `package` = 0 // this shall not be emitted
81 | val `static` = 0 // this shall not be emitted
82 | val `class` = 0 // this shall not be emitted
83 |
84 | val `4711-whatever` = 0 // this shall not be emitted
85 |
86 | /**
87 | * scala.Nothing should be converted to scala.runtime.Nothing$.
88 | */
89 | def nothing(msg: String) = throw new IllegalArgumentException(msg)
90 |
91 | /**
92 | * Unitparam
93 | */
94 | def unitParam(unit: Unit) = 42
95 |
96 | /**
97 | * mangledNames
98 | */
99 | def mangledNames(default: String, goto: String, interface: String) = 12
100 |
101 | /**
102 | * blarb
103 | */
104 | def blarb: Blarb.Fuz = Blarb.A
105 |
106 | /**
107 | * refined
108 | */
109 | def refined: Z with Y[Unit] = null
110 |
111 | /**
112 | * poly
113 | */
114 | def poly[A, M[A] <: Y[A]] = 42
115 |
116 | /**
117 | * extra comment
118 | */
119 |
120 | /**
121 | * varargs
122 | */
123 | @varargs
124 | def hello(s: String*) = 0
125 |
126 | /**
127 | * throws
128 | */
129 | @throws[IllegalArgumentException]
130 | @throws(classOf[NullPointerException])
131 | def testthrows = 0
132 |
133 | def getNull: Null = null
134 |
135 | /**
136 | * class A.B
137 | */
138 | // one line comment
139 | class B extends X {
140 | /**
141 | * secondary constructor
142 | */
143 | def this(stest: String) = this()
144 | /**
145 | * def b(args: java.lang.String*): Unit
146 | */
147 | @varargs
148 | def b(args: String*) {
149 | /**
150 | * new AnyRef {}
151 | */
152 | new AnyRef {
153 | /**
154 | * def x: Int
155 | */
156 | def x = 2
157 | }
158 | }
159 | def d(a: String)(b: X) = ""
160 | }
161 |
162 | class C extends { val i = 1 } with X
163 | /**
164 | * class A.D
165 | */
166 | class D extends { /** val i */ val i = 1 } with B
167 | /**
168 | * object A.D
169 | */
170 | object D {
171 | /**
172 | * def A.D.math
173 | */
174 | def math = 0l
175 |
176 | /**
177 | * A nested non-static class.
178 | */
179 | class NonStatic
180 |
181 | /**
182 | * And a nested object.
183 | */
184 | object E
185 | }
186 |
187 | /** tailrecced */
188 | final class TR {
189 | @scala.annotation.tailrec def tr(r: String): Unit = r match {
190 | case _ => tr(r)
191 | }
192 | }
193 |
194 | }
195 |
196 | /**
197 | * object A
198 | */
199 | object A {
200 | /**
201 | * def IAmStatic: Int
202 | */
203 | def IAmStatic = 42
204 | /**
205 | * val stattic: java.lang.String
206 | */
207 | val stattic = "1"
208 | /**
209 | * static p
210 | */
211 | def p = "i am not forwarded"
212 |
213 | /**
214 | * class A.C
215 | */
216 | class C1 {
217 | /**
218 | * object A.C.C1
219 | */
220 | object C1
221 | }
222 |
223 | /**
224 | * object C1
225 | */
226 | object C1 {
227 | /**
228 | * A.C1.method
229 | */
230 | def method = ()
231 |
232 | /**
233 | * And another nested object.
234 | */
235 | object EE
236 | }
237 |
238 | /**
239 | * object A.NoComment
240 | */
241 | private object NoComment
242 |
243 | /**
244 | * a non-comment
245 | */
246 | p
247 | val x = new AnyRef
248 | }
249 |
250 | trait Trait
251 | object Trait {
252 | private final case class TraitPrivate()
253 | }
254 |
255 | /**
256 | * Privacy is an illusion.
257 | */
258 | private[it] object PPrivate {
259 | def method = ()
260 | }
261 |
262 | /**
263 | * Don't touch this!
264 | */
265 | @deprecated("This is replaced by TouchThisInstead", since = "now")
266 | private[it] class DontTouchThis {
267 | /**
268 | * Some methods are forever.
269 | */
270 | @deprecated("This is replaced by someDiamondsAre", since = "now")
271 | def orNotSoMuch = ()
272 |
273 | /**
274 | * @deprecated This is already deprecated. Since now.
275 | */
276 | @deprecated("This will be ignored", since = "ever")
277 | def alreadyDeprecatedInComment = ()
278 |
279 | /**
280 | * buh!
281 | */
282 | @Deprecated
283 | def javaDeprecatedThingie = ()
284 | }
285 |
286 | @deprecated("Les Scalac Voyages Extraordinaire", since = "now")
287 | class DeprecatedNoComment {
288 | @deprecated("This is replaced by theShinyNewMethod", since = "now")
289 | def oldMethod = ()
290 | }
291 |
292 |
293 | /**
294 | * Privacy is an illusion.
295 | */
296 | private object Private {
297 | def method = ()
298 | }
299 |
300 | /**
301 | * Use protection.
302 | */
303 | protected[it] object PProtected {
304 | def method = ()
305 | }
306 |
307 | /**
308 | * Privacy is an illusion.
309 | */
310 | private[it] trait PTrait {
311 | def method = ()
312 | protected final def protectedMethod = ()
313 | }
314 |
315 | /**
316 | * AbstractTypeRef
317 | */
318 | trait AnAbstractTypeRef {
319 | type Self <: AnAbstractTypeRef
320 |
321 | def someMethod(): Self = this.asInstanceOf[Self]
322 |
323 | /**
324 | * And a parameter type ref.
325 | */
326 | def otherMethod(t: PTrait, string: String): t.type = t
327 | }
328 |
329 | /**
330 | * The exponentially weighted moving average (EWMA) approach captures short-term
331 | * movements in volatility for a conditional volatility forecasting model. By virtue
332 | * of its alpha, or decay factor, this provides a statistical streaming data model
333 | * that is exponentially biased towards newer entries.
334 | *
335 | * http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
336 | *
337 | * An EWMA only needs the most recent forecast value to be kept, as opposed to a standard
338 | * moving average model.
339 | *
340 | * @param alpha decay factor, sets how quickly the exponential weighting decays for past data compared to new data,
341 | * see http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
342 | *
343 | * @param value the current exponentially weighted moving average, e.g. Y(n - 1), or,
344 | * the sampled value resulting from the previous smoothing iteration.
345 | * This value is always used as the previous EWMA to calculate the new EWMA.
346 | *
347 | */
348 | @SerialVersionUID(1L)
349 | final case class EWMA(value: Double, alpha: Double) {
350 |
351 | require(0.0 <= alpha && alpha <= 1.0, "alpha must be between 0.0 and 1.0")
352 |
353 | /**
354 | * Calculates the exponentially weighted moving average for a given monitored data set.
355 | *
356 | * @param xn the new data point
357 | * @return a new EWMA with the updated value
358 | */
359 | def :+(xn: Double): EWMA = {
360 | val newValue = (alpha * xn) + (1 - alpha) * value
361 | if (newValue == value) this // no change
362 | else copy(value = newValue)
363 | }
364 |
365 | }
366 | object EWMA {
367 |
368 | /**
369 | * math.log(2)
370 | */
371 | private val LogOf2 = 0.69315
372 |
373 | /**
374 | * Calculate the alpha (decay factor) used in [[akka.cluster.EWMA]]
375 | * from specified half-life and interval between observations.
376 | * Half-life is the interval over which the weights decrease by a factor of two.
377 | * The relevance of each data sample is halved for every passing half-life duration,
378 | * i.e. after 4 times the half-life, a data sample’s relevance is reduced to 6% of
379 | * its original relevance. The initial relevance of a data sample is given by
380 | * 1 – 0.5 ^ (collect-interval / half-life).
381 | */
382 | def alpha(halfLife: FiniteDuration, collectInterval: FiniteDuration): Double = {
383 | val halfLifeMillis = halfLife.toMillis
384 | require(halfLife.toMillis > 0, "halfLife must be > 0 s")
385 | val decayRate = LogOf2 / halfLifeMillis
386 | 1 - math.exp(-decayRate * collectInterval.toMillis)
387 | }
388 | }
389 |
390 | abstract class Reserved {
391 | //reserved keyword in java, should not be generated
392 | final def goto(x: String): String = x
393 | }
394 |
395 | object ReservedImpl extends Reserved
396 |
397 | class ClassWithInner {
398 |
399 | class Foo {
400 | def methodOfFoo(i: Int) = 42
401 | }
402 | object Foo {
403 | val companionObjectValue = 32
404 | }
405 |
406 | }
407 |
408 | private[buh] object CompressionProtocol {
409 |
410 | private[buh] object Events {
411 |
412 | private[buh] sealed trait Event
413 |
414 | final case class HeavyHitterDetected(key: Any, id: Int, count: Long) extends Event
415 |
416 | }
417 |
418 | }
--------------------------------------------------------------------------------