diff --git a/.cargo/config.toml b/.cargo/config.toml index 10f97e0..23a5430 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,5 +4,12 @@ default = "oksoftware" [registries.oksoftware] index = "https://ok.software/ok/_cargo-index.git" # Git + +[registries.crates-io] +index = "https://github.com/rust-lang/crates.io-index" + [net] -git-fetch-with-cli = true \ No newline at end of file +git-fetch-with-cli = true + +[build] +rustflags = "--cfg=web_sys_unstable_apis" diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d330888 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,84 @@ +ARG VARIANT "bookworm-20240701" + +# FROM debian:${VARIANT} +FROM debian:bookworm-20240701 + +RUN apt-get update && apt-get install -y \ + sudo \ + libssl-dev \ + lsb-release \ + musl-dev \ + make \ + cmake \ + git \ + qemu-kvm \ + perl \ + gzip \ + ca-certificates \ + clang \ + cloud-image-utils \ + curl \ + dpkg-dev \ + expect \ + g++ \ + gcc \ + git \ + jq \ + libavcodec-dev \ + libc++abi1-14 \ + libavutil-dev \ + libcap-dev \ + libclang-dev \ + libdbus-1-dev \ + libdrm-dev \ + libepoxy-dev \ + libglib2.0-dev \ + libguestfs-tools \ + libslirp-dev \ + libssl-dev \ + libswscale-dev \ + libva-dev \ + libunwind-dev \ + libunwind-14 \ + libwayland-dev \ + libxext-dev \ + lld \ + make \ + meson \ + mypy \ + nasm \ + npm \ + ncat \ + ninja-build \ + openssh-client \ + pipx \ + pkg-config \ + protobuf-compiler \ + python3 \ + python3-argh \ + python3-pip \ + python3-rich \ + qemu-system-x86 \ + rsync \ + screen \ + strace \ + tmux \ + wayland-protocols \ + wget \ + && rm -rf /var/lib/apt/lists/* + + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y +ENV PATH="/root/.cargo/bin:${PATH}" +ENV CARGO_HOME=/root/.cargo + +# install wasm32-unknown-unknown +RUN rustup target add wasm32-unknown-unknown + +# update rust +RUN rustup update + +RUN curl https://raw.githubusercontent.com/SeaQL/FireDBG.for.Rust/main/install.sh -sSf | sh + +WORKDIR /workspaces \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..89cacb1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +{ + "name": "ok.dev", + "build": { + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "bookworm-20240701" + } + }, + "runArgs": [ + "--device=/dev/kvm", + "--group-add=kvm", + "--pids-limit=4096" + ], + // "remoteUser": "root", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "updateRemoteUserUID": true, + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml", + "esbenp.prettier-vscode", + "ms-python.vscode-pylance", + "foxundermoon.shell-format", + "timonwong.shellcheck", + "GitHub.copilot", + "SeaQL.firedbg-rust" + ] + } + } +} diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index b078357..01f0bf8 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -21,20 +21,16 @@ on: jobs: rust-clippy-analyze: name: Run rust-clippy analyzing - runs-on: self-hosted + runs-on: ubuntu-latest + container: ghcr.io/sevki/devcontainer:main permissions: contents: read security-events: write actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status - + steps: - - name: Modify hosts file - run: | - echo "66.241.125.220 ok.software" >> /etc/hosts - - name: Checkout code uses: actions/checkout@v2 - - name: Install Rust toolchain uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1 with: @@ -42,10 +38,8 @@ jobs: toolchain: stable components: clippy override: true - - name: Install required cargo run: cargo install clippy-sarif sarif-fmt - - name: Run rust-clippy run: cargo clippy @@ -57,4 +51,4 @@ jobs: uses: github/codeql-action/upload-sarif@v2 with: sarif_file: rust-clippy-results.sarif - wait-for-processing: true \ No newline at end of file + wait-for-processing: true diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml index 4e8807f..e208b63 100644 --- a/.github/workflows/mdbook.yml +++ b/.github/workflows/mdbook.yml @@ -8,6 +8,8 @@ on: # Runs on pushes targeting the default branch push: branches: ["main"] + pull_request: + branches: ["main"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -28,29 +30,41 @@ jobs: # Build job build: runs-on: ubuntu-latest - container: rust:latest + container: ghcr.io/sevki/devcontainer:main + strategy: + matrix: + targets: + - x86_64-unknown-linux-gnu + packages: + - srclang + toolchains: + - stable + env: MDBOOK_VERSION: 0.4.40 steps: - - name: Modify hosts file - run: | - echo "66.241.125.220 ok.software" >> /etc/hosts - - uses: actions/checkout@v4 + - name: rustup update + run: | + rustup toolchain install ${{ matrix.toolchains }} + rustup component add cargo + rustup component add clippy + rustup component add rust-src + rustup target add ${{ matrix.targets }} + rustup update - name: Install mdBook run: | - curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh - rustup update cargo install --version ${MDBOOK_VERSION} mdbook - name: Setup Pages id: pages uses: actions/configure-pages@v5 - - name: install deps - run: | - cargo install mdbook-svgbob@0.2.0 - cargo install mdbook-alerts - name: Build with mdBook run: mdbook build + - name: Build the ide + run: | + cd packages/app + npm install + npm run build - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: @@ -62,6 +76,7 @@ jobs: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' needs: build steps: - name: Deploy to GitHub Pages diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index dc9dc72..6167180 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,5 +1,4 @@ name: Rust - on: push: branches: [ "main" ] @@ -8,21 +7,35 @@ on: env: CARGO_TERM_COLOR: always - jobs: build: + env: + MDBOOK_VERSION: 0.4.40 runs-on: ubuntu-latest + container: ghcr.io/sevki/devcontainer:main - container: rust:latest + strategy: + matrix: + targets: + - x86_64-unknown-linux-gnu + packages: + - srclang + toolchains: + - stable + - nightly steps: - - name: Modify hosts file - run: | - echo "66.241.125.220 ok.software" >> /etc/hosts - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - name: rustup update + run: | + rustup toolchain install ${{ matrix.toolchains }} + rustup component add cargo + rustup component add clippy + rustup component add rust-src + rustup target add ${{ matrix.targets }} + rustup update + - name: Build ${{ matrix.packages }} for ${{ matrix.targets }} + run: cargo build --verbose --target ${{ matrix.targets }} -p ${{ matrix.packages }} + - name: Test ${{ matrix.packages }} for ${{ matrix.targets }} + run: cargo test --verbose --target ${{ matrix.targets }} -p ${{ matrix.packages }} diff --git a/.gitignore b/.gitignore index 05ff2e4..720beba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ book target +node_modules +packages/app/assets/wasm/src_lsp_browser.d.ts +packages/app/assets/wasm/src_lsp_browser.js +packages/app/assets/wasm/src_lsp_browser_bg.wasm +packages/app/assets/wasm/src_lsp_browser_bg.wasm.d.ts diff --git a/.rust-toolchain.toml b/.rust-toolchain.toml new file mode 100644 index 0000000..435bdee --- /dev/null +++ b/.rust-toolchain.toml @@ -0,0 +1,17 @@ + +[toolchain] +channel = "1.79" +components = [ + "rust-src", + "rustc-dev", + "llvm-tools-preview", + "clippy", + "rustfmt", + "miri", + "cargo", +] +targets = [ + "wasm32-unknown-unknown", + "x86_64-unknown-linux-musl", + "x86_64-unknown-linux-gnu", +] diff --git a/Cargo.lock b/Cargo.lock index 729496c..e02f4f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -46,9 +46,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arc-swap" @@ -56,12 +56,6 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "ascii-canvas" version = "3.0.0" @@ -71,6 +65,54 @@ dependencies = [ "term", ] +[[package]] +name = "async-codec-lite" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2527c30e3972d8ff366b353125dae828c4252a154dbe6063684f6c5e014760a3" +dependencies = [ + "anyhow", + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "log", + "pin-project-lite", + "thiserror", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-trait" +version = "0.1.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "auto_impl" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -79,9 +121,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", @@ -90,7 +132,6 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "serde", ] [[package]] @@ -99,21 +140,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64-simd" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5" -dependencies = [ - "simd-abstraction", -] - -[[package]] -name = "binary-merge" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597bb81c80a54b6a4381b23faba8d7774b144c94cbd1d6fe3f1329bd776554ab" - [[package]] name = "bit-set" version = "0.5.3" @@ -142,31 +168,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] -name = "bitvec" -version = "1.0.1" +name = "bumpalo" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "brownstone" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5839ee4f953e811bfdcf223f509cb2c6a3e1447959b0bff459405575bc17f22" -dependencies = [ - "arrayvec", -] - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytes" @@ -176,9 +181,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -186,6 +191,27 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "colored" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f741c91823341bebf717d4c71bda820630ce065443b58bd1b7451af008355" +dependencies = [ + "is-terminal", + "lazy_static", + "winapi", +] + +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "console" version = "0.15.8" @@ -198,6 +224,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "core2" version = "0.3.3" @@ -207,15 +243,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "cpp_demangle" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" -dependencies = [ - "cfg-if", -] - [[package]] name = "crc16" version = "0.4.0" @@ -223,10 +250,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" [[package]] -name = "crc32fast" -version = "1.4.0" +name = "crc32_digest" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "45d5efbc16ba04a6c1691aee22f18e9cce02fb7b7bdf85296d99139389b41983" +dependencies = [ + "crc32fast", + "digest", + "generic-array", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -246,9 +284,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -283,9 +321,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -293,41 +331,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "darling" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "dashmap" version = "5.5.3" @@ -335,35 +338,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "lock_api", "once_cell", "parking_lot_core", ] [[package]] -name = "data-encoding" -version = "2.6.0" +name = "diff" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] -name = "debugid" -version = "0.8.0" +name = "digest" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "serde", - "uuid", -] - -[[package]] -name = "deranged" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" -dependencies = [ - "powerfmt", + "generic-array", ] [[package]] @@ -387,35 +380,11 @@ dependencies = [ "winapi", ] -[[package]] -name = "dmsort" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0bc8fbe9441c17c9f46f75dfe27fa1ddb6c68a461ccaed0481419219d4f10d3" - [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" - -[[package]] -name = "elementtree" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efd4742acf458718a6456e0adf0b4d734d6b783e452bbf1ac36bf31f4085cb3" -dependencies = [ - "string_cache", -] - -[[package]] -name = "elsa" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98e71ae4df57d214182a2e5cb90230c0192c6ddfcaa05c36453d46a54713e10" -dependencies = [ - "stable_deref_trait", -] +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "ena" @@ -448,6 +417,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "eyre" version = "0.6.12" @@ -458,18 +433,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fallible-iterator" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" - [[package]] name = "fastrand" version = "2.1.0" @@ -485,22 +448,22 @@ dependencies = [ "core2", ] +[[package]] +name = "fern" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" +dependencies = [ + "colored 1.9.4", + "log", +] + [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "flate2" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - [[package]] name = "fnv" version = "1.0.7" @@ -516,12 +479,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "futures" version = "0.3.30" @@ -578,7 +535,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.66", ] [[package]] @@ -611,6 +568,15 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -618,30 +584,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" -dependencies = [ - "fallible-iterator 0.3.0", - "stable_deref_trait", -] +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] -name = "goblin" -version = "0.7.1" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27c1b4369c2cd341b5de549380158b105a04c331be5db9110eef7b6d2742134" -dependencies = [ - "log", - "plain", - "scroll", -] +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" @@ -659,7 +618,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -681,10 +640,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "ident_case" -version = "1.0.1" +name = "httparse" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "idna" @@ -696,24 +655,22 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "if_chain" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" - -[[package]] -name = "indent_write" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfe9645a18782869361d9c8732246be7b410ad4e919d3609ebabdac00ba12c3" - [[package]] name = "indenter" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -721,17 +678,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", ] [[package]] -name = "inplace-vec-builder" -version = "0.1.1" +name = "indoc" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf64c2edc8226891a71f127587a2861b132d2b942310843814d5001d99a1d307" -dependencies = [ - "smallvec", -] +checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "insta" @@ -772,10 +726,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] -name = "joinery" -version = "2.1.0" +name = "js-sys" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "lalrpop" @@ -814,17 +771,11 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -850,9 +801,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -871,10 +822,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] -name = "maybe-owned" -version = "0.3.4" +name = "lsp-text" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" +checksum = "756678d230c24143e31305c399b8c9175615db7230646258736a270717c611da" +dependencies = [ + "anyhow", + "bytes", + "lsp-types", + "ropey", +] + +[[package]] +name = "lsp-types" +version = "0.93.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be6e9c7e2d18f651974370d7aff703f9513e0df6e464fd795660edc77e6ca51" +dependencies = [ + "bitflags 1.3.2", + "serde", + "serde_json", + "serde_repr", + "url", +] [[package]] name = "memchr" @@ -882,26 +852,11 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "memmap2" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" -dependencies = [ - "libc", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] @@ -917,50 +872,12 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "msvc-demangler" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb67c6dd0fa9b00619c41c5700b6f92d5f418be49b45ddb9970fbd4569df3c8" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "new_debug_unreachable" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "nom-supreme" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd3ae6c901f1959588759ff51c95d24b491ecb9ff91aa9c2ef4acc5b1dcab27" -dependencies = [ - "brownstone", - "indent_write", - "joinery", - "memchr", - "nom", -] - -[[package]] -name = "num-conv" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" - [[package]] name = "num-traits" version = "0.2.19" @@ -983,49 +900,45 @@ dependencies = [ [[package]] name = "object" -version = "0.32.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" dependencies = [ "memchr", ] [[package]] name = "ok_macros" -version = "0.1.3" +version = "0.1.9" source = "registry+https://ok.software/ok/_cargo-index.git" -checksum = "59f4d3b83f7297c240c4d7dbcd31d8e2a6f19f29535953726759c489fdf48a94" +checksum = "769aac233e4883cafe74ae54d6ed7195f32498efce93eb325656408fc7fb4f07" dependencies = [ - "darling", "proc-macro2", "quote", - "slog", - "syn 2.0.63", + "syn 2.0.66", ] [[package]] name = "okstd" -version = "0.1.3" +version = "0.1.9" source = "registry+https://ok.software/ok/_cargo-index.git" -checksum = "49a64360a2959ff4269724c60f9c2479c7c81df55ce0a7ee79f2fb56c44e7ad6" +checksum = "a444fcc714b7bfe7ad667ae981c432cbb3dae61887f10279a6ea294e5ae06ee8" dependencies = [ "anyhow", - "backtrace", "base64", + "colored 2.1.0", "crc16", + "crc32_digest", "fastvlq", + "fern", "futures", "hex", + "log", "num_cpus", "ok_macros", "rustc-demangle", "serde", "serde_json", - "slog", - "slog-scope", - "slog-term", - "sourcemap", - "symbolic", "termcolor", "tokio", "url", @@ -1037,17 +950,11 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "outref" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4" - [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -1067,29 +974,10 @@ dependencies = [ ] [[package]] -name = "pdb" -version = "0.8.0" +name = "paste" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82040a392923abe6279c00ab4aff62d5250d1c8555dc780e4b02783a7aa74863" -dependencies = [ - "fallible-iterator 0.2.0", - "scroll", - "uuid", -] - -[[package]] -name = "pdb-addr2line" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e89a9f2f40b2389ba6da0814c8044bf942bece03dffa1514f84e3b525f4f9a" -dependencies = [ - "bitflags 1.3.2", - "elsa", - "maybe-owned", - "pdb", - "range-collections", - "thiserror", -] +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" @@ -1104,7 +992,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.2.6", ] [[package]] @@ -1142,6 +1030,26 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "pin-project-lite" version = "0.2.14" @@ -1154,18 +1062,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1179,10 +1075,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] -name = "proc-macro2" -version = "1.0.82" +name = "pretty_assertions" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ "unicode-ident", ] @@ -1222,12 +1152,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -1267,17 +1191,6 @@ dependencies = [ "rand_core", ] -[[package]] -name = "range-collections" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fdfd79629e2b44a1d34b4d227957174cb858e6b86ee45fad114edbcfc903ab" -dependencies = [ - "binary-merge", - "inplace-vec-builder", - "smallvec", -] - [[package]] name = "redox_syscall" version = "0.5.1" @@ -1327,6 +1240,16 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "ropey" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93411e420bcd1a75ddd1dc3caf18c23155eda2c090631a85af21ba19e97093b5" +dependencies = [ + "smallvec", + "str_indices", +] + [[package]] name = "rustc-demangle" version = "0.1.24" @@ -1339,15 +1262,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustix" version = "0.38.34" @@ -1396,7 +1310,7 @@ dependencies = [ "crossbeam-utils", "dashmap", "hashlink", - "indexmap", + "indexmap 2.2.6", "log", "parking_lot", "rustc-hash", @@ -1432,65 +1346,24 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scroll" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.63", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.66", ] [[package]] @@ -1504,6 +1377,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -1513,15 +1397,6 @@ dependencies = [ "libc", ] -[[package]] -name = "simd-abstraction" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987" -dependencies = [ - "outref", -] - [[package]] name = "similar" version = "2.5.0" @@ -1543,36 +1418,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "slog" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" - -[[package]] -name = "slog-scope" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f95a4b4c3274cd2869549da82b57ccc930859bdbf5bcea0424bc5f140b3c786" -dependencies = [ - "arc-swap", - "lazy_static", - "slog", -] - -[[package]] -name = "slog-term" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e022d0b998abfe5c3782c1f03551a596269450ccd677ea51c56f8b214610e8" -dependencies = [ - "is-terminal", - "slog", - "term", - "thread_local", - "time", -] - [[package]] name = "smallvec" version = "1.13.2" @@ -1590,22 +1435,78 @@ dependencies = [ ] [[package]] -name = "sourcemap" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "208d40b9e8cad9f93613778ea295ed8f3c2b1824217c6cfc7219d3f6f45b96d4" +name = "src-collections" +version = "0.1.0" dependencies = [ - "base64-simd", - "bitvec", - "data-encoding", - "debugid", - "if_chain", + "indexmap 1.9.3", "rustc-hash", - "rustc_version", - "serde", + "typed-index-collections", +] + +[[package]] +name = "src-derive" +version = "0.1.0" +dependencies = [ + "insta", + "okstd", + "pretty_assertions", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "src-derive-test" +version = "0.1.0" +dependencies = [ + "okstd", + "src-derive", + "srclang", +] + +[[package]] +name = "src-lsp-browser" +version = "0.0.0" +dependencies = [ + "console_error_panic_hook", + "futures", + "js-sys", + "src-lsp-server", + "srclang", + "tower-lsp", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", +] + +[[package]] +name = "src-lsp-server" +version = "0.0.0" +dependencies = [ + "anyhow", + "async-lock", + "console_error_panic_hook", + "dashmap", + "futures", + "indoc", + "js-sys", + "lazy_static", + "log", + "lsp-text", + "lsp-types", + "ropey", + "salsa-2022", + "salsa-2022-macros", "serde_json", - "unicode-id-start", - "url", + "src-collections", + "srclang", + "thiserror", + "tower-lsp", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", ] [[package]] @@ -1614,24 +1515,28 @@ version = "0.1.0" dependencies = [ "anyhow", "bitflags 2.5.0", + "getrandom", + "hashbrown 0.14.5", "insta", "lalrpop", "lalrpop-util", "okstd", + "paste", "phf_codegen", "proptest", + "ropey", "salsa-2022", "salsa-2022-macros", - "stringzilla", - "syn 2.0.63", + "src-derive", + "syn 2.0.66", "tiny-keccak", ] [[package]] -name = "stable_deref_trait" -version = "1.2.0" +name = "str_indices" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "e9557cb6521e8d009c51a8666f09356f4b817ba9ba0981a305bd86aee47bd35c" [[package]] name = "string_cache" @@ -1644,122 +1549,6 @@ dependencies = [ "parking_lot", "phf_shared", "precomputed-hash", - "serde", -] - -[[package]] -name = "stringzilla" -version = "3.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9a1352f8eeb0d30185b926e5199036f193e48be49731bf87f461ba0e0a46e6c" -dependencies = [ - "cc", -] - -[[package]] -name = "strsim" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" - -[[package]] -name = "symbolic" -version = "12.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec4f53c56d7ee8809c2322925d362e193bcc7bbe7e777a3304b34ea7e85a36" -dependencies = [ - "symbolic-common", - "symbolic-debuginfo", - "symbolic-demangle", - "symbolic-symcache", -] - -[[package]] -name = "symbolic-common" -version = "12.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cccfffbc6bb3bb2d3a26cd2077f4d055f6808d266f9d4d158797a4c60510dfe" -dependencies = [ - "debugid", - "memmap2", - "serde", - "stable_deref_trait", - "uuid", -] - -[[package]] -name = "symbolic-debuginfo" -version = "12.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb52777be67777947c5a159f1b6e8bfe4473d91fad7e5d4aff85ee4d3963cc04" -dependencies = [ - "debugid", - "dmsort", - "elementtree", - "elsa", - "fallible-iterator 0.3.0", - "flate2", - "gimli", - "goblin", - "lazy_static", - "nom", - "nom-supreme", - "once_cell", - "parking_lot", - "pdb-addr2line", - "regex", - "scroll", - "serde", - "serde_json", - "smallvec", - "symbolic-common", - "symbolic-ppdb", - "thiserror", - "wasmparser", - "zip", -] - -[[package]] -name = "symbolic-demangle" -version = "12.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a99812da4020a67e76c4eb41f08c87364c14170495ff780f30dd519c221a68" -dependencies = [ - "cc", - "cpp_demangle", - "msvc-demangler", - "rustc-demangle", - "symbolic-common", -] - -[[package]] -name = "symbolic-ppdb" -version = "12.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dace84623ccc926886fc880c36e2a81af4b17f8276abc4d77dc947ca3c6c8f8c" -dependencies = [ - "flate2", - "indexmap", - "serde", - "serde_json", - "symbolic-common", - "thiserror", - "uuid", - "watto", -] - -[[package]] -name = "symbolic-symcache" -version = "12.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5bddf351855de48a9b9deb1ef1a755e228ee2902fbeb8ef255e2522afd6dae" -dependencies = [ - "indexmap", - "symbolic-common", - "symbolic-debuginfo", - "thiserror", - "tracing", - "watto", ] [[package]] @@ -1775,21 +1564,15 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tempfile" version = "3.10.1" @@ -1824,63 +1607,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", -] - -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "time" -version = "0.3.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", + "syn 2.0.66", ] [[package]] @@ -1934,39 +1676,79 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.66", ] [[package]] -name = "tracing" -version = "0.1.40" +name = "tower" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ + "futures-core", + "futures-util", + "pin-project", "pin-project-lite", - "tracing-attributes", - "tracing-core", + "tower-layer", + "tower-service", ] [[package]] -name = "tracing-attributes" -version = "0.1.27" +name = "tower-layer" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-lsp" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43e094780b4447366c59f79acfd65b1375ecaa84e61dddbde1421aa506334024" +dependencies = [ + "async-codec-lite", + "async-trait", + "auto_impl", + "bytes", + "dashmap", + "futures", + "httparse", + "log", + "lsp-types", + "memchr", + "serde", + "serde_json", + "tower", + "tower-lsp-macros", +] + +[[package]] +name = "tower-lsp-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebd99eec668d0a450c177acbc4d05e0d0d13b1f8d3db13cd706c52cbec4ac04" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 1.0.109", ] [[package]] -name = "tracing-core" -version = "0.1.32" +name = "tower-service" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "typed-index-collections" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183496e014253d15abbe6235677b1392dba2d40524c88938991226baa38ac7c4" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unarray" @@ -1980,12 +1762,6 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" -[[package]] -name = "unicode-id-start" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f73150333cb58412db36f2aca8f2875b013049705cc77b94ded70a1ab1f5da" - [[package]] name = "unicode-ident" version = "1.0.12" @@ -2016,14 +1792,9 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] -[[package]] -name = "uuid" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" - [[package]] name = "version_check" version = "0.9.4" @@ -2056,23 +1827,93 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasmparser" -version = "0.118.2" +name = "wasm-bindgen" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f1154f1ab868e2a01d9834a805faca7bf8b50d041b4ca714d005d0dab1c50c" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "indexmap", - "semver 1.0.23", + "cfg-if", + "wasm-bindgen-macro", ] [[package]] -name = "watto" -version = "0.1.0" +name = "wasm-bindgen-backend" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6746b5315e417144282a047ebb82260d45c92d09bf653fa9ec975e3809be942b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ - "leb128", - "thiserror", + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.66", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f" +dependencies = [ + "cfg-if", + "futures-core", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "wasm-streams" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bbae3363c08332cadccd13b67db371814cd214c2524020932f0804b8cf7c078" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", ] [[package]] @@ -2246,13 +2087,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] -name = "wyz" +name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" @@ -2271,17 +2109,5 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", -] - -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", - "flate2", + "syn 2.0.66", ] diff --git a/Cargo.toml b/Cargo.toml index cc1d665..b75e77b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,15 @@ name = "srclang" version = "0.1.0" edition = "2021" +[workspace] +members = [ + "crates/src-collections", + "crates/src-derive", + "crates/src-derive-test", + "crates/src-lsp-browser", + "crates/src-lsp-server", +] + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] default = ["lalrpop"] @@ -13,18 +22,20 @@ anyhow = "1.0.45" phf_codegen = "0.10" tiny-keccak = { version = "2", features = ["sha3"] } - [dependencies] -salsa = { version = "0.1.0", registry = "oksoftware", package = "salsa-2022" } -salsa-macros = { version = "0.1.0", registry = "oksoftware" , package = "salsa-2022-macros" } -insta = "1.38.0" -lalrpop = "0.20.2" +getrandom = { version = "0.2", features = ["js"] } +salsa = { version = "0.1.0", registry = "oksoftware", package = "salsa-2022" } +salsa-macros = { version = "0.1.0", registry = "oksoftware", package = "salsa-2022-macros" } lalrpop-util = { version = "0.20.2", features = ["lexer", "unicode"] } -okstd = { version = "0.1.3", features = [], default-features = false, registry = "oksoftware" } -proptest = "1.4.0" -stringzilla = "3.8.1" +okstd = { features = [ + "macros", +], default-features = false, registry = "oksoftware", version = "0.1.9" } syn = "2.0.60" bitflags = "2.5.0" +ropey = { version = "1.6.1", features = ["small_chunks"] } +hashbrown = "0.14.5" +src-derive = { version = "0.1.0", path = "crates/src-derive", registry = "oksoftware" } +paste = "1.0.15" [dev-dependencies] insta = "1.38.0" diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..477ea1b --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,47 @@ +[config] +default_to_workspace = false +skip_core_tasks = true + +[tasks.deps] +script = ''' +cargo install wasm-bindgen-cli --version 0.2.81 --registry crates-io +npm install +''' + +[tasks.build-server] +script = ''' +cargo build --release +wasm-bindgen --out-dir ./packages/app/assets/wasm --target web --typescript ./target/wasm32-unknown-unknown/release/demo_lsp_browser.wasm +''' + +[tasks.build-app] +script = ''' +npm run build --workspace=packages/app +''' + +[tasks.build] +dependencies = ["build-server", "build-app"] + +[tasks.clean-server] +script = ''' +cargo clean +''' + +[tasks.clean-app] +script = ''' +rm -rf packages/app/dist +rm -rf packages/app/assets/wasm +''' + +[tasks.clean] +dependencies = ["clean-server", "clean-app"] + +[tasks.format] +script = ''' +cargo +nightly fmt --all +''' + +[tasks.run] +script = ''' +npm run app --workspace=packages/app +''' diff --git a/book.toml b/book.toml index e6b925f..65bc11e 100644 --- a/book.toml +++ b/book.toml @@ -6,12 +6,15 @@ src = "docs" # additional css https://raw.githubusercontent.com/oknotokcomputer/okcss/main/ok.css [output.html] -additional-css = ["ok.css"] +additional-css = ["ok.css", "skill-tree.css"] theme = "docs/theme" default-theme = "dark" git-repository-url = "https://ok.software/ok/src" preferred-dark-theme = "rust" +additional-js =["viz.js", "full.render.js", "panzoom.min.js", "skill-tree.js"] -[preprocessor.svgbob] +# [preprocessor.svgbob] [preprocessor.alerts] +[preprocessor.skill-tree] +command = "mdbook-skill-tree" diff --git a/crates/src-collections/Cargo.toml b/crates/src-collections/Cargo.toml new file mode 100644 index 0000000..7e3702b --- /dev/null +++ b/crates/src-collections/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "src-collections" +version = "0.1.0" +edition = "2021" +publish = ["oksoftware"] + +[dependencies] +rustc-hash = "1.1.0" +indexmap = "1.9.1" +typed-index-collections = "3.0.3" \ No newline at end of file diff --git a/crates/src-collections/src/lib.rs b/crates/src-collections/src/lib.rs new file mode 100644 index 0000000..56b3645 --- /dev/null +++ b/crates/src-collections/src/lib.rs @@ -0,0 +1,10 @@ +use rustc_hash::FxHasher; +use std::hash::BuildHasherDefault; + +pub use rustc_hash::FxHashMap as Map; +pub use rustc_hash::FxHashSet as Set; + +pub type IndexMap = indexmap::IndexMap>; +pub type IndexSet = indexmap::IndexSet>; + +pub type IndexVec = typed_index_collections::TiVec; \ No newline at end of file diff --git a/crates/src-derive-test/Cargo.toml b/crates/src-derive-test/Cargo.toml new file mode 100644 index 0000000..d3281b6 --- /dev/null +++ b/crates/src-derive-test/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "src-derive-test" +version = "0.1.0" +edition = "2021" +publish = ["oksoftware"] + +[dependencies] +okstd = { version = "0.1.9", registry = "oksoftware", features = ["macros"] } + +src-derive = { version = "0.1.0", path = "../src-derive", registry = "oksoftware" } +srclang = { version = "0.1.0", path = "../..", registry = "oksoftware" } + +# [[bin]] +# name = "src-derive-test" +# path = "expanded.rs" \ No newline at end of file diff --git a/crates/src-derive-test/src/main.rs b/crates/src-derive-test/src/main.rs new file mode 100644 index 0000000..2150fe0 --- /dev/null +++ b/crates/src-derive-test/src/main.rs @@ -0,0 +1,119 @@ +use src_derive::node; +use srclang::lexer::Location; +use srclang::ops; +use srclang::parser::span::Spanned; +use srclang::span; +use std::fmt::Display; +use std::ops::Range; + +#[node] +struct Ident { + name: String, + generics: Vec, +} + +#[node] +struct Field { + vis: Option, + name: String, + ty: Ident, +} + +pub enum Literal { + Bool(bool), + Float(f64), + Integer(i64), + String(String), +} + +#[derive(Debug)] +pub enum Visibility { + Private, + Public, +} + +impl Display for Visibility { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Visibility::Public => write!(f, "pub"), + Visibility::Private => write!(f, "priv"), + } + } +} + +pub enum Operator { + Add, + Sub, + Mul, + Div, + Mod, + And, + Or, + Not, + Eq, + Ne, + Lt, + Le, + Gt, + Ge, +} + +struct PrettyPrinter; + +impl FieldVisitor for PrettyPrinter { + fn visit_vis(&self, vis: &Visibility, range: &Range) -> ops::traversal::Result { + print!("{} ", vis); + ops::traversal::Result::Continue + } + + fn visit_name(&self, name: &String, range: &Range) -> ops::traversal::Result { + print!("{} :", name); + ops::traversal::Result::Continue + } + + fn visit_ty(&self, ty: &Ident, range: &Range) -> ops::traversal::Result { + ty.accept(self); + ops::traversal::Result::Continue + } +} + +impl IdentVisitor for PrettyPrinter { + fn visit_name(&self, name: &String, range: &Range) -> ops::traversal::Result { + print!("{}", name); + ops::traversal::Result::Continue + } + + fn visit_generics(&self, generic: &Ident, range: &Range) -> ops::traversal::Result { + print!("<"); + generic.accept(self); + print!(">"); + ops::traversal::Result::Continue + } +} + +fn main() { + let b = Ident::new( + span!(Location::default(), "b".to_string(), Location::default()), + vec![span!( + Location::default(), + Ident::new( + span!(Location::default(), "c".to_string(), Location::default()), + vec![] + ), + Location::default() + )], + ); + let a = Field::new( + Some(span!( + Location::default(), + Visibility::Public, + Location::default() + )), + span!(Location::default(), "a".to_string(), Location::default()), + span!(Location::default(), b, Location::default()), + ); + + let pretty_printer = PrettyPrinter; + a.accept(&pretty_printer); + println!(""); +} diff --git a/crates/src-derive/Cargo.toml b/crates/src-derive/Cargo.toml new file mode 100644 index 0000000..8412ac4 --- /dev/null +++ b/crates/src-derive/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "src-derive" +version = "0.1.0" +edition = "2021" +publish = ["oksoftware"] + + +[lib] +proc-macro = true + +[dependencies] +quote = "1.0" +proc-macro2 = "1.0" +syn = { version = "1.0", features = ["full"] } + +okstd = { version = "0.1.9", registry = "oksoftware", features = ["macros"] } + +[dev-dependencies] +insta = "1.39.0" +pretty_assertions = "1.4.0" diff --git a/crates/src-derive/src/lib.rs b/crates/src-derive/src/lib.rs new file mode 100644 index 0000000..eab6525 --- /dev/null +++ b/crates/src-derive/src/lib.rs @@ -0,0 +1,13 @@ +use proc_macro::TokenStream; +mod node; +mod walker; + +#[proc_macro_attribute] +pub fn node(_attr: TokenStream, item: TokenStream) -> TokenStream { + TokenStream::from(node::define_nodes(_attr, item)) +} + +#[proc_macro_attribute] +pub fn walker(_attr: TokenStream, item: TokenStream) -> TokenStream { + TokenStream::from(walker::generate_walker_impl(item)) +} diff --git a/crates/src-derive/src/node.rs b/crates/src-derive/src/node.rs new file mode 100644 index 0000000..2c287d1 --- /dev/null +++ b/crates/src-derive/src/node.rs @@ -0,0 +1,346 @@ +use proc_macro::TokenStream; +use quote::{format_ident, quote, ToTokens}; +use syn::{ + parse_macro_input, Data, DeriveInput, Fields, GenericArgument, Ident, PathArguments, Type, + TypePath, +}; + +pub fn define_nodes(_attr: TokenStream, item: TokenStream) -> TokenStream { + let input = parse_macro_input!(item as DeriveInput); + + let struct_name = &input.ident; + let fields = match &input.data { + Data::Struct(data) => &data.fields, + _ => { + return quote! { + compile_error!("define_nodes can only be used on structs"); + } + .into() + } + }; + + let spanned_fields = fields.iter().map(|field| { + let field_name = &field.ident; + let field_type = &field.ty; + match field_type { + Type::Path(path) => { + let expanded_type = wrap_path_in_spanned(path); + quote! { + #field_name: #expanded_type, + } + } + _ => { + panic!( + "Only named fields are supported which {} is not", + field_type.into_token_stream() + ); + } + } + }); + + let expanded_impl = fields.iter().map(|field| { + let field_name = &field.ident; + let field_span_getter = format_ident!("{}_span", field_name.as_ref().unwrap()); + let field_node_getter = format_ident!("{}_node", field_name.as_ref().unwrap()); + let field_type = &field.ty; + match field_type { + Type::Path(path) => { + let expanded_type = wrap_path_in_spanned(path); + let expanded_range_type = wrap_range_location(path); + quote! { + fn #field_node_getter(&self) -> &#expanded_type { + todo!() + } + fn #field_span_getter(&self) -> &#expanded_range_type { + todo!() + } + } + } + _ => { + panic!( + "Only named fields are supported which {} is not", + field_type.into_token_stream() + ); + } + } + }); + + let visitor_name = format_ident!("{}Visitor", struct_name); + let visitor_trait_stub = fields.iter().map(|field| { + let field_name = &field.ident; + let field_visit = format_ident!("visit_{}", field_name.as_ref().unwrap()); + let field_type = &field.ty; + match field_type { + Type::Path(path) => { + let unwrapped_type = unwrap_path(path); + quote! { + fn #field_visit(&self, node: &#unwrapped_type, span: &Range) -> ops::traversal::Result; + } + } + _ => { + panic!( + "Only named fields are supported which {} is not", + field_type.into_token_stream() + ); + } + } + }); + + let accept_impl = fields.iter().map(|field| { + let field_name = &field.ident; + let field_type = &field.ty; + match field_type { + Type::Path(path) => { + let visit_fn = format_ident!("visit_{}", field_name.as_ref().unwrap()); + match path.path.segments.last() { + Some(syn::PathSegment { ident, arguments }) => match arguments { + PathArguments::None => { + quote! { + if let cont = visitor.#visit_fn( + &self.#field_name.1, + &(self.#field_name.0..self.#field_name.2) + ) { + return; + } + } + } + PathArguments::AngleBracketed(args) => match args.args.first() { + Some(GenericArgument::Type(_)) => match ident.to_string().as_str() { + "Option" => { + quote! { + if let Some(inner) = &self.#field_name { + if let cont = visitor.#visit_fn( + &inner.1, + &(inner.0..inner.2) + ) { + return; + } + } + } + } + "Vec" => { + quote! { + for inner in self.#field_name.iter() { + if let cont = visitor.#visit_fn( + &inner.1, + &(inner.0..inner.2) + ) { + return; + } + } + } + } + _ => { + quote! { + if let cont =visitor.#visit_fn( + &self.#field_name.1, + &(self.#field_name.0..self.#field_name.2) + ) { + return; + } + } + } + }, + _ => { + quote! { + if let cont = visitor.#visit_fn( + self.1, + self.0..self.2 + ) { + return; + } + } + } + }, + PathArguments::Parenthesized(_) => todo!(), + }, + None => { + quote! { + compile_error!("No path segments found"); + } + } + } + } + _ => { + panic!( + "Only named fields are supported which {} is not", + field_type.into_token_stream() + ); + } + } + }); + + let field_names = fields.iter().map(|field| { + let field_name = &field.ident; + quote! { + #field_name + } + }); + let not_spanned_fileds = spanned_fields.clone(); + let field_types = fields.iter().map(|field| { + let field_type = &field.ty; + match field_type { + Type::Path(path) => { + let expanded_type = wrap_path_in_spanned(path); + quote! { + #expanded_type + } + } + _ => { + panic!( + "Only named fields are supported which {} is not", + field_type.into_token_stream() + ); + } + } + }); + let field_types_clone = field_types.clone(); + let struct_name_lower = format_ident!("{}", struct_name.to_string().to_lowercase()); + let field_ids = fields.iter().enumerate().map(|field| { + let field_name = syn::Index::from(field.0); + quote! { + #struct_name_lower.#field_name + } + }); + let vis = &input.vis; + let expanded = quote! { + #[derive(Debug)] + #vis struct #struct_name { + #(#spanned_fields)* + } + #vis trait #visitor_name { + #(#visitor_trait_stub)* + } + impl From< + (#(#field_types),*) + > for #struct_name { + fn from( + #struct_name_lower: ( + #(#field_types_clone),* + ) + ) -> Self { + Self::new( + #(#field_ids),* + ) + } + } + + impl #struct_name { + fn new(#(#not_spanned_fileds)*) -> Self { + Self { + #(#field_names,)* + } + } + + } + impl #struct_name { + fn accept(&self, visitor: &impl #visitor_name) { + #(#accept_impl)* + } + } + }; + + expanded.into() +} +fn wrap_range_location(path: &TypePath) -> impl ToTokens { + match path.path.segments.last() { + Some(syn::PathSegment { ident, arguments }) => { + if let syn::PathArguments::AngleBracketed(args) = arguments { + if let Some(GenericArgument::Type(inner_ty)) = args.args.first() { + quote! { + #ident> + } + } else { + quote! { + Range + } + } + } else { + quote! { + Range + } + } + } + _ => { + quote! { + Range + } + } + } +} + +fn wrap_path_in_spanned(path: &TypePath) -> impl ToTokens { + match path.path.segments.last() { + Some(syn::PathSegment { ident, arguments }) => { + if let syn::PathArguments::AngleBracketed(args) = arguments { + if let Some(GenericArgument::Type(inner_ty)) = args.args.first() { + quote! { + #ident> + } + } else { + quote! { + Spanned<#ident> + } + } + } else { + quote! { + Spanned<#ident> + } + } + } + _ => { + quote! { + Spanned<#path> + } + } + } +} + +fn unwrap_path(path: &TypePath) -> impl ToTokens { + match path.path.segments.last() { + Some(syn::PathSegment { ident, arguments }) => { + if let syn::PathArguments::AngleBracketed(args) = arguments { + if let Some(GenericArgument::Type(inner_ty)) = args.args.first() { + quote! { + #inner_ty + } + } else { + quote! { + #ident + } + } + } else { + quote! { + #ident + } + } + } + _ => { + quote! { + #path + } + } + } +} + +fn wrap_type_in_spanned(ty: &Type, field_name: &Option) -> impl ToTokens { + match (ty, field_name) { + (Type::Path(path), Some(field_name)) => { + let ty = wrap_path_in_spanned(path); + quote! { + #field_name: #ty, + } + } + (Type::Path(path), None) => { + let ty = wrap_path_in_spanned(path); + quote! { + #ty, + } + } + _ => { + quote! { + compile_error!("Only named fields are supported"); + } + } + } +} diff --git a/crates/src-derive/src/snapshots/src_derive__tests__.snap b/crates/src-derive/src/snapshots/src_derive__tests__.snap new file mode 100644 index 0000000..5b7f7fb --- /dev/null +++ b/crates/src-derive/src/snapshots/src_derive__tests__.snap @@ -0,0 +1,5 @@ +--- +source: crates/src-derive/src/lib.rs +expression: expected.to_string() +--- +pub trait BinaryOperationVisitor : BoxVisitor + SpannedVisitor + NodeVisitor + OperatorVisitor { fn visit (& mut self , node : & BinaryOperation) { self . visit_lhs (& node . lhs) ; self . visit_op (& node . op) ; self . visit_rhs (& node . rhs) ; } fn visit_lhs (& mut self , value : & Box < Spanned < Node >>) { } fn visit_op (& mut self , value : & Operator) { } fn visit_rhs (& mut self , value : & Box < Spanned < Node >>) { } } diff --git a/crates/src-derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap b/crates/src-derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap new file mode 100644 index 0000000..5b7f7fb --- /dev/null +++ b/crates/src-derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap @@ -0,0 +1,5 @@ +--- +source: crates/src-derive/src/lib.rs +expression: expected.to_string() +--- +pub trait BinaryOperationVisitor : BoxVisitor + SpannedVisitor + NodeVisitor + OperatorVisitor { fn visit (& mut self , node : & BinaryOperation) { self . visit_lhs (& node . lhs) ; self . visit_op (& node . op) ; self . visit_rhs (& node . rhs) ; } fn visit_lhs (& mut self , value : & Box < Spanned < Node >>) { } fn visit_op (& mut self , value : & Operator) { } fn visit_rhs (& mut self , value : & Box < Spanned < Node >>) { } } diff --git a/crates/src-derive/src/walker.rs b/crates/src-derive/src/walker.rs new file mode 100644 index 0000000..a92743a --- /dev/null +++ b/crates/src-derive/src/walker.rs @@ -0,0 +1,179 @@ +use proc_macro2::{Ident, TokenStream}; +use quote::{format_ident, quote, ToTokens}; +use syn::{ + parse_macro_input, Data, DeriveInput, Fields, GenericArgument, PathArguments, Type, TypePath, +}; + +pub fn generate_walker_impl(item: proc_macro::TokenStream) -> proc_macro::TokenStream { + let input = parse_macro_input!(item as DeriveInput); + let type_name = &input.ident; + let walker_name = format_ident!("{}Walker", type_name); + let visitor_name = format_ident!("{}Visitor", type_name); + + let walk_impl = generate_walk_impl(type_name, &input.data); + + let expanded = quote! { + #input + + pub struct #walker_name; + + impl #walker_name { + pub fn walk(node: &Spanned<#type_name>, visitor: &mut V) { + #walk_impl + } + } + }; + + proc_macro::TokenStream::from(expanded) +} + +fn generate_walk_impl(type_name: &Ident, data: &Data) -> TokenStream { + match data { + Data::Struct(data_struct) => generate_struct_walk_impl(data_struct), + Data::Enum(data_enum) => generate_enum_walk_impl(type_name, data_enum), + Data::Union(_) => panic!("Unions are not supported"), + } +} +fn generate_field_visit(ty: &Type, field_access: TokenStream) -> TokenStream { + match ty { + Type::Path(TypePath { path, .. }) => { + if let Some(segment) = path.segments.last() { + match segment.ident.to_string().as_str() { + "Spanned" => { + if let PathArguments::AngleBracketed(args) = &segment.arguments { + if let Some(GenericArgument::Type(inner_type)) = args.args.first() { + let visit_method = format_ident!( + "visit_{}", + inner_type.to_token_stream().to_string().to_lowercase() + ); + return quote! { + visitor.#visit_method(&(#field_access).1, (#field_access).span()); + }; + } + } + } + "Box" => { + if let PathArguments::AngleBracketed(args) = &segment.arguments { + if let Some(GenericArgument::Type(inner_type)) = args.args.first() { + let inner_visit = + generate_field_visit(inner_type, quote! { (*#field_access) }); + return quote! { + #inner_visit + }; + } + } + } + "Option" => { + if let PathArguments::AngleBracketed(args) = &segment.arguments { + if let Some(GenericArgument::Type(inner_type)) = args.args.first() { + let inner_visit = + generate_field_visit(inner_type, quote! { inner }); + return quote! { + if let Some(inner) = #field_access.as_ref() { + #inner_visit + } + }; + } + } + } + "Vec" => { + if let PathArguments::AngleBracketed(args) = &segment.arguments { + if let Some(GenericArgument::Type(inner_type)) = args.args.first() { + let inner_visit = generate_field_visit(inner_type, quote! { item }); + return quote! { + for item in #field_access.iter() { + #inner_visit + } + }; + } + } + } + _ => {} + } + } + } + _ => {} + } + quote! {} +} + +fn generate_struct_walk_impl(data_struct: &syn::DataStruct) -> TokenStream { + let field_visits = data_struct + .fields + .iter() + .map(|field| { + let field_name = &field.ident; + generate_field_visit(&field.ty, quote!(node.1.#field_name)) + }) + .collect::>(); + + quote! { + #(#field_visits)* + } +} + +fn generate_enum_walk_impl(enum_name: &Ident, data_enum: &syn::DataEnum) -> TokenStream { + let variant_matches = data_enum + .variants + .iter() + .map(|variant| { + let variant_name = &variant.ident; + + match &variant.fields { + Fields::Unnamed(fields) if fields.unnamed.len() == 1 => { + let field_visit = generate_field_visit(&fields.unnamed[0].ty, quote!(value)); + quote! { + #enum_name::#variant_name(value) => { + #field_visit + } + } + } + _ => quote! { + #enum_name::#variant_name { .. } => {} + }, + } + }) + .collect::>(); + + quote! { + match &node.1 { + #(#variant_matches)* + } + } +} + +fn is_spanned_type(ty: &Type) -> bool { + if let Type::Path(TypePath { path, .. }) = ty { + if let Some(segment) = path.segments.last() { + return segment.ident == "Spanned"; + } + } + false +} + +fn is_box_type(ty: &Type) -> bool { + if let Type::Path(TypePath { path, .. }) = ty { + if let Some(segment) = path.segments.last() { + return segment.ident == "Box"; + } + } + false +} + +fn is_option_type(ty: &Type) -> bool { + if let Type::Path(TypePath { path, .. }) = ty { + if let Some(segment) = path.segments.last() { + return segment.ident == "Option"; + } + } + false +} + +fn is_vec_type(ty: &Type) -> bool { + if let Type::Path(TypePath { path, .. }) = ty { + if let Some(segment) = path.segments.last() { + return segment.ident == "Vec"; + } + } + false +} diff --git a/crates/src-lsp-browser/Cargo.toml b/crates/src-lsp-browser/Cargo.toml new file mode 100644 index 0000000..ff342a2 --- /dev/null +++ b/crates/src-lsp-browser/Cargo.toml @@ -0,0 +1,30 @@ +[package] +publish = false +edition = "2021" +name = "src-lsp-browser" +version = "0.0.0" + +[features] +default = ["tower-lsp/runtime-agnostic"] + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +console_error_panic_hook = "0.1.7" +src-lsp-server = { version = "0.0", path = "../src-lsp-server", default-features = false } +futures = "0.3.21" +js-sys = "0.3.57" +tower-lsp = { version = "0.17.0", default-features = false } +wasm-bindgen = "0.2.81" +wasm-bindgen-futures = { version = "0.4.30", features = [ + "futures-core-03-stream", +] } +wasm-streams = "0.2.3" +srclang = { version = "0.1.0", path = "../..", registry = "oksoftware" } +web-sys = { version = "0.3.69", features = [ + "console", + "HtmlTextAreaElement", + "ReadableStream", + "WritableStream", +] } diff --git a/crates/src-lsp-browser/src/lib.rs b/crates/src-lsp-browser/src/lib.rs new file mode 100644 index 0000000..4c50f02 --- /dev/null +++ b/crates/src-lsp-browser/src/lib.rs @@ -0,0 +1,65 @@ +#![deny(clippy::all)] +#![deny(unsafe_code)] + +use futures::stream::TryStreamExt; +use tower_lsp::{LspService, Server}; +use wasm_bindgen::{prelude::*, JsCast}; +use wasm_bindgen_futures::stream::JsStream; + +#[wasm_bindgen] +pub struct ServerConfig { + into_server: js_sys::AsyncIterator, + from_server: web_sys::WritableStream, +} + +#[wasm_bindgen] +impl ServerConfig { + #[wasm_bindgen(constructor)] + pub fn new(into_server: js_sys::AsyncIterator, from_server: web_sys::WritableStream) -> Self { + Self { + into_server, + from_server, + } + } +} + +// NOTE: we don't use web_sys::ReadableStream for input here because on the +// browser side we need to use a ReadableByteStreamController to construct it +// and so far only Chromium-based browsers support that functionality. + +// NOTE: input needs to be an AsyncIterator specifically +#[wasm_bindgen] +pub async fn serve(config: ServerConfig) -> Result<(), JsValue> { + console_error_panic_hook::set_once(); + + web_sys::console::log_1(&"server::serve".into()); + + let ServerConfig { + into_server, + from_server, + } = config; + + let input = JsStream::from(into_server); + let input = input + .map_ok(|value| { + value + .dyn_into::() + .expect("could not cast stream item to Uint8Array") + .to_vec() + }) + .map_err(|_err| std::io::Error::from(std::io::ErrorKind::Other)) + .into_async_read(); + + let output = JsCast::unchecked_into::(from_server); + let output = wasm_streams::WritableStream::from_raw(output); + let output = output.try_into_async_write().map_err(|err| err.0)?; + + let (service, messages) = LspService::new(|client| src_lsp_server::Server::new(client)); + Server::new(input, output, messages).serve(service).await; + + Ok(()) +} + +mod tokenizer; + +pub use tokenizer::{token_type_as_js_string, tokenize}; \ No newline at end of file diff --git a/crates/src-lsp-browser/src/tokenizer.rs b/crates/src-lsp-browser/src/tokenizer.rs new file mode 100644 index 0000000..c545d4d --- /dev/null +++ b/crates/src-lsp-browser/src/tokenizer.rs @@ -0,0 +1,152 @@ +use js_sys::JsString; +use srclang::lexer::{self}; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +pub struct TokenSpan { + pub start: usize, + pub end: usize, + pub scope: TokenType, +} + +#[wasm_bindgen] +#[derive(Clone, Copy)] +pub enum TokenType { + Pipe, + Ampersand, + Semicolon, + Equals, + LessThan, + GreaterThan, + Variable, + Word, + String, + Comment, + Integer, + Float, + Eof, + NewLine, + LeftParen, + RightParen, + LeftBrace, + RightBrace, + LeftBracket, + RightBracket, + Comma, + Dot, + Colon, + Underscore, + Minus, + Plus, + Arrow, + FatArrow, + Divide, + Multiply, + Percent, + Dollar, + Exclamation, + Question, + Tilde, + At, + Caret, + Shebang, +} + +#[wasm_bindgen] +pub fn token_type_as_js_string(token_type: TokenType) -> JsString { + match token_type { + TokenType::Pipe => "Pipe", + TokenType::Ampersand => "Ampersand", + TokenType::Semicolon => "Semicolon", + TokenType::Equals => "Equals", + TokenType::LessThan => "LessThan", + TokenType::GreaterThan => "GreaterThan", + TokenType::Variable => "Variable", + TokenType::Word => "Word", + TokenType::String => "String", + TokenType::Comment => "Comment", + TokenType::Integer => "Integer", + TokenType::Float => "Float", + TokenType::Eof => "Eof", + TokenType::NewLine => "NewLine", + TokenType::LeftParen => "LeftParen", + TokenType::RightParen => "RightParen", + TokenType::LeftBrace => "LeftBrace", + TokenType::RightBrace => "RightBrace", + TokenType::LeftBracket => "LeftBracket", + TokenType::RightBracket => "RightBracket", + TokenType::Comma => "Comma", + TokenType::Dot => "Dot", + TokenType::Colon => "Colon", + TokenType::Underscore => "Underscore", + TokenType::Minus => "Minus", + TokenType::Plus => "Plus", + TokenType::Arrow => "Arrow", + TokenType::FatArrow => "FatArrow", + TokenType::Divide => "Divide", + TokenType::Multiply => "Multiply", + TokenType::Percent => "Percent", + TokenType::Dollar => "Dollar", + TokenType::Exclamation => "Exclamation", + TokenType::Question => "Question", + TokenType::Tilde => "Tilde", + TokenType::At => "At", + TokenType::Caret => "Caret", + TokenType::Shebang => "Shebang", + } + .into() +} + +#[wasm_bindgen] +pub fn tokenize(input: &str) -> Result, JsValue> { + let lexer = srclang::lexer::Lexer::new(input, 0); + + let tokens: Vec = lexer + .map(|token| TokenSpan { + start: token.start, + end: token.end, + scope: match token.node { + lexer::Token::Pipe => TokenType::Pipe, + lexer::Token::Ampersand => TokenType::Ampersand, + lexer::Token::Semicolon => TokenType::Semicolon, + lexer::Token::Equals => TokenType::Equals, + lexer::Token::LessThan => TokenType::LessThan, + lexer::Token::GreaterThan => TokenType::GreaterThan, + lexer::Token::Variable(_) => TokenType::Variable, + lexer::Token::Word(_) => TokenType::Word, + lexer::Token::String(_) => TokenType::String, + lexer::Token::Comment(_) => TokenType::Comment, + lexer::Token::Integer(_) => TokenType::Integer, + lexer::Token::Float(_) => TokenType::Float, + lexer::Token::Eof => TokenType::Eof, + lexer::Token::NewLine => TokenType::NewLine, + lexer::Token::LeftParen => TokenType::LeftParen, + lexer::Token::RightParen => TokenType::RightParen, + lexer::Token::LeftBrace => TokenType::LeftBrace, + lexer::Token::RightBrace => TokenType::RightBrace, + lexer::Token::LeftBracket => TokenType::LeftBracket, + lexer::Token::RightBracket => TokenType::RightBracket, + lexer::Token::Comma => TokenType::Comma, + lexer::Token::Dot => TokenType::Dot, + lexer::Token::Colon => TokenType::Colon, + lexer::Token::Underscore => TokenType::Underscore, + lexer::Token::Minus => TokenType::Minus, + lexer::Token::Plus => TokenType::Plus, + lexer::Token::Arrow => TokenType::Arrow, + lexer::Token::FatArrow => TokenType::FatArrow, + lexer::Token::Divide => TokenType::Divide, + lexer::Token::Multiply => TokenType::Multiply, + lexer::Token::Percent => TokenType::Percent, + lexer::Token::Dollar => TokenType::Dollar, + lexer::Token::Exclamation => TokenType::Exclamation, + lexer::Token::Question => TokenType::Question, + lexer::Token::Tilde => TokenType::Tilde, + lexer::Token::At => TokenType::At, + lexer::Token::Caret => TokenType::Caret, + lexer::Token::Shebang => TokenType::Shebang, + }, + }) + .collect(); + + Ok(tokens) +} diff --git a/crates/src-lsp-server/Cargo.toml b/crates/src-lsp-server/Cargo.toml new file mode 100644 index 0000000..061d8f2 --- /dev/null +++ b/crates/src-lsp-server/Cargo.toml @@ -0,0 +1,46 @@ +[package] +publish = false +edition = "2021" +name = "src-lsp-server" +version = "0.0.0" + +[features] +default = ["tower-lsp/runtime-agnostic"] + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +anyhow = "1.0.57" +async-lock = "2.5.0" +console_error_panic_hook = "0.1.7" +dashmap = "5.3.4" +futures = "0.3.21" +indoc = "1.0" +js-sys = "0.3.57" +log = "0.4" +lsp = { version = "0.93", package = "lsp-types" } +lsp-text = "0.9" +ropey = "1.6.1" +serde_json = "1.0" +srclang = { version = "0.1.0", path = "../..", registry = "oksoftware" } +salsa = { version = "0.1.0", registry = "oksoftware", package = "salsa-2022" } +salsa-macros = { version = "0.1.0", registry = "oksoftware" , package = "salsa-2022-macros" } +thiserror = "1.0" +tower-lsp = { version = "0.17.0", default-features = false } +wasm-bindgen = "0.2.81" +wasm-bindgen-futures = { version = "0.4.30", features = ["futures-core-03-stream"] } +wasm-streams = "0.2.3" +src-collections = { version = "0.1.0", path = "../src-collections", registry = "oksoftware" } +lazy_static = "1.4.0" + +[dependencies.web-sys] +version = "0.3.57" +features = [ + "console", + "CssStyleDeclaration", + "Document", + "ReadableStream", + "Window", + "WritableStream", +] diff --git a/crates/src-lsp-server/src/db.rs b/crates/src-lsp-server/src/db.rs new file mode 100644 index 0000000..2323a4b --- /dev/null +++ b/crates/src-lsp-server/src/db.rs @@ -0,0 +1,158 @@ +use lsp::{InitializeParams, InitializeResult, Url}; + +use lsp_text::RopeExt; +use salsa::function::DynDb; +use src_collections::Map; +use srclang::{ + analyzer::{self, span_text}, + compiler::text::{self, Document, SourceProgram}, + parser::{ + self, + span::{ByteOrLineColOrCoord, ByteOrLineColOrCoordInterned}, + }, + Db, +}; +use std::{borrow::BorrowMut, sync::Mutex}; +use tower_lsp::{jsonrpc, LanguageServer}; + +use crate::update_channel; + +pub struct LspServerDatabase { + db: Mutex, +} + +impl LspServerDatabase { + pub fn new() -> Self { + Self { + db: Mutex::new(srclang::analyzer::db::Database::default()), + } + } +} + +// create a global singleton for input files input_files: Map, +// so that we can access it from the analyzer it should be a mutable map so that we can add new files to it +// we can use a Mutex to make it thread safe +lazy_static::lazy_static! { + static ref FILES: Mutex> = Mutex::new(Map::default()); +} +#[tower_lsp::async_trait] +impl LanguageServer for LspServerDatabase { + async fn initialize(&self, params: InitializeParams) -> jsonrpc::Result { + web_sys::console::log_1(&"server::initialize".into()); + Ok(InitializeResult { + ..InitializeResult::default() + }) + } + + async fn shutdown(&self) -> jsonrpc::Result<()> { + web_sys::console::log_1(&"server::shutdown".into()); + Ok(()) + } + + async fn initialized(&self, _: lsp::InitializedParams) { + web_sys::console::log_1(&"server::initialized".into()); + } + + async fn did_open(&self, params: lsp::DidOpenTextDocumentParams) { + let url = params.text_document.uri; + let text = params.text_document.text; + let db = &*self.db.lock().unwrap(); + let document = text::Document::new(db, url.to_string(), ropey::Rope::from_str(&text)); + FILES.lock().unwrap().insert(url, document); + update_channel(&text); + } + + async fn did_change(&self, params: lsp::DidChangeTextDocumentParams) { + let url = params.text_document.uri; + let db = &*self.db.lock().unwrap(); + let mut files = FILES.lock().unwrap(); + let file = files.get(&url).unwrap(); + let mut rope = file.text(db); + let text_edit = rope.build_edit(¶ms.content_changes[0]).unwrap(); + rope.apply_edit(&text_edit); + let text = rope.clone().to_string(); + files.insert(url.clone(), text::Document::new(db, url.to_string(), rope)); + update_channel(&text); + } + + async fn document_symbol( + &self, + params: lsp::DocumentSymbolParams, + ) -> jsonrpc::Result> { + web_sys::console::log_1(&"server::document_symbol".into()); + let db = &*self.db.lock().unwrap(); + + Ok(None) + } + + async fn hover(&self, params: lsp::HoverParams) -> jsonrpc::Result> { + web_sys::console::log_1(&"server::hover".into()); + let db = &*self.db.lock().unwrap(); + let url = params.text_document_position_params.text_document.uri; + let position = params.text_document_position_params.position; + let files = FILES.lock().unwrap(); + let text = files.get(&url).unwrap(); + let text = text.text(db); + let text = text::SourceProgram::new(db, url.to_string(), text.to_string()); + let line: usize = position.line.try_into().unwrap(); + let character: usize = position.character.try_into().unwrap(); + web_sys::console::log_1(&format!("line: {}, character: {}", line, character).into()); + let spanned = analyzer::get_symbol( + db, + text, + ByteOrLineColOrCoordInterned::new(db, ByteOrLineColOrCoord::LineCol(line, character)), + ); + + web_sys::console::log_1(&format!("{:#?}", spanned).into()); + let hover = spanned.map(|span| { + // let text = span_text(db, span); + lsp::Hover { + contents: lsp::HoverContents::Markup(lsp::MarkupContent { + kind: lsp::MarkupKind::Markdown, + value: format!("```src\n{:#?}\n```src anaylzer", span), + }), + range: None, + } + }); + Ok(hover) + } + + async fn document_highlight( + &self, + params: lsp::DocumentHighlightParams, + ) -> jsonrpc::Result>> { + web_sys::console::log_1(&"server::document_highlight".into()); + let db = &*self.db.lock().unwrap(); + let url = params.text_document_position_params.text_document.uri; + let position = params.text_document_position_params.position; + let text = FILES.lock().unwrap(); + let text = text.get(&url).unwrap(); + let text = text.text(db); + let text = text::SourceProgram::new(db, url.to_string(), text.to_string()); + let text = analyzer::get_symbol( + db, + text, + ByteOrLineColOrCoordInterned::new( + db, + ByteOrLineColOrCoord::LineCol(position.line as usize, position.character as usize), + ), + ); + let hightlight_kind = lsp::DocumentHighlightKind::TEXT; + let highlights = text.map(|text| { + vec![lsp::DocumentHighlight { + range: lsp::Range { + start: lsp::Position { + line: 0, + character: 0, + }, + end: lsp::Position { + line: 0, + character: 0, + }, + }, + kind: Some(hightlight_kind), + }] + }); + Ok(highlights) + } +} diff --git a/crates/src-lsp-server/src/lib.rs b/crates/src-lsp-server/src/lib.rs new file mode 100644 index 0000000..9355680 --- /dev/null +++ b/crates/src-lsp-server/src/lib.rs @@ -0,0 +1,14 @@ +#![deny(clippy::all)] +#![deny(unsafe_code)] + +// mod core; +// pub mod handler; +mod server; + +mod db; + +use srclang::compiler; + +pub use server::*; + +pub use srclang::Jar; \ No newline at end of file diff --git a/crates/src-lsp-server/src/server.rs b/crates/src-lsp-server/src/server.rs new file mode 100644 index 0000000..7fae2a1 --- /dev/null +++ b/crates/src-lsp-server/src/server.rs @@ -0,0 +1,200 @@ +use anyhow::anyhow; +use srclang::parser; +use std::result::Result::Ok; +use std::sync::Arc; +use tower_lsp::{jsonrpc, lsp_types::*, LanguageServer}; +use wasm_bindgen::JsCast; +use web_sys::HtmlTextAreaElement; + +pub fn capabilities() -> lsp::ServerCapabilities { + let document_symbol_provider = Some(lsp::OneOf::Left(true)); + + let text_document_sync = { + let options = lsp::TextDocumentSyncOptions { + open_close: Some(true), + change: Some(lsp::TextDocumentSyncKind::FULL), + ..Default::default() + }; + Some(lsp::TextDocumentSyncCapability::Options(options)) + }; + + let hover_provider = Some(true.into()); + + let semantic_tokens_provider = Some( + lsp::SemanticTokensServerCapabilities::SemanticTokensOptions(lsp::SemanticTokensOptions { + legend: lsp::SemanticTokensLegend { + token_types: vec![], + token_modifiers: vec![], + }, + range: Some(true), + full: Some(lsp::SemanticTokensFullOptions::Delta { delta: Some(true) }), + ..Default::default() + }), + ); + + let _document_highlight_provider: Option> = + Some(lsp::OneOf::Left(true)); + + let code_lens_provider = Some(lsp::CodeLensOptions { + resolve_provider: Some(true), + }); + + let completion_provider = Some(CompletionOptions { + resolve_provider: Some(true), + trigger_characters: Some(vec![".".into()]), + work_done_progress_options: WorkDoneProgressOptions { + work_done_progress: None, + }, + all_commit_characters: None, + }); + + lsp::ServerCapabilities { + text_document_sync, + document_symbol_provider, + hover_provider, + semantic_tokens_provider, + // document_highlight_provider, + code_lens_provider, + completion_provider, + ..Default::default() + } +} + +pub struct Server { + pub client: tower_lsp::Client, + pub db: Arc, +} + +impl Server { + pub fn new(client: tower_lsp::Client) -> Self { + Server { + client, + db: Arc::new(crate::db::LspServerDatabase::new()), + } + } +} + +#[tower_lsp::async_trait] +impl LanguageServer for Server { + async fn initialize(&self, params: InitializeParams) -> jsonrpc::Result { + web_sys::console::log_1(&"server::initialize".into()); + let capabilities = capabilities(); + Ok(InitializeResult { + server_info: Some( + ServerInfo { + name: "src language server".to_string(), + version: Some(env!("CARGO_PKG_VERSION").to_string()), + } + .into(), + ), + capabilities, + }) + } + + async fn initialized(&self, _: lsp::InitializedParams) { + web_sys::console::log_1(&"server::initialized".into()); + let typ = lsp::MessageType::INFO; + let message = "src language server initialized!"; + self.client.log_message(typ, message).await; + } + + async fn shutdown(&self) -> jsonrpc::Result<()> { + web_sys::console::log_1(&"server::shutdown".into()); + Ok(()) + } + + // FIXME: for some reason this doesn't trigger + async fn did_open(&self, params: lsp::DidOpenTextDocumentParams) { + web_sys::console::log_1(&"server::did_open".into()); + self.db.did_open(params).await; + } + + async fn did_change(&self, params: lsp::DidChangeTextDocumentParams) { + web_sys::console::log_1(&"server::did_change".into()); + self.db.did_change(params).await; + } + + async fn document_symbol( + &self, + params: lsp::DocumentSymbolParams, + ) -> jsonrpc::Result> { + web_sys::console::log_1(&"server::document_symbol".into()); + self.db.document_symbol(params).await + } + + async fn hover(&self, params: lsp::HoverParams) -> jsonrpc::Result> { + web_sys::console::log_1(&"server::hover".into()); + self.db.hover(params).await + } + + async fn document_highlight( + &self, + params: lsp::DocumentHighlightParams, + ) -> jsonrpc::Result>> { + web_sys::console::log_1(&"server::document_highlight".into()); + self.db.document_highlight(params).await + } +} + +pub fn get_channel_syntax() -> anyhow::Result { + use wasm_bindgen::JsCast; + let element_id = "channel-syntax"; + let channel_syntax = web_sys::window() + .ok_or_else(|| anyhow!("failed to get window"))? + .document() + .ok_or_else(|| anyhow!("failed to get document"))? + .get_element_by_id(element_id) + .ok_or_else(|| anyhow!("failed to get channel-syntax element"))? + .unchecked_into(); + Ok(channel_syntax) +} + +pub fn update_channel(input: &str) { + // let tree = parser::parse(input); + // // assume errors; use red + // let element_id = "channel-syntax"; + // match tree { + // Ok(module) => { + // // use green + // web_sys::window() + // .unwrap() + // .document() + // .unwrap() + // .get_element_by_id(element_id) + // .unwrap() + // .set_inner_html(&format!("{:#?}", module)); + // // set the border of the textarea to green + // web_sys::window() + // .unwrap() + // .document() + // .unwrap() + // .get_element_by_id(element_id) + // .unwrap() + // .unchecked_into::() + // .style() + // .set_property("border", "1px solid green") + // .unwrap(); + // } + // Err(errs) => { + // // use red + // web_sys::window() + // .unwrap() + // .document() + // .unwrap() + // .get_element_by_id(element_id) + // .unwrap() + // .set_inner_html(&format!("{:#?}", errs)); + // // set the border of the textarea to red + // web_sys::window() + // .unwrap() + // .document() + // .unwrap() + // .get_element_by_id(element_id) + // .unwrap() + // .unchecked_into::() + // .style() + // .set_property("border", "1px solid red") + // .unwrap(); + // } + // }; +} diff --git a/docs/0intro.md b/docs/0intro.md index 49f03da..b93c9a9 100644 --- a/docs/0intro.md +++ b/docs/0intro.md @@ -41,3 +41,14 @@ impl Make for Local { } } ``` + +## Acknowledgements + +Building upon the incredible work of the Rust community and many others, src would not be possible without the following projects: + +- [salsa-rs](https://github.com/salsa-rs/salsa) +- [lalrpop](https://github.com/lalrpop/lalrpop) +- [tower-lsp-web-demo](https://github.com/silvanshade/tower-lsp-web-demo) +- [tower-lsp-boilerplate](https://github.com/IWANABETHATGUY/tower-lsp-boilerplate) +- [tower-lsp](https:://github.com/tower-rs/tower-lsp) +- [gluon-lang](https://gluon-lang.org/) \ No newline at end of file diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index b9d57ec..4739ff7 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -1,5 +1,21 @@ # Summary - [Intro](0intro.md) + + +# Language +- [Specification](language/0intro.md) - [Examples](examples.md) - - [Language](language/0intro.md) \ No newline at end of file + + +# Playground + +* [Compiler Explorer](playground/index.md) + +# Skills + +- [Skills](skill-tree.md) + +# Research Notes + +- [Research](research.md) \ No newline at end of file diff --git a/docs/examples.md b/docs/examples.md index abe2378..b2f4d9a 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -1,5 +1,6 @@ # Examples +## innitguv ```src use { native_fs, native_exec } from host use { fs } from std @@ -27,4 +28,4 @@ impl Actor for Innitguv { self.exec(msg.path, msg.args) } } -``` \ No newline at end of file +``` diff --git a/docs/playground/index.md b/docs/playground/index.md new file mode 100644 index 0000000..6d7efbb --- /dev/null +++ b/docs/playground/index.md @@ -0,0 +1,22 @@ +
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/docs/playground/taocp.png b/docs/playground/taocp.png new file mode 100644 index 0000000..e4aef3d Binary files /dev/null and b/docs/playground/taocp.png differ diff --git a/docs/research.md b/docs/research.md new file mode 100644 index 0000000..8ea9863 --- /dev/null +++ b/docs/research.md @@ -0,0 +1,3 @@ +# Research + +- [Hindley-Milner Type Inference](https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system) \ No newline at end of file diff --git a/docs/skill-tree.md b/docs/skill-tree.md new file mode 100644 index 0000000..fa7496c --- /dev/null +++ b/docs/skill-tree.md @@ -0,0 +1,16 @@ + + + + +# Skills + +```skill-tree +{{#include src-skill-tree.toml}} +``` diff --git a/docs/src-skill-tree.toml b/docs/src-skill-tree.toml new file mode 100644 index 0000000..9ec722e --- /dev/null +++ b/docs/src-skill-tree.toml @@ -0,0 +1,95 @@ +[graphviz] +rankdir = "TD" + +[doc] +columns = ["status", "assigned"] + +[doc.defaults] +status = "tbd" +assigned = "no" + +[doc.emoji.status] +"tbd" = "░️░️░️░️░️" +"exploration" = "█░️░️░️░️" +"design" = "██░️░️░️" +"implementation" = "███░️░️" +"stabilization" = "████░️" +"done" = "█████" + +[doc.emoji.assigned] +"no" = "🫥" +"yes" = "👍" +"blocked" = "🤐" + + +[[group]] +name = "srclang" +label = "src language" +description = ["src programming language"] +items = [ + { label = "lexer", status = "stabilization" }, + { label = "parser", status = "stabilization" }, + { label = "lsp-server", status = "implementation" }, + { label = "type checker", status = "exploration" }, + { label = "codegen", status = "exploration" }, +] +requires = ["lexer", "parser", "type checker", "codegen", "lsp-server", "vm"] + +[[group]] +name = "lexer" +label = "lexer" +description = ["lexer for src programming language"] +requires = [] +items = [ + { label = "lexer", status = "stabilization", assigned = "yes" }, + { label = "forbid unsafe", status = "exploration", assigned = "yes" }, + { label = "better diagnostics", status = "implementation", assigned = "yes" }, +] + +[[group]] +name = "parser" +label = "parser" +description = ["parser for src programming language"] +requires = ["lexer"] +items = [ + { label = "implement parser", status = "stabilization", assigned = "yes" }, +] + +[[group]] +name = "type checker" +label = "type checker" +description = ["type checker for src programming language"] +requires = ["lexer", "parser"] +items = [ + { label = "type inference", status = "exploration" }, + { label = "type checking", status = "exploration" }, + { label = "type error reporting", status = "exploration" }, + { label = "type checker", status = "exploration" }, +] + + +[[group]] +name = "codegen" +label = "Code Generator" +description = ["Code Generator for src programming language"] +requires = ["lexer", "parser", "type checker"] +items = [{ label = "codegen", status = "exploration" }] + +[[group]] +name = "lsp-server" +label = "LSP Server" +description = ["Language Server Protocol Server for src programming language"] +requires = ["lexer", "parser", "type checker"] +items = [ + { label = "apply edits to ropey on documentDidChange", status = "done" }, +] + +[[group]] +name = "vm" +label = "VM" +description = ["VM for src programming language"] +requires = ["lexer", "parser", "type checker", "codegen"] +items = [ + { label = "vm", status = "exploration" }, + { label = "vm tests", status = "exploration" }, +] diff --git a/docs/theme/index.hbs b/docs/theme/index.hbs index ca1be88..1289d9e 100644 --- a/docs/theme/index.hbs +++ b/docs/theme/index.hbs @@ -24,7 +24,6 @@ - {{/if}} @@ -150,7 +149,7 @@ 🍔