| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For the SHIFT-impaired: you can just write everything in lowercase,
(whisper-case?) and we'll try to DWYM.
We treat capital letters that you *do* enter as significant, they
can't match a lower case letter in an identifier.
Modelled after IntellIJ's completion.
I still don't fall into this mode if you enter an exact prefix of
a candidate, but we might consider changing that.
```
scala> classOf[String].typ<TAB>
getAnnotationsByType getComponentType getDeclaredAnnotationsByType getTypeName getTypeParameters
scala> classOf[String].typN<TAB>
scala> classOf[String].getTypeName
res3: String = java.lang.String
scala> def foo(s: str<TAB>
scala> def foo(s: String
String StringBuffer StringBuilder StringCanBuildFrom StringContext StringFormat StringIndexOutOfBoundsException
scala> def foo(s: string<TAB>
scala> def foo(s: String
String StringBuffer StringBuilder StringCanBuildFrom StringContext StringFormat StringIndexOutOfBoundsException
```
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is just too useful to leave on the cutting room floor.
```
scala> classOf[String].enclo<TAB>
scala> classOf[String].getEnclosing
getEnclosingClass getEnclosingConstructor getEnclosingMethod
scala> classOf[String].simpl<TAB>
scala> classOf[String].getSimpleName
type X = global.TTWD<TAB>
scala> type X = global.TypeTreeWithDeferredRefCheck
```
I revised the API of `matchingResults` as it was clunky to reuse
the filtering on accessibility and term/type-ness while providing
a custom name matcher.
|
| |
|
|
|
|
|
| |
Trying harder to keep the synthetic interpretter wrapper classes
behind the curtain
|
|
|
|
|
| |
This makes life easier for clients of these APIs, we use this
to avoid passing this around in the wrapper result `TypeMembers`.
|
|
|
|
| |
Move misplaced and malindented comment and remove two lines of unneeded code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The old implementation is still avaiable under a flag, but we'll
remove it in due course.
Design goal:
- Push as much code in src/interactive as possible to enable reuse
outside of the REPL
- Don't entangle the REPL completion with JLine. The enclosed test
case drives the REPL and autocompletion programatically.
- Don't hard code UI choices, like how to render symbols or
how to filter candidates.
When completion is requested, we wrap the entered code into the
same "interpreter wrapper" synthetic code as is done for regular
execution. We then start a throwaway instance of the presentation
compiler, which takes this as its one and only source file, and
has a classpath formed from the REPL's classpath and the REPL's
output directory (by default, this is in memory).
We can then typecheck the tree, and find the position in the synthetic
source corresponding to the cursor location. This is enough to use
the new completion APIs in the presentation compiler to prepare
a list of candidates.
We go to extra lengths to allow completion of partially typed
identifiers that appear to be keywords, e.g `global.def` should offer
`definitions`.
Two secret handshakes are included; move the the end of the line,
type `// print<TAB>` and you'll see the post-typer tree.
`// typeAt 4 6<TAB>` shows the type of the range position within
the buffer.
The enclosed unit test exercises most of the new functionality.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
val and var members of classes are split into getter/setter and field
symbols. However, we can't call `defString` on any of these and see
what existed in source code.
Example:
```
scala> class X { protected var x: Int = 0 }
defined class X
scala> val xField = typeOf[X].member(TermName("x "))
xField: $r.intp.global.Symbol = variable x
scala> xField.defString
res10: String = private[this] var x: Int
scala> xField.getterIn(xField.owner).defString
res11: String = protected def x: Int
scala> xField.setterIn(xField.owner).defString
res12: String = protected def x_=(x$1: Int): Unit
```
This commit introduces a new method on `Symbol` that pieces together
the information from these symbols to create an artificial symbol
that has the `defString` we're after:
```
scala> xField.sugaredSymbolOrSelf.defString
res14: String = protected var x: Int
```
|
|
|
|
|
|
|
|
| |
In preparation for use of the presentation compiler to drive
REPL tab completion, add a dependency in the build.
As far as the outside world is concerned, these are already comingled
in scala-compiler.jar, and this patch doesn't change that.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Conveniences added:
- The client need not determine ahead of time whether it wants
scope completions of type member completions, this is inferred
from the tree at the cursor
- Computes the delta from the cursor to point where a suggested
completion item should be written. This includes finding the
position of the name within a Select node, which is tricky.
- Includes a matcher that matches results base on prefix,
accessibility and suitability in the syntactic location.
Type members are not offered in term positions, and term members
only offered in type position if they could for a prefix for
a type. E.g. `type T = glob<TAB>` should offer `global` to help
writing `global.Tree`.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The presentation compiler currently demands that all interaction
is performed by asynchronous submission of work items, which are
queued and executed on the presentation compiler thread.
This is fairly inconvenient if you are a known-single-threaded client
that is trying to use the compiler from your own thread.
This commit adds an option to disable "assertCorrectThread" to better
support this use case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Transcript paste mode invites the user to keep typing like
regular paste mode, but really you must enter more transcript.
This matters if the script ends in the middle of incomplete
code that the user wants to complete by hand.
Previously,
```
scala> scala> def f() = {
// Detected repl transcript paste: ctrl-D to finish.
// Replaying 1 commands from transcript.
scala> def f() = {
scala> scala> def f() = {
// Detected repl transcript paste: ctrl-D to finish.
| }
// Replaying 1 commands from transcript.
scala> def f() = {
}
f: ()Unit
```
Now,
```
scala> scala> def f() = {
// Detected repl transcript. Paste more, or ctrl-D to finish.
// Replaying 1 commands from transcript.
scala> def f() = {
| 42
| }
f: ()Int
scala> f()
res0: Int = 42
```
|
|
|
|
|
|
|
|
|
|
|
| |
The classic banner is available under -Dscala.repl.power.banner=classic.
```
scala> :power
Power mode enabled. :phase is at typer.
import scala.tools.nsc._, intp.global._, definitions._
Try :help or completions for vals._ and power._
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix cross talk between candidates in ImplicitComputation#findAll.
Haoyi reported that he couldn't get the presentation compiler
to offer completion suggestions for extension methods on primitive
arrays.
Turns out that an error in typechecking the previous candidate
had not been cleared, and this was taken to mean that `arrayIntOps`
was itself ineligible.
After this patch:
```
scala> Array(1, 2, 3) reverse
reverseIterator reverse reverseMap reversed
scala> Array(1,2,3).reverse //print
scala.Predef.intArrayOps(scala.Array.apply(1, 2, 3)).reverse
scala> Array(1, 2, 3) to
toString toCollection toSeq toIterator to toMap toSet toList
toArray toBuffer toStream toIterable toTraversable toVector toIndexedSeq
scala> Array(1, 2, 3) toSeq
override def toSeq: Seq[Int]
```
|
|\
| |
| | |
SI-6636 Fix macro expansion in toolboxes
|
| | |
|
|\ \
| | |
| | | |
Format and content enhance README.md
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Replace bullet points with tables for
- Review labels
- Command overviews
Rescue sbt section from midst of Ant section.
Syntax correct use of ANT_OPTS.
Synchronise IntelliJ menu path to 14.1.
Update OSS repo name. The Central Repository was formerly known
as Maven Central.
Standardise on @-mention instead of @mention.
Mark unfinished section with TODO.
Include a few other minor improvements.
|
|\ \
| | |
| | | |
Add link to online version of Programming in Scala
|
| | | |
|
|\ \ \
| | | |
| | | | |
SI-9450 Fix triple quoted strings in REPL :power mode
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Some extra synthetic code generated under this mode failed to escape
input before adding it to a literal string. It used to get away with
this most of the time by triple quoting the literal.
This commit reuses Scala string escaping logic buried in `Constant`
to do this properly. Actually, the proper approach would be to build
the synthetic code with trees and quasiquotes, and avoid the mess
of stringly-genererated code.
I threw in some defensive hygiene for the reference to `Nil` while
I was in the neighbourhood.
|
|\ \ \
| |/ /
|/| | |
SI-8346 Re-established soundness of toSet (element type widening)
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
toSet needs to rebuild some child classes, but not others, as toSet is
allowed to widen element types (which the invariant Set normally cannot do),
and some sets rely upon their invariance. Thus, sets that rely upon their
invariance now rebuild themselves into a generic set upon toSet, while those
that do not just sit there.
Note: there was a similar patch previously that fixed the same problem, but
this is a reimplementation to circumvent license issues.
Note: the newBuilder method was benchmarked as (surprisingly!) the most
efficient way to create small sets, so it is used where sets may need to
be rebuild.
|
|\ \
| | |
| | | |
Fix typos in spec, docs and comments
|
| | |
| | |
| | |
| | | |
Since it's a private method, it's safe to just rename it.
|
|/ / |
|
|\ \
| | |
| | | |
Sync commit advice to README.md and fix Scabot URL
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
CONTRIBUTING.md offered different advice on commit subject line length
to README.md. Align CONTRIBUTING to README.
Fix Scabot repo URL
|
|\| |
| | |
| | | |
Extend documentation contacts
|
| |/ |
|
|\ \
| | |
| | | |
Revert "SI-8346 Rebuild invariant sets in #toSet, avoiding CCE"
|
| |/ |
|
|\ \
| | |
| | | |
Fix documentation of Stream.filter introduced in 13f30c
|
| |/ |
|
|\ \
| |/
|/| |
Fix method name reference in Predef documentation
|
|/ |
|
|\
| |
| | |
Improved error message for "filename too long" build errors
|
| |
| |
| |
| |
| |
| |
| |
| | |
When building on ecryptfs filenames can be limited to ~142 characters.
This limit doesn't take long to hit and can leave the the user with a
hard to diagnosis error message. Some legacy file systems will have
similarly small limits. This just adds a hint that the error might
be related to the underlying fs.
|
|\ \
| | |
| | | |
Fix tracing of implicit search under -Ytyper-debug
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The log messages intented to chronicle implicit search were
always being filtered out by virtue of the fact that the the tree
passed to `printTyping` was already typed, (e.g. with an implicit
MethodType.)
This commit enabled printing in this case, although it still
filters out trees that are deemed unfit for typer tracing,
such as `()`. In the context of implicit search, this happens
to filter out the noise of:
```
| | | [search #2] start `()`, searching for adaptation to pt=Unit => Foo[Int,Int] (silent: value <local Test> in Test) implicits disabled
| | | [search #3] start `()`, searching for adaptation to pt=(=> Unit) => Foo[Int,Int] (silent: value <local Test> in Test) implicits disabled
| | | \-> <error>
```
... which I think is desirable.
The motivation for this fix was to better display the interaction
between implicit search and type inference. For instance:
```
class Foo[A, B]
class Test {
implicit val f: Foo[Int, String] = ???
def t[A, B](a: A)(implicit f: Foo[A, B]) = ???
t(1)
}
```
````
% scalac -Ytyper-debug sandbox/instantiate.scala
...
| |-- t(1) BYVALmode-EXPRmode (site: value <local Test> in Test)
| | |-- t BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value <local Test> in Test)
| | | [adapt] [A, B](a: A)(implicit f: Foo[A,B])Nothing adapted to [A, B](a: A)(implicit f: Foo[A,B])Nothing
| | | \-> (a: A)(implicit f: Foo[A,B])Nothing
| | |-- 1 BYVALmode-EXPRmode-POLYmode (site: value <local Test> in Test)
| | | \-> Int(1)
| | solving for (A: ?A, B: ?B)
| | solving for (B: ?B)
| | [search #1] start `[A, B](a: A)(implicit f: Foo[A,B])Nothing` inferring type B, searching for adaptation to pt=Foo[Int,B] (silent: value <local Test> in Test) implicits disabled
| | [search #1] considering f
| | [adapt] f adapted to => Foo[Int,String] based on pt Foo[Int,B]
| | [search #1] solve tvars=?B, tvars.constr= >: String <: String
| | solving for (B: ?B)
| | [search #1] success inferred value of type Foo[Int,=?String] is SearchResult(Test.this.f, TreeTypeSubstituter(List(type B),List(String)))
| | |-- [A, B](a: A)(implicit f: Foo[A,B])Nothing BYVALmode-EXPRmode (site: value <local Test> in Test)
| | | \-> Nothing
| | [adapt] [A, B](a: A)(implicit f: Foo[A,B])Nothing adapted to [A, B](a: A)(implicit f: Foo[A,B])Nothing
| | \-> Nothing
```
|
|\ \ \
| | | |
| | | | |
Fix the bug in the example in scala.sys.process
|
| | | | |
|
| | | |
| | | |
| | | | |
There's no `!` method with argument type `ProcessIO`. I suppose this is intended to be `run`.
|
|\ \ \ \
| | | | |
| | | | | |
SI-8362: AbstractPromise extends AtomicReference, avoids sun.misc.Unsafe
|
| | |_|/
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
To avoid `sun.misc.Unsafe`, which is not supported on Google App Engine.
Deprecate `AbstractPromise` --> extend `j.u.c.atomic.AtomicReference` directly.
`AtomicReference.compareAndSet()` should also provide better performance on
HotSpot, which compiles it down to the machine's CAS instruction.
The binary incompatible change is ok because it's in an internal package.
I can't think of any real issue with adding a superclass (which contributes
only final methods) to a class in an implementation package (as long as
those methods were not introduced in any illicit subclasses of said class).
Instead of changing `DefaultPromise`'s super class, let's be more
conservative, and do it closest to the source. This is both clearer and more
focussed, leaving those subclasses of AbstractPromise we never heard of
unaffected.
Genesis of the commit: since the work on `Future` performance, `AbstractPromise`
is using `Unsafe`, breaking the ability for `Future` to be executed on GAE. At
that time, viktorklang suggested to implement a fallback in case `Unsafe` is
not available. carey proposed an implementation, and mchv submitted a patch,
which was refined by adriaanm.
|
|\ \ \ \
| | | | |
| | | | | |
SI-1931 Hide Predef.any2stringadd in REPL
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
User imports that reference Predef are relocated to the top of
the wrapping template so that they can hide implicits defined
in Predef.
Only one import from Predef is retained for special treatment.
This is simple and sane. The test shows that `import Predef._`
restores Predef implicits even if a user-defined term would
normally be in scope.
A smart `:import` command to turn off or quarantine imports explicitly
would allow fine-grained control.
|