summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2016-08-13 08:32:41 -0700
committerGitHub <noreply@github.com>2016-08-13 08:32:41 -0700
commitd6f601d53e53be6f8071c0646c19b68faac69ec0 (patch)
tree8d8aec4c13199596a8cf04991380fed4fb3b902b /test
parent69c6500b5f25e1b4a66d3a62cf40d23877a9023f (diff)
parent36732d7a14ab246d9ab6b011a0eafe4115978f19 (diff)
downloadscala-d6f601d53e53be6f8071c0646c19b68faac69ec0.tar.gz
scala-d6f601d53e53be6f8071c0646c19b68faac69ec0.tar.bz2
scala-d6f601d53e53be6f8071c0646c19b68faac69ec0.zip
Merge pull request #5332 from retronym/review/5304
Fixes to Java source support in Scaladoc
Diffstat (limited to 'test')
-rw-r--r--test/files/pos/t2377b/Q.java13
-rw-r--r--test/files/pos/t2377b/a.scala5
-rw-r--r--test/scaladoc/resources/SI-4826.java289
-rw-r--r--test/scaladoc/run/SI-4826-no-comments.check1
-rw-r--r--test/scaladoc/run/SI-4826-no-comments.scala20
-rw-r--r--test/scaladoc/run/SI-4826.scala15
6 files changed, 331 insertions, 12 deletions
diff --git a/test/files/pos/t2377b/Q.java b/test/files/pos/t2377b/Q.java
new file mode 100644
index 0000000000..fbf9c776e9
--- /dev/null
+++ b/test/files/pos/t2377b/Q.java
@@ -0,0 +1,13 @@
+public class Q {
+
+ public static class Builder {}
+
+ public static class Inner {
+ public static class Builder { public void innerMethod() {} }
+ public Builder foo() { return new Builder(); } // this line gives an error, that Builder is ambiguous
+
+ public Inner.Builder viaSelect() { return new Builder(); } // this line gives an error, that Builder is ambiguous
+ }
+
+}
+
diff --git a/test/files/pos/t2377b/a.scala b/test/files/pos/t2377b/a.scala
new file mode 100644
index 0000000000..3053841589
--- /dev/null
+++ b/test/files/pos/t2377b/a.scala
@@ -0,0 +1,5 @@
+object Test {
+ (new Q.Inner).foo.innerMethod
+ (new Q.Inner).viaSelect.innerMethod
+
+}
diff --git a/test/scaladoc/resources/SI-4826.java b/test/scaladoc/resources/SI-4826.java
index f735ce6335..18a1cb86f2 100644
--- a/test/scaladoc/resources/SI-4826.java
+++ b/test/scaladoc/resources/SI-4826.java
@@ -1,3 +1,6 @@
+/**
+ * A package header
+ */
package test.scaladoc;
/**
@@ -6,6 +9,29 @@ package test.scaladoc;
*/
public class JavaComments {
+ /** A field */
+ public final int x;
+ /** A field */
+ protected int y;
+ /** A field */
+ private int z;
+
+ /**
+ * Inner class
+ */
+ public class Inner {
+ /** Inner method */
+ public void foo() {
+ }
+ }
+
+ /**
+ * A typed inner class
+ * @param <T> some type
+ */
+ public class InnerTyped<T> {
+ }
+
/**
* Compute the answer to the ultimate question of life, the
* universe, and everything. :marker:
@@ -16,5 +42,268 @@ public class JavaComments {
return 42 * factor;
}
+ /** Private */
+ private double foo(double value) {
+ return value;
+ }
+
+ /** Protected */
+ protected double bar(double value) {
+ return value;
+ }
+
+ /** No qualifier*/
+ String noqualifier() {
+ return "something";
+ }
+
+ /** Void */
+ public void voidmethod(boolean t) {
+ }
+
+ /**
+ * Typed parameter
+ * @param <A> the parameter type
+ * @param a parameter
+ * @return something
+ */
+ public <A> void tparams(A a) {
+ }
+
+ /**
+ * Typed parameter
+ * @param <A> the return type
+ * @param <B> the parameter typeA
+ * @param b parameter
+ * @return casts B to A
+ */
+ public <A, B extends A> A cast(B b) {
+ return (B) b;
+ }
+
}
+// The following snippet is taken from Akka, it mainly tests interfaces
+
+/**
+ * Class that encapsulates all the Functional Interfaces
+ * used for creating partial functions.
+ *
+ * This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.
+ */
+public final class FI {
+
+ /** Doc comment on constructor */
+ private FI() {
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I> the input type, that this Apply will be applied to
+ * @param <R> the return type, that the results of the application will have
+ */
+ public static interface Apply<I, R> {
+ /**
+ * The application to perform.
+ *
+ * @param i an instance that the application is performed on
+ * @return the result of the application
+ */
+ public R apply(I i) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <R> the return type, that the results of the application will have
+ */
+ public static interface Apply2<I1, I2, R> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @return the result of the application
+ */
+ public R apply(I1 i1, I2 i2) throws Exception;
+ }
+
+ /**
+ * Functional interface for a predicate.
+ *
+ * @param <T> the type that the predicate will operate on.
+ */
+ public static interface TypedPredicate<T> {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param t an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(T t);
+ }
+
+ /**
+ * Functional interface for a predicate.
+ *
+ * @param <T> the type that the predicate will operate on.
+ * @param <U> the type that the predicate will operate on.
+ */
+ public static interface TypedPredicate2<T, U> {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param t an instance that the predicate is evaluated on.
+ * @param u an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(T t, U u);
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I> the input type, that this Apply will be applied to
+ */
+ public static interface UnitApply<I> {
+ /**
+ * The application to perform.
+ *
+ * @param i an instance that the application is performed on
+ */
+ public void apply(I i) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ */
+ public static interface UnitApply2<I1, I2> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <I3> the third input type, that this Apply will be applied to
+ */
+ public static interface UnitApply3<I1, I2, I3> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @param i3 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2, I3 i3) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <I3> the third input type, that this Apply will be applied to
+ * @param <I4> the fourth input type, that this Apply will be applied to
+ */
+ public static interface UnitApply4<I1, I2, I3, I4> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @param i3 an instance that the application is performed on
+ * @param i4 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2, I3 i3, I4 i4) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ */
+ public static interface UnitApplyVoid {
+ /**
+ * The application to perform.
+ */
+ public void apply() throws Exception;
+ }
+
+ /**
+ * Package scoped functional interface for a predicate. Used internally to match against arbitrary types.
+ */
+ static interface Predicate {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param o an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(Object o);
+ }
+
+ /** comment about */
+ /** a comment about */
+ /** a comment */
+ void foo() {}
+
+ /** someone forgot to uncomment */
+ //void thisMethod() {}
+ /** and also this */
+ //void otherMethod() {}
+}
+
+/**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <I3> the third input type, that this Apply will be applied to
+ * @param <I4> the fourth input type, that this Apply will be applied to
+ */
+public interface UnitApply4<I1, I2, I3, I4> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @param i3 an instance that the application is performed on
+ * @param i4 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2, I3 i3, I4 i4) throws Exception;
+}
+
+/**
+ * Functional interface for an application.
+ */
+public interface UnitApplyVoid {
+ /**
+ * The application to perform.
+ */
+ public void apply() throws Exception;
+}
+
+/**
+ * Package scoped functional interface for a predicate. Used internally to match against arbitrary types.
+ */
+interface Predicate {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param o an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(Object o);
+}
diff --git a/test/scaladoc/run/SI-4826-no-comments.check b/test/scaladoc/run/SI-4826-no-comments.check
new file mode 100644
index 0000000000..3925a0d464
--- /dev/null
+++ b/test/scaladoc/run/SI-4826-no-comments.check
@@ -0,0 +1 @@
+Done. \ No newline at end of file
diff --git a/test/scaladoc/run/SI-4826-no-comments.scala b/test/scaladoc/run/SI-4826-no-comments.scala
new file mode 100644
index 0000000000..217fc29d81
--- /dev/null
+++ b/test/scaladoc/run/SI-4826-no-comments.scala
@@ -0,0 +1,20 @@
+import scala.tools.nsc.doc.Universe
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocJavaModelTest
+
+object Test extends ScaladocJavaModelTest {
+
+ override def resourceFile = "SI-4826.java"
+ override def scaladocSettings = "-no-java-comments"
+
+ def testModel(rootPackage: Package) = {
+ import access._
+
+ val base = rootPackage._package("test")._package("scaladoc")
+ val clazz = base._class("JavaComments")
+ val method = clazz._method("answer")
+
+ assert(clazz.comment == None)
+ assert(method.comment == None)
+ }
+}
diff --git a/test/scaladoc/run/SI-4826.scala b/test/scaladoc/run/SI-4826.scala
index 50e4468002..6d4b3a6da7 100644
--- a/test/scaladoc/run/SI-4826.scala
+++ b/test/scaladoc/run/SI-4826.scala
@@ -1,20 +1,11 @@
import scala.tools.nsc.doc.Universe
import scala.tools.nsc.doc.model._
-import scala.tools.partest.ScaladocModelTest
+import scala.tools.partest.ScaladocJavaModelTest
-object Test extends ScaladocModelTest {
+object Test extends ScaladocJavaModelTest {
override def resourceFile = "SI-4826.java"
-
- // overridden to pass explicit files to newDocFactory.makeUniverse (rather than code strings)
- // since the .java file extension is required
- override def model: Option[Universe] = {
- val path = resourcePath + "/" + resourceFile
- newDocFactory.makeUniverse(Left(List(path)))
- }
-
- // no need for special settings
- def scaladocSettings = ""
+ override def scaladocSettings = ""
def testModel(rootPackage: Package) = {
import access._