Merge branch 'master' into electron-4

This commit is contained in:
Rafael Oleza 2019-06-24 10:17:21 +02:00
commit 5b61fbaf3a
33 changed files with 862 additions and 497 deletions

View File

@ -1,4 +1,4 @@
**/spec/fixtures/**/*.js
node_modules
/vendor/
/out/
/out/

View File

@ -1,6 +1,6 @@
# Atom
[![Build status](https://dev.azure.com/github/Atom/_apis/build/status/Atom%20Production%20Branches?branchName=master)](https://dev.azure.com/github/Atom/_build/latest?definitionId=32&branchName=master) [![Linux Build Status](https://travis-ci.org/atom/atom.svg?branch=master)](https://travis-ci.org/atom/atom) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/1tkktwh654w07eim?svg=true)](https://ci.appveyor.com/project/Atom/atom)
[![Build status](https://dev.azure.com/github/Atom/_apis/build/status/Atom%20Production%20Branches?branchName=master)](https://dev.azure.com/github/Atom/_build/latest?definitionId=32&branchName=master) [![Linux Build Status](https://travis-ci.org/atom/atom.svg?branch=master)](https://travis-ci.org/atom/atom)
[![Dependency Status](https://david-dm.org/atom/atom.svg)](https://david-dm.org/atom/atom)
[![Join the Atom Community on Slack](https://atom-slack.herokuapp.com/badge.svg)](https://atom-slack.herokuapp.com)

View File

@ -1,93 +0,0 @@
image: Visual Studio 2015
version: '{build}'
skip_tags: true
clone_folder: c:\projects\atom
clone_depth: 10
branches:
only:
- /^[0-9.]+-releases$/
platform:
- x64
- x86
environment:
global:
ATOM_DEV_RESOURCE_PATH: c:\projects\atom
ATOM_JASMINE_REPORTER: list
CI: true
NODE_VERSION: 10.2.1
matrix:
- TASK: test
- TASK: installer
matrix:
fast_finish: true
exclude:
- platform: x86
TASK: test
install:
- SET PATH=C:\Program Files\Atom\resources\cli;%PATH%
- ps: Install-Product node $env:NODE_VERSION $env:PLATFORM
- npm install --global npm@6.2.0
build_script:
- CD %APPVEYOR_BUILD_FOLDER%
- IF NOT EXIST C:\tmp MKDIR C:\tmp
- SET SQUIRREL_TEMP=C:\tmp
- IF [%APPVEYOR_REPO_BRANCH:~-9%]==[-releases] IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER SET IS_RELEASE_BRANCH=true
- IF [%APPVEYOR_REPO_BRANCH%]==[master] IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER SET IS_SIGNED_ZIP_BRANCH=true
- IF [%APPVEYOR_REPO_BRANCH:~0,9%]==[electron-] IF NOT DEFINED APPVEYOR_PULL_REQUEST_NUMBER SET IS_SIGNED_ZIP_BRANCH=true
- IF [%TASK%]==[installer] (
IF [%IS_RELEASE_BRANCH%]==[true] (
ECHO Building on release branch - Creating production artifacts &&
script\build.cmd --code-sign --compress-artifacts --create-windows-installer
) ELSE (
IF [%IS_SIGNED_ZIP_BRANCH%]==[true] (
ECHO Building on %APPVEYOR_REPO_BRANCH% branch - Creating signed zips &&
script\build.cmd --code-sign --compress-artifacts
) ELSE (
ECHO Skipping installer build for non-release/non-master branch
)
)
) ELSE (
ECHO Test build only - Not creating artifacts &&
script\build.cmd
)
test_script:
- IF [%TASK%]==[test] (
script\lint.cmd &&
script\test.cmd
) ELSE (
ECHO Skipping tests on installer build matrix row
)
deploy: off
artifacts:
- path: out\AtomSetup.exe
name: AtomSetup.exe
- path: out\atom-windows.zip
name: atom-windows.zip
- path: out\RELEASES
name: RELEASES
- path: out\AtomSetup-x64.exe
name: AtomSetup-x64.exe
- path: out\atom-x64-windows.zip
name: atom-x64-windows.zip
- path: out\RELEASES-x64
name: RELEASES-x64
- path: out\atom-*-delta.nupkg
name: atom-delta.nupkg
- path: out\atom-*-full.nupkg
name: atom-full.nupkg
cache:
- '%APPVEYOR_BUILD_FOLDER%\electron'
- '%USERPROFILE%\.atom\.apm'
- '%USERPROFILE%\.atom\compile-cache'

View File

@ -2,7 +2,7 @@
| System | Travis | AppVeyor/Win | VSTS | Dependencies |
|--------|--------|--------------|------------|--------------|
| [Atom](https://github.com/atom/atom) | [![Travis Build Status](https://travis-ci.org/atom/atom.svg?branch=master)](https://travis-ci.org/atom/atom) | [![AppVeyor/Wi Build Status](https://ci.appveyor.com/api/projects/status/1tkktwh654w07eim?svg=true)](https://ci.appveyor.com/project/Atom/atom) | [![Build status](https://github.visualstudio.com/Atom/_apis/build/status/Atom%20Production%20Branches?branch=master)](https://github.visualstudio.com/Atom/_build/latest?definitionId=32&branch=master) | [![Dependency Status](https://david-dm.org/atom/atom.svg)](https://david-dm.org/atom/atom) |
| [Atom](https://github.com/atom/atom) | [![Travis Build Status](https://travis-ci.org/atom/atom.svg?branch=master)](https://travis-ci.org/atom/atom) | | [![Build status](https://github.visualstudio.com/Atom/_apis/build/status/Atom%20Production%20Branches?branch=master)](https://github.visualstudio.com/Atom/_build/latest?definitionId=32&branch=master) | [![Dependency Status](https://david-dm.org/atom/atom.svg)](https://david-dm.org/atom/atom) |
| [APM](https://github.com/atom/apm) | [![Travis Build Status](https://travis-ci.org/atom/apm.svg?branch=master)](https://travis-ci.org/atom/apm) | [![AppVeyor/Wi Build Status](https://ci.appveyor.com/api/projects/status/j6ixw374a397ugkb/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/apm/branch/master) | | [![Dependency Status](https://david-dm.org/atom/apm.svg)](https://david-dm.org/atom/apm) |
| [Electron](https://github.com/electron/electron) | [![Travis Build Status](https://travis-ci.org/electron/electron.svg?branch=master)](https://travis-ci.org/electron/electron) | [![AppVeyor/Wi Build Status](https://ci.appveyor.com/api/projects/status/kvxe4byi7jcxbe26/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/electron) | | [![Dependency Status](https://david-dm.org/electron/electron/dev-status.svg)](https://david-dm.org/electron/electron)

233
package-lock.json generated
View File

@ -35,18 +35,6 @@
"requires": {
"fs-extra": "^7.0.0",
"nan": "^2.10.0"
},
"dependencies": {
"fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
}
}
},
"@atom/source-map-support": {
@ -68,16 +56,6 @@
"prebuild-install": "5.2.4"
},
"dependencies": {
"fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"nan": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz",
@ -2863,8 +2841,8 @@
}
},
"find-and-replace": {
"version": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.13/tarball",
"integrity": "sha512-pLWj62GTg/i2p3IKYLz3sbYtY7SDJvR6ZSOFBJuYNsGde6GBxIY5RLuITmgaHISbwt3q/jIy8DVYGbxVpeFm6A==",
"version": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.14/tarball",
"integrity": "sha512-ceaKDpLAyUmebe0q5aJ9vsiz3bZK8BAR9zDJwo3vl7Lb/GfK1QYrh8UllapOfltGdqCB59sKfAW/c3GBOzvrpA==",
"requires": {
"binary-search": "^1.3.3",
"element-resize-detector": "^1.1.10",
@ -2991,9 +2969,9 @@
"integrity": "sha1-a+Dem+mYzhavivwkSXue6bfM2a0="
},
"fs-extra": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz",
"integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==",
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
@ -3070,8 +3048,8 @@
"integrity": "sha1-gy9kifvodnaUWVmckUpnDsIpR+4="
},
"fuzzy-finder": {
"version": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.13.7/tarball",
"integrity": "sha512-79C7IWrHrPk5UKL48KlcHoFy8T+FGfh/HXRwChkxrLYCrUZSl8a+Bj956j2xIRVanO+lNAnLR5QVyrDhbJ2McA==",
"version": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.13.8/tarball",
"integrity": "sha512-uhBHzD0B42k4KQ+CktomP16nxH/0fxlM9of3r/1bEAAxK4i0+/4Z22Qmxv3qsawo+4DxFUc3P9KCTgjxZHTaBA==",
"requires": {
"@atom/fuzzy-native": "^1.0.3",
"async": "0.2.6",
@ -3192,9 +3170,9 @@
}
},
"git-utils": {
"version": "5.5.1-electron-4.0",
"resolved": "https://registry.npmjs.org/git-utils/-/git-utils-5.5.1-electron-4.0.tgz",
"integrity": "sha512-mvSFHEDW+1SFFGjufxpJA4yGZQJMuvX11yEvw/5xGLlCM/pJvxchlm77PiL8qQn1dL/gKfcZmtPFlrZ/O3wdkg==",
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/git-utils/-/git-utils-5.6.1.tgz",
"integrity": "sha512-wDF7vSbH940NupuMFC87As0x/VSke51P7xTnkdSlk96YN3tzOagXzBUNq5Nq16KOVuMSxcGj1l3qHF5VXl39Ng==",
"requires": {
"fs-plus": "^3.0.0",
"nan": "^2.0.0"
@ -3246,6 +3224,16 @@
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
},
"fs-extra": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz",
"integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"moment": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
@ -3886,11 +3874,11 @@
}
},
"language-c": {
"version": "https://www.atom.io/api/packages/language-c/versions/0.60.17/tarball",
"integrity": "sha512-jGu5Eo/QqqmMM1r62nYJhLdgop/pf4RUUK+udYyp0mOQpU3qPRT+9lVv14/9SDpwkiBB1DQSLJekhVobcD0McQ==",
"version": "https://www.atom.io/api/packages/language-c/versions/0.60.18/tarball",
"integrity": "sha512-q+oTv3QtnLGP8L3qIuWdOQ9XVKskVTsCp8hvURaSz9MGIIjKIK1ssO/r/gkCiBF/AWqaBuglYix4E6RmytHlVg==",
"requires": {
"tree-sitter-c": "^0.13.13",
"tree-sitter-cpp": "^0.13.15"
"tree-sitter-c": "^0.15.0",
"tree-sitter-cpp": "^0.15.0"
}
},
"language-clojure": {
@ -3921,19 +3909,19 @@
"integrity": "sha512-xvsGO/d3/XsKJmwdAz9VGHo6t7A13VuJeuEoZaoLmvzwkVpFdpJcK8PNwVMPHav+lpNeu73qiXmqS+YIlvLwLQ=="
},
"language-go": {
"version": "https://www.atom.io/api/packages/language-go/versions/0.47.0/tarball",
"integrity": "sha512-41lrL5fCPKJSxZ+GUkOemPcDSfme2E2KULuhJGnWLUun5vTrqevtkLgQGAnqH+M/D9zOqJH6H3Lc2kYPrLdUaA==",
"version": "https://www.atom.io/api/packages/language-go/versions/0.47.1/tarball",
"integrity": "sha512-SiySXDxMZ0nUvNCBAClB8sbil0VQi6MJq2ut+jNuNLKtXvO+PtuHxohtbfsSwSYeET0a8ylVahLv1lo0HBgUjw==",
"requires": {
"tree-sitter-go": "^0.13.3"
"tree-sitter-go": "^0.15.0"
}
},
"language-html": {
"version": "https://www.atom.io/api/packages/language-html/versions/0.52.1/tarball",
"integrity": "sha512-39BmsxqzTJcb6u5bSqv/k/bigdZibbMm3BHascMuWHHl5swIQlJhYf+QPR3ozaojNK/aFbx4hj4zDolmlFEKlA==",
"version": "https://www.atom.io/api/packages/language-html/versions/0.52.3/tarball",
"integrity": "sha512-NcEU2LTS76VgnLJIc7sN8QGpiYqTmIPwB+jAv7Wg6kzbt7H0GGZwlUCtHqo7OUFnF9dc++BtDLNKUCNchnh6UA==",
"requires": {
"atom-grammar-test": "^0.6.3",
"tree-sitter-embedded-template": "^0.13.0",
"tree-sitter-html": "^0.13.2"
"tree-sitter-embedded-template": "^0.15.0",
"tree-sitter-html": "^0.15.0"
}
},
"language-hyperlink": {
@ -3945,12 +3933,12 @@
"integrity": "sha512-QXVHoj0eJDbl3pJK+Dm0+vnR1yRB80lSrvThwoVnnxsNphovsglXSGkhHoZ6RbEwkX9fEhtwOrhLUspT2NkG3A=="
},
"language-javascript": {
"version": "https://www.atom.io/api/packages/language-javascript/versions/0.130.0/tarball",
"integrity": "sha512-PHuHeuHivsm8gYZR2FopxhBMIbapFFLdztyao7E9D/qDlayyTGHoGzBVPMBPXWCOh/JUnco8JArhOCAOv83Mng==",
"version": "https://www.atom.io/api/packages/language-javascript/versions/0.130.1/tarball",
"integrity": "sha512-KLz0V7EjpoYQxihWXYiNqFIdbZrOO4lMXg2K7ZA5y8/vb44reOQu1UnOwiC3f6kd1bPyJfv9zR2dUYoXVREy1Q==",
"requires": {
"tree-sitter-javascript": "^0.13.10",
"tree-sitter-jsdoc": "^0.13.4",
"tree-sitter-regex": "^0.13.1"
"tree-sitter-javascript": "^0.15.0",
"tree-sitter-jsdoc": "^0.15.0",
"tree-sitter-regex": "^0.15.0"
}
},
"language-json": {
@ -3989,18 +3977,18 @@
"integrity": "sha512-HD6HI41u57i0/Tu9catiriURhJsef0RDrzJDkGDtdFkE9F9KPxC9Fayq2JBLJrhIyADRVXFxwxsfwQ2Jmh6hxg=="
},
"language-python": {
"version": "https://www.atom.io/api/packages/language-python/versions/0.53.2/tarball",
"integrity": "sha512-ACNHWQWlRUfWrOb5MTvjP2wMTFdAq8Wnd3tWXYEd/TcfECtmCGy+6h33dt9X6SmAZz6OGKQ7V8lnVbOlh3X+Fw==",
"version": "https://www.atom.io/api/packages/language-python/versions/0.53.3/tarball",
"integrity": "sha512-oZJ1WLqpdkpx8ca08jG6BmP/S6YNyu15Q0qMQKAle6ucbK0MagdmpaEcTP/1PkIIncCLaYa1Kdi15QZ+mCva8Q==",
"requires": {
"atom-grammar-test": "^0.6.4",
"tree-sitter-python": "^0.14.0"
"tree-sitter-python": "^0.15.0"
}
},
"language-ruby": {
"version": "https://www.atom.io/api/packages/language-ruby/versions/0.72.16/tarball",
"integrity": "sha512-7Ju9OP+fIo5qvFWFLuSR8KJe7wldZYI8m3ToBcds4v0+Q8i7+xNO2marC0JD72uEiK/x26xP9pYv/isSqTQ4dg==",
"version": "https://www.atom.io/api/packages/language-ruby/versions/0.72.17/tarball",
"integrity": "sha512-Yz+Kq06P07qz6KrC3I9vkMf60HjWTFGZBr8XTZOFs1AyLlHdxhXOnm67Rimlb4deCbGjzLda2JhqRkbUq6Y9FQ==",
"requires": {
"tree-sitter-ruby": "^0.13.12"
"tree-sitter-ruby": "^0.15.0"
}
},
"language-ruby-on-rails": {
@ -4010,7 +3998,7 @@
"language-rust-bundled": {
"version": "file:packages/language-rust-bundled",
"requires": {
"tree-sitter-rust": "^0.13.7"
"tree-sitter-rust": "^0.15.1"
}
},
"language-sass": {
@ -4018,10 +4006,10 @@
"integrity": "sha512-qaH8BDNBOkpbR4thmcRimEphnrzzhpDxeQM+WCM3Unp3a8r3aV2xcY9LlvbZxpclz8TOUyvuc5qgj1YI//ge9w=="
},
"language-shellscript": {
"version": "https://www.atom.io/api/packages/language-shellscript/versions/0.27.11/tarball",
"integrity": "sha512-SgVIqPfJz47jaJOe8d6INI6dIJUhznSsyF3rIyePQoDzimjPIOsgrMQEXYjfHicVts/q4Pa6D6x8v/sn2fTgog==",
"version": "https://www.atom.io/api/packages/language-shellscript/versions/0.27.12/tarball",
"integrity": "sha512-qulEv2pSginsKhMuIrqjBLmuNIEHorAjhNQZRsycW+cKR4c4Py+NEoMoGETEJhzIgxDs7bw7vffbFNRHUCPLgA==",
"requires": {
"tree-sitter-bash": "^0.13.9"
"tree-sitter-bash": "^0.15.0"
}
},
"language-source": {
@ -4045,10 +4033,10 @@
"integrity": "sha512-6xFDqM6nZpynmxGKUS85iUWY0yeub7GYvLyzSOqDejMuOL5UXAITnSNcb7jhr+hQA8KTj5dCmRjphkAQER4Ucg=="
},
"language-typescript": {
"version": "https://www.atom.io/api/packages/language-typescript/versions/0.5.0/tarball",
"integrity": "sha512-rRArdgBSjIxfMceapfPil4n5fraIr3lBWGWuXpRqGvYkmB7scvt01MpbCvdKlJGz/KAd7wKG8criIYqBvy2QDg==",
"version": "https://www.atom.io/api/packages/language-typescript/versions/0.5.2/tarball",
"integrity": "sha512-ji8aJg5QOueUHwwljnhDX/MkGSNReAJ2U0JyrB1HHZSJuYz89w1uSYYkoUfwK05FOkMLQr8kPi6SruZyIcRCUQ==",
"requires": {
"tree-sitter-typescript": "^0.14.0"
"tree-sitter-typescript": "^0.15.1"
}
},
"language-xml": {
@ -5667,12 +5655,12 @@
"integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc="
},
"scandal": {
"version": "3.1.1-electron-4.0",
"resolved": "https://registry.npmjs.org/scandal/-/scandal-3.1.1-electron-4.0.tgz",
"integrity": "sha512-zWLvW9CAkAkczxghs5FHpiXX35tPTmvq69jhlVFbVAnQqpNg1o83V/hZCXqIazgoKuoybhLZnepq7jPgmsKwbA==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/scandal/-/scandal-3.2.0.tgz",
"integrity": "sha512-kXICe3ygxwyyO3Ur+k49UzQlu8yrdQgzD03eMgV8sMWDom9q4qpEvZuQRUcbyAujC1TpISPRUPoirOIO1bRxcQ==",
"requires": {
"argparse": "^1.0.2",
"git-utils": "^5.5.1-electron-4.0",
"git-utils": "^5.6.0",
"isbinaryfile": "^2.0.4",
"minimatch": "^2.0.9",
"split": "^1.0.0",
@ -6175,16 +6163,6 @@
"ms": "^2.1.1"
}
},
"fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
@ -6532,9 +6510,9 @@
"integrity": "sha512-4hjqbObwlh2dLyW4tcz0Ymw0ggoaVDMveUB9w8kFSQScdRLo0gxO9J7WFcUBo+W3C1TLdFIEwNOWebgZZ0RH9Q=="
},
"tree-sitter": {
"version": "0.15.5",
"resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.15.5.tgz",
"integrity": "sha512-3rrww3lc9NNbbVPT1uGkvbom5Ivr/lZqpzru/x+S0Jnh/jHKACNz7ED1JiAPKfR89eLRJxBGh+ZV5g+QqQrQaw==",
"version": "0.15.6",
"resolved": "https://registry.npmjs.org/tree-sitter/-/tree-sitter-0.15.6.tgz",
"integrity": "sha512-OYe9n9Td3iSoGpV39kOZymnjQfkzBaOOzaPEBsAZuBhoVsr+FjLl8IqqyQg8iNNJOEBI5Qc1LbDH1acVXVHIpA==",
"requires": {
"nan": "^2.13.2",
"prebuild-install": "^5.0.0"
@ -6548,26 +6526,26 @@
}
},
"tree-sitter-bash": {
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/tree-sitter-bash/-/tree-sitter-bash-0.13.9.tgz",
"integrity": "sha512-b0L+QLS2eeIVrHnnbkFlvO1nElhPwqTxLIwyTeJytPYT0TS50Pe7bP+uPi3gkHT1YajxcauCxX1aDWDiZK1h5Q==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-bash/-/tree-sitter-bash-0.15.0.tgz",
"integrity": "sha512-rqXLK1S7ILV2W/mHrugruycDIJE/LXZzIqOUAWBXN4cTiFTcCnLlreTAu8nRqpxfPk76qQeJ9Os5D14Comg21Q==",
"requires": {
"nan": "^2.10.0",
"prebuild-install": "^5.0.0"
}
},
"tree-sitter-c": {
"version": "0.13.13",
"resolved": "https://registry.npmjs.org/tree-sitter-c/-/tree-sitter-c-0.13.13.tgz",
"integrity": "sha512-ToGn+YgTnidSN7Y1qYoEUlk6kws+WKsEL7G3GmQ62ZUhxE7Oumom65l+QS0JuQXpLeic4BWhXEhOKugOkYpqzA==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-c/-/tree-sitter-c-0.15.0.tgz",
"integrity": "sha512-TCae6lqrzIoOL0LAbAoC//zrdzqyouJO7zp9qTfVJmlz/BEw5Z6UrnDYNt6n1t1ENPDVgUAjPI8dU0TuZfjF2A==",
"requires": {
"nan": "^2.10.0"
}
},
"tree-sitter-cpp": {
"version": "0.13.15",
"resolved": "https://registry.npmjs.org/tree-sitter-cpp/-/tree-sitter-cpp-0.13.15.tgz",
"integrity": "sha512-S+29FaAfWFCkG02Lw0p4dVFRYnFua9Ua8tY+oFM9ZTgZMaBc7o5rfXVCxNIv5kXKdkHVq0TJWybsFJhtLlQuAw==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-cpp/-/tree-sitter-cpp-0.15.0.tgz",
"integrity": "sha512-ckK6eIGljzEaOrGRR+5aQGQTXgkTcV6iiqZJoSlPSCNbbSjQHztNRFFlV5yWwQxHnpGfgNUdHnQgnEqd3ffObQ==",
"requires": {
"nan": "^2.10.0"
}
@ -6588,49 +6566,56 @@
}
},
"tree-sitter-embedded-template": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/tree-sitter-embedded-template/-/tree-sitter-embedded-template-0.13.0.tgz",
"integrity": "sha512-IJVjMcL2Bg+qF+HibtEXTF4CE6A66ppGSqU8E+2ddn2pCqDtZGREhI+KfqerF9NpKSo1OtbvhXiEXPdXQANLGg==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-embedded-template/-/tree-sitter-embedded-template-0.15.0.tgz",
"integrity": "sha512-LyDtwopMlAHg3T4qeBCywKIMGC4A+a59Y4OaE0LO+UtPVgm5xC3kY+Rq3A9T3Dp6L4ZxZl+zL6LBQA5D0mMnlg==",
"requires": {
"nan": "^2.0.0"
}
},
"tree-sitter-go": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/tree-sitter-go/-/tree-sitter-go-0.13.3.tgz",
"integrity": "sha512-pXnlEDMwrCdnYaOzfEzlMlWqZEKDJXEG4bPvc9j5JSd7IYDWBrwxo+XXuraLSlbj1mJL2kKLIDO8cKDNxUscHw==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-go/-/tree-sitter-go-0.15.0.tgz",
"integrity": "sha512-booht80IETCTTj79Yeicr0UmH9DhZeg8IA58Cf8evuARatbebsUQdh4Zg49Ye+15zVD663/LM+NxkmnJLfq2Rw==",
"requires": {
"nan": "^2.10.0"
}
},
"tree-sitter-html": {
"version": "0.13.5",
"resolved": "https://registry.npmjs.org/tree-sitter-html/-/tree-sitter-html-0.13.5.tgz",
"integrity": "sha512-lawojfDlj/9ujEYvLoW4+WTTh2ocrYCYP2Dw5LmwxuvvE2lHr/D4RWA8W1N4jpR58tVef0SSqnnQwJkl1pNIeA==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-html/-/tree-sitter-html-0.15.0.tgz",
"integrity": "sha512-i8pUX4hNljVpo35D4S+8iopJBU6mS8XRbupjEycjsI7+FSBhr8tnMrx9hjjYhgKYCHdxTnYGTi9K7jc0p3gVDA==",
"requires": {
"nan": "^2.10.0"
}
},
"tree-sitter-javascript": {
"version": "0.13.10",
"resolved": "https://registry.npmjs.org/tree-sitter-javascript/-/tree-sitter-javascript-0.13.10.tgz",
"integrity": "sha512-ku/841Nu7k/VXwI2ifm7xxv2cUiiYztLlIeYTYZXpjaIHMfFer5XZRgmZldJHVthTQ9uRMEr7UQ0qeqnWKzOlg==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-javascript/-/tree-sitter-javascript-0.15.0.tgz",
"integrity": "sha512-1MJ1gO2Bp///UNexxUfGfh5A75Gb5qFxklAhQPgrbWSK6OgjgaHRiYMmW5tRMqoexSp3U2+9bp4j4Nc3Q2lEpg==",
"requires": {
"nan": "^2.4.0"
"nan": "^2.12.1"
},
"dependencies": {
"nan": {
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
}
}
},
"tree-sitter-jsdoc": {
"version": "0.13.4",
"resolved": "https://registry.npmjs.org/tree-sitter-jsdoc/-/tree-sitter-jsdoc-0.13.4.tgz",
"integrity": "sha512-823BIawpN3JegYIhP3tTUlVO+Qc1iaGSl9CEiXt5Lun58TOV56HMnqq6iWgtdcMVcykO24C6Yeovqk+3y20FFw==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-jsdoc/-/tree-sitter-jsdoc-0.15.0.tgz",
"integrity": "sha512-Z5jPAYpB0ofLJYwXTr8oQLBMHqIzMNnpGYKaMVIMpt+wa6ee9pSyy4Uq/tMUQB3qxiYT+66Ij8hu4ou1TNW2CA==",
"requires": {
"nan": "^2.11.1"
},
"dependencies": {
"nan": {
"version": "2.13.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz",
"integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw=="
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
}
}
},
@ -6643,49 +6628,49 @@
}
},
"tree-sitter-python": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/tree-sitter-python/-/tree-sitter-python-0.14.0.tgz",
"integrity": "sha512-Kcj5AUdeI4/c/JLsQV8OFI0zLrwcQ1nKoqCRr+W73Tp5SIK+Dd1ILNC5TFHPw1IqOGstcg8AH0XTeU0uq3boZg==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-python/-/tree-sitter-python-0.15.0.tgz",
"integrity": "sha512-lOV84DUTsyab8xRfU0o8pBQOKAZPjIJsGL7q0buuORHQvvwnvy3iwF/83OGSyiNYRJzPz6gW+E1N/VgNNavMHA==",
"requires": {
"nan": "^2.4.0"
}
},
"tree-sitter-regex": {
"version": "0.13.1",
"resolved": "https://registry.npmjs.org/tree-sitter-regex/-/tree-sitter-regex-0.13.1.tgz",
"integrity": "sha512-A+ULuVOc37NOjmmmddqXMRwUq8g51FCRZ7YSupLdFcHngl1adI3nBRPskC9A8e++9jF+5fLytwA4X6uHW/v/mg==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-regex/-/tree-sitter-regex-0.15.0.tgz",
"integrity": "sha512-e6SWC2vvDwFlTrKZMiqrKz5+6YpOawjb4wh7VyQClpF5fjOC6AeQO0EB0+oWXXKcveFZK0Xdn+cB/zY0GHwYrg==",
"requires": {
"nan": "^2.10.0"
}
},
"tree-sitter-ruby": {
"version": "0.13.14",
"resolved": "https://registry.npmjs.org/tree-sitter-ruby/-/tree-sitter-ruby-0.13.14.tgz",
"integrity": "sha512-ye0Bpzp12HifMoocwhDVR0Adqo7DdR44anPHkx1qhhmdpzMdzsW7WzQYBTJjQo/iFXsgahl/Q9L7AwNI+2cKLw==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/tree-sitter-ruby/-/tree-sitter-ruby-0.15.0.tgz",
"integrity": "sha512-DWLepimzxB6miFLS2dRUQHvQKxEyd3nkzl4WuYvGZEeqiVb3Y4KbzCgk4LCuhmqb+nhONZEgHsNBSN0G6hcpGw==",
"requires": {
"nan": "^2.12.1",
"prebuild-install": "^5.0.0"
},
"dependencies": {
"nan": {
"version": "2.13.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz",
"integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw=="
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
}
}
},
"tree-sitter-rust": {
"version": "0.13.7",
"resolved": "https://registry.npmjs.org/tree-sitter-rust/-/tree-sitter-rust-0.13.7.tgz",
"integrity": "sha512-OX7VlqNhw67yIB69ZhgtJb6sXhwLVwGx991EjLf4PP2bY4dWBgmZ+KxwxN7HBwk9RdUsNLf0KbTwzVRadKhPGw==",
"version": "0.15.1",
"resolved": "https://registry.npmjs.org/tree-sitter-rust/-/tree-sitter-rust-0.15.1.tgz",
"integrity": "sha512-nkuVgr/1QS/IkC1IE9DhjMKbGUUNymrMnRlV6HcOOOsW8s4ubCaL9Yu0M+eyVwSGjiD92xWEZMtt1I5ekUILYg==",
"requires": {
"nan": "^2.8.0"
}
},
"tree-sitter-typescript": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/tree-sitter-typescript/-/tree-sitter-typescript-0.14.0.tgz",
"integrity": "sha512-gx54LvIbjIdqSYGwau5G4Kr7j1oEwfWoZDKrR3jUlINEwskNOXaOzgsSdIM92JnFyqdBU+N6mBHpzjafbJ8EFw==",
"version": "0.15.1",
"resolved": "https://registry.npmjs.org/tree-sitter-typescript/-/tree-sitter-typescript-0.15.1.tgz",
"integrity": "sha512-xntREG9BE+zknNgcwmeVuq5/AT+lVCSUKvhX6T6KoZLk5OPY5EfHrTqGTxS97KDlSRiGfGPheOPMNzIgk/kwNQ==",
"requires": {
"nan": "^2.10.0"
}

View File

@ -54,7 +54,7 @@
"etch": "^0.12.6",
"event-kit": "^2.5.3",
"exception-reporting": "file:packages/exception-reporting",
"find-and-replace": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.13/tarball",
"find-and-replace": "https://www.atom.io/api/packages/find-and-replace/versions/0.218.14/tarball",
"find-parent-dir": "^0.3.0",
"first-mate": "7.4.0",
"focus-trap": "2.4.5",
@ -62,9 +62,9 @@
"fs-plus": "^3.1.1",
"fstream": "0.1.24",
"fuzzaldrin": "^2.1",
"fuzzy-finder": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.13.7/tarball",
"fuzzy-finder": "https://www.atom.io/api/packages/fuzzy-finder/versions/1.13.8/tarball",
"git-diff": "file:packages/git-diff",
"git-utils": "5.5.1-electron-4.0",
"git-utils": "5.6.1",
"github": "https://www.atom.io/api/packages/github/versions/0.29.0/tarball",
"glob": "^7.1.1",
"go-to-line": "file:packages/go-to-line",
@ -77,18 +77,18 @@
"jasmine-tagged": "^1.1.4",
"key-path-helpers": "^0.4.0",
"keybinding-resolver": "https://www.atom.io/api/packages/keybinding-resolver/versions/0.39.0/tarball",
"language-c": "https://www.atom.io/api/packages/language-c/versions/0.60.17/tarball",
"language-c": "https://www.atom.io/api/packages/language-c/versions/0.60.18/tarball",
"language-clojure": "https://www.atom.io/api/packages/language-clojure/versions/0.22.8/tarball",
"language-coffee-script": "https://www.atom.io/api/packages/language-coffee-script/versions/0.50.0/tarball",
"language-csharp": "https://www.atom.io/api/packages/language-csharp/versions/1.1.0/tarball",
"language-css": "https://www.atom.io/api/packages/language-css/versions/0.44.0/tarball",
"language-gfm": "https://www.atom.io/api/packages/language-gfm/versions/0.90.6/tarball",
"language-git": "https://www.atom.io/api/packages/language-git/versions/0.19.1/tarball",
"language-go": "https://www.atom.io/api/packages/language-go/versions/0.47.0/tarball",
"language-html": "https://www.atom.io/api/packages/language-html/versions/0.52.1/tarball",
"language-go": "https://www.atom.io/api/packages/language-go/versions/0.47.1/tarball",
"language-html": "https://www.atom.io/api/packages/language-html/versions/0.52.3/tarball",
"language-hyperlink": "https://www.atom.io/api/packages/language-hyperlink/versions/0.17.1/tarball",
"language-java": "https://www.atom.io/api/packages/language-java/versions/0.31.3/tarball",
"language-javascript": "https://www.atom.io/api/packages/language-javascript/versions/0.130.0/tarball",
"language-javascript": "https://www.atom.io/api/packages/language-javascript/versions/0.130.1/tarball",
"language-json": "https://www.atom.io/api/packages/language-json/versions/1.0.4/tarball",
"language-less": "https://www.atom.io/api/packages/language-less/versions/0.34.3/tarball",
"language-make": "https://www.atom.io/api/packages/language-make/versions/0.23.0/tarball",
@ -97,18 +97,18 @@
"language-perl": "https://www.atom.io/api/packages/language-perl/versions/0.38.1/tarball",
"language-php": "https://www.atom.io/api/packages/language-php/versions/0.44.1/tarball",
"language-property-list": "https://www.atom.io/api/packages/language-property-list/versions/0.9.1/tarball",
"language-python": "https://www.atom.io/api/packages/language-python/versions/0.53.2/tarball",
"language-ruby": "https://www.atom.io/api/packages/language-ruby/versions/0.72.16/tarball",
"language-python": "https://www.atom.io/api/packages/language-python/versions/0.53.3/tarball",
"language-ruby": "https://www.atom.io/api/packages/language-ruby/versions/0.72.17/tarball",
"language-ruby-on-rails": "https://www.atom.io/api/packages/language-ruby-on-rails/versions/0.25.3/tarball",
"language-rust-bundled": "file:packages/language-rust-bundled",
"language-sass": "https://www.atom.io/api/packages/language-sass/versions/0.62.0/tarball",
"language-shellscript": "https://www.atom.io/api/packages/language-shellscript/versions/0.27.11/tarball",
"language-shellscript": "https://www.atom.io/api/packages/language-shellscript/versions/0.27.12/tarball",
"language-source": "https://www.atom.io/api/packages/language-source/versions/0.9.0/tarball",
"language-sql": "https://www.atom.io/api/packages/language-sql/versions/0.25.10/tarball",
"language-text": "https://www.atom.io/api/packages/language-text/versions/0.7.4/tarball",
"language-todo": "https://www.atom.io/api/packages/language-todo/versions/0.29.4/tarball",
"language-toml": "https://www.atom.io/api/packages/language-toml/versions/0.20.0/tarball",
"language-typescript": "https://www.atom.io/api/packages/language-typescript/versions/0.5.0/tarball",
"language-typescript": "https://www.atom.io/api/packages/language-typescript/versions/0.5.2/tarball",
"language-xml": "https://www.atom.io/api/packages/language-xml/versions/0.35.3/tarball",
"language-yaml": "https://www.atom.io/api/packages/language-yaml/versions/0.32.0/tarball",
"less-cache": "1.1.0",
@ -138,7 +138,7 @@
"property-accessors": "^1.1.3",
"random-words": "0.0.1",
"resolve": "^1.1.6",
"scandal": "^3.1.1-electron-4.0",
"scandal": "^3.2.0",
"scoped-property-store": "^0.17.0",
"scrollbar-style": "^3.2",
"season": "^6.0.2",
@ -157,7 +157,7 @@
"temp": "^0.9.0",
"text-buffer": "13.17.0",
"timecop": "https://www.atom.io/api/packages/timecop/versions/0.36.2/tarball",
"tree-sitter": "0.15.5",
"tree-sitter": "0.15.6",
"tree-sitter-css": "^0.13.7",
"tree-view": "https://www.atom.io/api/packages/tree-view/versions/0.228.0/tarball",
"typescript-simple": "1.0.0",
@ -200,8 +200,8 @@
"dev-live-reload": "file:./packages/dev-live-reload",
"encoding-selector": "0.23.9",
"exception-reporting": "file:./packages/exception-reporting",
"find-and-replace": "0.218.13",
"fuzzy-finder": "1.13.7",
"find-and-replace": "0.218.14",
"fuzzy-finder": "1.13.8",
"github": "0.29.0",
"git-diff": "file:./packages/git-diff",
"go-to-line": "file:./packages/go-to-line",
@ -229,18 +229,18 @@
"welcome": "0.36.9",
"whitespace": "0.37.7",
"wrap-guide": "0.41.0",
"language-c": "0.60.17",
"language-c": "0.60.18",
"language-clojure": "0.22.8",
"language-coffee-script": "0.50.0",
"language-csharp": "1.1.0",
"language-css": "0.44.0",
"language-gfm": "0.90.6",
"language-git": "0.19.1",
"language-go": "0.47.0",
"language-html": "0.52.1",
"language-go": "0.47.1",
"language-html": "0.52.3",
"language-hyperlink": "0.17.1",
"language-java": "0.31.3",
"language-javascript": "0.130.0",
"language-javascript": "0.130.1",
"language-json": "1.0.4",
"language-less": "0.34.3",
"language-make": "0.23.0",
@ -249,18 +249,18 @@
"language-perl": "0.38.1",
"language-php": "0.44.1",
"language-property-list": "0.9.1",
"language-python": "0.53.2",
"language-ruby": "0.72.16",
"language-python": "0.53.3",
"language-ruby": "0.72.17",
"language-ruby-on-rails": "0.25.3",
"language-rust-bundled": "file:./packages/language-rust-bundled",
"language-sass": "0.62.0",
"language-shellscript": "0.27.11",
"language-shellscript": "0.27.12",
"language-source": "0.9.0",
"language-sql": "0.25.10",
"language-text": "0.7.4",
"language-todo": "0.29.4",
"language-toml": "0.20.0",
"language-typescript": "0.5.0",
"language-typescript": "0.5.2",
"language-xml": "0.35.3",
"language-yaml": "0.32.0"
},

View File

@ -18,9 +18,25 @@ module.exports = class GrammarListView {
const div = document.createElement('div');
div.classList.add('pull-right');
if (isTreeSitter(grammar)) {
const parser = document.createElement('span');
parser.classList.add(
'grammar-selector-parser',
'badge',
'badge-success'
);
parser.textContent = 'Tree-sitter';
parser.setAttribute(
'title',
'(Recommended) A faster parser with improved syntax highlighting & code navigation support.'
);
div.appendChild(parser);
}
if (grammar.scopeName) {
const scopeName = document.createElement('scopeName');
scopeName.classList.add('key-binding'); // It will be styled the same as the keybindings in the command palette
scopeName.classList.add('badge', 'badge-info');
scopeName.textContent = grammar.scopeName;
div.appendChild(scopeName);
element.appendChild(div);
@ -33,7 +49,7 @@ module.exports = class GrammarListView {
if (grammar === this.autoDetect) {
atom.textEditors.clearGrammarOverride(this.editor);
} else {
atom.textEditors.setGrammarOverride(this.editor, grammar.scopeName);
atom.grammars.assignGrammar(this.editor, grammar);
}
},
didCancelSelection: () => {
@ -72,28 +88,44 @@ module.exports = class GrammarListView {
async toggle() {
if (this.panel != null) {
this.cancel();
} else if (atom.workspace.getActiveTextEditor()) {
this.editor = atom.workspace.getActiveTextEditor();
return;
}
const editor = atom.workspace.getActiveTextEditor();
if (editor) {
this.editor = editor;
this.currentGrammar = this.editor.getGrammar();
if (this.currentGrammar === atom.grammars.nullGrammar) {
this.currentGrammar = this.autoDetect;
}
const grammars = atom.grammars.getGrammars().filter(grammar => {
return grammar !== atom.grammars.nullGrammar && grammar.name;
});
let grammars = atom.grammars
.getGrammars({ includeTreeSitter: true })
.filter(grammar => {
return grammar !== atom.grammars.nullGrammar && grammar.name;
});
if (atom.config.get('grammar-selector.hideDuplicateTextMateGrammars')) {
const blacklist = new Set();
grammars.forEach(grammar => {
if (isTreeSitter(grammar)) {
blacklist.add(grammar.name);
}
});
grammars = grammars.filter(
grammar => isTreeSitter(grammar) || !blacklist.has(grammar.name)
);
}
grammars.sort((a, b) => {
if (a.scopeName === 'text.plain') {
return -1;
} else if (b.scopeName === 'text.plain') {
return 1;
} else if (a.name) {
return a.name.localeCompare(b.name);
} else if (a.scopeName) {
return a.scopeName.localeCompare(b.scopeName);
} else {
return 1;
} else if (a.name === b.name) {
return compareGrammarType(a, b);
}
return a.name.localeCompare(b.name);
});
grammars.unshift(this.autoDetect);
await this.selectListView.update({ items: grammars });
@ -101,3 +133,16 @@ module.exports = class GrammarListView {
}
}
};
function isTreeSitter(grammar) {
return grammar.constructor.name === 'TreeSitterGrammar';
}
function compareGrammarType(a, b) {
if (isTreeSitter(a)) {
return -1;
} else if (isTreeSitter(b)) {
return 1;
}
return 0;
}

View File

@ -37,6 +37,11 @@
"type": "boolean",
"default": true,
"description": "Show the active pane item's language on the right side of Atom's status bar, instead of the left."
},
"hideDuplicateTextMateGrammars": {
"type": "boolean",
"default": true,
"description": "Hides the TextMate grammar when there is an existing Tree-sitter grammar"
}
}
}

View File

@ -7,6 +7,7 @@ describe('GrammarSelector', () => {
beforeEach(async () => {
jasmine.attachToDOM(atom.views.getView(atom.workspace));
atom.config.set('grammar-selector.showOnRightSideOfStatusBar', false);
atom.config.set('grammar-selector.hideDuplicateTextMateGrammars', false);
await atom.packages.activatePackage('status-bar');
await atom.packages.activatePackage('grammar-selector');
@ -27,21 +28,15 @@ describe('GrammarSelector', () => {
describe('when grammar-selector:show is triggered', () =>
it('displays a list of all the available grammars', async () => {
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
const grammarView = (await getGrammarView(editor)).element;
const grammarView = atom.workspace.getModalPanels()[0].getItem().element;
// TODO: Remove once Atom 1.23 reaches stable
if (parseFloat(atom.getVersion()) >= 1.23) {
// Do not take into account the two JS regex grammars or language-with-no-name
expect(grammarView.querySelectorAll('li').length).toBe(
atom.grammars.grammars.length - 3
);
} else {
expect(grammarView.querySelectorAll('li').length).toBe(
atom.grammars.grammars.length - 1
);
}
// -1 for removing nullGrammar, +1 for adding "Auto Detect"
// Tree-sitter names the regex and JSDoc grammars
expect(grammarView.querySelectorAll('li').length).toBe(
atom.grammars
.getGrammars({ includeTreeSitter: true })
.filter(g => g.name).length
);
expect(grammarView.querySelectorAll('li')[0].textContent).toBe(
'Auto Detect'
);
@ -51,31 +46,23 @@ describe('GrammarSelector', () => {
.forEach(li =>
expect(li.textContent).not.toBe(atom.grammars.nullGrammar.name)
);
expect(grammarView.textContent.includes('Tree-sitter')).toBe(true); // check we are showing and labelling Tree-sitter grammars
}));
describe('when a grammar is selected', () =>
it('sets the new grammar on the editor', async () => {
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
const grammarView = atom.workspace.getModalPanels()[0].getItem();
const grammarView = await getGrammarView(editor);
grammarView.props.didConfirmSelection(textGrammar);
expect(editor.getGrammar()).toBe(textGrammar);
}));
describe('when auto-detect is selected', () =>
it('restores the auto-detected grammar on the editor', async () => {
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
let grammarView = atom.workspace.getModalPanels()[0].getItem();
let grammarView = await getGrammarView(editor);
grammarView.props.didConfirmSelection(textGrammar);
expect(editor.getGrammar()).toBe(textGrammar);
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
grammarView = atom.workspace.getModalPanels()[0].getItem();
grammarView = await getGrammarView(editor);
grammarView.props.didConfirmSelection(grammarView.items[0]);
expect(editor.getGrammar()).toBe(jsGrammar);
}));
@ -83,10 +70,7 @@ describe('GrammarSelector', () => {
describe("when the editor's current grammar is the null grammar", () =>
it('displays Auto Detect as the selected grammar', async () => {
editor.setGrammar(atom.grammars.nullGrammar);
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
const grammarView = atom.workspace.getModalPanels()[0].getItem().element;
const grammarView = (await getGrammarView(editor)).element;
expect(grammarView.querySelector('li.active').textContent).toBe(
'Auto Detect'
);
@ -97,10 +81,7 @@ describe('GrammarSelector', () => {
editor = await atom.workspace.open();
expect(editor.getGrammar()).not.toBe(jsGrammar);
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
const grammarView = atom.workspace.getModalPanels()[0].getItem();
const grammarView = await getGrammarView(editor);
grammarView.props.didConfirmSelection(jsGrammar);
expect(editor.getGrammar()).toBe(jsGrammar);
}));
@ -199,6 +180,73 @@ describe('GrammarSelector', () => {
);
}));
describe('when toggling hideDuplicateTextMateGrammars', () => {
it('shows only the Tree-sitter if true and both exist', async () => {
// the main JS grammar has both a TextMate and Tree-sitter implementation
atom.config.set('grammar-selector.hideDuplicateTextMateGrammars', true);
const grammarView = await getGrammarView(editor);
const observedNames = new Set();
grammarView.element.querySelectorAll('li').forEach(li => {
const name = li.getAttribute('data-grammar');
expect(observedNames.has(name)).toBe(false);
observedNames.add(name);
});
// check the seen JS is actually the Tree-sitter one
const list = atom.workspace.getModalPanels()[0].item;
for (const item of list.items) {
if (item.name === 'JavaScript') {
expect(item.constructor.name === 'TreeSitterGrammar');
}
}
});
it('shows both if false', async () => {
await atom.packages.activatePackage('language-c'); // punctuation making it sort wrong
atom.config.set(
'grammar-selector.hideDuplicateTextMateGrammars',
false
);
await getGrammarView(editor);
let cppCount = 0;
const listItems = atom.workspace.getModalPanels()[0].item.items;
for (let i = 0; i < listItems.length; i++) {
const grammar = listItems[i];
const name = grammar.name;
if (cppCount === 0 && name === 'C++') {
expect(grammar.constructor.name).toBe('TreeSitterGrammar'); // first C++ entry should be Tree-sitter
cppCount++;
} else if (cppCount === 1) {
expect(name).toBe('C++');
expect(grammar.constructor.name).toBe('Grammar'); // immediate next grammar should be the TextMate version
cppCount++;
} else {
expect(name).not.toBe('C++'); // there should not be any other C++ grammars
}
}
expect(cppCount).toBe(2); // ensure we actually saw both grammars
});
});
describe('for every Tree-sitter grammar', () => {
it('adds a label to identify it as Tree-sitter', async () => {
const grammarView = await getGrammarView(editor);
const elements = grammarView.element.querySelectorAll('li');
const listItems = atom.workspace.getModalPanels()[0].item.items;
for (let i = 0; i < listItems.length; i++) {
if (listItems[i].constructor.name === 'TreeSitterGrammar') {
expect(
elements[i].childNodes[1].childNodes[0].className.startsWith(
'grammar-selector-parser'
)
).toBe(true);
}
}
});
});
describe('when clicked', () =>
it('shows the grammar selector modal', () => {
const eventHandler = jasmine.createSpy('eventHandler');
@ -224,3 +272,9 @@ function getTooltipText(element) {
const [tooltip] = atom.tooltips.findTooltips(element);
return tooltip.getTitle();
}
async function getGrammarView(editor) {
atom.commands.dispatch(editor.getElement(), 'grammar-selector:show');
await SelectListView.getScheduler().getNextUpdatePromise();
return atom.workspace.getModalPanels()[0].getItem();
}

View File

@ -4,3 +4,7 @@
.grammar-status a:hover {
color: @text-color;
}
.grammar-selector-parser {
margin-right: @component-padding;
}

View File

@ -2,6 +2,7 @@ name: 'Rust'
scopeName: 'source.rust'
type: 'tree-sitter'
parser: 'tree-sitter-rust'
injectionRegex: 'rust'
fileTypes: [
'rs'

View File

@ -0,0 +1,14 @@
exports.activate = function() {
for (const nodeType of ['macro_invocation', 'macro_rule']) {
atom.grammars.addInjectionPoint('source.rust', {
type: nodeType,
language() {
return 'rust';
},
content(node) {
return node.lastChild;
},
includeChildren: true
});
}
};

View File

@ -7,10 +7,11 @@
"grammar",
"rust"
],
"main": "lib/main.js",
"repository": "https://github.com/atom/atom",
"license": "MIT",
"dependencies": {
"tree-sitter-rust": "^0.13.7"
"tree-sitter-rust": "^0.15.1"
},
"engines": {
"atom": ">=1.0.0 <2.0.0"

View File

@ -26,7 +26,7 @@ chmod 755 "%{buildroot}/<%= installDir %>/bin/<%= appFileName %>"
mkdir -p "%{buildroot}/<%= installDir %>/share/applications/"
cp "<%= appFileName %>.desktop" "%{buildroot}/<%= installDir %>/share/applications/"
mkdir -p "%{buildroot}/<%= installDir %>/share/polkit-1/actions/"
cp "atom.policy" "%{buildroot}/<%= installDir %>/share/polkit-1/actions/atom.policy"
cp "<%= policyFileName %>" "%{buildroot}/<%= installDir %>/share/polkit-1/actions/<%= policyFileName %>"
mkdir -p "%{buildroot}/<%= installDir %>/share/icons/hicolor/1024x1024/apps"
cp "icons/1024.png" "%{buildroot}/<%= installDir %>/share/icons/hicolor/1024x1024/apps/<%= appFileName %>.png"
@ -52,5 +52,5 @@ cp "icons/16.png" "%{buildroot}/<%= installDir %>/share/icons/hicolor/16x16/apps
<%= installDir %>/bin/<%= apmFileName %>
<%= installDir %>/share/<%= appFileName %>/
<%= installDir %>/share/applications/<%= appFileName %>.desktop
<%= installDir %>/share/polkit-1/actions/atom.policy
<%= installDir %>/share/polkit-1/actions/<%= policyFileName %>
<%= installDir %>/share/icons/hicolor/

View File

@ -109,7 +109,7 @@ if (!argv.generateApiDocs) {
if (argv.codeSign) {
const executablesToSign = [ path.join(packagedAppPath, 'Atom.exe') ]
if (argv.createWindowsInstaller) {
executablesToSign.push(path.join(__dirname, 'node_modules', 'electron-winstaller', 'vendor', 'Update.exe'))
executablesToSign.push(path.join(__dirname, 'node_modules', '@atom', 'electron-winstaller', 'vendor', 'Squirrel.exe'))
}
codeSignOnWindows(executablesToSign)
} else {

View File

@ -40,6 +40,7 @@ module.exports = function(filesToSign) {
__dirname,
'..',
'node_modules',
'@atom',
'electron-winstaller',
'vendor',
'signtool.exe'

View File

@ -209,7 +209,12 @@ module.exports = function(packagedAppPath) {
);
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'resources', 'linux', 'atom.policy'),
path.join(debianPackageShareDirPath, 'polkit-1', 'actions', 'atom.policy')
path.join(
debianPackageShareDirPath,
'polkit-1',
'actions',
`atom-${CONFIG.channel}.policy`
)
);
console.log(`Generating .deb file from ${debianPackageDirPath}`);

View File

@ -19,6 +19,7 @@ module.exports = function(packagedAppPath) {
// RPM versions can't have dashes or tildes in them.
// (Ref.: https://twiki.cern.ch/twiki/bin/view/Main/RPMAndDebVersioning)
const appVersion = CONFIG.appMetadata.version.replace(/-/g, '.');
const policyFileName = `atom-${CONFIG.channel}.policy`;
const rpmPackageDirPath = path.join(CONFIG.homeDirPath, 'rpmbuild');
const rpmPackageBuildDirPath = path.join(rpmPackageDirPath, 'BUILD');
@ -80,7 +81,8 @@ module.exports = function(packagedAppPath) {
apmFileName: apmExecutableName,
description: appDescription,
installDir: '/usr',
version: appVersion
version: appVersion,
policyFileName
});
fs.writeFileSync(rpmPackageSpecFilePath, rpmPackageSpecsContents);
@ -114,7 +116,7 @@ module.exports = function(packagedAppPath) {
console.log(`Copying atom.policy into "${rpmPackageBuildDirPath}"`);
fs.copySync(
path.join(CONFIG.repositoryRootPath, 'resources', 'linux', 'atom.policy'),
path.join(rpmPackageBuildDirPath, 'atom.policy')
path.join(rpmPackageBuildDirPath, policyFileName)
);
console.log(`Generating .rpm package from "${rpmPackageDirPath}"`);

View File

@ -1,6 +1,6 @@
'use strict';
const electronInstaller = require('electron-winstaller');
const electronInstaller = require('@atom/electron-winstaller');
const fs = require('fs');
const glob = require('glob');
const path = require('path');
@ -25,7 +25,6 @@ module.exports = packagedAppPath => {
),
outputDirectory: CONFIG.buildOutputPath,
noMsi: true,
noDelta: CONFIG.channel === 'nightly', // Delta packages are broken for nightly versions past nightly9 due to Squirrel/NuGet limitations
remoteReleases: `${updateUrlPrefix}/api/updates${archSuffix}?version=${
CONFIG.computedAppVersion
}`,

View File

@ -16,7 +16,6 @@ const EXCLUDE_REGEXPS_SOURCES = [
escapeRegExp('.npmignore'),
escapeRegExp('.pairs'),
escapeRegExp('.travis.yml'),
escapeRegExp('appveyor.yml'),
escapeRegExp('.idea'),
escapeRegExp('.editorconfig'),
escapeRegExp('.lint'),

228
script/package-lock.json generated
View File

@ -8,6 +8,66 @@
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-4.0.2.tgz",
"integrity": "sha512-XtGk+IF57pr852UK1AhQJXqmm1WmSgS5uISL+LPs0z/iAxXouMvdlLJrHPeukP6gd7yR2rDTMSMkHNODgwIq7A=="
},
"@atom/electron-winstaller": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@atom/electron-winstaller/-/electron-winstaller-0.0.1.tgz",
"integrity": "sha512-E8bGTBrhf4HsZZS5oPxQgx8XL2wCz04vi0gtYzQH+i9gpxdkuGuV+RHGAtQY+k+wbG5RVR89sB6ICMmhUYNi2Q==",
"requires": {
"@babel/runtime": "^7.3.4",
"asar": "^1.0.0",
"debug": "^4.1.1",
"fs-extra": "^7.0.1",
"lodash.template": "^4.2.2",
"pify": "^4.0.1",
"temp": "^0.9.0"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"fs-extra": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz",
"integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "^4.1.6"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
},
"temp": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/temp/-/temp-0.9.0.tgz",
"integrity": "sha512-YfUhPQCJoNQE5N+FJQcdPz63O3x3sdT4Xju69Gj4iZe0lBKOtnAMi0SLj9xKhGkcGhsxThvTJ/usxtFPo438zQ==",
"requires": {
"rimraf": "~2.6.2"
}
}
}
},
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
@ -119,6 +179,14 @@
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.4.tgz",
"integrity": "sha512-5pCS4mOsL+ANsFZGdvNLybx4wtqAZJ0MJjMHxvzI3bvIsz6sQvzW8XX92EYIkiPtIvcfG3Aj+Ir5VNyjnZhP7w=="
},
"@babel/runtime": {
"version": "7.4.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.5.tgz",
"integrity": "sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==",
"requires": {
"regenerator-runtime": "^0.13.2"
}
},
"@babel/template": {
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz",
@ -507,27 +575,34 @@
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
"asar": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/asar/-/asar-0.11.0.tgz",
"integrity": "sha1-uSbnksMV+MBIxDNx4yWwnJenZGQ=",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/asar/-/asar-1.0.0.tgz",
"integrity": "sha512-MBiDU5cDr9UWuY2F0zq2fZlnyRq1aOPmJGMas22Qa14K1odpRXL3xkMHPN3uw2hAK5mD89Q+/KidOUtpi4V0Cg==",
"requires": {
"chromium-pickle-js": "^0.1.0",
"commander": "^2.9.0",
"cuint": "^0.2.1",
"glob": "^6.0.4",
"minimatch": "^3.0.0",
"mkdirp": "^0.5.0",
"mksnapshot": "^0.3.0"
"chromium-pickle-js": "^0.2.0",
"commander": "^2.19.0",
"cuint": "^0.2.2",
"glob": "^7.1.3",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"pify": "^4.0.1",
"tmp-promise": "^1.0.5"
},
"dependencies": {
"commander": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ=="
},
"glob": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
"integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=",
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "2 || 3",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
@ -539,6 +614,11 @@
"requires": {
"brace-expansion": "^1.1.7"
}
},
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
}
}
},
@ -1174,9 +1254,9 @@
"integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g=="
},
"chromium-pickle-js": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.1.0.tgz",
"integrity": "sha1-HUixB9ghJqLz4hHC6iX4A7pVGyE="
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU="
},
"circular-json": {
"version": "0.3.3",
@ -2339,38 +2419,6 @@
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.52.tgz",
"integrity": "sha1-0tnxJwuko7lnuDHEDvcftNmrXOA="
},
"electron-winstaller": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-2.6.4.tgz",
"integrity": "sha1-a0gHboc6bqNWJR8Ve2i55dwDtak=",
"requires": {
"asar": "^0.11.0",
"bluebird": "^3.3.4",
"debug": "^2.2.0",
"fs-extra": "^0.26.7",
"lodash.template": "^4.2.2",
"temp": "^0.8.3"
},
"dependencies": {
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
},
"fs-extra": {
"version": "0.26.7",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz",
"integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
}
}
}
},
"emoji-regex": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
@ -5155,30 +5203,6 @@
"resolved": "https://registry.npmjs.org/mkpath/-/mkpath-0.1.0.tgz",
"integrity": "sha1-dVSm+Nhxg0zJe1RisSLEwSTW3pE="
},
"mksnapshot": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/mksnapshot/-/mksnapshot-0.3.1.tgz",
"integrity": "sha1-JQHAVldDbXQs6Vik/5LHfkDdN+Y=",
"requires": {
"decompress-zip": "0.3.0",
"fs-extra": "0.26.7",
"request": "^2.79.0"
},
"dependencies": {
"fs-extra": {
"version": "0.26.7",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz",
"integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=",
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
}
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@ -9083,6 +9107,11 @@
"through": "~2.3.8"
}
},
"regenerator-runtime": {
"version": "0.13.2",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz",
"integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA=="
},
"regex-cache": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz",
@ -10484,6 +10513,59 @@
"os-tmpdir": "~1.0.2"
}
},
"tmp-promise": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-1.1.0.tgz",
"integrity": "sha512-8+Ah9aB1IRXCnIOxXZ0uFozV1nMU5xiu7hhFVUSxZ3bYu+psD4TzagCzVbexUCgNNGJnsmNDQlS4nG3mTyoNkw==",
"requires": {
"bluebird": "^3.5.0",
"tmp": "0.1.0"
},
"dependencies": {
"bluebird": {
"version": "3.5.5",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz",
"integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w=="
},
"glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
"integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"rimraf": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"requires": {
"glob": "^7.1.3"
}
},
"tmp": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz",
"integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==",
"requires": {
"rimraf": "^2.6.3"
}
}
}
},
"to-buffer": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz",

View File

@ -14,7 +14,7 @@
"electron-link": "0.4.0",
"electron-mksnapshot": "^4.2.0",
"electron-packager": "12.2.0",
"electron-winstaller": "2.6.4",
"@atom/electron-winstaller": "0.0.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.2.0",
"eslint-config-standard": "^12.0.0",

View File

@ -97,32 +97,60 @@ module.exports.generateForNightly = async function(
releaseVersion,
githubToken
) {
const releases = await octokit.repos.getReleases({
owner: 'atom',
repo: 'atom-nightly-releases'
});
const previousRelease = getPreviousRelease(releaseVersion, releases.data);
const oldReleaseNotes = previousRelease ? previousRelease.body : undefined;
const latestCommitResult = childProcess.spawnSync('git', [
'rev-parse',
'--short',
'HEAD'
]);
if (!latestCommitResult) {
console.log("Couldn't get the current commmit from git.");
if (latestCommitResult && oldReleaseNotes) {
const latestCommit = latestCommitResult.stdout.toString().trim();
const extractMatch = oldReleaseNotes.match(
/atom\/atom\/compare\/([0-9a-f]{5,40})\.\.\.([0-9a-f]{5,40})/
);
if (extractMatch) {
return `### Click [here](https://github.com/atom/atom/compare/${
extractMatch[2]
}...${latestCommit}) to see the changes included with this release! :atom: :night_with_stars:`;
}
return undefined;
}
return undefined;
const latestCommit = latestCommitResult.stdout.toString().trim();
const output = [
`### This nightly release is based on https://github.com/atom/atom/commit/${latestCommit} :atom: :night_with_stars:`
];
try {
const releases = await octokit.repos.getReleases({
owner: 'atom',
repo: 'atom-nightly-releases'
});
const previousRelease = getPreviousRelease(releaseVersion, releases.data);
const oldReleaseNotes = previousRelease ? previousRelease.body : undefined;
if (oldReleaseNotes) {
const extractMatch = oldReleaseNotes.match(
/atom\/atom\/commit\/([0-9a-f]{5,40})/
);
if (extractMatch.length > 1 && extractMatch[1]) {
output.push('', '---', '');
const previousCommit = extractMatch[1];
if (
previousCommit === latestCommit ||
previousCommit.startsWith(latestCommit) ||
latestCommit.startsWith(previousCommit)
) {
// TODO: Maybe we can bail out and not publish a release if it contains no commits?
output.push('No changes have been included in this release');
} else {
output.push(
`Click [here](https://github.com/atom/atom/compare/${previousCommit}...${latestCommit}) to see the changes included with this release!`
);
}
}
}
} catch (e) {
console.log(
'Error when trying to find the previous nightly release: ' + e.message
);
}
return output.join('\n');
};
function extractWrittenReleaseNotes(oldReleaseNotes) {

View File

@ -53,7 +53,7 @@ jobs:
displayName: Download Release Artifacts
- script: |
node $(Build.SourcesDirectory)\script\vsts\upload-artifacts.js --create-github-release --assets-path "$(System.ArtifactsDirectory)"
node $(Build.SourcesDirectory)\script\vsts\upload-artifacts.js --create-github-release --assets-path "$(System.ArtifactsDirectory)" --linux-repo-name "atom"
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
ATOM_RELEASE_VERSION: $(ReleaseVersion)

View File

@ -115,6 +115,9 @@ jobs:
versionSpec: 10.2.1
displayName: Install Node.js 10.2.1
- script: npm install --global npm@6.2.0
displayName: Update npm
- task: 1ESLighthouseEng.PipelineArtifactCaching.RestoreCacheV1.RestoreCache@1
displayName: Restore node_modules cache
inputs:
@ -122,6 +125,16 @@ jobs:
targetfolder: '**/node_modules, !**/node_modules/**/node_modules'
vstsFeed: 'bae1bc26-220d-43c7-a955-4de039370de2'
# The artifact caching task does not work on forks, so we need to
# bootstrap again for pull requests coming from forked repositories.
- script: script/bootstrap
displayName: Bootstrap build environment
env:
CI: true
CI_PROVIDER: VSTS
NPM_BIN_PATH: /usr/local/bin/npm
condition: ne(variables['CacheRestored'], 'true')
- task: DownloadBuildArtifacts@0
displayName: Download atom-mac.zip
inputs:

View File

@ -69,6 +69,23 @@ describe('GrammarRegistry', () => {
});
});
describe('.assignGrammar(buffer, grammar)', () => {
it('allows a TextMate grammar to be assigned directly, even when Tree-sitter is permitted', () => {
grammarRegistry.loadGrammarSync(
require.resolve(
'language-javascript/grammars/tree-sitter-javascript.cson'
)
);
const tmGrammar = grammarRegistry.loadGrammarSync(
require.resolve('language-javascript/grammars/javascript.cson')
);
const buffer = new TextBuffer();
expect(grammarRegistry.assignGrammar(buffer, tmGrammar)).toBe(true);
expect(buffer.getLanguageMode().getGrammar()).toBe(tmGrammar);
});
});
describe('.grammarForId(languageId)', () => {
it('returns a text-mate grammar when `core.useTreeSitterParsers` is false', () => {
atom.config.set('core.useTreeSitterParsers', false, {
@ -859,6 +876,29 @@ describe('GrammarRegistry', () => {
expect(buffer2Copy.getLanguageMode().getLanguageId()).toBe('source.js');
});
});
describe('when working with grammars', () => {
beforeEach(async () => {
await atom.packages.activatePackage('language-javascript');
});
it('returns only Tree-sitter grammars by default', async () => {
const tmGrammars = atom.grammars.getGrammars();
const allGrammars = atom.grammars.getGrammars({
includeTreeSitter: true
});
expect(allGrammars.length).toBeGreaterThan(tmGrammars.length);
});
it('executes the foreach callback on both Tree-sitter and TextMate grammars', async () => {
const numAllGrammars = atom.grammars.getGrammars({
includeTreeSitter: true
}).length;
let i = 0;
atom.grammars.forEachGrammar(() => i++);
expect(i).toBe(numAllGrammars);
});
});
});
function retainedBufferCount(grammarRegistry) {

View File

@ -7,7 +7,6 @@ import { promisify } from 'util';
import { CompositeDisposable } from 'event-kit';
import { watchPath, stopAllWatchers } from '../src/path-watcher';
import { timeoutPromise } from './async-spec-helpers';
temp.track();
@ -22,7 +21,6 @@ describe('watchPath', function() {
let subs;
beforeEach(function() {
jasmine.useRealClock();
subs = new CompositeDisposable();
});
@ -111,12 +109,6 @@ describe('watchPath', function() {
waitForChanges(rootWatcher, subFile),
waitForChanges(childWatcher, subFile)
]);
// In Windows64, in some situations nsfw (the currently default watcher)
// does not trigger the change events if they happen just after start watching,
// so we need to wait some time. More info: https://github.com/atom/atom/issues/19442
await timeoutPromise(300);
await writeFile(subFile, 'subfile\n', { encoding: 'utf8' });
await firstChanges;
@ -164,11 +156,6 @@ describe('watchPath', function() {
expect(subWatcher0.native).toBe(parentWatcher.native);
expect(subWatcher1.native).toBe(parentWatcher.native);
// In Windows64, in some situations nsfw (the currently default watcher)
// does not trigger the change events if they happen just after start watching,
// so we need to wait some time. More info: https://github.com/atom/atom/issues/19442
await timeoutPromise(300);
// Ensure events are filtered correctly
await Promise.all([
appendFile(rootFile, 'change\n', { encoding: 'utf8' }),

View File

@ -27,6 +27,9 @@ const ejsGrammarPath = require.resolve(
const rubyGrammarPath = require.resolve(
'language-ruby/grammars/tree-sitter-ruby.cson'
);
const rustGrammarPath = require.resolve(
'language-rust-bundled/grammars/tree-sitter-rust.cson'
);
describe('TreeSitterLanguageMode', () => {
let editor, buffer;
@ -831,6 +834,81 @@ describe('TreeSitterLanguageMode', () => {
]);
});
it('respects the `includeChildren` property of injection points', async () => {
const rustGrammar = new TreeSitterGrammar(
atom.grammars,
rustGrammarPath,
{
scopeName: 'rust',
parser: 'tree-sitter-rust',
scopes: {
identifier: 'variable',
field_identifier: 'property',
'call_expression > field_expression > field_identifier':
'function',
'macro_invocation > identifier': 'macro'
},
injectionRegExp: 'rust',
injectionPoints: [
{
type: 'macro_invocation',
language() {
return 'rust';
},
content(node) {
return node.lastChild;
},
// The tokens within a `token_tree` are all parsed as separate
// children of the `token_tree`. By default, when adding a language
// injection for a node, the node's children's ranges would be
// excluded from the injection. But for this injection point
// (parsing token trees as rust code), we want to reparse all of the
// content of the token tree.
includeChildren: true
}
]
}
);
atom.grammars.addGrammar(rustGrammar);
// Macro call within another macro call.
buffer.setText('assert_eq!(a.b.c(), vec![d.e()]); f.g();');
const languageMode = new TreeSitterLanguageMode({
buffer,
grammar: rustGrammar,
grammars: atom.grammars
});
buffer.setLanguageMode(languageMode);
// There should not be duplicate scopes due to the root layer
// and for the injected rust layer.
expectTokensToEqual(editor, [
[
{ text: 'assert_eq', scopes: ['macro'] },
{ text: '!(', scopes: [] },
{ text: 'a', scopes: ['variable'] },
{ text: '.', scopes: [] },
{ text: 'b', scopes: ['property'] },
{ text: '.', scopes: [] },
{ text: 'c', scopes: ['function'] },
{ text: '(), ', scopes: [] },
{ text: 'vec', scopes: ['macro'] },
{ text: '![', scopes: [] },
{ text: 'd', scopes: ['variable'] },
{ text: '.', scopes: [] },
{ text: 'e', scopes: ['function'] },
{ text: '()]); ', scopes: [] },
{ text: 'f', scopes: ['variable'] },
{ text: '.', scopes: [] },
{ text: 'g', scopes: ['function'] },
{ text: '();', scopes: [] }
]
]);
});
it('notifies onDidTokenize listeners the first time all syntax highlighting is done', async () => {
const promise = new Promise(resolve => {
editor.onDidTokenize(event => {
@ -1477,7 +1555,7 @@ describe('TreeSitterLanguageMode', () => {
scopes: {},
folds: [
{
type: ['element', 'raw_element'],
type: ['element', 'script_element'],
start: { index: 0 },
end: { index: -1 }
}
@ -1618,7 +1696,7 @@ describe('TreeSitterLanguageMode', () => {
parser: 'tree-sitter-html',
scopes: {
fragment: 'text.html',
raw_element: 'script.tag'
script_element: 'script.tag'
},
injectionRegExp: 'html',
injectionPoints: [SCRIPT_TAG_INJECTION_POINT]
@ -1781,7 +1859,7 @@ describe('TreeSitterLanguageMode', () => {
'text.html',
'fragment',
'element',
'raw_element',
'script_element',
'raw_text',
'program',
'expression_statement',
@ -2331,7 +2409,7 @@ const HTML_TEMPLATE_LITERAL_INJECTION_POINT = {
};
const SCRIPT_TAG_INJECTION_POINT = {
type: 'raw_element',
type: 'script_element',
language() {
return 'javascript';
},

View File

@ -1994,15 +1994,18 @@ describe('Workspace', () => {
expect(
atom2.grammars
.getGrammars()
.getGrammars({ includeTreeSitter: true })
.map(grammar => grammar.scopeName)
.sort()
).toEqual([
'source.coffee',
'source.js', // Tree-sitter grammars also load
'source.js',
'source.js.regexp',
'source.js.regexp',
'source.js.regexp.replacement',
'source.jsdoc',
'source.jsdoc',
'source.litcoffee',
'text.plain.null-grammar',
'text.todo'

View File

@ -148,6 +148,26 @@ module.exports = class GrammarRegistry {
return true;
}
// Extended: Force a {TextBuffer} to use a different grammar than the
// one that would otherwise be selected for it.
//
// * `buffer` The {TextBuffer} whose grammar will be set.
// * `grammar` The desired {Grammar}.
//
// Returns a {Boolean} that indicates whether the assignment was sucessful
assignGrammar(buffer, grammar) {
if (!grammar) return false;
if (buffer.getBuffer) buffer = buffer.getBuffer();
this.languageOverridesByBufferId.set(buffer.id, grammar.scopeName || null);
this.grammarScoresByBuffer.set(buffer, null);
if (grammar !== buffer.getLanguageMode().grammar) {
buffer.setLanguageMode(
this.languageModeForGrammarAndBuffer(grammar, buffer)
);
}
return true;
}
// Extended: Get the `languageId` that has been explicitly assigned to
// to the given buffer, if any.
//
@ -330,11 +350,7 @@ module.exports = class GrammarRegistry {
}
forEachGrammar(callback) {
this.textmateRegistry.grammars.forEach(callback);
for (const grammarId in this.treeSitterGrammarsById) {
const grammar = this.treeSitterGrammarsById[grammarId];
if (grammar.scopeName) callback(grammar);
}
this.getGrammars({ includeTreeSitter: true }).forEach(callback);
}
grammarForId(languageId) {
@ -482,7 +498,7 @@ module.exports = class GrammarRegistry {
}
get grammars() {
return this.textmateRegistry.grammars;
return this.getGrammars();
}
decodeTokens() {
@ -601,9 +617,19 @@ module.exports = class GrammarRegistry {
// Extended: Get all the grammars in this registry.
//
// * `options` (optional) {Object}
// * `includeTreeSitter` (optional) {Boolean} Set to include
// [Tree-sitter](https://github.blog/2018-10-31-atoms-new-parsing-system/) grammars
//
// Returns a non-empty {Array} of {Grammar} instances.
getGrammars() {
return this.textmateRegistry.getGrammars();
getGrammars(params) {
let tmGrammars = this.textmateRegistry.getGrammars();
if (!(params && params.includeTreeSitter)) return tmGrammars;
const tsGrammars = Object.values(this.treeSitterGrammarsById).filter(
g => g.scopeName
);
return tmGrammars.concat(tsGrammars); // NullGrammar is expected to be first
}
scopeForId(id) {

View File

@ -41,6 +41,7 @@ if (global.isGeneratingSnapshot) {
require('language-html');
require('language-javascript');
require('language-ruby');
require('language-rust-bundled');
require('language-typescript');
require('line-ending-selector');
require('link');

View File

@ -119,6 +119,25 @@ module.exports = class TreeSitterGrammar {
}
}
}
/*
Section - Backward compatibility shims
*/
onDidUpdate(callback) {
// do nothing
}
tokenizeLines(text, compatibilityMode = true) {
return text.split('\n').map(line => this.tokenizeLine(line, null, false));
}
tokenizeLine(line, ruleStack, firstLine) {
return {
value: line,
scopes: [this.scopeName]
};
}
};
const preprocessScopes = value =>

View File

@ -32,7 +32,7 @@ class TreeSitterLanguageMode {
this.config = config;
this.grammarRegistry = grammars;
this.parser = new Parser();
this.rootLanguageLayer = new LanguageLayer(this, grammar);
this.rootLanguageLayer = new LanguageLayer(this, grammar, 0);
this.injectionsMarkerLayer = buffer.addMarkerLayer();
if (syncTimeoutMicros != null) {
@ -637,13 +637,13 @@ class TreeSitterLanguageMode {
}
class LanguageLayer {
constructor(languageMode, grammar, contentChildTypes) {
constructor(languageMode, grammar, depth) {
this.languageMode = languageMode;
this.grammar = grammar;
this.tree = null;
this.currentParsePromise = null;
this.patchSinceCurrentParseStarted = null;
this.contentChildTypes = contentChildTypes;
this.depth = depth;
}
buildHighlightIterator() {
@ -885,7 +885,7 @@ class LanguageLayer {
marker.languageLayer = new LanguageLayer(
this.languageMode,
grammar,
injectionPoint.contentChildTypes
this.depth + 1
);
marker.parentLanguageLayer = this;
}
@ -895,7 +895,8 @@ class LanguageLayer {
new NodeRangeSet(
nodeRangeSet,
injectionNodes,
injectionPoint.newlinesBetween
injectionPoint.newlinesBetween,
injectionPoint.includeChildren
)
);
}
@ -910,7 +911,6 @@ class LanguageLayer {
}
if (markersToUpdate.size > 0) {
this.lastUpdateWasAsync = true;
const promises = [];
for (const [marker, nodeRangeSet] of markersToUpdate) {
promises.push(marker.languageLayer.update(nodeRangeSet));
@ -947,75 +947,131 @@ class HighlightIterator {
}
);
this.iterators = [
this.languageMode.rootLanguageLayer.buildHighlightIterator()
];
for (const marker of injectionMarkers) {
this.iterators.push(marker.languageLayer.buildHighlightIterator());
}
this.iterators.sort((a, b) => b.getIndex() - a.getIndex());
const containingTags = [];
const containingTagStartIndices = [];
const targetIndex = this.languageMode.buffer.characterIndexForPosition(
targetPosition
);
for (let i = this.iterators.length - 1; i >= 0; i--) {
this.iterators[i].seek(
targetIndex,
containingTags,
containingTagStartIndices
);
this.iterators = [];
const iterator = this.languageMode.rootLanguageLayer.buildHighlightIterator();
if (iterator.seek(targetIndex, containingTags, containingTagStartIndices)) {
this.iterators.push(iterator);
}
this.iterators.sort((a, b) => b.getIndex() - a.getIndex());
// Populate the iterators array with all of the iterators whose syntax
// trees span the given position.
for (const marker of injectionMarkers) {
const iterator = marker.languageLayer.buildHighlightIterator();
if (
iterator.seek(targetIndex, containingTags, containingTagStartIndices)
) {
this.iterators.push(iterator);
}
}
// Sort the iterators so that the last one in the array is the earliest
// in the document, and represents the current position.
this.iterators.sort((a, b) => b.compare(a));
this.detectCoveredScope();
return containingTags;
}
moveToSuccessor() {
const lastIndex = this.iterators.length - 1;
const leader = this.iterators[lastIndex];
leader.moveToSuccessor();
const leaderCharIndex = leader.getIndex();
let i = lastIndex;
while (i > 0 && this.iterators[i - 1].getIndex() < leaderCharIndex) i--;
if (i < lastIndex) this.iterators.splice(i, 0, this.iterators.pop());
// Advance the earliest layer iterator to its next scope boundary.
let leader = last(this.iterators);
// Maintain the sorting of the iterators by their position in the document.
if (leader.moveToSuccessor()) {
const leaderIndex = this.iterators.length - 1;
let i = leaderIndex;
while (i > 0 && this.iterators[i - 1].compare(leader) < 0) i--;
if (i < leaderIndex) {
this.iterators.splice(i, 0, this.iterators.pop());
}
} else {
// If the layer iterator was at the end of its syntax tree, then remove
// it from the array.
this.iterators.pop();
}
this.detectCoveredScope();
}
// Detect whether or not another more deeply-nested language layer has a
// scope boundary at this same position. If so, the current language layer's
// scope boundary should not be reported.
detectCoveredScope() {
const layerCount = this.iterators.length;
if (layerCount > 1) {
const first = this.iterators[layerCount - 1];
const next = this.iterators[layerCount - 2];
if (
next.offset === first.offset &&
next.atEnd === first.atEnd &&
next.depth > first.depth
) {
this.currentScopeIsCovered = true;
return;
}
}
this.currentScopeIsCovered = false;
}
getPosition() {
return last(this.iterators).getPosition();
const iterator = last(this.iterators);
if (iterator) {
return iterator.getPosition();
} else {
return Point.INFINITY;
}
}
getCloseScopeIds() {
return last(this.iterators).getCloseScopeIds();
const iterator = last(this.iterators);
if (iterator && !this.currentScopeIsCovered) {
return iterator.getCloseScopeIds();
}
return [];
}
getOpenScopeIds() {
return last(this.iterators).getOpenScopeIds();
const iterator = last(this.iterators);
if (iterator && !this.currentScopeIsCovered) {
return iterator.getOpenScopeIds();
}
return [];
}
logState() {
const iterator = last(this.iterators);
if (iterator.treeCursor) {
if (iterator && iterator.treeCursor) {
console.log(
iterator.getPosition(),
iterator.treeCursor.nodeType,
`depth=${iterator.languageLayer.depth}`,
new Range(
iterator.languageLayer.tree.rootNode.startPosition,
iterator.languageLayer.tree.rootNode.endPosition
).toString()
);
console.log(
'close',
iterator.closeTags.map(id =>
this.languageMode.grammar.scopeNameForScopeId(id)
)
);
console.log(
'open',
iterator.openTags.map(id =>
this.languageMode.grammar.scopeNameForScopeId(id)
)
);
if (this.currentScopeIsCovered) {
console.log('covered');
} else {
console.log(
'close',
iterator.closeTags.map(id =>
this.languageMode.grammar.scopeNameForScopeId(id)
)
);
console.log(
'open',
iterator.openTags.map(id =>
this.languageMode.grammar.scopeNameForScopeId(id)
)
);
}
}
}
}
@ -1023,11 +1079,13 @@ class HighlightIterator {
class LayerHighlightIterator {
constructor(languageLayer, treeCursor) {
this.languageLayer = languageLayer;
this.depth = this.languageLayer.depth;
// The iterator is always positioned at either the start or the end of some node
// in the syntax tree.
this.atEnd = false;
this.treeCursor = treeCursor;
this.offset = 0;
// In order to determine which selectors match its current node, the iterator maintains
// a list of the current node's ancestors. Because the selectors can use the `:nth-child`
@ -1046,7 +1104,6 @@ class LayerHighlightIterator {
seek(targetIndex, containingTags, containingTagStartIndices) {
while (this.treeCursor.gotoParent()) {}
this.done = false;
this.atEnd = true;
this.closeTags.length = 0;
this.openTags.length = 0;
@ -1057,8 +1114,7 @@ class LayerHighlightIterator {
const containingTagEndIndices = [];
if (targetIndex >= this.treeCursor.endIndex) {
this.done = true;
return;
return false;
}
let childIndex = -1;
@ -1091,22 +1147,24 @@ class LayerHighlightIterator {
}
if (this.atEnd) {
const currentIndex = this.treeCursor.endIndex;
this.offset = this.treeCursor.endIndex;
for (let i = 0, { length } = containingTags; i < length; i++) {
if (containingTagEndIndices[i] === currentIndex) {
if (containingTagEndIndices[i] === this.offset) {
this.closeTags.push(containingTags[i]);
}
}
} else {
this.offset = this.treeCursor.startIndex;
}
return containingTags;
return true;
}
moveToSuccessor() {
this.closeTags.length = 0;
this.openTags.length = 0;
while (!this.done && !this.closeTags.length && !this.openTags.length) {
while (!this.closeTags.length && !this.openTags.length) {
if (this.atEnd) {
if (this._moveRight()) {
const scopeId = this._currentScopeId();
@ -1116,7 +1174,7 @@ class LayerHighlightIterator {
} else if (this._moveUp(true)) {
this.atEnd = true;
} else {
this.done = true;
return false;
}
} else if (!this._moveDown()) {
const scopeId = this._currentScopeId();
@ -1125,26 +1183,30 @@ class LayerHighlightIterator {
this._moveUp(false);
}
}
if (this.atEnd) {
this.offset = this.treeCursor.endIndex;
} else {
this.offset = this.treeCursor.startIndex;
}
return true;
}
getPosition() {
if (this.done) {
return Point.INFINITY;
} else if (this.atEnd) {
if (this.atEnd) {
return this.treeCursor.endPosition;
} else {
return this.treeCursor.startPosition;
}
}
getIndex() {
if (this.done) {
return Infinity;
} else if (this.atEnd) {
return this.treeCursor.endIndex;
} else {
return this.treeCursor.startIndex;
}
compare(other) {
const result = this.offset - other.offset;
if (result !== 0) return result;
if (this.atEnd && !other.atEnd) return -1;
if (other.atEnd && !this.atEnd) return 1;
return this.languageLayer.depth - other.languageLayer.depth;
}
getCloseScopeIds() {
@ -1156,6 +1218,7 @@ class LayerHighlightIterator {
}
// Private methods
_moveUp(atLastChild) {
let result = false;
const { endIndex } = this.treeCursor;
@ -1263,10 +1326,10 @@ class NullHighlightIterator {
seek() {
return [];
}
moveToSuccessor() {}
getIndex() {
return Infinity;
compare() {
return 1;
}
moveToSuccessor() {}
getPosition() {
return Point.INFINITY;
}
@ -1279,10 +1342,11 @@ class NullHighlightIterator {
}
class NodeRangeSet {
constructor(previous, nodes, newlinesBetween) {
constructor(previous, nodes, newlinesBetween, includeChildren) {
this.previous = previous;
this.nodes = nodes;
this.newlinesBetween = newlinesBetween;
this.includeChildren = includeChildren;
}
getRanges(buffer) {
@ -1293,18 +1357,20 @@ class NodeRangeSet {
let position = node.startPosition;
let index = node.startIndex;
for (const child of node.children) {
const nextIndex = child.startIndex;
if (nextIndex > index) {
this._pushRange(buffer, previousRanges, result, {
startIndex: index,
endIndex: nextIndex,
startPosition: position,
endPosition: child.startPosition
});
if (!this.includeChildren) {
for (const child of node.children) {
const nextIndex = child.startIndex;
if (nextIndex > index) {
this._pushRange(buffer, previousRanges, result, {
startIndex: index,
endIndex: nextIndex,
startPosition: position,
endPosition: child.startPosition
});
}
position = child.endPosition;
index = child.endIndex;
}
position = child.endPosition;
index = child.endIndex;
}
if (node.endIndex > index) {