Skip to content

Commit 08501f8

Browse files
committed
scopes type definitions + remove babel
Update scopes.ts
1 parent 0fdc409 commit 08501f8

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib_src/misc/scopes.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/** @babel */
2-
3-
import { Point, Range } from "atom"
1+
import {Point, PointCompatible, Range, RangeCompatible, TextEditor} from "atom"
42

53
const juliaScopes = ["source.julia", "source.embedded.julia"]
64
const openers = [
@@ -21,18 +19,18 @@ const openers = [
2119
"do",
2220
"quote",
2321
"abstract type",
24-
"primitive type"
22+
"primitive type",
2523
]
2624
const reopeners = ["else", "elseif", "catch", "finally"]
2725

28-
function isKeywordScope(scopes) {
26+
function isKeywordScope(scopes: string[]) {
2927
// Skip 'source.julia'
3028
return scopes.slice(1).some(scope => {
3129
return scope.indexOf("keyword") > -1
3230
})
3331
}
3432

35-
export function isStringScope(scopes) {
33+
export function isStringScope(scopes: readonly string[]) {
3634
let isString = false
3735
let isInterp = false
3836
for (const scope of scopes) {
@@ -46,14 +44,14 @@ export function isStringScope(scopes) {
4644
return isString && !isInterp
4745
}
4846

49-
function forRange(editor, range) {
47+
function forRange(editor: TextEditor, range: RangeCompatible) {
5048
// this should happen here and not a top-level so that we aren't relying on
5149
// Atom to load packages in a specific order:
5250
const juliaGrammar = atom.grammars.grammarForScopeName("source.julia")
5351

5452
if (juliaGrammar === undefined) return []
5553

56-
const scopes = []
54+
const scopes: string[] = []
5755
let n_parens = 0
5856
let n_brackets = 0
5957
const text = editor.getTextInBufferRange(range)
@@ -90,14 +88,14 @@ function forRange(editor, range) {
9088
return scopes
9189
}
9290

93-
export function forLines(editor, start, end) {
91+
export function forLines(editor: TextEditor, start: number, end: number) {
9492
const startPoint = new Point(start, 0)
9593
const endPoint = new Point(end, Infinity)
9694
const range = new Range(startPoint, endPoint)
9795
return forRange(editor, range)
9896
}
9997

100-
export function isCommentScope(scopes) {
98+
export function isCommentScope(scopes: readonly string[]) {
10199
// Skip 'source.julia'
102100
return scopes.slice(1).some(scope => {
103101
return scope.indexOf("comment") > -1
@@ -109,7 +107,7 @@ export function isCommentScope(scopes) {
109107
* Supposed to be used within Atom-IDE integrations, whose `grammarScopes` setting doesn't support
110108
* embedded scopes by default.
111109
*/
112-
export function isValidScopeToInspect(editor, bufferPosition) {
110+
export function isValidScopeToInspect(editor: TextEditor, bufferPosition: PointCompatible) {
113111
const scopes = editor
114112
.scopeDescriptorForBufferPosition(bufferPosition)
115113
.getScopesArray()

0 commit comments

Comments
 (0)