是否可以使用Ensime和SBT来定义Scala库类?
我知道可以看到元素的定义(使用M-.或Control +左键单击),从那里可以看到文档页面.有没有办法将此功能绑定到src中?
更新:
我的项目配置(.ensime文件):
(
:root-dir "/Users/eugene/tmp/scrap"
:sources (
"/Users/eugene/tmp/scrap"
)
:reference-source-roots (
"/usr/local/Cellar/scala/2.9.2/libexec/src"
)
:compile-deps (
""
)
:target "/Users/eugene/tmp/scrap"
)
Run Code Online (Sandbox Code Playgroud)
/usr/local/Cellar/scala/2.9.2/libexec/src包含:
scala-compiler-src.jar scala-library-src.jar scala-swing-src.jar
scala-dbc-src.jar scala-partest-src.jar scalap-src.jar
Run Code Online (Sandbox Code Playgroud)
build.sbt:
name := "scrap"
version := "0.1-SNAPSHOT"
scalaVersion := "2.9.2"
Run Code Online (Sandbox Code Playgroud) def isLegalFor(board:Board) =
(board(from), board(to)) match {
case (Nil, _) => false
case (x :: _, Nil) => true
case (x :: _, y :: _) if x < y => true
case (x :: _, y :: _) if x > y => false
}
Run Code Online (Sandbox Code Playgroud)
board(from)和board(to)都是List [Int]
产生警告:
[warn] missing combination * Nil * *
Run Code Online (Sandbox Code Playgroud)
这看起来真的很混乱.第一种情况应该包括list1为空,list2为任何内容.最后三种情况应该包括list1,其中至少有一个元素,list2为空或至少有一个元素.
列表可以是空的也可以不是......这是四个总组合.好像没问题.缺什么?
我不确定squeryl在这里试图告诉我什么:
错误:无法证明org.squeryl.dsl.fsm.Unconditioned =:= org.squeryl.dsl.fsm.Conditioned.
上:
inTransaction {
update(AppDB.postTable) { p =>
where(p.id === postId)
set(p.upVotes := p.upVotes.~ + 1)
}
Run Code Online (Sandbox Code Playgroud)
错误发生在set子句中
模式:
object AppDB extends Schema {
val postTable = table[Post]("post")
val replyTable = table[Reply]("reply")
val postToReplies = oneToManyRelation(postTable, replyTable)
.via((p,r) => p.id === r.postId)
}
case class Post(body: String, image:Option[String]) extends KeyedEntity[Long] {
val id: Long = 0
val posted: Date = new Date()
var upVotes: Long = 0
var downVotes: Long = 0
}
case class Reply(postId: …Run Code Online (Sandbox Code Playgroud)