| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Symbol.scala)

This example Scala source code file (Symbol.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Scala source code examples by using tags.

All credit for the original source code belongs to; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Scala tags/keywords

entry, int, long, option, scalasigsymbol, seq, string, symbol, symbolinfo, symbolinfosymbol

The Symbol.scala Scala example source code

package scalax
package rules
package scalasig

import ScalaSigEntryParsers._

trait Symbol extends Flags {
  def name: String
  def parent: Option[Symbol]
  def children: Seq[Symbol]

  def path: String = + ".").getOrElse("") + name

case object NoSymbol extends Symbol {
  def name = "<no symbol>"
  def parent = None
  def hasFlag(flag: Long) = false
  def children = Nil

abstract class ScalaSigSymbol extends Symbol {
  def applyRule[A](rule: EntryParser[A]): A = expect(rule)(entry)
  def applyScalaSigRule[A](rule: ScalaSigParsers.Parser[A]) = ScalaSigParsers.expect(rule)(entry.scalaSig)

  def entry: ScalaSig#Entry
  def index = entry.index

  lazy val children: Seq[Symbol] = applyScalaSigRule(ScalaSigParsers.symbols) filter (_.parent == Some(this))
  lazy val attributes: Seq[AttributeInfo] = applyScalaSigRule(ScalaSigParsers.attributes) filter (_.symbol == this)

case class ExternalSymbol(name: String, parent: Option[Symbol], entry: ScalaSig#Entry) extends ScalaSigSymbol {
  override def toString = path
  def hasFlag(flag: Long) = false

case class SymbolInfo(name: String, owner: Symbol, flags: Int, privateWithin: Option[AnyRef], info: Int, entry: ScalaSig#Entry) {
  def symbolString(any: AnyRef) = any match {
    case sym: SymbolInfoSymbol => sym.index.toString
    case other => other.toString

  override def toString = name + ", owner=" + symbolString(owner) + ", flags=" + flags.toHexString + ", info=" + info + (privateWithin match {
    case Some(any) => ", privateWithin=" + symbolString(any)
    case None => " "

abstract class SymbolInfoSymbol extends ScalaSigSymbol {
  def symbolInfo: SymbolInfo

  def entry = symbolInfo.entry
  def name =
  def parent = Some(symbolInfo.owner)
  def hasFlag(flag: Long) = (symbolInfo.flags & flag) != 0L

  lazy val infoType = applyRule(parseEntry(typeEntry)(

case class TypeSymbol(symbolInfo: SymbolInfo) extends SymbolInfoSymbol{
  override def path = name

case class AliasSymbol(symbolInfo: SymbolInfo) extends SymbolInfoSymbol{
  override def path = name
case class ClassSymbol(symbolInfo: SymbolInfo, thisTypeRef: Option[Int]) extends SymbolInfoSymbol {
  lazy val selfType ={(x: Int) => applyRule(parseEntry(typeEntry)(x))}
case class ObjectSymbol(symbolInfo: SymbolInfo) extends SymbolInfoSymbol
case class MethodSymbol(symbolInfo: SymbolInfo, aliasRef: Option[Int]) extends SymbolInfoSymbol

Other Scala source code examples

Here is a short list of links related to this Scala Symbol.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.