diff options
Diffstat (limited to 'test/files/presentation')
32 files changed, 898 insertions, 106 deletions
diff --git a/test/files/presentation/doc.check b/test/files/presentation/doc.check new file mode 100644 index 0000000000..5a3ff13151 --- /dev/null +++ b/test/files/presentation/doc.check @@ -0,0 +1 @@ +reload: Base.scala, Class.scala, Derived.scala diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala new file mode 100755 index 0000000000..f2233f1828 --- /dev/null +++ b/test/files/presentation/doc/doc.scala @@ -0,0 +1,147 @@ +import scala.reflect.internal.util.{ BatchSourceFile, SourceFile } +import scala.tools.nsc.doc +import scala.tools.nsc.doc.base._ +import scala.tools.nsc.doc.base.comment._ +import scala.tools.nsc.interactive._ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest { + val tags = Seq( + "@example `\"abb\".permutations = Iterator(abb, bab, bba)`", + "@version 1.0, 09/07/2012", + "@since 2.10", + "@todo this is unsafe!", + "@note Don't inherit!", + "@see something else" + ) + + val names = Seq("Class", "Def", "Val", "Var", "AbstracType", "TypeAlias", "Trait", "InnerClass") + val bareText = + """abstract class %s { + | def %s = "" + | val %s = "" + | var %s: String = _ + | type %s + | type %s = String + | class %s + |} + |trait %s""".stripMargin.format(names: _*) + + def docComment(nTags: Int) = "/**\n%s*/".format(tags.take(nTags).mkString("\n")) + + def text(name: String, nTags: Int) = { + val nameIndex = bareText.indexOf(name) + val (pre, post) = bareText.splitAt(nameIndex) + val crIndex = pre.lastIndexOf("\n") + val (prepre, prepost) = pre.splitAt(crIndex) + prepre + docComment(nTags) + prepost + post + } + + override lazy val compiler = { + prepareSettings(settings) + new Global(settings, compilerReporter) with MemberLookupBase with CommentFactoryBase with doc.ScaladocGlobalTrait { + outer => + + val global: this.type = this + + override lazy val analyzer = new { + val global: outer.type = outer + } with doc.ScaladocAnalyzer with InteractiveAnalyzer { + override def newTyper(context: Context): InteractiveTyper with ScaladocTyper = + new Typer(context) with InteractiveTyper with ScaladocTyper + } + + def chooseLink(links: List[LinkTo]): LinkTo = links.head + def internalLink(sym: Symbol, site: Symbol) = None + def toString(link: LinkTo) = link.toString + def warnNoLink = false + def findExternalLink(sym: Symbol, name: String) = None + + override def forScaladoc = true + + def getComment(sym: Symbol, source: SourceFile, fragments: List[(Symbol,SourceFile)]): Option[Comment] = { + val docResponse = new Response[(String, String, Position)] + askDocComment(sym, source, sym.owner, fragments, docResponse) + docResponse.get.left.toOption flatMap { + case (expanded, raw, pos) => + if (expanded.isEmpty) + None + else + Some(ask { () => parseAtSymbol(expanded, raw, pos, sym.owner) }) + } + } + } + } + + override def runDefaultTests() { + import compiler._ + def findSource(name: String) = sourceFiles.find(_.file.name == name).get + + val className = names.head + for (name <- names; + i <- 1 to tags.length) { + val newText = text(name, i) + val source = findSource("Class.scala") + val batch = new BatchSourceFile(source.file, newText.toCharArray) + val reloadResponse = new Response[Unit] + compiler.askReload(List(batch), reloadResponse) + reloadResponse.get.left.toOption match { + case None => + println("Couldn't reload") + case Some(_) => + val parseResponse = new Response[Tree] + askParsedEntered(batch, true, parseResponse) + parseResponse.get.left.toOption match { + case None => + println("Couldn't parse") + case Some(_) => + val sym = compiler.ask { () => + val toplevel = compiler.rootMirror.EmptyPackage.info.decl(TypeName(name)) + if (toplevel eq NoSymbol) { + val clazz = compiler.rootMirror.EmptyPackage.info.decl(TypeName(className)) + val term = clazz.info.decl(TermName(name)) + if (term eq NoSymbol) clazz.info.decl(TypeName(name)) else + if (term.isAccessor) term.accessed else term + } else toplevel + } + + getComment(sym, batch, (sym,batch)::Nil) match { + case None => println(s"Got no doc comment for $name") + case Some(comment) => + import comment._ + def cnt(bodies: Iterable[Body]) = bodies.size + val actual = cnt(example) + cnt(version) + cnt(since) + cnt(todo) + cnt(note) + cnt(see) + if (actual != i) + println(s"Got docComment with $actual tags instead of $i, file text:\n$newText") + } + } + } + } + + // Check inter-classes documentation one-time retrieved ok. + val baseSource = findSource("Base.scala") + val derivedSource = findSource("Derived.scala") + def existsText(where: Any, text: String): Boolean = where match { + case s: String => s contains text + case s: Seq[_] => s exists (existsText(_, text)) + case p: Product => p.productIterator exists (existsText(_, text)) + case c: Comment => existsText(c.body, text) + } + val (derived, base) = compiler.ask { () => + val derived = compiler.rootMirror.RootPackage.info.decl(newTermName("p")).info.decl(newTypeName("Derived")) + (derived, derived.ancestors(0)) + } + val cmt1 = getComment(derived, derivedSource, (base, baseSource)::(derived, derivedSource)::Nil) + if (!existsText(cmt1, "This is Derived comment")) + println("Unexpected Derived class comment:"+cmt1) + + val (fooDerived, fooBase) = compiler.ask { () => + val decl = derived.tpe.decl(newTermName("foo")) + (decl, decl.allOverriddenSymbols(0)) + } + + val cmt2 = getComment(fooDerived, derivedSource, (fooBase, baseSource)::(fooDerived, derivedSource)::Nil) + if (!existsText(cmt2, "Base method has documentation")) + println("Unexpected foo method comment:"+cmt2) + } +} diff --git a/test/files/presentation/doc/src/Class.scala b/test/files/presentation/doc/src/Class.scala new file mode 100755 index 0000000000..a974bd6f5c --- /dev/null +++ b/test/files/presentation/doc/src/Class.scala @@ -0,0 +1 @@ +object Class
\ No newline at end of file diff --git a/test/files/presentation/doc/src/p/Base.scala b/test/files/presentation/doc/src/p/Base.scala new file mode 100755 index 0000000000..d91632b6f6 --- /dev/null +++ b/test/files/presentation/doc/src/p/Base.scala @@ -0,0 +1,11 @@ +package p + +/** + * @define BaseComment This is $BaseVar comment. + */ +trait Base { + /** + * Base method has documentation. + */ + def foo: String +} diff --git a/test/files/presentation/doc/src/p/Derived.scala b/test/files/presentation/doc/src/p/Derived.scala new file mode 100755 index 0000000000..1a9c9a26d1 --- /dev/null +++ b/test/files/presentation/doc/src/p/Derived.scala @@ -0,0 +1,9 @@ +package p + +/** + * $BaseComment + * @define BaseVar Derived + */ +class Derived extends Base { + def foo = "" +} diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index d8c7a369f7..12eafcd6de 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -1,111 +1,24 @@ -reload: CrashOnLoad.scala +reload: CrashOnLoad.scala, TestIterable.java -askTypeCompletion at CrashOnLoad.scala(6,12) +askTypeCompletion at CrashOnLoad.scala(6,11) ================================================================================ -[response] askTypeCompletion at (6,12) -retrieved 117 members +[response] askTypeCompletion at (6,11) +retrieved 30 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit -[inaccessible] protected[this] def reversed: List[B] -class GroupedIterator[B >: A] extends AbstractIterator[Seq[B]] with Iterator[Seq[B]] def +(other: String): String -def ++[B >: B](that: => scala.collection.GenTraversableOnce[B]): Iterator[B] -def ->[B](y: B): (java.util.Iterator[B], B) -def /:[B](z: B)(op: (B, B) => B): B -def :\[B](z: B)(op: (B, B) => B): B -def addString(b: StringBuilder): StringBuilder -def addString(b: StringBuilder,sep: String): StringBuilder -def addString(b: StringBuilder,start: String,sep: String,end: String): StringBuilder -def aggregate[B](z: => B)(seqop: (B, B) => B,combop: (B, B) => B): B -def buffered: scala.collection.BufferedIterator[B] -def collectFirst[B](pf: PartialFunction[B,B]): Option[B] -def collect[B](pf: PartialFunction[B,B]): Iterator[B] -def contains(elem: Any): Boolean -def copyToArray[B >: B](xs: Array[B]): Unit -def copyToArray[B >: B](xs: Array[B],start: Int): Unit -def copyToArray[B >: B](xs: Array[B],start: Int,len: Int): Unit -def copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B]): Unit -def corresponds[B](that: scala.collection.GenTraversableOnce[B])(p: (B, B) => Boolean): Boolean -def count(p: B => Boolean): Int -def drop(n: Int): Iterator[B] -def dropWhile(p: B => Boolean): Iterator[B] -def duplicate: (Iterator[B], Iterator[B]) -def ensuring(cond: Boolean): java.util.Iterator[B] -def ensuring(cond: Boolean,msg: => Any): java.util.Iterator[B] -def ensuring(cond: java.util.Iterator[B] => Boolean): java.util.Iterator[B] -def ensuring(cond: java.util.Iterator[B] => Boolean,msg: => Any): java.util.Iterator[B] +def ->[B](y: B): (other.TestIterator[Nothing], B) +def ensuring(cond: Boolean): other.TestIterator[Nothing] +def ensuring(cond: Boolean,msg: => Any): other.TestIterator[Nothing] +def ensuring(cond: other.TestIterator[Nothing] => Boolean): other.TestIterator[Nothing] +def ensuring(cond: other.TestIterator[Nothing] => Boolean,msg: => Any): other.TestIterator[Nothing] def equals(x$1: Any): Boolean -def exists(p: B => Boolean): Boolean -def filter(p: B => Boolean): Iterator[B] -def filterNot(p: B => Boolean): Iterator[B] -def find(p: B => Boolean): Option[B] -def flatMap[B](f: B => scala.collection.GenTraversableOnce[B]): Iterator[B] -def foldLeft[B](z: B)(op: (B, B) => B): B -def foldRight[B](z: B)(op: (B, B) => B): B -def fold[A1 >: B](z: A1)(op: (A1, A1) => A1): A1 -def forall(p: B => Boolean): Boolean -def foreach[U](f: B => U): Unit def formatted(fmtstr: String): String -def grouped[B >: B](size: Int): Iterator[B]#GroupedIterator[B] -def hasDefiniteSize: Boolean -def hasNext(): Boolean +def hasNext: Boolean def hashCode(): Int -def indexOf[B >: B](elem: B): Int -def indexWhere(p: B => Boolean): Int -def isEmpty: Boolean -def isTraversableAgain: Boolean -def length: Int -def map[B](f: B => B): Iterator[B] -def maxBy[B](f: B => B)(implicit cmp: Ordering[B]): B -def max[B >: B](implicit cmp: Ordering[B]): B -def minBy[B](f: B => B)(implicit cmp: Ordering[B]): B -def min[B >: B](implicit cmp: Ordering[B]): B -def mkString(sep: String): String -def mkString(start: String,sep: String,end: String): String -def mkString: String -def next(): B -def nonEmpty: Boolean -def padTo[A1 >: B](len: Int,elem: A1): Iterator[A1] -def partition(p: B => Boolean): (Iterator[B], Iterator[B]) -def patch[B >: B](from: Int,patchElems: Iterator[B],replaced: Int): Iterator[B] -def product[B >: B](implicit num: Numeric[B]): B -def reduceLeftOption[B >: B](op: (B, B) => B): Option[B] -def reduceLeft[B >: B](op: (B, B) => B): B -def reduceOption[A1 >: B](op: (A1, A1) => A1): Option[A1] -def reduceRightOption[B >: B](op: (B, B) => B): Option[B] -def reduceRight[B >: B](op: (B, B) => B): B -def reduce[A1 >: B](op: (A1, A1) => A1): A1 -def remove(): Unit -def sameElements(that: Iterator[_]): Boolean -def scanLeft[B](z: B)(op: (B, B) => B): Iterator[B] -def scanRight[B](z: B)(op: (B, B) => B): Iterator[B] -def seq: Iterator[B] -def size: Int -def slice(from: Int,until: Int): Iterator[B] -def sliding[B >: B](size: Int,step: Int): Iterator[B]#GroupedIterator[B] -def span(p: B => Boolean): (Iterator[B], Iterator[B]) -def sum[B >: B](implicit num: Numeric[B]): B -def take(n: Int): Iterator[B] -def takeWhile(p: B => Boolean): Iterator[B] -def toArray[B >: B](implicit evidence$1: scala.reflect.ClassTag[B]): Array[B] -def toBuffer[B >: B]: scala.collection.mutable.Buffer[B] -def toIndexedSeq: scala.collection.immutable.IndexedSeq[B] -def toIterable: Iterable[B] -def toIterator: Iterator[B] -def toList: List[B] -def toMap[T, U](implicit ev: <:<[B,(T, U)]): scala.collection.immutable.Map[T,U] -def toSeq: Seq[B] -def toSet[B >: B]: scala.collection.immutable.Set[B] -def toStream: scala.collection.immutable.Stream[B] +def next: T def toString(): String -def toTraversable: Traversable[B] -def toVector: Vector[B] -def to[Col[_]](implicit cbf: scala.collection.generic.CanBuildFrom[Nothing,B,Col[B]]): Col[B] -def withFilter(p: B => Boolean): Iterator[B] -def zipAll[B, A1 >: B, B1 >: B](that: Iterator[B],thisElem: A1,thatElem: B1): Iterator[(A1, B1)] -def zipWithIndex: Iterator[(B, Int)] -def zip[B](that: Iterator[B]): Iterator[(B, B)] -def →[B](y: B): (java.util.Iterator[B], B) +def →[B](y: B): (other.TestIterator[Nothing], B) final def !=(x$1: Any): Boolean final def ##(): Int final def ==(x$1: Any): Boolean diff --git a/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala b/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala index 878bbfa19e..3f59282083 100644 --- a/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala +++ b/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala @@ -1,7 +1,14 @@ /** When this files is opened within the IDE, a typing error is reported. */ -class A[B] extends java.lang.Iterable[B] { +class A[B] extends TestIterable[B] { import scala.collection.JavaConversions._ - def iterator = Iterator.empty + def iterator: other.TestIterator[Nothing] = ??? - iterator. /*!*/ -}
\ No newline at end of file + iterator./*!*/ +} + +object other { + trait TestIterator[T] { + def hasNext: Boolean + def next: T + } +} diff --git a/test/files/presentation/ide-bug-1000531/src/TestIterable.java b/test/files/presentation/ide-bug-1000531/src/TestIterable.java new file mode 100644 index 0000000000..84a6fe77f1 --- /dev/null +++ b/test/files/presentation/ide-bug-1000531/src/TestIterable.java @@ -0,0 +1,7 @@ +public abstract class TestIterable<T> { + public abstract TestIterator<T> iterator(); + public static abstract class TestIterator<T> { + public abstract T next(); + public abstract boolean hasNext(); + } +} diff --git a/test/files/presentation/infix-completion.check b/test/files/presentation/infix-completion.check new file mode 100644 index 0000000000..f62dc81d34 --- /dev/null +++ b/test/files/presentation/infix-completion.check @@ -0,0 +1,193 @@ +reload: Snippet.scala + +askTypeCompletion at Snippet.scala(1,34) +================================================================================ +[response] askTypeCompletion at (1,34) +retrieved 192 members +[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type +[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type +[inaccessible] protected def ord: math.Ordering.Double.type +[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean +[inaccessible] protected def unifiedPrimitiveHashcode(): Int +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def !=(x: Byte): Boolean +def !=(x: Char): Boolean +def !=(x: Double): Boolean +def !=(x: Float): Boolean +def !=(x: Int): Boolean +def !=(x: Long): Boolean +def !=(x: Short): Boolean +def %(x: Byte): Int +def %(x: Char): Int +def %(x: Double): Double +def %(x: Float): Float +def %(x: Int): Int +def %(x: Long): Long +def %(x: Short): Int +def &(x: Byte): Int +def &(x: Char): Int +def &(x: Int): Int +def &(x: Long): Long +def &(x: Short): Int +def *(x: Byte): Int +def *(x: Char): Int +def *(x: Double): Double +def *(x: Float): Float +def *(x: Int): Int +def *(x: Long): Long +def *(x: Short): Int +def +(x: Byte): Int +def +(x: Char): Int +def +(x: Double): Double +def +(x: Float): Float +def +(x: Int): Int +def +(x: Long): Long +def +(x: Short): Int +def +(x: String): String +def -(x: Byte): Int +def -(x: Char): Int +def -(x: Double): Double +def -(x: Float): Float +def -(x: Int): Int +def -(x: Long): Long +def -(x: Short): Int +def ->[B](y: B): (Int, B) +def /(x: Byte): Int +def /(x: Char): Int +def /(x: Double): Double +def /(x: Float): Float +def /(x: Int): Int +def /(x: Long): Long +def /(x: Short): Int +def <(x: Byte): Boolean +def <(x: Char): Boolean +def <(x: Double): Boolean +def <(x: Float): Boolean +def <(x: Int): Boolean +def <(x: Long): Boolean +def <(x: Short): Boolean +def <<(x: Int): Int +def <<(x: Long): Int +def <=(x: Byte): Boolean +def <=(x: Char): Boolean +def <=(x: Double): Boolean +def <=(x: Float): Boolean +def <=(x: Int): Boolean +def <=(x: Long): Boolean +def <=(x: Short): Boolean +def ==(x: Byte): Boolean +def ==(x: Char): Boolean +def ==(x: Double): Boolean +def ==(x: Float): Boolean +def ==(x: Int): Boolean +def ==(x: Long): Boolean +def ==(x: Short): Boolean +def >(x: Byte): Boolean +def >(x: Char): Boolean +def >(x: Double): Boolean +def >(x: Float): Boolean +def >(x: Int): Boolean +def >(x: Long): Boolean +def >(x: Short): Boolean +def >=(x: Byte): Boolean +def >=(x: Char): Boolean +def >=(x: Double): Boolean +def >=(x: Float): Boolean +def >=(x: Int): Boolean +def >=(x: Long): Boolean +def >=(x: Short): Boolean +def >>(x: Int): Int +def >>(x: Long): Int +def >>>(x: Int): Int +def >>>(x: Long): Int +def ^(x: Byte): Int +def ^(x: Char): Int +def ^(x: Int): Int +def ^(x: Long): Long +def ^(x: Short): Int +def byteValue(): Byte +def ceil: Double +def compare(y: Double): Int +def compare(y: Long): Int +def compareTo(that: Double): Int +def compareTo(that: Long): Int +def compareTo(x$1: Double): Int +def compareTo(x$1: Long): Int +def doubleValue(): Double +def ensuring(cond: Boolean): Int +def ensuring(cond: Boolean,msg: => Any): Int +def ensuring(cond: Int => Boolean): Int +def ensuring(cond: Int => Boolean,msg: => Any): Int +def equals(x$1: Any): Boolean +def floatValue(): Float +def floor: Double +def formatted(fmtstr: String): String +def hashCode(): Int +def intValue(): Int +def isInfinite(): Boolean +def isInfinity: Boolean +def isNaN(): Boolean +def isNegInfinity: Boolean +def isPosInfinity: Boolean +def isValidLong: Boolean +def longValue(): Long +def round: Long +def shortValue(): Short +def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double] +def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def toBinaryString: String +def toByte: Byte +def toChar: Char +def toDegrees: Double +def toDouble: Double +def toFloat: Float +def toHexString: String +def toInt: Int +def toLong: Long +def toOctalString: String +def toRadians: Double +def toShort: Short +def toString(): String +def unary_+: Int +def unary_-: Int +def unary_~: Int +def underlying(): AnyRef +def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double] +def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def |(x: Byte): Int +def |(x: Char): Int +def |(x: Int): Int +def |(x: Long): Long +def |(x: Short): Int +def →[B](y: B): (Int, B) +final def !=(x$1: Any): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +override def abs: Double +override def isValidByte: Boolean +override def isValidChar: Boolean +override def isValidInt: Boolean +override def isValidShort: Boolean +override def isWhole(): Boolean +override def max(that: Double): Double +override def max(that: Long): Long +override def min(that: Double): Double +override def min(that: Long): Long +override def signum: Int +private[this] val self: Double +================================================================================ diff --git a/test/files/presentation/infix-completion/Runner.scala b/test/files/presentation/infix-completion/Runner.scala new file mode 100644 index 0000000000..1c03e3d5ba --- /dev/null +++ b/test/files/presentation/infix-completion/Runner.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest diff --git a/test/files/presentation/infix-completion/src/Snippet.scala b/test/files/presentation/infix-completion/src/Snippet.scala new file mode 100644 index 0000000000..7e03c486ba --- /dev/null +++ b/test/files/presentation/infix-completion/src/Snippet.scala @@ -0,0 +1 @@ +object Snippet{val x = 123; 1 + 1./*!*/} diff --git a/test/files/presentation/infix-completion2.check b/test/files/presentation/infix-completion2.check new file mode 100644 index 0000000000..5c69cd84cb --- /dev/null +++ b/test/files/presentation/infix-completion2.check @@ -0,0 +1,211 @@ +reload: Snippet.scala + +askTypeCompletion at Snippet.scala(1,34) +================================================================================ +[response] askTypeCompletion at (1,34) +retrieved 211 members +[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type +[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type +[inaccessible] protected def ord: math.Ordering.Double.type +[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean +[inaccessible] protected def unifiedPrimitiveHashcode(): Int +[inaccessible] protected[package lang] def clone(): Object +[inaccessible] protected[package lang] def finalize(): Unit +def !=(x: Byte): Boolean +def !=(x: Char): Boolean +def !=(x: Double): Boolean +def !=(x: Float): Boolean +def !=(x: Int): Boolean +def !=(x: Long): Boolean +def !=(x: Short): Boolean +def %(x: Byte): Int +def %(x: Char): Int +def %(x: Double): Double +def %(x: Float): Float +def %(x: Int): Int +def %(x: Long): Long +def %(x: Short): Int +def &(x: Byte): Int +def &(x: Char): Int +def &(x: Int): Int +def &(x: Long): Long +def &(x: Short): Int +def *(x: Byte): Int +def *(x: Char): Int +def *(x: Double): Double +def *(x: Float): Float +def *(x: Int): Int +def *(x: Long): Long +def *(x: Short): Int +def +(x: Byte): Int +def +(x: Char): Int +def +(x: Double): Double +def +(x: Float): Float +def +(x: Int): Int +def +(x: Long): Long +def +(x: Short): Int +def +(x: String): String +def -(x: Byte): Int +def -(x: Char): Int +def -(x: Double): Double +def -(x: Float): Float +def -(x: Int): Int +def -(x: Long): Long +def -(x: Short): Int +def ->[B](y: B): (Int, B) +def /(x: Byte): Int +def /(x: Char): Int +def /(x: Double): Double +def /(x: Float): Float +def /(x: Int): Int +def /(x: Long): Long +def /(x: Short): Int +def <(x: Byte): Boolean +def <(x: Char): Boolean +def <(x: Double): Boolean +def <(x: Float): Boolean +def <(x: Int): Boolean +def <(x: Long): Boolean +def <(x: Short): Boolean +def <<(x: Int): Int +def <<(x: Long): Int +def <=(x: Byte): Boolean +def <=(x: Char): Boolean +def <=(x: Double): Boolean +def <=(x: Float): Boolean +def <=(x: Int): Boolean +def <=(x: Long): Boolean +def <=(x: Short): Boolean +def ==(x: Byte): Boolean +def ==(x: Char): Boolean +def ==(x: Double): Boolean +def ==(x: Float): Boolean +def ==(x: Int): Boolean +def ==(x: Long): Boolean +def ==(x: Short): Boolean +def >(x: Byte): Boolean +def >(x: Char): Boolean +def >(x: Double): Boolean +def >(x: Float): Boolean +def >(x: Int): Boolean +def >(x: Long): Boolean +def >(x: Short): Boolean +def >=(x: Byte): Boolean +def >=(x: Char): Boolean +def >=(x: Double): Boolean +def >=(x: Float): Boolean +def >=(x: Int): Boolean +def >=(x: Long): Boolean +def >=(x: Short): Boolean +def >>(x: Int): Int +def >>(x: Long): Int +def >>>(x: Int): Int +def >>>(x: Long): Int +def ^(x: Byte): Int +def ^(x: Char): Int +def ^(x: Int): Int +def ^(x: Long): Long +def ^(x: Short): Int +def byteValue(): Byte +def ceil: Double +def compare(y: Double): Int +def compare(y: Float): Int +def compare(y: Int): Int +def compare(y: Long): Int +def compareTo(that: Double): Int +def compareTo(that: Float): Int +def compareTo(that: Int): Int +def compareTo(that: Long): Int +def compareTo(x$1: Double): Int +def compareTo(x$1: Float): Int +def compareTo(x$1: Integer): Int +def compareTo(x$1: Long): Int +def doubleValue(): Double +def ensuring(cond: Boolean): Int +def ensuring(cond: Boolean,msg: => Any): Int +def ensuring(cond: Int => Boolean): Int +def ensuring(cond: Int => Boolean,msg: => Any): Int +def equals(x$1: Any): Boolean +def floatValue(): Float +def floor: Double +def formatted(fmtstr: String): String +def hashCode(): Int +def intValue(): Int +def isInfinite(): Boolean +def isInfinity: Boolean +def isNaN(): Boolean +def isNegInfinity: Boolean +def isPosInfinity: Boolean +def isValidLong: Boolean +def longValue(): Long +def round: Long +def shortValue(): Short +def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double] +def to(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]] +def to(end: Float,step: Float): scala.collection.immutable.NumericRange.Inclusive[Float] +def to(end: Int): scala.collection.immutable.Range.Inclusive +def to(end: Int,step: Int): scala.collection.immutable.Range.Inclusive +def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long] +def toBinaryString: String +def toByte: Byte +def toChar: Char +def toDegrees: Double +def toDouble: Double +def toFloat: Float +def toHexString: String +def toInt: Int +def toLong: Long +def toOctalString: String +def toRadians: Double +def toShort: Short +def toString(): String +def unary_+: Int +def unary_-: Int +def unary_~: Int +def underlying(): AnyRef +def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]] +def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double] +def until(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]] +def until(end: Float,step: Float): scala.collection.immutable.NumericRange.Exclusive[Float] +def until(end: Int): scala.collection.immutable.Range +def until(end: Int,step: Int): scala.collection.immutable.Range +def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long] +def |(x: Byte): Int +def |(x: Char): Int +def |(x: Int): Int +def |(x: Long): Long +def |(x: Short): Int +def →[B](y: B): (Int, B) +final def !=(x$1: Any): Boolean +final def ##(): Int +final def ==(x$1: Any): Boolean +final def asInstanceOf[T0]: T0 +final def eq(x$1: AnyRef): Boolean +final def isInstanceOf[T0]: Boolean +final def ne(x$1: AnyRef): Boolean +final def notify(): Unit +final def notifyAll(): Unit +final def synchronized[T0](x$1: T0): T0 +final def wait(): Unit +final def wait(x$1: Long): Unit +final def wait(x$1: Long,x$2: Int): Unit +override def abs: Double +override def isValidByte: Boolean +override def isValidChar: Boolean +override def isValidInt: Boolean +override def isValidShort: Boolean +override def isWhole(): Boolean +override def max(that: Double): Double +override def max(that: Float): Float +override def max(that: Int): Int +override def max(that: Long): Long +override def min(that: Double): Double +override def min(that: Float): Float +override def min(that: Int): Int +override def min(that: Long): Long +override def signum: Int +private[this] val self: Double +================================================================================ diff --git a/test/files/presentation/infix-completion2/Runner.scala b/test/files/presentation/infix-completion2/Runner.scala new file mode 100644 index 0000000000..1c03e3d5ba --- /dev/null +++ b/test/files/presentation/infix-completion2/Runner.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests._ + +object Test extends InteractiveTest diff --git a/test/files/presentation/infix-completion2/src/Snippet.scala b/test/files/presentation/infix-completion2/src/Snippet.scala new file mode 100644 index 0000000000..4eb8c24a2e --- /dev/null +++ b/test/files/presentation/infix-completion2/src/Snippet.scala @@ -0,0 +1 @@ +object Snippet{val x = 123; 1 + x./*!*/} diff --git a/test/files/presentation/private-case-class-members.check b/test/files/presentation/private-case-class-members.check new file mode 100644 index 0000000000..678f9a34e6 --- /dev/null +++ b/test/files/presentation/private-case-class-members.check @@ -0,0 +1 @@ +Test OK diff --git a/test/files/presentation/private-case-class-members/Test.scala b/test/files/presentation/private-case-class-members/Test.scala new file mode 100644 index 0000000000..e64c8238ea --- /dev/null +++ b/test/files/presentation/private-case-class-members/Test.scala @@ -0,0 +1,34 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.reflect.internal.util.SourceFile +import scala.tools.nsc.interactive.Response + +object Test extends InteractiveTest { + override def execute(): Unit = { + val source = loadSourceAndWaitUntilTypechecked("State.scala") + checkErrors(source) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + compiler.askToDoFirst(sourceFile) + val res = new Response[Unit] + compiler.askReload(List(sourceFile), res) + res.get + askLoadedTyped(sourceFile).get + // the second round of type-checking makes it fail + compiler.askReload(List(sourceFile), res) + res.get + askLoadedTyped(sourceFile).get + + sourceFile + } + + private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => + val problems = unit.problems.toList + if(problems.isEmpty) reporter.println("Test OK") + else problems.foreach(problem => reporter.println(problem.msg)) + + case None => reporter.println("No compilation unit found for " + source.file.name) + } +} diff --git a/test/files/presentation/private-case-class-members/src/State.scala b/test/files/presentation/private-case-class-members/src/State.scala new file mode 100644 index 0000000000..c31817076c --- /dev/null +++ b/test/files/presentation/private-case-class-members/src/State.scala @@ -0,0 +1,5 @@ +object State +case class State(private val foo: Int) + +case class State2(private val foo: Int) +object State2 diff --git a/test/files/presentation/quasiquotes.flags b/test/files/presentation/quasiquotes.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/presentation/quasiquotes.flags diff --git a/test/files/presentation/t7915.check b/test/files/presentation/t7915.check index b18b4ddb55..0849aaa82b 100644 --- a/test/files/presentation/t7915.check +++ b/test/files/presentation/t7915.check @@ -9,3 +9,23 @@ askHyperlinkPos for `bar` at (7,22) Foo.scala ================================================================================ [response] found askHyperlinkPos for `bar` at (2,7) Foo.scala ================================================================================ + +askHyperlinkPos for `Bar` at (8,11) Foo.scala +================================================================================ +[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala +================================================================================ + +askHyperlinkPos for `baz` at (8,22) Foo.scala +================================================================================ +[response] found askHyperlinkPos for `baz` at (2,31) Foo.scala +================================================================================ + +askHyperlinkPos for `Bar` at (9,11) Foo.scala +================================================================================ +[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala +================================================================================ + +askHyperlinkPos for `baz` at (9,22) Foo.scala +================================================================================ +[response] found askHyperlinkPos for `baz` at (2,31) Foo.scala +================================================================================ diff --git a/test/files/presentation/t7915/src/Foo.scala b/test/files/presentation/t7915/src/Foo.scala index a4166ae5b4..5c9ca36a6e 100644 --- a/test/files/presentation/t7915/src/Foo.scala +++ b/test/files/presentation/t7915/src/Foo.scala @@ -1,9 +1,11 @@ class Bar { - def bar(b: Int = 2) {} + def bar(b: Int = 2) {}; def baz[X](b: Int = 2) {} } class Foo { def foo() { new Bar/*#*/().bar/*#*/() + new Bar/*#*/().baz/*#*/[Any]() + new Bar/*#*/().baz/*#*/() } } diff --git a/test/files/presentation/t8459.check b/test/files/presentation/t8459.check new file mode 100644 index 0000000000..336c147141 --- /dev/null +++ b/test/files/presentation/t8459.check @@ -0,0 +1,14 @@ +reload: IncompleteDynamicSelect.scala + +askType at IncompleteDynamicSelect.scala(12,2) +================================================================================ +[response] askTypeAt (12,2) +scala.AnyRef { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + private[this] val bar: F = new F(); + Foo.this.bar.<selectDynamic: error>("<error>") +} +================================================================================ diff --git a/test/files/presentation/t8459/Test.scala b/test/files/presentation/t8459/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/t8459/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest
\ No newline at end of file diff --git a/test/files/presentation/t8459/src/IncompleteDynamicSelect.scala b/test/files/presentation/t8459/src/IncompleteDynamicSelect.scala new file mode 100644 index 0000000000..61976fe2f9 --- /dev/null +++ b/test/files/presentation/t8459/src/IncompleteDynamicSelect.scala @@ -0,0 +1,14 @@ +import scala.language.dynamics + +class F extends Dynamic { + def applyDynamic(name: String)(args: Any*) = + s"method '$name' called with arguments ${args.mkString("'", "', '", "'")}" +} + +class Foo { + val bar = new F + + bar. //note whitespace after dot + /*?*/ //force typechecking +} + diff --git a/test/files/presentation/t8934.check b/test/files/presentation/t8934.check new file mode 100644 index 0000000000..0ece87f808 --- /dev/null +++ b/test/files/presentation/t8934.check @@ -0,0 +1,2 @@ +reload: Source.scala +Test OK diff --git a/test/files/presentation/t8934/Runner.scala b/test/files/presentation/t8934/Runner.scala new file mode 100644 index 0000000000..944f458391 --- /dev/null +++ b/test/files/presentation/t8934/Runner.scala @@ -0,0 +1,27 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.reflect.internal.util.SourceFile +import scala.tools.nsc.interactive.Response + +object Test extends InteractiveTest { + + override def execute(): Unit = { + val src = loadSourceAndWaitUntilTypechecked("Source.scala") + checkErrors(src) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + askReload(List(sourceFile)).get + askLoadedTyped(sourceFile).get + sourceFile + } + + private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => + val problems = unit.problems.toList + if(problems.isEmpty) reporter.println("Test OK") + else problems.foreach(problem => reporter.println(problem.msg)) + + case None => reporter.println("No compilation unit found for " + source.file.name) + } +} diff --git a/test/files/presentation/t8934/src/Source.scala b/test/files/presentation/t8934/src/Source.scala new file mode 100644 index 0000000000..769c8fd38b --- /dev/null +++ b/test/files/presentation/t8934/src/Source.scala @@ -0,0 +1,10 @@ +class Quasi { + import reflect.runtime.universe._ + + def test: Unit = { + (null: Any) match { + case q"$foo($bar)" => + } + () + } +} diff --git a/test/files/presentation/t8941.check b/test/files/presentation/t8941.check new file mode 100644 index 0000000000..341804903a --- /dev/null +++ b/test/files/presentation/t8941.check @@ -0,0 +1,7 @@ +reload: Source.scala + +askType at Source.scala(6,7) +================================================================================ +[response] askTypeAt (6,7) +scala.this.Predef.??? +================================================================================ diff --git a/test/files/presentation/t8941/Runner.scala b/test/files/presentation/t8941/Runner.scala new file mode 100644 index 0000000000..0a8923a583 --- /dev/null +++ b/test/files/presentation/t8941/Runner.scala @@ -0,0 +1,11 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest { + override def runDefaultTests() { + // make sure typer is done.. the virtual pattern matcher might translate + // some trees and mess up positions. But we'll catch it red handed! + // sourceFiles foreach (src => askLoadedTyped(src).get) + super.runDefaultTests() + } + +} diff --git a/test/files/presentation/t8941/src/Source.scala b/test/files/presentation/t8941/src/Source.scala new file mode 100644 index 0000000000..7438cccb03 --- /dev/null +++ b/test/files/presentation/t8941/src/Source.scala @@ -0,0 +1,8 @@ +object Foo { + implicit class MatCreator(val ctx: StringContext) extends AnyVal { + def m(args: Any*): Unit = { + ctx.checkLengths(args) + } + ???/*?*/ + } +} diff --git a/test/files/presentation/t8941b/IdempotencyTest.scala b/test/files/presentation/t8941b/IdempotencyTest.scala new file mode 100644 index 0000000000..af01b36898 --- /dev/null +++ b/test/files/presentation/t8941b/IdempotencyTest.scala @@ -0,0 +1,73 @@ +package scala.tools.nsc +package interactive +package tests.core + +import reporters.{Reporter => CompilerReporter} +import scala.tools.nsc.interactive.InteractiveReporter +import scala.reflect.internal.util.SourceFile + +/** Determistically interrupts typechecking of `code` when a defintion named + * `MagicInterruptionMarker` is typechecked, and then performs a targetted + * typecheck of the tree at the specal comment marker marker + */ +abstract class IdempotencyTest { self => + private val settings = new Settings + settings.usejavacp.value = true + + private object Break extends scala.util.control.ControlThrowable + + private val compilerReporter: CompilerReporter = new InteractiveReporter { + override def compiler = self.compiler + } + + object compiler extends Global(settings, compilerReporter) { + override def checkForMoreWork(pos: Position) { + } + override def signalDone(context: Context, old: Tree, result: Tree) { + // println("signalDone: " + old.toString.take(50).replaceAll("\n", "\\n")) + if (!interrupted && analyzer.lockedCount == 0 && interruptsEnabled && shouldInterrupt(result)) { + interrupted = true + val typed = typedTreeAt(markerPosition) + checkTypedTree(typed) + throw Break + } + super.signalDone(context, old, result) + } + + // we're driving manually using our own thread, disable the check here. + override def assertCorrectThread() {} + } + + import compiler._ + + private var interrupted = false + + // Extension points + protected def code: String + protected def shouldInterrupt(tree: Tree): Boolean = { + tree.symbol != null && tree.symbol.name.toString == "MagicInterruptionMarker" + } + protected def checkTypedTree(tree: Tree): Unit = {} + + + private val source: SourceFile = newSourceFile(code) + private def markerPosition: Position = source.position(code.indexOf("/*?*/")) + + def assertNoProblems() { + val problems = getUnit(source).get.problems + assert(problems.isEmpty, problems.mkString("\n")) + } + + def show() { + reloadSource(source) + try { + typedTree(source, true) + assert(false, "Expected to break out of typechecking.") + } catch { + case Break => // expected + } + assertNoProblems() + } + + def main(args: Array[String]) { show() } +} diff --git a/test/files/presentation/t8941b/Test.scala b/test/files/presentation/t8941b/Test.scala new file mode 100644 index 0000000000..7269a14286 --- /dev/null +++ b/test/files/presentation/t8941b/Test.scala @@ -0,0 +1,53 @@ +import scala.tools.nsc.interactive.tests.core.IdempotencyTest + +// At the time of writing this test, removing any part of `enterExistingSym` +// leads to a failure. +object Test { + def main(args: Array[String]) { + test(""" + object Foo { + def term { + def foo(c: String = "") = c + class MagicInterruptionMarker + foo()/*?*/ + } + } + """) + + test(""" + object Foo { + def term { + def foo = 42 + class MagicInterruptionMarker + foo/*?*/ + } + } + """) + + test(""" + object Foo { + def term { + lazy val foo = 42 + class MagicInterruptionMarker + foo/*?*/ + } + } + """) + + test(""" + object Foo { + implicit class C(val a: String) extends AnyVal + class MagicInterruptionMarker + ""/*?*/ + } + """) + } + + def test(code0: String) { + val t = new IdempotencyTest { + def code = code0 + } + t.show() + } +} + diff --git a/test/files/presentation/visibility/src/Completions.scala b/test/files/presentation/visibility/src/Completions.scala index 8c07934915..69ec3959ad 100644 --- a/test/files/presentation/visibility/src/Completions.scala +++ b/test/files/presentation/visibility/src/Completions.scala @@ -11,7 +11,7 @@ package accessibility { def secretPublic(): Unit def someTests(other: Foo) { - other./*!*/secretPrivate // should be all but scretThis + other./*!*/secretPrivate // should be all but secretThis this./*!*/secretProtected // should hit five completions } @@ -25,7 +25,7 @@ package accessibility { class UnrelatedClass { def someTests(foo: Foo) { - foo./*!*/ // should list public and protected[accessiblity] + foo./*!*/ // should list public and protected[accessibility] } } |