Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAST and XML Compatability #24

Merged
merged 65 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
bf24400
Update Lezer grammar to parse xml-compliant files
siefkenj Aug 28, 2023
e915421
Add XML printing ability
siefkenj Aug 29, 2023
e92c4da
Keep track of errors while processing
siefkenj Aug 30, 2023
a754c1b
Update DAST syntax
siefkenj Sep 1, 2023
efb4ae1
Merge remote-tracking branch 'upstream/main' into xml
siefkenj Sep 1, 2023
3f74bfa
Add Prettier-based pretty printing
siefkenj Sep 3, 2023
19cf213
Merge remote-tracking branch 'upstream/main' into xml
siefkenj Sep 3, 2023
4579ec5
Merge remote-tracking branch 'upstream/main' into xml
siefkenj Sep 3, 2023
e7ce785
Updated snapshots
siefkenj Sep 3, 2023
2f50260
Add `showFormatter` option to `codeEditor`
siefkenj Sep 3, 2023
d483cd9
Fix ampersand parsing
siefkenj Sep 3, 2023
a9be034
Add basic macro parsing as a separate library
siefkenj Sep 4, 2023
51d2271
Add DAST support for macros and function macros
siefkenj Sep 6, 2023
7779ded
Allow balanced parens in function arguments
siefkenj Sep 7, 2023
64c1568
Add static genrator for schema
siefkenj Sep 8, 2023
1e7e27d
Update package-lock.json
siefkenj Sep 8, 2023
308fbec
Move schema dependency to static-assets
siefkenj Sep 8, 2023
fa7f840
Change build order
siefkenj Sep 8, 2023
9cc010b
Added a test viewer for DAST
siefkenj Sep 10, 2023
5ed87dd
Include more types of errors in error handling
siefkenj Sep 11, 2023
ce8d075
Upgrade codemirror and lezer
jaltekruse Sep 14, 2023
4875672
Start of LSP
siefkenj Sep 14, 2023
7dc7518
Merge remote-tracking branch 'origin/static-assets' into xml
siefkenj Sep 14, 2023
13a8092
Moved files
siefkenj Sep 14, 2023
65bdf72
Import directly from @doenet/parser
siefkenj Sep 14, 2023
fe0a97a
Merge remote-tracking branch 'upstream/main' into xml
siefkenj Sep 14, 2023
cca5174
Make lsp-tools buildable
siefkenj Sep 14, 2023
5339822
Add missing files
siefkenj Sep 15, 2023
56062a6
Merge remote-tracking branch 'jasona/upgrade-codemirror' into xml
siefkenj Sep 15, 2023
24af175
Updated codemirror
siefkenj Sep 15, 2023
c42fbc0
Add name lookup
siefkenj Sep 15, 2023
cbf0103
Have generatd assest re-exported as Javascript
siefkenj Sep 16, 2023
d38aa94
Import static assets as JS
siefkenj Sep 16, 2023
3eb80cf
Add query support for macro references
siefkenj Sep 26, 2023
6e5c7b0
Merge branch 'main' into xml
siefkenj Sep 26, 2023
4235f47
Fix test
siefkenj Sep 26, 2023
d6eb911
Merge remote-tracking branch 'upstream/main' into xml
siefkenj Oct 14, 2023
8813e3a
Add tsconfig to test dir
siefkenj Oct 14, 2023
08942e4
Allow <a><=</a> in the grammar.
siefkenj Oct 17, 2023
4fb08c4
vscode extension added
siefkenj Oct 17, 2023
17b4d19
Fixes
siefkenj Oct 17, 2023
c9e49d9
Updated tests
siefkenj Oct 17, 2023
83f1ea4
Split autocompletions into separate file
siefkenj Oct 18, 2023
ac95480
Merge remote-tracking branch 'upstream/main' into xml
siefkenj Oct 18, 2023
805561b
Move doenetml-core index file into src/ dir
siefkenj Oct 18, 2023
0a21375
Update reference
siefkenj Oct 18, 2023
052da74
Check whether attributes satisfy the schema
siefkenj Oct 18, 2023
7992ec7
Fixed README
siefkenj Oct 19, 2023
59486ab
Better tagging of errors
siefkenj Oct 19, 2023
7dee399
Fix printing of ampersands
siefkenj Oct 19, 2023
5f39e93
Review changes
siefkenj Oct 19, 2023
12f2c4c
Fixed error message
siefkenj Oct 19, 2023
68b1cdd
Fix range for items missing from schema
siefkenj Oct 19, 2023
bf2528c
Fix Issue #43 two-space indent
siefkenj Oct 19, 2023
052296a
Update vite version
siefkenj Oct 19, 2023
399b719
Fix crash when putting `=` after macro
siefkenj Oct 19, 2023
076c594
Highlight incorrect attribute values
siefkenj Oct 19, 2023
1ed631b
Updated grammar
siefkenj Oct 20, 2023
129ab0e
Case-insensitive value checking
siefkenj Oct 20, 2023
8946256
Add preview functionality to vscode extension
siefkenj Oct 20, 2023
3f4df25
Treat attributes without values as having the value `"true"`
siefkenj Oct 22, 2023
7b08082
Printer fixes
siefkenj Oct 22, 2023
e284d19
Convert line endings to unix format
siefkenj Oct 22, 2023
80eceae
Fix typo
siefkenj Oct 22, 2023
19cc984
Pretty printer update
siefkenj Oct 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ src/test/testCode.doenet
**/cypress/videos
**/cypress/screenshots
runner-results
parallel-weights.json
parallel-weights.json

out
node_modules
client/server
.vscode-test
2,262 changes: 1,989 additions & 273 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"./packages/ui-components",
"./packages/utils",
"./packages/parser",
"./packages/lsp-tools",
"./packages/doenetml-worker",
"./packages/static-assets",
"./packages/virtual-keyboard",
Expand Down
15 changes: 13 additions & 2 deletions packages/codemirror/src/CodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import React, {
useRef,
useState,
} from "react";
import { EditorState, Transaction, StateEffect } from "@codemirror/state";
import {
EditorState,
Transaction,
StateEffect,
EditorSelection,
} from "@codemirror/state";
import { selectLine, deleteLine, cursorLineUp } from "@codemirror/commands";
import { EditorView, keymap, Command } from "@codemirror/view";
import { basicSetup } from "codemirror";
Expand All @@ -25,13 +30,15 @@ import { doenetSchema } from "@doenet/static-assets";
export function CodeMirror({
setInternalValueTo,
onBeforeChange,
onCursorChange,
readOnly,
onBlur,
onFocus,
paddingBottom,
}: {
setInternalValueTo: string;
onBeforeChange: (str: string) => void;
onCursorChange?: (selection: EditorSelection) => any;
readOnly?: boolean;
onBlur?: () => void;
onFocus?: () => void;
Expand Down Expand Up @@ -86,6 +93,9 @@ export function CodeMirror({
const [count, setCount] = useState(0);

const changeFunc = useCallback((tr: Transaction) => {
if (tr.selection && onCursorChange) {
onCursorChange(tr.selection);
}
if (tr.docChanged) {
let strOfDoc = tr.state.sliceDoc();
onBeforeChange(strOfDoc);
Expand Down Expand Up @@ -206,6 +216,7 @@ export function CodeMirror({
onBlurExtension,
onFocusExtension,
EditorState.changeFilter.of(changeFunc),

// XXX This type appears to be incorrect, but I am not sure what this function is doing...
// @ts-ignore
EditorView.updateListener.of(changeFunc),
Expand Down Expand Up @@ -233,7 +244,7 @@ export function CodeMirror({
tagNameNode?.to,
);

//an ineffecient hack to make it so the modified document is saved directly after tagMatch
//an inefficient hack to make it so the modified document is saved directly after tagMatch
let tra = tr.state.update({
changes: {
from: cursorPos,
Expand Down
5 changes: 5 additions & 0 deletions packages/doenet-vscode-extension/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/**
client/node_modules/**
client/out/**
server/node_modules/**
server/out/**
20 changes: 20 additions & 0 deletions packages/doenet-vscode-extension/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**@type {import('eslint').Linter.Config} */
// eslint-disable-next-line no-undef
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'semi': [2, "always"],
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
}
};
9 changes: 9 additions & 0 deletions packages/doenet-vscode-extension/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
30 changes: 30 additions & 0 deletions packages/doenet-vscode-extension/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.2.0",
"configurations": [
{
"type": "extensionHost",
"request": "launch",
"name": "Launch Client",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
"preLaunchTask": {
"type": "npm",
"script": "watch"
}
},
{
"name": "Language Server E2E Test",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/client/out/test/index",
"${workspaceRoot}/client/testFixture"
],
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
}
]
}
19 changes: 19 additions & 0 deletions packages/doenet-vscode-extension/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"editor.insertSpaces": false,
"typescript.tsc.autoDetect": "off",
"typescript.preferences.quoteStyle": "single",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"cSpell.ignoreWords": [
"Dast",
"clientrc",
"documentroot",
"doublequoted",
"entitytype",
"internalsubset",
"localname",
"singlequoted",
"taglib"
]
}
33 changes: 33 additions & 0 deletions packages/doenet-vscode-extension/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "compile",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc"
]
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc-watch"
]
}
]
}
15 changes: 15 additions & 0 deletions packages/doenet-vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.vscode/**
**/*.ts
**/*.map
.gitignore
**/tsconfig.json
**/tsconfig.base.json
contributing.md
.travis.yml
client/node_modules/**
!client/node_modules/vscode-jsonrpc/**
!client/node_modules/vscode-languageclient/**
!client/node_modules/vscode-languageserver-protocol/**
!client/node_modules/vscode-languageserver-types/**
!client/node_modules/{minimatch,brace-expansion,concat-map,balanced-match}/**
!client/node_modules/{semver,lru-cache,yallist}/**
37 changes: 37 additions & 0 deletions packages/doenet-vscode-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# LSP Example

Heavily documented sample code for https://code.visualstudio.com/api/language-extensions/language-server-extension-guide

## Functionality

This Language Server works for plain text file. It has the following language features:
- Completions
- Diagnostics regenerated on each file change or configuration change

It also includes an End-to-End test.

## Structure

```
.
├── client // Language Client
│ ├── src
│ │ ├── test // End to End tests for Language Client / Server
│ │ └── extension.ts // Language Client entry point
├── package.json // The extension manifest.
└── server // Language Server
└── src
└── server.ts // Language Server entry point
```

## Running the Sample

- Run `npm install` in this folder. This installs all necessary npm modules in both the client and server folder
- Open VS Code on this folder.
- Press Ctrl+Shift+B to start compiling the client and server in [watch mode](https://code.visualstudio.com/docs/editor/tasks#:~:text=The%20first%20entry%20executes,the%20HelloWorld.js%20file.).
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
- Select `Launch Client` from the drop down (if it is not already).
- Press ▷ to run the launch config (F5).
- In the [Extension Development Host](https://code.visualstudio.com/api/get-started/your-first-extension#:~:text=Then%2C%20inside%20the%20editor%2C%20press%20F5.%20This%20will%20compile%20and%20run%20the%20extension%20in%20a%20new%20Extension%20Development%20Host%20window.) instance of VSCode, open a document in 'plain text' language mode.
- Type `j` or `t` to see `Javascript` and `TypeScript` completion.
- Enter text content such as `AAA aaa BBB`. The extension will emit diagnostics for all words in all-uppercase.
Loading