mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Lint.
This commit is contained in:
@@ -2,23 +2,6 @@ const path = require('path')
|
||||
const SyntaxScopeMap = require('./syntax-scope-map')
|
||||
const Module = require('module')
|
||||
|
||||
tap = x => (console.log(x), x)
|
||||
|
||||
const toSyntaxClasses = scopes =>
|
||||
typeof scopes == 'string'
|
||||
? scopes
|
||||
.split('.')
|
||||
.map(s => `syntax--${s}`)
|
||||
.join(' ')
|
||||
:
|
||||
Array.isArray(scopes)
|
||||
? scopes.map(toSyntaxClasses)
|
||||
:
|
||||
scopes.match
|
||||
? tap({match: new RegExp(scopes.match), scopes: toSyntaxClasses(scopes.scopes)})
|
||||
:
|
||||
Object.assign({}, scopes, {scopes: toSyntaxClasses(scopes.scopes)})
|
||||
|
||||
module.exports =
|
||||
class TreeSitterGrammar {
|
||||
constructor (registry, filePath, params) {
|
||||
@@ -86,3 +69,15 @@ class TreeSitterGrammar {
|
||||
if (this.registration) this.registration.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
const toSyntaxClasses = scopes =>
|
||||
typeof scopes === 'string'
|
||||
? scopes
|
||||
.split('.')
|
||||
.map(s => `syntax--${s}`)
|
||||
.join(' ')
|
||||
: Array.isArray(scopes)
|
||||
? scopes.map(toSyntaxClasses)
|
||||
: scopes.match
|
||||
? {match: new RegExp(scopes.match), scopes: toSyntaxClasses(scopes.scopes)}
|
||||
: Object.assign({}, scopes, {scopes: toSyntaxClasses(scopes.scopes)})
|
||||
|
||||
@@ -919,7 +919,7 @@ class LayerHighlightIterator {
|
||||
const applyLeafRules = (rules, cursor) => {
|
||||
if (!rules || typeof rules === 'string') return rules
|
||||
if (Array.isArray(rules)) {
|
||||
for (let i = 0, {length} = rules; i != length; ++i) {
|
||||
for (let i = 0, {length} = rules; i !== length; ++i) {
|
||||
const result = applyLeafRules(rules[i], cursor)
|
||||
if (result) return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user