Skip to content

Commit

Permalink
DAST and XML Compatability (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
siefkenj authored Oct 22, 2023
1 parent 7c7e584 commit 3616d26
Show file tree
Hide file tree
Showing 166 changed files with 23,135 additions and 1,119 deletions.
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
3,711 changes: 3,077 additions & 634 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
18 changes: 9 additions & 9 deletions packages/codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
},
"dependencies": {
"codemirror": "6.0.1",
"@codemirror/commands": "^6.2.5",
"@codemirror/commands": "^6.3.0",
"@codemirror/lang-xml": "^6.0.2",
"@codemirror/language": "^6.9.0",
"@codemirror/state": "^6.2.1",
"@codemirror/view": "^6.18.1",
"@lezer/common": "^1.0.4",
"@codemirror/language": "^6.9.1",
"@codemirror/state": "^6.3.1",
"@codemirror/view": "^6.21.3",
"@lezer/common": "^1.1.0",
"@lezer/highlight": "^1.1.6",
"@lezer/lr": "^1.3.10",
"@lezer/lr": "^1.3.13",
"@lezer/xml": "^1.0.2"
},
"devDependencies": {
"glob": "^10.3.3",
"vite": "^4.4.9",
"vite-plugin-dts": "^3.5.2"
"glob": "^10.3.10",
"vite": "^4.5.0",
"vite-plugin-dts": "^3.6.0"
}
}
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/**
16 changes: 16 additions & 0 deletions packages/doenet-vscode-extension/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**@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,
"@typescript-eslint/ban-ts-comment": 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

0 comments on commit 3616d26

Please sign in to comment.