Skip to content

Commit

Permalink
Merge pull request #12 from valtzu/typescript-tests
Browse files Browse the repository at this point in the history
Use cm-buildhelper to simplify build
  • Loading branch information
valtzu authored Jan 2, 2025
2 parents d2385fc + 96d67c2 commit 638c20d
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 295 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
package-lock.json
/dist
/src/*.js
/test/*.js
/src/*.d.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

0.9
---

* **BC BREAK:** Separate files are no longer included in the release (due to using `cm-buildhelper`)
* Tests are now in TypeScript too


0.8
---

Expand Down
17 changes: 5 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@valtzu/codemirror-lang-el",
"description": "Symfony Expression Language language support for CodeMirror",
"scripts": {
"test": "mocha test/*.js",
"dev": "rollup -c -w",
"prepare": "rollup -c"
"pretest": "npm run-script prepare",
"test": "cm-runtests",
"prepare": "cm-buildhelper src/index.ts"
},
"type": "module",
"main": "dist/index.cjs",
Expand All @@ -19,20 +19,13 @@
"@codemirror/autocomplete": "^6.9.0",
"@codemirror/language": "^6.0.0",
"@codemirror/lint": "^6.4.2",
"@codemirror/view": "^6.26.3",
"@codemirror/state": "^6.2.1",
"@codemirror/view": "^6.26.3",
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0"
},
"devDependencies": {
"@lezer/generator": "^1.0.0",
"@types/mocha": "^10.0.1",
"ist": "^1.1.7",
"mocha": "10.4.0",
"rollup": "^2.60.2",
"rollup-plugin-dts": "^4.0.1",
"rollup-plugin-ts": "^3.0.2",
"typescript": "^4.3.4"
"@codemirror/buildhelper": "^1.0.0"
},
"license": "MIT",
"repository": {
Expand Down
52 changes: 0 additions & 52 deletions rollup.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const autocompleteFunction = (x: ELFunction): Completion => ({
view.dispatch(
{
...insertCompletionText(view.state, `${x.name}()`, from, to),
selection: { anchor: from + x.name.length + (x.args?.length > 0 ? 1 : 2) }
selection: { anchor: from + x.name.length + ((x.args?.length ?? 0) > 0 ? 1 : 2) }
}
);
},
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { parser } from "./syntax.grammar";
import { LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, delimitedIndent } from "@codemirror/language";
import { styleTags, tags as t } from "@lezer/highlight";
import { ELFunction, ELIdentifier, ExpressionLanguageConfig } from "./types";
import { ExpressionLanguageConfig } from "./types";
import { expressionLanguageLinter } from "./linter";
import { expressionLanguageCompletion } from "./complete";
import { cursorTooltipField, keywordTooltip } from "./tooltip";
import { Extension } from "@codemirror/state";
import { baseTheme } from "./theme";

export { ELFunction, ELIdentifier, ExpressionLanguageConfig };
export * from "./types";
// for tests
export * as _complete from "./complete";
export * as _linter from "./linter";
export * as _utils from "./utils";
export * as _tooltip from "./tooltip";

export const ELLanguage = LRLanguage.define({
parser: parser.configure({
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ELIdentifier {
*/
export interface ELFunction {
name: string;
args: ELParameter[];
args?: ELParameter[];
info?: string;
returnType?: string[];
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const resolveIdentifier = (nodeName: 'Method' | 'Property' | 'Function' |
}
};

export function resolveTypes(state: EditorState, node: SyntaxNode | undefined, config: ExpressionLanguageConfig, matchExact: boolean): Set<string> {
export function resolveTypes(state: EditorState, node: SyntaxNode | undefined | null, config: ExpressionLanguageConfig, matchExact: boolean): Set<string> {
let types: Set<string> = new Set<string>();
if (!node) {
return types;
Expand Down
188 changes: 0 additions & 188 deletions test/test-complete.js

This file was deleted.

Loading

0 comments on commit 638c20d

Please sign in to comment.