diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000..7569cd4abf2e5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "oxc.path.server": "editors/vscode/target/debug/oxc_language_server" +} diff --git a/Cargo.lock b/Cargo.lock index 8b7c0e99d8484..18cf35a65163c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -595,6 +595,22 @@ dependencies = [ "syn", ] +[[package]] +name = "dhat" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cd11d84628e233de0ce467de10b8633f4ddaecafadefc86e13b84b8739b827" +dependencies = [ + "backtrace", + "lazy_static", + "mintex", + "parking_lot", + "rustc-hash 1.1.0", + "serde", + "serde_json", + "thousands", +] + [[package]] name = "digest" version = "0.10.7" @@ -715,7 +731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] @@ -1201,7 +1217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" dependencies = [ "equivalent", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "rayon", "serde", "serde_core", @@ -1452,6 +1468,12 @@ dependencies = [ "adler2", ] +[[package]] +name = "mintex" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c505b3e17ed6b70a7ed2e67fbb2c560ee327353556120d6e72f5232b6880d536" + [[package]] name = "mio" version = "1.0.4" @@ -1474,7 +1496,7 @@ dependencies = [ "napi-build", "napi-sys", "nohash-hasher", - "rustc-hash", + "rustc-hash 2.1.1", "tokio", ] @@ -1684,7 +1706,7 @@ dependencies = [ "bincode 2.0.1", "flate2", "nom", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "thiserror", @@ -1740,7 +1762,7 @@ dependencies = [ "oxc_ast_macros", "oxc_data_structures", "oxc_estree", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", ] @@ -1789,7 +1811,7 @@ dependencies = [ "proc-macro2", "quote", "rayon", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "syn", @@ -1824,7 +1846,7 @@ dependencies = [ "oxc_span", "oxc_tasks_common", "oxc_transformer", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", ] @@ -1839,7 +1861,7 @@ dependencies = [ "oxc_index", "oxc_syntax", "petgraph", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -1862,7 +1884,7 @@ dependencies = [ "oxc_span", "oxc_syntax", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -1872,7 +1894,7 @@ dependencies = [ "cow-utils", "oxc-browserslist", "oxc_syntax", - "rustc-hash", + "rustc-hash 2.1.1", "serde", ] @@ -1908,7 +1930,7 @@ dependencies = [ "phf", "pico-args", "rayon", - "rustc-hash", + "rustc-hash 2.1.1", "saphyr", "serde", "serde_json", @@ -1967,7 +1989,7 @@ dependencies = [ "oxc_span", "oxc_syntax", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", "unicode-width", ] @@ -1995,13 +2017,14 @@ dependencies = [ "oxc_parser", "oxc_span", "oxc_syntax", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] name = "oxc_language_server" version = "1.19.0" dependencies = [ + "dhat", "env_logger", "futures", "ignore", @@ -2014,7 +2037,7 @@ dependencies = [ "oxc_linter", "oxc_parser", "papaya", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "tokio", @@ -2065,7 +2088,7 @@ dependencies = [ "project-root", "rayon", "rust-lapper", - "rustc-hash", + "rustc-hash 2.1.1", "self_cell", "serde", "serde_json", @@ -2079,7 +2102,7 @@ version = "0.0.0" dependencies = [ "convert_case", "project-root", - "rustc-hash", + "rustc-hash 2.1.1", "syn", ] @@ -2106,7 +2129,7 @@ dependencies = [ "oxc_parser", "oxc_semantic", "oxc_span", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -2132,7 +2155,7 @@ dependencies = [ "oxc_syntax", "oxc_traverse", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -2170,7 +2193,7 @@ dependencies = [ "oxc_tasks_common", "oxc_transformer_plugins", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", "similar-asserts", ] @@ -2207,7 +2230,7 @@ dependencies = [ "oxc_span", "oxc_syntax", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", "seq-macro", ] @@ -2223,7 +2246,7 @@ dependencies = [ "oxc_ast_macros", "oxc_estree", "oxc_napi", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -2239,7 +2262,7 @@ dependencies = [ "oxc_linter", "oxc_napi", "oxc_transformer_plugins", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", ] @@ -2257,7 +2280,7 @@ dependencies = [ "oxc_span", "oxc_tasks_common", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", "similar", "walkdir", ] @@ -2272,7 +2295,7 @@ dependencies = [ "oxc_diagnostics", "oxc_span", "phf", - "rustc-hash", + "rustc-hash 2.1.1", "unicode-id-start", ] @@ -2288,7 +2311,7 @@ dependencies = [ "libc", "once_cell", "papaya", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "simdutf8", @@ -2328,7 +2351,7 @@ dependencies = [ "oxc_span", "oxc_syntax", "phf", - "rustc-hash", + "rustc-hash 2.1.1", "self_cell", "serde_json", ] @@ -2343,7 +2366,7 @@ dependencies = [ "napi", "napi-build", "napi-derive", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", ] @@ -2403,7 +2426,7 @@ dependencies = [ "oxc_semantic", "oxc_span", "oxc_syntax", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -2445,7 +2468,7 @@ dependencies = [ "oxc", "oxc_napi", "oxc_sourcemap", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -2473,7 +2496,7 @@ dependencies = [ "oxc_syntax", "oxc_traverse", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "sha1", @@ -2502,7 +2525,7 @@ dependencies = [ "oxc_transformer", "oxc_traverse", "pico-args", - "rustc-hash", + "rustc-hash 2.1.1", "similar", ] @@ -2519,7 +2542,7 @@ dependencies = [ "oxc_semantic", "oxc_span", "oxc_syntax", - "rustc-hash", + "rustc-hash 2.1.1", ] [[package]] @@ -2561,7 +2584,7 @@ dependencies = [ "oxc_linter", "oxc_span", "rayon", - "rustc-hash", + "rustc-hash 2.1.1", "serde", "serde_json", "simdutf8", @@ -2580,6 +2603,16 @@ dependencies = [ "seize", ] +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + [[package]] name = "parking_lot_core" version = "0.9.11" @@ -2892,7 +2925,7 @@ dependencies = [ "oxc_parser", "oxc_span", "oxc_tasks_common", - "rustc-hash", + "rustc-hash 2.1.1", "serde", ] @@ -2911,6 +2944,12 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hash" version = "2.1.1" @@ -2927,7 +2966,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] @@ -3031,7 +3070,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b55fb86dfd3a2f5f76ea78310a88f96c4ea21a3031f8d212443d56123fd0521" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] @@ -3292,7 +3331,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] @@ -3326,6 +3365,12 @@ dependencies = [ "syn", ] +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + [[package]] name = "thread_local" version = "1.1.9" @@ -3800,7 +3845,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e5d93b8296151..e6c479cbee938 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -241,7 +241,8 @@ debug = false [profile.test] # Disabling debug info speeds up local and CI builds, # and we don't rely on it for debugging that much. -debug = false +debug = true +strip = false # Keep [profile.dev.package] # Compile macros with some optimizations to make consuming crates build faster @@ -258,11 +259,8 @@ opt-level = 'z' [profile.release] # Configurations explicitly listed here for clarity. # Using the best options for performance. -opt-level = 3 -lto = "fat" -codegen-units = 1 -strip = "symbols" # Set to `false` for debug information -debug = false # Set to `true` for debug information +debug = true +strip = false # Keep panic = "abort" # Let it crash and force ourselves to write safe Rust # Profile used for release mode, but with debugging information for profiling diff --git a/crates/oxc_language_server/Cargo.toml b/crates/oxc_language_server/Cargo.toml index c478dabc92c7e..0d913d86bfa8b 100644 --- a/crates/oxc_language_server/Cargo.toml +++ b/crates/oxc_language_server/Cargo.toml @@ -18,8 +18,11 @@ workspace = true [[bin]] name = "oxc_language_server" -test = true +path = "src/lib.rs" +test = false doctest = false +debug = true +strip = false # Keep debug information in binary [dependencies] oxc_allocator = { workspace = true } @@ -30,6 +33,7 @@ oxc_linter = { workspace = true, features = ["language_server"] } oxc_parser = { workspace = true } # +dhat = "0.3.3" env_logger = { workspace = true, features = ["humantime"] } futures = { workspace = true } ignore = { workspace = true, features = ["simd-accel"] } diff --git a/crates/oxc_language_server/fixtures/linter/memory/.gitignore b/crates/oxc_language_server/fixtures/linter/memory/.gitignore new file mode 100644 index 0000000000000..c2658d7d1b318 --- /dev/null +++ b/crates/oxc_language_server/fixtures/linter/memory/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/crates/oxc_language_server/fixtures/linter/memory/.oxlintrc.json b/crates/oxc_language_server/fixtures/linter/memory/.oxlintrc.json new file mode 100644 index 0000000000000..3340f2e824309 --- /dev/null +++ b/crates/oxc_language_server/fixtures/linter/memory/.oxlintrc.json @@ -0,0 +1,3 @@ +{ + "plugins": ["import"] +} diff --git a/crates/oxc_language_server/fixtures/linter/memory/file.ts b/crates/oxc_language_server/fixtures/linter/memory/file.ts new file mode 100644 index 0000000000000..9424147cf0c63 --- /dev/null +++ b/crates/oxc_language_server/fixtures/linter/memory/file.ts @@ -0,0 +1,5 @@ + +import { Canvas } from '@react-three/fiber'; + +// @ts-ignore +Canvas(); diff --git a/crates/oxc_language_server/fixtures/linter/memory/package-lock.json b/crates/oxc_language_server/fixtures/linter/memory/package-lock.json new file mode 100644 index 0000000000000..70cfc22aa7f89 --- /dev/null +++ b/crates/oxc_language_server/fixtures/linter/memory/package-lock.json @@ -0,0 +1,288 @@ +{ + "name": "memory", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@react-three/fiber": "^9.2" + } + }, + "node_modules/@babel/runtime": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz", + "integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@react-three/fiber": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-9.3.0.tgz", + "integrity": "sha512-myPe3YL/C8+Eq939/4qIVEPBW/uxV0iiUbmjfwrs9sGKYDG8ib8Dz3Okq7BQt8P+0k4igedONbjXMQy84aDFmQ==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@types/react-reconciler": "^0.32.0", + "@types/webxr": "*", + "base64-js": "^1.5.1", + "buffer": "^6.0.3", + "its-fine": "^2.0.0", + "react-reconciler": "^0.31.0", + "react-use-measure": "^2.1.7", + "scheduler": "^0.25.0", + "suspend-react": "^0.1.3", + "use-sync-external-store": "^1.4.0", + "zustand": "^5.0.3" + }, + "peerDependencies": { + "expo": ">=43.0", + "expo-asset": ">=8.4", + "expo-file-system": ">=11.0", + "expo-gl": ">=11.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "react-native": ">=0.78", + "three": ">=0.156" + }, + "peerDependenciesMeta": { + "expo": { + "optional": true + }, + "expo-asset": { + "optional": true + }, + "expo-file-system": { + "optional": true + }, + "expo-gl": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "react-native": { + "optional": true + } + } + }, + "node_modules/@types/react": { + "version": "19.1.16", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.16.tgz", + "integrity": "sha512-WBM/nDbEZmDUORKnh5i1bTnAz6vTohUf9b8esSMu+b24+srbaxa04UbJgWx78CVfNXA20sNu0odEIluZDFdCog==", + "license": "MIT", + "peer": true, + "dependencies": { + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-reconciler": { + "version": "0.32.1", + "resolved": "https://registry.npmjs.org/@types/react-reconciler/-/react-reconciler-0.32.1.tgz", + "integrity": "sha512-RsqPttsBQ+6af0nATFXJJpemYQH7kL9+xLNm1z+0MjQFDKBZDM2R6SBrjdvRmHu9i9fM6povACj57Ft+pKRNOA==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*" + } + }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "license": "MIT" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "license": "MIT", + "peer": true + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/its-fine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/its-fine/-/its-fine-2.0.0.tgz", + "integrity": "sha512-KLViCmWx94zOvpLwSlsx6yOCeMhZYaxrJV87Po5k/FoZzcPSahvK5qJ7fYhS61sZi5ikmh2S3Hz55A2l3U69ng==", + "license": "MIT", + "dependencies": { + "@types/react-reconciler": "^0.28.9" + }, + "peerDependencies": { + "react": "^19.0.0" + } + }, + "node_modules/its-fine/node_modules/@types/react-reconciler": { + "version": "0.28.9", + "resolved": "https://registry.npmjs.org/@types/react-reconciler/-/react-reconciler-0.28.9.tgz", + "integrity": "sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*" + } + }, + "node_modules/react": { + "version": "19.1.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz", + "integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-reconciler": { + "version": "0.31.0", + "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.31.0.tgz", + "integrity": "sha512-7Ob7Z+URmesIsIVRjnLoDGwBEG/tVitidU0nMsqX/eeJaLY89RISO/10ERe0MqmzuKUUB1rmY+h1itMbUHg9BQ==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.25.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "peerDependencies": { + "react": "^19.0.0" + } + }, + "node_modules/react-use-measure": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/react-use-measure/-/react-use-measure-2.1.7.tgz", + "integrity": "sha512-KrvcAo13I/60HpwGO5jpW7E9DfusKyLPLvuHlUyP5zqnmAPhNc6qTRjUQrdTADl0lpPpDVU2/Gg51UlOGHXbdg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.13", + "react-dom": ">=16.13" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, + "node_modules/scheduler": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.25.0.tgz", + "integrity": "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==", + "license": "MIT" + }, + "node_modules/suspend-react": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/suspend-react/-/suspend-react-0.1.3.tgz", + "integrity": "sha512-aqldKgX9aZqpoDp3e8/BZ8Dm7x1pJl+qI3ZKxDN0i/IQTWUwBx/ManmlVJ3wowqbno6c2bmiIfs+Um6LbsjJyQ==", + "license": "MIT", + "peerDependencies": { + "react": ">=17.0" + } + }, + "node_modules/three": { + "version": "0.180.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.180.0.tgz", + "integrity": "sha512-o+qycAMZrh+TsE01GqWUxUIKR1AL0S8pq7zDkYOQw8GqfX8b8VoCKYUoHbhiX5j+7hr8XsuHDVU6+gkQJQKg9w==", + "license": "MIT", + "peer": true + }, + "node_modules/use-sync-external-store": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz", + "integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/zustand": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.8.tgz", + "integrity": "sha512-gyPKpIaxY9XcO2vSMrLbiER7QMAMGOQZVRdJ6Zi782jkbzZygq5GI9nG8g+sMgitRtndwaBSl7uiqC49o1SSiw==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } + } + } +} diff --git a/crates/oxc_language_server/fixtures/linter/memory/package.json b/crates/oxc_language_server/fixtures/linter/memory/package.json new file mode 100644 index 0000000000000..8188eb402478d --- /dev/null +++ b/crates/oxc_language_server/fixtures/linter/memory/package.json @@ -0,0 +1,6 @@ + +{ + "dependencies": { + "@react-three/fiber": "^9.2" + } +} diff --git a/crates/oxc_language_server/src/lib.rs b/crates/oxc_language_server/src/lib.rs new file mode 100644 index 0000000000000..1af015ece8458 --- /dev/null +++ b/crates/oxc_language_server/src/lib.rs @@ -0,0 +1,57 @@ +use rustc_hash::FxBuildHasher; +use tower_lsp_server::{ + LanguageServer, LspService, Server, UriExt, + lsp_types::{ + ClientCapabilities, DocumentFormattingClientCapabilities, InitializeParams, + InitializedParams, TextDocumentClientCapabilities, Uri, + }, +}; + +mod backend; +mod capabilities; +mod code_actions; +mod commands; +mod file_system; +mod formatter; +mod linter; +mod options; +#[cfg(test)] +mod tester; +mod worker; + +use crate::{ + backend::Backend, + linter::{ + options::LintOptions, + server_linter::{ServerLinter, ServerLinterRun}, + }, +}; + +type ConcurrentHashMap = papaya::HashMap; + +const OXC_CONFIG_FILE: &str = ".oxlintrc.json"; + +// max range for LSP integer is 2^31 - 1 +// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#baseTypes +const LSP_MAX_INT: u32 = 2u32.pow(31) - 1; + +#[global_allocator] +static ALLOC: dhat::Alloc = dhat::Alloc; + +#[tokio::main] +async fn main() { + let _profiler = dhat::Profiler::new_heap(); + + let cwd = std::env::current_dir().expect("Failed to get current working directory"); + let fixture_path = cwd.join("crates/oxc_language_server/fixtures/linter/memory"); + let fake_file_path = fixture_path.join("file.ts"); + let uri = Uri::from_file_path(fake_file_path).unwrap(); + + let server = + ServerLinter::new(&Uri::from_file_path(fixture_path).unwrap(), &LintOptions::default()); + + for _i in 0..100 { + let _ = server.run_single(&uri, None, ServerLinterRun::OnType).await; + server.remove_diagnostics(&uri); + } +}