Not recognizing object in IDEA 14.0.2

I upgraded IDEA from 14 to 14.0.2 recently, while aso upgrading the Scala plugin to the latest version. Our project is a mix of Java and scala, but the compiler does not recognize a reference to a declared scala object in another scala file in the same path. There are two scala files. The first is ExcelGenerator.scala

 
package com.ias.core.poi

import java.io.OutputStream
import org.apache.poi.xssf.streaming.SXSSFWorkbook
import java.util.{Date, Calendar}
import org.apache.poi.ss.usermodel.{BuiltinFormats, RichTextString}
import com.ias.util.date.DateUtil


object
ExcelGenerator {

  val ExcelContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

  private val maxCachedRows
= 100
  private val characterWidthMultiplier
= 256

  object
CellStyles {

    sealed trait Style

    case object None extends Style

    case object Date extends Style

    case object DateTime extends Style

    case object Currency extends Style

    case object Percent extends Style

  }

  case class RowElement(element: Any, style: CellStyles.Style = CellStyles.None)

  def create(rows: Seq[Seq[RowElement]], freezeFirstRow: Boolean)(implicit outputStream: OutputStream) {

    val workbook = new SXSSFWorkbook(maxCachedRows)
    val sheet = workbook.createSheet()

    sheet.setDefaultColumnWidth(12)
    val creationHelper = workbook.getCreationHelper

    lazy val dateCellStyle = {
      val style = workbook.createCellStyle
      style.setDataFormat(creationHelper.createDataFormat.getFormat(DateUtil.US_STANDARD_DATE_ONLY)) // [asieland:9/16/13] TODO: might need to change this
      
style
    }

    lazy val dateTimeCellStyle = {
      val style = workbook.createCellStyle
      style.setDataFormat(creationHelper.createDataFormat.getFormat(DateUtil.DATE_AND_TIME_MEDIUM))
      style
    }

    lazy val currencyCellStyle = {
      val style = workbook.createCellStyle
      style.setDataFormat(creationHelper.createDataFormat.getFormat(BuiltinFormats.getBuiltinFormat(5)))
      style
    }

    lazy val percentCellStyle = {
      val style = workbook.createCellStyle
      style.setDataFormat(creationHelper.createDataFormat.getFormat(BuiltinFormats.getBuiltinFormat(0xa)))
      style
    }

    for (rowNum <- 0 until rows.size) {
      val row = sheet.createRow(rowNum)
      for (cellNum <- 0 until rows(rowNum).size) {
        val cell = row.createCell(cellNum)
        rows(rowNum)(cellNum) match {
          case RowElement(x: Int, _) => cell.setCellValue(x) //these are all different method calls and need to be separate
          case RowElement
(x: Double, style) => {
            cell.setCellValue(x)
            if (style == CellStyles.Currency) cell.setCellStyle(currencyCellStyle)
            else if (style == CellStyles.Percent) cell.setCellStyle(percentCellStyle)
          }
          case RowElement(x: Boolean, _) => cell.setCellValue(x)
          case RowElement(x: Date, style) => {
            cell.setCellValue(x)
            if (style == CellStyles.DateTime) cell.setCellStyle(dateTimeCellStyle)
            else cell.setCellStyle(dateCellStyle)
          }
          case RowElement(x: Calendar, style) => {
            cell.setCellValue(x)
            if (style == CellStyles.DateTime) cell.setCellStyle(dateTimeCellStyle)
            else cell.setCellStyle(dateCellStyle)
          }
          case RowElement(x: RichTextString, _) => cell.setCellValue(x)
          case RowElement(x: Any, _) => cell.setCellValue(x.toString)
        }
      }
    }

    if (freezeFirstRow) {
      sheet.createFreezePane(0, 1)
    }

    //size based on column headers
    
(0 until rows.head.size).foreach((i) => sheet.setColumnWidth(i, (rows.head(i).toString.length + 2) * characterWidthMultiplier))

    workbook.write(outputStream)
    workbook.dispose
  }

  def create(header: Seq[String], rows: Seq[Map[String, Any]], freezeHeader: Boolean, styles: Map[String, CellStyles.Style] = Map(),
             keyMapFunc: (String) => String = (x) => x)(implicit outputStream: OutputStream) {
    val sortedRows = for (row <- rows) yield {
      header.map((key) => RowElement(row.getOrElse(keyMapFunc(key), ""), styles.getOrElse(keyMapFunc(key), CellStyles.None)))
    }
    create(Seq(header.map(RowElement(_))) ++ sortedRows, freezeHeader)
  }

  /**
   * Builds an Excel file based on a case class
   * @param header header names in coulmn order to appear
   * @param clazzSeq case class to be Excel-erated
   * @param freezeHeader wether or not to freeze the header bar in place
   * @param keyMapFunc function that accepts a field name and returns the name in header
   * @param outputStream the outputstream to write to
   * @tparam T the type of the case class
   */
  def
fromCaseClass[T <: AnyRef](header: Seq[String], clazzSeq: Seq[T], freezeHeader: Boolean, styles: Map[String, CellStyles.Style] = Map(),
                                 keyMapFunc: (String) => String = (x) => x)(implicit outputStream: OutputStream) {
    val clazzRows = for (clazz <- clazzSeq) yield {
      clazz.getClass.getDeclaredFields.map((field) => {
        field.setAccessible(true)
        (field.getName, field.get(clazz) match {
          case None => ""
          case Some
(x) => x
          case x: Any => x
        })
      }).toMap
    }
    create(header, clazzRows, freezeHeader, styles, keyMapFunc)
  }

  def fromCaseClass[T <: AnyRef](clazzSeq: Seq[T], freezeHeader: Boolean, styles: Map[String, CellStyles.Style] = Map())(implicit outputStream: OutputStream) {
    fromCaseClass(clazzSeq.head.getClass.getDeclaredFields.map(_.getName), clazzSeq, freezeHeader, styles)
  }

}

The second is ExcelCellType.scala:

 
package com.ias.core.poi

import com.ias.core.poi.ExcelGenerator.CellStyles.Style


trait
ExcelCellType {

  def cellType: Option[Style] = None

}

When compiling this second file, I get the following error:
Error:(15, 25) object ExcelGenerator is not a member of package com.ias.core.poi
import com.ias.core.poi.ExcelGenerator.CellStyles.Style
                        ^
Error:(24, 24) not found: type Style
  def cellType: Option[Style] = None
                       ^

Can anyone help me figure out what is gong on?

Thanks,
Boris Zakharin

2 comments
Comment actions Permalink

Hi Boris,
I was not able to reproduce the problem with given files. Can you attach a project example with this issue?

0
Comment actions Permalink

I got it to work. Not sure what I did, but it has something to do with checking "search all symbols" and/or "Resolve to All Classes" in Languages & Frameworks / Scala

0

Please sign in to leave a comment.