@codemirror/lang-javascript
Advanced tools
Comparing version
@@ -0,1 +1,9 @@ | ||
## 6.0.1 (2022-06-29) | ||
### Bug fixes | ||
Avoid completing variables/keywords in property or definition positions. | ||
Fix a bug that broke local variable completion if JavaScript was parsed an overlay in an outer language. | ||
## 6.0.0 (2022-06-08) | ||
@@ -2,0 +10,0 @@ |
@@ -126,2 +126,9 @@ import { parser } from '@lezer/javascript'; | ||
const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/; | ||
const dontComplete = [ | ||
"TemplateString", "String", "RegExp", | ||
"LineComment", "BlockComment", | ||
"VariableDefinition", "TypeDefinition", "Label", | ||
"PropertyDefinition", "PropertyName", | ||
"PrivatePropertyDefinition", "PrivatePropertyName" | ||
]; | ||
/** | ||
@@ -132,5 +139,4 @@ Completion source that looks up locally defined names in | ||
function localCompletionSource(context) { | ||
let inner = syntaxTree(context.state).resolve(context.pos, -1); | ||
if (inner.name == "TemplateString" || inner.name == "String" || | ||
inner.name == "LineComment" || inner.name == "BlockComment") | ||
let inner = syntaxTree(context.state).resolveInner(context.pos, -1); | ||
if (dontComplete.indexOf(inner.name) > -1) | ||
return null; | ||
@@ -219,3 +225,3 @@ let isWord = inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to)); | ||
javascriptLanguage.data.of({ | ||
autocomplete: ifNotIn(["LineComment", "BlockComment", "String"], completeFromList(snippets.concat(keywords))) | ||
autocomplete: ifNotIn(dontComplete, completeFromList(snippets.concat(keywords))) | ||
}), | ||
@@ -222,0 +228,0 @@ javascriptLanguage.data.of({ |
{ | ||
"name": "@codemirror/lang-javascript", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "JavaScript language support for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,10 +5,10 @@ <!-- NOTE: README.md is generated from src/README.md --> | ||
[ [**WEBSITE**](https://codemirror.net/6/) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-javascript/blob/main/CHANGELOG.md) ] | ||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-javascript/blob/main/CHANGELOG.md) ] | ||
This package implements JavaScript language support for the | ||
[CodeMirror](https://codemirror.net/6/) code editor. | ||
[CodeMirror](https://codemirror.net/) code editor. | ||
The [project page](https://codemirror.net/6/) has more information, a | ||
number of [examples](https://codemirror.net/6/examples/) and the | ||
[documentation](https://codemirror.net/6/docs/). | ||
The [project page](https://codemirror.net/) has more information, a | ||
number of [examples](https://codemirror.net/examples/) and the | ||
[documentation](https://codemirror.net/docs/). | ||
@@ -26,3 +26,3 @@ This code is released under an | ||
<dt id="user-content-javascript"> | ||
<code><strong><a href="#user-content-javascript">javascript</a></strong>(<a id="user-content-javascript^config" href="#user-content-javascript^config">config</a>⁠?: {jsx⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, typescript⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>} = {}) → <a href="https://codemirror.net/6/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt> | ||
<code><strong><a href="#user-content-javascript">javascript</a></strong>(<a id="user-content-javascript^config" href="#user-content-javascript^config">config</a>⁠?: {jsx⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, typescript⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>} = {}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt> | ||
@@ -33,3 +33,3 @@ <dd><p>JavaScript support. Includes <a href="#user-content-snippets">snippet</a> | ||
<dt id="user-content-javascriptlanguage"> | ||
<code><strong><a href="#user-content-javascriptlanguage">javascriptLanguage</a></strong>: <a href="https://codemirror.net/6/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
<code><strong><a href="#user-content-javascriptlanguage">javascriptLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
@@ -41,3 +41,3 @@ <dd><p>A language provider based on the <a href="https://github.com/lezer-parser/javascript">Lezer JavaScript | ||
<dt id="user-content-typescriptlanguage"> | ||
<code><strong><a href="#user-content-typescriptlanguage">typescriptLanguage</a></strong>: <a href="https://codemirror.net/6/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
<code><strong><a href="#user-content-typescriptlanguage">typescriptLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
@@ -47,3 +47,3 @@ <dd><p>A language provider for TypeScript.</p> | ||
<dt id="user-content-jsxlanguage"> | ||
<code><strong><a href="#user-content-jsxlanguage">jsxLanguage</a></strong>: <a href="https://codemirror.net/6/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
<code><strong><a href="#user-content-jsxlanguage">jsxLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
@@ -53,3 +53,3 @@ <dd><p>Language provider for JSX.</p> | ||
<dt id="user-content-tsxlanguage"> | ||
<code><strong><a href="#user-content-tsxlanguage">tsxLanguage</a></strong>: <a href="https://codemirror.net/6/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
<code><strong><a href="#user-content-tsxlanguage">tsxLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt> | ||
@@ -59,15 +59,15 @@ <dd><p>Language provider for JSX + TypeScript.</p> | ||
<dt id="user-content-snippets"> | ||
<code><strong><a href="#user-content-snippets">snippets</a></strong>: readonly <a href="https://codemirror.net/6/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt> | ||
<code><strong><a href="#user-content-snippets">snippets</a></strong>: readonly <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt> | ||
<dd><p>A collection of JavaScript-related | ||
<a href="https://codemirror.net/6/docs/ref/#autocomplete.snippet">snippets</a>.</p> | ||
<a href="https://codemirror.net/docs/ref/#autocomplete.snippet">snippets</a>.</p> | ||
</dd> | ||
<dt id="user-content-eslint"> | ||
<code><strong><a href="#user-content-eslint">esLint</a></strong>(<a id="user-content-eslint^eslint" href="#user-content-eslint^eslint">eslint</a>: any, <a id="user-content-eslint^config" href="#user-content-eslint^config">config</a>⁠?: any) → fn(<a id="user-content-eslint^returns^view" href="#user-content-eslint^returns^view">view</a>: <a href="https://codemirror.net/6/docs/ref#view.EditorView">EditorView</a>) → <a href="https://codemirror.net/6/docs/ref#lint.Diagnostic">Diagnostic</a>[]</code></dt> | ||
<code><strong><a href="#user-content-eslint">esLint</a></strong>(<a id="user-content-eslint^eslint" href="#user-content-eslint^eslint">eslint</a>: any, <a id="user-content-eslint^config" href="#user-content-eslint^config">config</a>⁠?: any) → fn(<a id="user-content-eslint^returns^view" href="#user-content-eslint^returns^view">view</a>: <a href="https://codemirror.net/docs/ref#view.EditorView">EditorView</a>) → <a href="https://codemirror.net/docs/ref#lint.Diagnostic">Diagnostic</a>[]</code></dt> | ||
<dd><p>Connects an <a href="https://eslint.org/">ESLint</a> linter to CodeMirror's | ||
<a href="https://codemirror.net/6/docs/ref/#lint">lint</a> integration. <code>eslint</code> should be an instance of the | ||
<a href="https://codemirror.net/docs/ref/#lint">lint</a> integration. <code>eslint</code> should be an instance of the | ||
<a href="https://eslint.org/docs/developer-guide/nodejs-api#linter"><code>Linter</code></a> | ||
class, and <code>config</code> an optional ESLint configuration. The return | ||
value of this function can be passed to <a href="https://codemirror.net/6/docs/ref/#lint.linter"><code>linter</code></a> | ||
value of this function can be passed to <a href="https://codemirror.net/docs/ref/#lint.linter"><code>linter</code></a> | ||
to create a JavaScript linting extension.</p> | ||
@@ -74,0 +74,0 @@ <p>Note that ESLint targets node, and is tricky to run in the |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39305
1.13%729
1.67%