Skip to content

Commit

Permalink
Merge pull request #263 from ssanj/master
Browse files Browse the repository at this point in the history
Add regression test around #252 and fix formatting
  • Loading branch information
lihaoyi committed Nov 17, 2015
2 parents 91ed65b + 1169621 commit c51d83c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions repl/src/main/scala/ammonite/repl/interp/Pressy.scala
Expand Up @@ -116,7 +116,16 @@ object Pressy {

val dotOffset = if (qualifier.pos.point == t.pos.point) 0 else 1

handleTypeCompletion(qualifier.pos.end, name.decoded, dotOffset)
//In scala 2.10.x if we call pos.end on a scala.reflect.internal.util.Position
//that is not a range, a java.lang.UnsupportedOperationException is thrown.
//We check here if Position is a range before calling .end on it.
//This is not needed for scala 2.11.x.
if (qualifier.pos.isRange) {
handleTypeCompletion(qualifier.pos.end, name.decoded, dotOffset)
} else {
//not prefixed
(0, Seq.empty)
}

case t @ pressy.Import(expr, selectors) =>
// If the selectors haven't been defined yet...
Expand Down Expand Up @@ -162,7 +171,7 @@ object Pressy {
val result = Try(Compiler.awaitResponse[List[pressy.Member]](query(position, _)))
result match {
case Success(scopes) => scopes.filter(_.accessible)
case Failure(error) =>List.empty[pressy.Member]
case Failure(error) => List.empty[pressy.Member]
}
}

Expand Down
4 changes: 4 additions & 0 deletions repl/src/test/scala/ammonite/repl/AutocompleteTests.scala
Expand Up @@ -151,6 +151,10 @@ object AutocompleteTests extends TestSuite{
//Assert no NullPointerException was thrown. Does not verify any completions.
complete( """def<caret>""", Set.empty -- _)
}
'Array {
//Test around https://github.com/lihaoyi/Ammonite/issues/252
complete("""new Array<caret>""", Set() ^)
}
}
}
}
Expand Down

0 comments on commit c51d83c

Please sign in to comment.