summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4771 from som-snytt/issue/9492-hereSeth Tisue2015-10-142-16/+37
|\ | | | | SI-9492 REPL paste here doc
| * SI-9492 Line trimming pasteSom Snytt2015-09-272-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use `-` stripmargin character to indicate trim (i.e. remove leading indentation). `<<` looks more like shift left, but is already the standard here doc sequence. Indentation is often mangled by pasting, so trimming normalizes lines for error messages. The entire paste text was already trimmed as a whole. `-Dscala.repl.here` provides a default end string, which is unset unless specified. ``` scala> :pa <- // Entering paste mode (ctrl-D to finish) def g = 10 def f! = 27 -- // Exiting paste mode, now interpreting. <console>:2: error: '=' expected but identifier found. def f! = 27 ^ ```
| * SI-9492 REPL paste here docSom Snytt2015-09-271-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple here documentish syntax for REPL paste. This makes it easier to paste a block of script (as opposed to transcript). It also means you won't accidentally ctl-D out of the REPL and then out of SBT and then out of the terminal window. ``` scala> :paste < EOF // Entering paste mode (EOF to finish) class C { def c = 42 } EOF // Exiting paste mode, now interpreting. defined class C scala> new C().c res0: Int = 42 scala> :paste <| EOF // Entering paste mode (EOF to finish) |class D { def d = 42 } EOF // Exiting paste mode, now interpreting. defined class D scala> new D().d res1: Int = 42 scala> :quit ```
* | Rename forall, exists and find predicate and operator params.Janek Bogucki2015-10-099-71/+86
| | | | | | | | | | | | | | | | | | | | | | | | Align parameters names to use p for predicates and op for combining operations. Based on #4760. Extended to include, - Tuple2Zipped - Tuple3Zipped - Either The original author was vsalvis.
* | SI-9506 suppress Scala IDE-generated files in the Eclipse project dirsPerformant Data LLC2015-10-062-0/+4
| |
* | SI-9506 suppress Scala IDE-generated files in the Eclipse project dirsPerformant Data LLC2015-10-057-0/+14
| |
* | Merge pull request #4782 from performantdata/issue/9502Lukas Rytz2015-10-051-3/+3
|\ \ | | | | | | SI-9502 Update Eclipse classpaths for scaladoc project.
| * | SI-9502 Update Eclipse classpaths for scaladoc project.Michael2015-10-021-3/+3
| | |
* | | Merge pull request #4770 from SethTisue/windows-testing-fixesLukas Rytz2015-10-054-4/+20
|\ \ \ | | | | | | | | get test suite passing on Windows
| * | | add missing newline at eof in Scala sourceSeth Tisue2015-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this was causing a mysterious compilation failure on Windows. (it may not have been a sufficient cause in itself -- which is why I say "mysterious" -- but in any case, adding the newline made the failure go away. and besides, the newline should be there. so here it is.) (it's tempting to make a big commit that fixes this in every source file. resisting for now)
| * | | fix bug in partest-extras causing test failures on WindowsSeth Tisue2015-09-251-2/+7
| | | | | | | | | | | | | | | | includes comment with full details
| * | | fix bug where -Xprint-icode leaked an InputStream and a file handleSeth Tisue2015-09-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | usually it hardly matters, but it's still a bug, and on Windows we can't delete an open file, so this can cause trouble for someone writing a test that relies on being able to generate icode files and then clean them up afterwards. (and in fact, two IcodeComparison-based tests were failing.)
| * | | add comments warning of InputStream leaks in scala.io.reflectSeth Tisue2015-09-251-0/+8
| | | |
* | | | Merge pull request #4777 from retronym/ticket/ide-1002552Lukas Rytz2015-10-051-1/+6
|\ \ \ \ | | | | | | | | | | Improve implicits wildcard imports in the IDE
| * | | | Improve implicits wildcard imports in the IDEJason Zaugg2015-09-301-1/+6
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 451cab967a, I changed handling of selection of members from package objects so as to correctly use `somePackage.package.type` as the prefix, rather than `somePackage`. This fixed generic substitution for members inherited from superclasses of the package object. However, this has subtly changed the scope from which we collect implicits given a wildcard import. It seems that the IDE gets into a situation after a scaladoc lookup, which temporarily typechecks the sources of a package object of a third party library, in which the members of package object differ from the members of the enclosing package. The upshot of this was spurious type errors due to implicit search discarding an candidate implicit whose symbol is not matched by typechecking an identifier with the symbol's name at the implicit usage site (this is how we discard shadowed implicits.) I'd like to ge to the bottom of this, but in the meantime, I've found that we can fix the regression by looking up the implicit member symbols in the package, even while correctly using the package object as the prefix.
* / | | Use InternalCallbackExecutor in Future.sequencePaul Draper2015-10-021-1/+1
|/ / / | | | | | | | | | | | | Previously _.result() was invoked in the "real" ExecutionContext, but this is an unnecessary use of the context.
* | | Fix typo in Process.scalaRyan Zhang2015-09-291-2/+2
| | |
* | | Merge pull request #4720 from retronym/ticket/9029Jason Zaugg2015-09-293-31/+44
|\ \ \ | |_|/ |/| | SI-9029 Fix regression in extractor patterns
| * | SI-9029 Remove unused methodJason Zaugg2015-09-221-5/+0
| | |
| * | SI-8127 Remove dead code in UncurryJason Zaugg2015-09-211-7/+0
| | | | | | | | | | | | | | | It remains from the days of yore, when patterns survived this long in the compiler.
| * | SI-8989 Better error message for invalid extractor patternJason Zaugg2015-09-211-3/+8
| | |
| * | SI-9029 Fix regression in extractor patternsJason Zaugg2015-09-212-16/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unified treatment of classical and named-based pattern matching does not correctly handle the generalization of "tuple capture". By "tuple capture", I mean: ``` scala> object Extractor { def unapply(a: Any): Option[(Int, String)] = Some((1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } scala> "" match { case Extractor(xy : (Int, String)) => } warning: there was one deprecation warning; re-run with -deprecation for details scala> :warnings <console>:9: warning: object Extractor expects 2 patterns to hold (Int, String) but crushing into 2-tuple to fit single pattern (SI-6675) "" match { case Extractor(xy : (Int, String)) => } ^ ``` Name based pattern matching, new in Scala 2.11, allows one to deconstruct the elements that structurally resembles `ProductN`: ``` scala> class P2(val _1: Int, val _2: String) defined class P2 scala> object Extractor { def unapply(a: Any): Option[P2] = Some(new P2(1, "2")) } defined object Extractor scala> "" match { case Extractor(x: Int, y: String) => } ``` However, attempting to extract the `P2` in its entirety leads to an internal error: ``` scala> "" match { case Extractor(p2: P2) => } <console>:10: warning: fruitless type test: a value of type (Int, String) cannot also be a P2 "" match { case Extractor(p2: P2) => } ^ <console>:10: error: error during expansion of this match (this is a scalac bug). The underlying error was: type mismatch; found : P2 required: (Int, String) "" match { case Extractor(p2: P2) => } ^ ``` Note that this match was legal and warning free in 2.10. This commit avoids the hard-coded assumption that the "tuple capture" results in a `TupleN`, and instead keeps track of the product-ish type from which we extracted the element types. I have also opted not to limit the deprecation warning to `TupleN` extractors.
* | | Merge pull request #4674 from kirillkh/2.11.xSeth Tisue2015-09-251-4/+9
|\ \ \ | | | | | | | | add support for MSys2 to bin/scala shell script
| * | | tool-unix: support environments with TERM=cygwinkirillkh2015-08-091-1/+1
| | | |
| * | | add support for MSys2 to bin/scala shell scriptKirill Khazan2015-07-311-3/+8
| | | |
* | | | Merge pull request #4768 from SethTisue/fix-indentationSeth Tisue2015-09-241-1/+1
|\ \ \ \ | |_|_|/ |/| | | fix indentation
| * | | fix indentationSeth Tisue2015-09-241-1/+1
| | | | | | | | | | | | | | | | this sneaked into 2d025fe2d0c9cd0e01e390055b0531166988f901
* | | | Improve presentation compilation of annotationsJason Zaugg2015-09-245-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A trio of problems were hampering autocompletion of annotations. First, given that that annotation is written before the annotated member, it is very common to end parse incomplete code that has a floating annotation without an anotatee. The parser was discarding the annotations (ie, the modifiers) and emitting an `EmptyTree`. Second, the presetation compiler was only looking for annotations in the Modifiers of a member def, but after typechecking annotations are moved into the symbol. Third, if an annotation failed to typecheck, it was being discarded in place of `ErroneousAnnotation`. This commit: - modifies the parser to uses a dummy class- or type-def tree, instead of EmptyTree, which can carry the annotations. - updates the locator to look in the symbol annotations of the modifiers contains no annotations. - uses a separate instance of `ErroneousAnnotation` for each erroneous annotation, and stores the original tree in its `original` tree.
* | | | Support completion in erroneous string interpolation.Jason Zaugg2015-09-241-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the code: ``` s"${fooo<CURSOR" ``` The parser treats `fooo` as a interpolator ID for the quote that we actually intend to end the interpolated string. Inserting a space (in addition to `__CURSOR__` that we already patch in to avoid parsing a partial identifier as a keyword), solves this problem.
* | | Merge pull request #4757 from lrytz/t9375-2.11Lukas Rytz2015-09-222-2/+15
|\ \ \ | | | | | | | | [backport] SI-9375 add synthetic readResolve only for static modules
| * | | [backport] SI-9375 add synthetic readResolve only for static modulesLukas Rytz2015-09-222-2/+15
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | For inner modules, the synthetic readResolve method would cause the module constructor to be invoked on de-serialization in certain situations. See the discussion in the ticket. Adds a comprehensive test around serializing and de-serializing modules.
* | | Merge pull request #4725 from retronym/topic/completely-2.11Lukas Rytz2015-09-2117-154/+596
|\ \ \ | | | | | | | | Topic/completely 2.11
| * | | Remove used param and document positionDeltaJason Zaugg2015-09-213-8/+9
| | | |
| * | | Merge remote-tracking branch 'origin/2.11.x' into topic/completely-2.11Jason Zaugg2015-09-1771-118/+281
| |\ \ \
| * | | | Workaround JLine bug for mid-line tab completionJason Zaugg2015-09-111-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` scala> {" ".char<TAB>} charAt chars scala> {" ".char<CURSOR>}} ``` I noticed that pressing <SPACE>-<BACKSPACE> re-rendered the line correctly, so I've added this workaround to our customization of the JLine console reader. After: ``` scala> {" ".char<TAB>} charAt chars scala> {" ".char<CURSOR>} ``` We can delete this workaround when JLine 2.13.1 is released, but I haven't heard back about when this might happen.
| * | | | Fix REPL completion of symbolic identifiersJason Zaugg2015-09-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recover part of the identifier that preceded the cursor from the source, rather than from the name in the `Select` node, which might contains an encoded name that differs in length from the one in source.
| * | | | Fix completion for synthetic case modules and methodsJason Zaugg2015-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm pretty sure the `isSynthetic` call added in 854de25ee6 should instead be `isArtifact`, so that's what I've implemented here. `isSynthetic` used to also filter out error symbols, which are created with the flags `SYNTHETIC | IS_ERROR`. I've added an addition test for `isError`, which was needed to keep the output of `presentation/scope-completion-import` unchanged. The checkfile for `presentation/callcc-interpreter` is modified to add the additional completion proposals: synthetic companion objects.
| * | | | Hide some completion candidates on the first TABJason Zaugg2015-09-091-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When `foo.<TAB>`, assume you don't want to see the inherited members from Any_ and universally applicable extension methods like `ensuring`. Hitting <TAB> a second time includes them in the results.
| * | | | Fix completion for multi-line entriesJason Zaugg2015-09-093-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to include the previously entered lines into the code that we presentation compile. Management of this state makes the interpret method non tail recursive, so we could blow the default stack with a multi-line entry of hundreds of lines. I think thats an acceptable limitation.
| * | | | More liberal matching in REPL autocompletionJason Zaugg2015-09-091-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
| * | | | Exclude <byname> and friends from REPL completionJason Zaugg2015-09-092-2/+4
| | | | |
| * | | | Camel Case and JavaBean completionJason Zaugg2015-09-082-15/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | Sort completion proposalsJason Zaugg2015-09-031-1/+1
| | | | |
| * | | | Don't offer `asInstanceOf` et al as completions in a fresh REPLJason Zaugg2015-09-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Trying harder to keep the synthetic interpretter wrapper classes behind the curtain
| * | | | Add the prefix the autocompletion results (Scope-, TypeMember)Jason Zaugg2015-09-033-13/+21
| | | | | | | | | | | | | | | | | | | | | | | | | This makes life easier for clients of these APIs, we use this to avoid passing this around in the wrapper result `TypeMembers`.
| * | | | Remove unneeded codeJason Zaugg2015-09-031-5/+3
| | | | | | | | | | | | | | | | | | | | Move misplaced and malindented comment and remove two lines of unneeded code.
| * | | | Use the presentation compiler to drive REPL tab completionJason Zaugg2015-09-0211-53/+317
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | Add a convenience method to Symbol to "resugar" fieldsJason Zaugg2015-09-021-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
| * | | | Publicize method in the presentation compilerJason Zaugg2015-09-021-1/+1
| | | | |
| * | | | Add a higher level completion API to the pres compilerJason Zaugg2015-09-021-1/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.