1
- /** @babel */
2
-
3
- import { Point , Range } from "atom"
1
+ import { Point , PointCompatible , Range , RangeCompatible , TextEditor } from "atom"
4
2
5
3
const juliaScopes = [ "source.julia" , "source.embedded.julia" ]
6
4
const openers = [
@@ -21,18 +19,18 @@ const openers = [
21
19
"do" ,
22
20
"quote" ,
23
21
"abstract type" ,
24
- "primitive type"
22
+ "primitive type" ,
25
23
]
26
24
const reopeners = [ "else" , "elseif" , "catch" , "finally" ]
27
25
28
- function isKeywordScope ( scopes ) {
26
+ function isKeywordScope ( scopes : string [ ] ) {
29
27
// Skip 'source.julia'
30
28
return scopes . slice ( 1 ) . some ( scope => {
31
29
return scope . indexOf ( "keyword" ) > - 1
32
30
} )
33
31
}
34
32
35
- export function isStringScope ( scopes ) {
33
+ export function isStringScope ( scopes : readonly string [ ] ) {
36
34
let isString = false
37
35
let isInterp = false
38
36
for ( const scope of scopes ) {
@@ -46,14 +44,14 @@ export function isStringScope(scopes) {
46
44
return isString && ! isInterp
47
45
}
48
46
49
- function forRange ( editor , range ) {
47
+ function forRange ( editor : TextEditor , range : RangeCompatible ) {
50
48
// this should happen here and not a top-level so that we aren't relying on
51
49
// Atom to load packages in a specific order:
52
50
const juliaGrammar = atom . grammars . grammarForScopeName ( "source.julia" )
53
51
54
52
if ( juliaGrammar === undefined ) return [ ]
55
53
56
- const scopes = [ ]
54
+ const scopes : string [ ] = [ ]
57
55
let n_parens = 0
58
56
let n_brackets = 0
59
57
const text = editor . getTextInBufferRange ( range )
@@ -90,14 +88,14 @@ function forRange(editor, range) {
90
88
return scopes
91
89
}
92
90
93
- export function forLines ( editor , start , end ) {
91
+ export function forLines ( editor : TextEditor , start : number , end : number ) {
94
92
const startPoint = new Point ( start , 0 )
95
93
const endPoint = new Point ( end , Infinity )
96
94
const range = new Range ( startPoint , endPoint )
97
95
return forRange ( editor , range )
98
96
}
99
97
100
- export function isCommentScope ( scopes ) {
98
+ export function isCommentScope ( scopes : readonly string [ ] ) {
101
99
// Skip 'source.julia'
102
100
return scopes . slice ( 1 ) . some ( scope => {
103
101
return scope . indexOf ( "comment" ) > - 1
@@ -109,7 +107,7 @@ export function isCommentScope(scopes) {
109
107
* Supposed to be used within Atom-IDE integrations, whose `grammarScopes` setting doesn't support
110
108
* embedded scopes by default.
111
109
*/
112
- export function isValidScopeToInspect ( editor , bufferPosition ) {
110
+ export function isValidScopeToInspect ( editor : TextEditor , bufferPosition : PointCompatible ) {
113
111
const scopes = editor
114
112
. scopeDescriptorForBufferPosition ( bufferPosition )
115
113
. getScopesArray ( )
0 commit comments