Type Boolean does not take parameters

3,140 views
Skip to first unread message

Eric Kolotyluk

unread,
Dec 14, 2011, 2:52:55 PM12/14/11
to Scala IDE User
In the Scala editor I get an error "Type Boolean does not take
parameters", but the compiler does cause the same error. Is this a
bug?

Cheers, Eric

def zip(contentPath:String) = {
Run(zipCommand ::: List(contentPath), Some(workingDirctory))
match {
case NormalResult(process, outLines, errLines) =>
emit("added " + contentPath)
case ErrorResult(process, outLines, errLines) =>
emitError("zip exitValue = " + process.exitValue)
if (!errLines.isEmpty()) { // error
emitError("zip errors:")
emitError(errLines)
}
if (!outLines.isEmpty()) { // error
emitError("zip output:")
emitError(outLines)
}
}
}

iulian dragos

unread,
Dec 14, 2011, 4:40:49 PM12/14/11
to scala-i...@googlegroups.com
On Wed, Dec 14, 2011 at 8:52 PM, Eric Kolotyluk <eric.ko...@gmail.com> wrote:
In the Scala editor I get an error "Type Boolean does not take
parameters", but the compiler does cause the same error. Is this a
bug?

Well, the Boolean type indeed does not take parameters so the compiler is right.

Joke aside, please post the full compilable code, or at least the line where the error occurs. I wish I could guess this, but I cannot.

cheers,
iulian
 

Cheers, Eric

   def zip(contentPath:String) = {
     Run(zipCommand ::: List(contentPath), Some(workingDirctory))
match {
     case NormalResult(process, outLines, errLines) =>
       emit("added " + contentPath)
     case ErrorResult(process, outLines, errLines) =>
       emitError("zip exitValue = " + process.exitValue)
       if (!errLines.isEmpty()) {  // error
         emitError("zip errors:")
         emitError(errLines)
       }
       if (!outLines.isEmpty()) {  // error
         emitError("zip output:")
         emitError(outLines)
       }
     }
   }



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais

Brian Smith

unread,
Dec 14, 2011, 5:08:09 PM12/14/11
to scala-i...@googlegroups.com
Well, the Boolean type indeed does not take parameters so the compiler is right.

Joke aside, please post the full compilable code, or at least the line where the error occurs. I wish I could guess this, but I cannot.

cheers,
iulian

I think it's the two lines with the // error comment on, presumably "isEmpty()" is disliked since it has no parameter list?  Is this scalariform complaining in eclipse which would explain why the compiler doesn't mind on it's own?

Cheers

Brian

Eric Kolotyluk

unread,
Dec 14, 2011, 9:22:34 PM12/14/11
to scala-i...@googlegroups.com
DOH!

I meant the compiler does 'not' cause the same error - just the Eclipse IDE

Here is some more context. I am using Scala 2.9.1

Cheers, Eric

---- Run.scala ----

package com.kodak.intersystem.scripts

import com.kodak.intersystem.common.OperatingSystemFamily
import com.kodak.intersystem.common.Properties
import com.kodak.intersystem.common.Property
import com.kodak.intersystem.common.TimeStamp

import java.io.File

import org.slf4j.Logger

import scala.sys.process.Process
import scala.sys.process.ProcessLogger

/**
 * Create a new O/S process and run it. For example
 * {{{
 * Run(List("command", "arg1", "arg2) match {
 *   case RunResult(process, outString, errString) =>
 *     // handle the normal case
 *   case ErrorResult(process, outString, errString) =>
 *     // handle the exception case
 * }
 * }}}
 *
 * @author Eric Kolotyluk
 * @see <a href="http://www.scala-lang.org/">Scala home</a>
 * @see <a href="http://www.codecommit.com/scala-style-guide.pdf">Style Guide</a>
 */
object Run extends Emitter {
  val properties = Properties.getScriptProperties();    // must call before getLogger() - EK
  override lazy val logger = Properties.getLogger(getClass())

  def apply(command:List[String], workingDirectory:Option[File] = None) : RunResult = {
    logger.info(command.foldLeft("run:") {(string, argument) => string + " " + argument})
    val outBuilder = new StringBuilder()
    val errBuilder = new StringBuilder()
    val processLogger = ProcessLogger(
      (outLine: String) => outBuilder.append(outLine).append("\n"),
      (errLine: String) => errBuilder.append(errLine).append("\n"))
    val processBuilder = Process(command, workingDirectory)
    val process = processBuilder.run(processLogger, false)
    if (process.exitValue() == 0)
      NormalResult(process, outBuilder.toString(), errBuilder.toString())
    else
      ErrorResult(process, outBuilder.toString(), errBuilder.toString())
  }
}

abstract class RunResult
case class NormalResult(process:Process, outString:String, errString:String) extends RunResult
case class ErrorResult(process:Process, outString:String, errString:String) extends RunResult

---- Archive.scala ----

package com.kodak.intersystem.scripts

import com.kodak.intersystem.common.OperatingSystemFamily
import com.kodak.intersystem.common.Properties
import com.kodak.intersystem.common.Property
import com.kodak.intersystem.common.TimeStamp

import java.io.File
import java.util.Calendar

import org.slf4j.Logger

import scala.sys
import scala.sys.env
import scala.sys.process.Process

/**
 * Create an archive and add contents to it. For example
 * {{{
 * Archive(content)
 * }}}
 * or
 * {{{
 * Archive(List(content1, content2, ...))
 * }}}
 *
 * @author Eric Kolotyluk
 * @see <a href="http://www.scala-lang.org/">Scala home</a>
 * @see <a href="http://www.codecommit.com/scala-style-guide.pdf">Style Guide</a>
 */

object Archive extends Emitter {
  val properties = Properties.getScriptProperties();    // must call before getLogger() - EK
  override lazy val logger = Properties.getLogger(getClass())

  val homeDirectory = Property.INTERSYSTEM_HOME.getFile()
  val archiveDirectory = new File(homeDirectory + File.separator + "archive")
 
  def apply(content:String) : Unit = apply(List(content))

  def apply(contents:List[String]) = {

    // Setting up the 7z command is a little tricky to get things to where you want them to go,
    // and how you want them to go. We set up the working directory so that when 7z builds the
    // folder structure in the archive, it will start with the Intersystem folder. The path names
    // of the archive file and directory to be added to the archive must be relative to the
    // working directory. EK

    val workingDirctory = homeDirectory.getParentFile()
    val archivePath = "Intersystem" + File.separator + "archive" +  File.separator + TimeStamp.toString(TimeStamp.getCurrentUTC()).replace(':','-') + ".7z"
    emit("creating archive " + archivePath)
    val zipCommand = List("7z", "a", "-mx", archivePath)

   
    def zip(contentPath:String) = {
      Run(zipCommand ::: List(contentPath), Some(workingDirctory)) match {
      case NormalResult(process, outLines, errLines) =>
        emit("added " + contentPath)
      case ErrorResult(process, outLines, errLines) =>
        emitError("zip exitValue = " + process.exitValue)
        if (!errLines.isEmpty()) {    // THE ERROR OCCURS HERE

          emitError("zip errors:")
          emitError(errLines)
        }
        if (!outLines.isEmpty()) {    // THE ERROR OCCURS HERE AS WELL

          emitError("zip output:")
          emitError(outLines)  
        }
      }
    }
       
    contents.foreach(zip(_))
Reply all
Reply to author
Forward
0 new messages