Skip to content

Commit

Permalink
Add types to docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 14, 2020
1 parent 3b43432 commit aa7daeb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib_src/misc/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { getLine } from "./blocks.js"

import { Point, TextEditor } from "atom"

/**
* @param {TextEditor} editor
* @returns {[Point, Point]}
*/
export function getRange(editor: TextEditor): [Point, Point] {
// Cell range is:
// Start of line below top delimiter (and/or start of top row of file) to
Expand Down Expand Up @@ -48,6 +52,9 @@ export function getRange(editor: TextEditor): [Point, Point] {
return [start, end]
}

/**
* @param {TextEditor} editor
*/
export function get(editor: TextEditor) {
if (editor.getGrammar().scopeName.indexOf("source.julia") > -1) {
return jlGet(editor)
Expand All @@ -56,6 +63,9 @@ export function get(editor: TextEditor) {
}
}

/**
* @param {TextEditor} editor
*/
function jlGet(editor: TextEditor) {
const range = getRange(editor)
let text = editor.getTextInBufferRange(range)
Expand All @@ -72,6 +82,9 @@ function jlGet(editor: TextEditor) {
return [res]
}

/**
* @param {TextEditor | null | undefined} editor
*/
export function moveNext(editor: TextEditor | null | undefined) {
if (!editor) {
editor = atom.workspace.getActiveTextEditor()
Expand All @@ -88,6 +101,9 @@ export function moveNext(editor: TextEditor | null | undefined) {
}
}

/**
* @param {TextEditor} editor
*/
function jlMoveNext(editor: TextEditor) {
const range = getRange(editor)
const sel = editor.getSelections()[0]
Expand All @@ -98,6 +114,9 @@ function jlMoveNext(editor: TextEditor) {
])
}

/**
* @param {TextEditor | undefined | null} editor
*/
export function movePrev(editor: TextEditor | undefined | null) {
if (!editor) {
editor = atom.workspace.getActiveTextEditor()
Expand All @@ -113,6 +132,9 @@ export function movePrev(editor: TextEditor | undefined | null) {
}
}

/**
* @param {TextEditor} editor
*/
function jlMovePrev(editor: TextEditor) {
const range = getRange(editor)
const prevRow = range[0].row - 2 // 2 = 1 to get to delimiter line + 1 more to go past it
Expand Down

0 comments on commit aa7daeb

Please sign in to comment.