Sorbet

Sorbet

  • Get started
  • Docs
  • Try
  • Community
  • GitHub
  • Blog

›Editor Features

Getting Started

  • Overview
  • Adopting Sorbet
  • Tracking Adoption
  • Quick Reference
  • Visual Studio Code
  • TypeScript ↔ Sorbet

Static & Runtime

  • Gradual Type Checking
  • Enabling Static Checks
  • Enabling Runtime Checks
  • RBI Files
  • CLI Quickstart
  • CLI Reference
  • Runtime Configuration

Troubleshooting

  • Troubleshooting
  • Why type annotations?
  • FAQ
  • Error Reference
  • Unsupported Ruby Features

Type System

  • sig
  • Type Annotations (non-sig)
  • T.let, T.cast, T.must, T.bind
  • Class Types (Integer, String)
  • Arrays & Hashes
  • Nilable Types (T.nilable)
  • Union Types (T.any)
  • Flow-Sensitivity (is_a?, nil?)
  • T.type_alias
  • Exhaustiveness (T.absurd)
  • T::Struct
  • T::Enum
  • T.untyped
  • Blocks, Procs, & Lambdas
  • Abstract Classes & Interfaces
  • Final Methods & Classes
  • Override Checking
  • Sealed Classes
  • T.class_of
  • T.self_type
  • T.noreturn
  • T.anything
  • T.attached_class
  • Intersection Types (T.all)
  • Generics
  • T::NonForcingConstants
  • Banning untyped

Editor Features

  • Language Server (LSP)
  • Server Status
  • LSP & Typed Level
  • Go to Definition
  • Hover
  • Autocompletion
  • Find All References
  • Code Actions
  • Outline & Document Symbols
  • Documentation Comments
  • Suggesting sigs
  • Highlighting untyped
  • sorbet: URIs

Experimental Features

  • Tuples
  • Shapes
  • Overloads
  • Requiring Ancestors
  • RBS Comments
Edit

Document Outline

Sorbet supports the textDocument/documentSymbol LSP feature, which powers many editor features. In particular, this powers VS Code’s Outline, Breadcrumbs, and Go to Symbol features.

For example, in this screenshot we see VS Code’s Outline view in the left column, and the Breadcrumbs view across the top of the editor:

Another example: this is what we see after pressing ⇧⌘O to bring up the Go to Symbol interface, indicated by the @ as the start of the line:

VS Code Symbol Icons

The icons used to show document symbols are the same as the icons used in completion results. Read the VS Code docs to learn what the icons mean, or see this chart:

Other language clients may use different icons to represent the symbol kinds.

Outlines in Test Files

As a side effect of how Sorbet models describe- and it-style tests, the document outline can be used to navigate tests defined in a file:

Notice how the describe blocks appear as if they were classes and the it blocks appear as if they are methods. This can also be useful with Go to Symbol to jump to a test defined in the current file.

← Code ActionsDocumentation Comments →
  • VS Code Symbol Icons
  • Outlines in Test Files

Get started · Docs · Try · Community · Blog · Twitter