diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala | 59 |
1 files changed, 1 insertions, 58 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala b/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala index c33675a83a..b3bbeb3169 100644 --- a/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala +++ b/src/compiler/scala/tools/nsc/interpreter/CompletionAware.scala @@ -12,40 +12,15 @@ import scala.reflect.NameTransformer * will supply their own candidates and resolve their own paths. */ trait CompletionAware { - /** The delimiters which are meaningful when this CompletionAware - * object is in control. - */ - // TODO - // def delimiters(): List[Char] = List('.') - /** The complete list of unqualified Strings to which this * object will complete. */ def completions(verbosity: Int): List[String] - /** Default filter to apply to completions. - */ - def filterNotFunction(s: String): Boolean = false - - /** Default sort. - */ - def sortFunction(s1: String, s2: String): Boolean = s1 < s2 - - /** Default map. - */ - def mapFunction(s: String) = NameTransformer decode s - /** The next completor in the chain. */ def follow(id: String): Option[CompletionAware] = None - /** What to return if this completion is given as a command. It - * returns None by default, which means to allow the repl to interpret - * the line normally. Returning Some(_) means the line will never - * reach the scala interpreter. - */ - def execute(id: String): Option[Any] = None - /** A list of useful information regarding a specific uniquely * identified completion. This is specifically written for the * following situation, but should be useful elsewhere too: @@ -75,45 +50,13 @@ trait CompletionAware { else comps else follow(parsed.bufferHead) map (_ completionsFor parsed.bufferTail) getOrElse Nil - results filterNot filterNotFunction map mapFunction sortWith (sortFunction _) - } - - /** TODO - unify this and completionsFor under a common traverser. - */ - def executionFor(parsed: Parsed): Option[Any] = { - import parsed._ - - if (isUnqualified && !isLastDelimiter && (completions(verbosity) contains buffer)) execute(buffer) - else if (!isQualified) None - else follow(bufferHead) flatMap (_ executionFor bufferTail) + results.sorted } } object CompletionAware { val Empty = new CompletionAware { def completions(verbosity: Int) = Nil } - /** Artificial object demonstrating completion */ - // lazy val replVars = CompletionAware( - // Map[String, CompletionAware]( - // "ids" -> CompletionAware(() => unqualifiedIds, completionAware _), - // "synthVars" -> CompletionAware(() => allBoundNames filter isSynthVarName map (_.toString)), - // "types" -> CompletionAware(() => allSeenTypes map (_.toString)), - // "implicits" -> CompletionAware(() => allImplicits map (_.toString)) - // ) - // ) - - // class Forwarder(underlying: CompletionAware) extends CompletionAware { - // override def completions() = underlying.completions() - // override def filterNotFunction(s: String) = underlying.filterNotFunction(s) - // override def sortFunction(s1: String, s2: String) = underlying.sortFunction(s1, s2) - // override def mapFunction(s: String) = underlying.mapFunction(s) - // override def follow(id: String) = underlying.follow(id) - // override def execute(id: String) = underlying.execute(id) - // override def completionsFor(parsed: Parsed) = underlying.completionsFor(parsed) - // override def executionFor(parsed: Parsed) = underlying.executionFor(parsed) - // } - // - def unapply(that: Any): Option[CompletionAware] = that match { case x: CompletionAware => Some((x)) case _ => None |