Class

scala.meta.internal.mtags

OnDemandSymbolIndex

Related Doc: package mtags

Permalink

final case class OnDemandSymbolIndex(toplevels: TrieMap[String, io.AbsolutePath] = TrieMap.empty, definitions: TrieMap[String, io.AbsolutePath] = TrieMap.empty, onError: PartialFunction[Throwable, Unit] = PartialFunction.empty) extends GlobalSymbolIndex with Product with Serializable

An implementation of GlobalSymbolIndex with fast indexing and low memory usage.

Fast indexing is enabled by ScalaToplevelMtags, a custom parser that extracts only toplevel symbols from a Scala source file. Java source files don't need indexing because their file location can be inferred from the symbol with the limitation that it doesn't work for Java source files with multiple package-private top-level classes.

Low memory usage is enabled by only storing "non-trivial toplevel" symbols. A symbol is "toplevel" when its owner is a package. A symbol is "non-trivial" when it doesn't match the path of the file it's defined in, for example Some# in Option.scala is non-trivial while Option# in Option.scala is trivial.

toplevels

keys are non-trivial toplevel symbols and values are the file the symbols are defined in.

definitions

keys are global symbols and the values are the files the symbols are defined in. Difference between toplevels and definitions is that toplevels contains only symbols generated by ScalaToplevelMtags while definitions contains only symbols generated by ScalaMtags.

Linear Supertypes
Serializable, java.io.Serializable, Product, Equals, GlobalSymbolIndex, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OnDemandSymbolIndex
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. GlobalSymbolIndex
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OnDemandSymbolIndex(toplevels: TrieMap[String, io.AbsolutePath] = TrieMap.empty, definitions: TrieMap[String, io.AbsolutePath] = TrieMap.empty, onError: PartialFunction[Throwable, Unit] = PartialFunction.empty)

    Permalink

    toplevels

    keys are non-trivial toplevel symbols and values are the file the symbols are defined in.

    definitions

    keys are global symbols and the values are the files the symbols are defined in. Difference between toplevels and definitions is that toplevels contains only symbols generated by ScalaToplevelMtags while definitions contains only symbols generated by ScalaMtags.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addSourceFile(source: io.AbsolutePath, sourceDirectory: Option[io.AbsolutePath]): Unit

    Permalink

    Add an individual Java or Scala source file to the index.

    Add an individual Java or Scala source file to the index.

    sourceDirectory

    the enclosing project source directory if file is on disk, used to relativize file. Can be None if file is inside a zip file assuming the file path is already relativized by that point.

    Definition Classes
    OnDemandSymbolIndexGlobalSymbolIndex
    Exceptions thrown

    Exception in case of problems processing the source file such as tokenization failure due to an unclosed literal.

  5. def addSourceJar(jar: io.AbsolutePath): Unit

    Permalink

    Index a jar or zip file containing Scala and Java source files.

    Index a jar or zip file containing Scala and Java source files.

    Published artifacts typically have accompanying sources.jar files that include the project sources.

    Sources of a published library can be fetched from the command-line with coursier using the --sources flag:

    $ coursier fetch com.thoughtworks.qdox:qdox:2.0-M9 --sources
    $HOME/.coursier/cache/v1/https/repo1.maven.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9-sources.jar.coursier/cache/v1/https/repo1.maven.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9-sources.jar

    Sources can be fetched from an sbt build through the updateClassifiers task:

    val sourceJars = for {
      configurationReport <- updateClassifiers.in(input).value.configurations
      moduleReport <- configurationReport.modules
      (artifact, file) <- moduleReport.artifacts
      if artifact.classifier.contains("sources")
    } yield file
    jar

    the path to a single jar or zip file.

    Definition Classes
    OnDemandSymbolIndexGlobalSymbolIndex
    Exceptions thrown

    Exception in case of problems processing the source file such as tokenization failure due to an unclosed literal.

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def close(): Unit

    Permalink
  9. def definition(symbol: Symbol): Option[SymbolDefinition]

    Permalink

    Lookup the definition of a global symbol.

    Lookup the definition of a global symbol.

    Returns the path of the file that defines the symbol but does not include the exact position of the definition. Computing the range position of the definition is not handled by this method, it is left for the user and can be done using the mtags module.

    symbol

    a global SemanticDB symbol. For comprehensive documentation of how a symbol is formatted consule the specification: https://scalameta.org/docs/semanticdb/specification.html#symbol Examples:

    "scala/Option#"                 // Option class
    "scala/Option."                 // Option companion object
    "scala/Option#.get()."          // `get` method for Option
    "scala/Predef.String#"          // String type alias in Predef
    "java/lang/String#format(+1)."  // Static `format` method for strings
    "java/util/Map#Entry#"          // Static inner interface.
    returns

    the definition of the symbol, if any.

    Definition Classes
    OnDemandSymbolIndexGlobalSymbolIndex
  10. val definitions: TrieMap[String, io.AbsolutePath]

    Permalink

    keys are global symbols and the values are the files the symbols are defined in.

    keys are global symbols and the values are the files the symbols are defined in. Difference between toplevels and definitions is that toplevels contains only symbols generated by ScalaToplevelMtags while definitions contains only symbols generated by ScalaMtags.

  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. var indexedSources: Long

    Permalink
  15. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  16. val mtags: Mtags

    Permalink
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. val onError: PartialFunction[Throwable, Unit]

    Permalink
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  22. val toplevels: TrieMap[String, io.AbsolutePath]

    Permalink

    keys are non-trivial toplevel symbols and values are the file the symbols are defined in.

  23. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from java.io.Serializable

Inherited from Product

Inherited from Equals

Inherited from GlobalSymbolIndex

Inherited from AnyRef

Inherited from Any

Ungrouped