mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 04:52:26 -05:00
Merge remote-tracking branch 'upstream/main' into check-workspace-member-compiler-options
This commit is contained in:
commit
f5b258cfdb
20 changed files with 446 additions and 147 deletions
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -1482,9 +1482,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_core"
|
||||
version = "0.324.0"
|
||||
version = "0.326.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24503eda646f246aa6eb0f794909f9a857c8f05095fed66f36e0eaef92edce23"
|
||||
checksum = "ed157162dc5320a2b46ffeeaec24788339df0f2437cfaea78a8d82696715ad7f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"az",
|
||||
|
@ -1492,6 +1492,7 @@ dependencies = [
|
|||
"bit-set",
|
||||
"bit-vec",
|
||||
"bytes",
|
||||
"capacity_builder",
|
||||
"cooked-waker",
|
||||
"deno_core_icudata",
|
||||
"deno_ops",
|
||||
|
@ -1573,9 +1574,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_doc"
|
||||
version = "0.161.2"
|
||||
version = "0.161.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3af787319136f3e7f73ef551c618aeec70794522e36cd75ae35132a3bad983ef"
|
||||
checksum = "353a39c70d248af04600928cefc8066a9e4535fb6e7d7c518411e5efc822819f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if",
|
||||
|
@ -2051,9 +2052,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_ops"
|
||||
version = "0.200.0"
|
||||
version = "0.202.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03a529a2c488cd3042f12f35666569ebe5b3cf89d2b7d1cafc1a652f6d7bcc8f"
|
||||
checksum = "4dd8ac1af251e292388e516dd339b9a3b982a6d1e7f8644c08e34671ca39003c"
|
||||
dependencies = [
|
||||
"proc-macro-rules",
|
||||
"proc-macro2",
|
||||
|
@ -6693,9 +6694,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_v8"
|
||||
version = "0.233.0"
|
||||
version = "0.235.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "307f176b7475480cee690c34c7118f96fe564d1f2a974bf990294b8310ae4983"
|
||||
checksum = "d07afd8b67b4a442ecc2823038473ac0e9e5682de93c213323b60661afdd7eb4"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"serde",
|
||||
|
@ -8280,9 +8281,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "v8"
|
||||
version = "130.0.1"
|
||||
version = "130.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c23b5c2caff00209b03a716609b275acae94b02dd3b63c4648e7232a84a8402f"
|
||||
checksum = "2ee0be58935708fa4d7efb970c6cf9f2d9511d24ee24246481a65b6ee167348d"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bitflags 2.6.0",
|
||||
|
|
|
@ -48,7 +48,7 @@ repository = "https://github.com/denoland/deno"
|
|||
|
||||
[workspace.dependencies]
|
||||
deno_ast = { version = "=0.44.0", features = ["transpiling"] }
|
||||
deno_core = { version = "0.324.0" }
|
||||
deno_core = { version = "0.326.0" }
|
||||
|
||||
deno_bench_util = { version = "0.176.0", path = "./bench_util" }
|
||||
# TODO(nayeemrmn): Use proper version when https://github.com/denoland/deno_config/pull/143 lands!
|
||||
|
|
|
@ -72,7 +72,7 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa
|
|||
deno_cache_dir.workspace = true
|
||||
deno_config.workspace = true
|
||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
||||
deno_doc = { version = "=0.161.2", features = ["rust", "comrak"] }
|
||||
deno_doc = { version = "=0.161.3", features = ["rust", "comrak"] }
|
||||
deno_graph = { version = "=0.86.3" }
|
||||
deno_lint = { version = "=0.68.2", features = ["docs"] }
|
||||
deno_lockfile.workspace = true
|
||||
|
|
|
@ -459,6 +459,19 @@ impl Default for LanguagePreferences {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SuggestionActionsSettings {
|
||||
#[serde(default = "is_true")]
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for SuggestionActionsSettings {
|
||||
fn default() -> Self {
|
||||
SuggestionActionsSettings { enabled: true }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateImportsOnFileMoveOptions {
|
||||
|
@ -490,6 +503,8 @@ pub struct LanguageWorkspaceSettings {
|
|||
#[serde(default)]
|
||||
pub suggest: CompletionSettings,
|
||||
#[serde(default)]
|
||||
pub suggestion_actions: SuggestionActionsSettings,
|
||||
#[serde(default)]
|
||||
pub update_imports_on_file_move: UpdateImportsOnFileMoveOptions,
|
||||
}
|
||||
|
||||
|
@ -2293,6 +2308,7 @@ mod tests {
|
|||
enabled: true,
|
||||
},
|
||||
},
|
||||
suggestion_actions: SuggestionActionsSettings { enabled: true },
|
||||
update_imports_on_file_move: UpdateImportsOnFileMoveOptions {
|
||||
enabled: UpdateImportsOnFileMoveEnabled::Prompt
|
||||
}
|
||||
|
@ -2339,6 +2355,7 @@ mod tests {
|
|||
enabled: true,
|
||||
},
|
||||
},
|
||||
suggestion_actions: SuggestionActionsSettings { enabled: true },
|
||||
update_imports_on_file_move: UpdateImportsOnFileMoveOptions {
|
||||
enabled: UpdateImportsOnFileMoveEnabled::Prompt
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ use crate::resolver::SloppyImportsCachedFs;
|
|||
use crate::tools::lint::CliLinter;
|
||||
use crate::tools::lint::CliLinterOptions;
|
||||
use crate::tools::lint::LintRuleProvider;
|
||||
use crate::tsc::DiagnosticCategory;
|
||||
use crate::util::path::to_percent_decoded_str;
|
||||
|
||||
use deno_ast::MediaType;
|
||||
|
@ -906,8 +907,22 @@ async fn generate_ts_diagnostics(
|
|||
} else {
|
||||
Default::default()
|
||||
};
|
||||
for (specifier_str, ts_json_diagnostics) in ts_diagnostics_map {
|
||||
for (specifier_str, mut ts_json_diagnostics) in ts_diagnostics_map {
|
||||
let specifier = resolve_url(&specifier_str)?;
|
||||
let suggestion_actions_settings = snapshot
|
||||
.config
|
||||
.language_settings_for_specifier(&specifier)
|
||||
.map(|s| s.suggestion_actions.clone())
|
||||
.unwrap_or_default();
|
||||
if !suggestion_actions_settings.enabled {
|
||||
ts_json_diagnostics.retain(|d| {
|
||||
d.category != DiagnosticCategory::Suggestion
|
||||
// Still show deprecated and unused diagnostics.
|
||||
// https://github.com/microsoft/vscode/blob/ce50bd4876af457f64d83cfd956bc916535285f4/extensions/typescript-language-features/src/languageFeatures/diagnostics.ts#L113-L114
|
||||
|| d.reports_deprecated == Some(true)
|
||||
|| d.reports_unnecessary == Some(true)
|
||||
});
|
||||
}
|
||||
let version = snapshot
|
||||
.documents
|
||||
.get(&specifier)
|
||||
|
|
|
@ -4496,6 +4496,7 @@ impl<'a> ToV8<'a> for TscRequestArray {
|
|||
|
||||
let method_name = deno_core::FastString::from_static(method_name)
|
||||
.v8_string(scope)
|
||||
.unwrap()
|
||||
.into();
|
||||
let args = args.unwrap_or_else(|| v8::Array::new(scope, 0).into());
|
||||
let scope_url = serde_v8::to_v8(scope, self.scope)
|
||||
|
@ -5745,6 +5746,7 @@ mod tests {
|
|||
"sourceLine": " import { A } from \".\";",
|
||||
"category": 2,
|
||||
"code": 6133,
|
||||
"reportsUnnecessary": true,
|
||||
}]
|
||||
})
|
||||
);
|
||||
|
@ -5827,6 +5829,7 @@ mod tests {
|
|||
"sourceLine": " import {",
|
||||
"category": 2,
|
||||
"code": 6192,
|
||||
"reportsUnnecessary": true,
|
||||
}, {
|
||||
"start": {
|
||||
"line": 8,
|
||||
|
|
|
@ -35,6 +35,7 @@ use serde::Serialize;
|
|||
use thiserror::Error;
|
||||
|
||||
use crate::util;
|
||||
use crate::util::display::human_size;
|
||||
use crate::util::display::DisplayTreeNode;
|
||||
use crate::util::fs::canonicalize_path;
|
||||
|
||||
|
@ -512,96 +513,238 @@ pub fn output_vfs(vfs: &BuiltVfs, executable_name: &str) {
|
|||
let mut text = String::new();
|
||||
let display_tree = vfs_as_display_tree(vfs, executable_name);
|
||||
display_tree.print(&mut text).unwrap(); // unwrap ok because it's writing to a string
|
||||
log::info!(
|
||||
"\n{}\n",
|
||||
deno_terminal::colors::bold("Embedded File System")
|
||||
);
|
||||
log::info!("\n{}\n", deno_terminal::colors::bold("Embedded Files"));
|
||||
log::info!("{}\n", text.trim());
|
||||
log::info!(
|
||||
"Size: {}\n",
|
||||
human_size(vfs.files.iter().map(|f| f.len() as f64).sum())
|
||||
);
|
||||
}
|
||||
|
||||
fn vfs_as_display_tree(
|
||||
vfs: &BuiltVfs,
|
||||
executable_name: &str,
|
||||
) -> DisplayTreeNode {
|
||||
/// The VFS only stores duplicate files once, so track that and display
|
||||
/// it to the user so that it's not confusing.
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
struct Size {
|
||||
unique: u64,
|
||||
total: u64,
|
||||
}
|
||||
|
||||
impl std::ops::Add for Size {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, other: Self) -> Self {
|
||||
Self {
|
||||
unique: self.unique + other.unique,
|
||||
total: self.total + other.total,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::Sum for Size {
|
||||
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
|
||||
iter.fold(Self::default(), std::ops::Add::add)
|
||||
}
|
||||
}
|
||||
|
||||
enum EntryOutput<'a> {
|
||||
All,
|
||||
All(Size),
|
||||
Subset(Vec<DirEntryOutput<'a>>),
|
||||
File,
|
||||
File(Size),
|
||||
Symlink(&'a [String]),
|
||||
}
|
||||
|
||||
impl<'a> EntryOutput<'a> {
|
||||
pub fn as_display_tree(&self, name: String) -> DisplayTreeNode {
|
||||
let mut children = match self {
|
||||
EntryOutput::Subset(vec) => vec
|
||||
.iter()
|
||||
.map(|e| e.output.as_display_tree(e.name.to_string()))
|
||||
.collect(),
|
||||
EntryOutput::All | EntryOutput::File | EntryOutput::Symlink(_) => {
|
||||
vec![]
|
||||
pub fn size(&self) -> Size {
|
||||
match self {
|
||||
EntryOutput::All(size) => *size,
|
||||
EntryOutput::Subset(children) => {
|
||||
children.iter().map(|c| c.output.size()).sum()
|
||||
}
|
||||
};
|
||||
// we only want to collapse leafs so that nodes of the
|
||||
// same depth have the same indentation
|
||||
let collapse_single_child =
|
||||
children.len() == 1 && children[0].children.is_empty();
|
||||
EntryOutput::File(size) => *size,
|
||||
EntryOutput::Symlink(_) => Size {
|
||||
unique: 0,
|
||||
total: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EntryOutput<'a> {
|
||||
pub fn as_display_tree(&self, name: String) -> DisplayTreeNode {
|
||||
fn format_size(size: Size) -> String {
|
||||
if size.unique == size.total {
|
||||
human_size(size.unique as f64)
|
||||
} else {
|
||||
format!(
|
||||
"{}{}",
|
||||
human_size(size.total as f64),
|
||||
deno_terminal::colors::gray(format!(
|
||||
" - {} unique",
|
||||
human_size(size.unique as f64)
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
DisplayTreeNode {
|
||||
text: match self {
|
||||
EntryOutput::All => format!("{}/*", name),
|
||||
EntryOutput::Subset(_) => {
|
||||
if collapse_single_child {
|
||||
format!("{}/{}", name, children[0].text)
|
||||
} else {
|
||||
name
|
||||
}
|
||||
EntryOutput::All(size) => {
|
||||
format!("{}/* ({})", name, format_size(*size))
|
||||
}
|
||||
EntryOutput::Subset(children) => {
|
||||
let size = children.iter().map(|c| c.output.size()).sum::<Size>();
|
||||
format!("{} ({})", name, format_size(size))
|
||||
}
|
||||
EntryOutput::File(size) => {
|
||||
format!("{} ({})", name, format_size(*size))
|
||||
}
|
||||
EntryOutput::File => name,
|
||||
EntryOutput::Symlink(parts) => {
|
||||
format!("{} --> {}", name, parts.join("/"))
|
||||
}
|
||||
},
|
||||
children: if collapse_single_child {
|
||||
children.remove(0).children
|
||||
} else {
|
||||
children
|
||||
children: match self {
|
||||
EntryOutput::All(_) => Vec::new(),
|
||||
EntryOutput::Subset(children) => children
|
||||
.iter()
|
||||
.map(|entry| entry.output.as_display_tree(entry.name.to_string()))
|
||||
.collect(),
|
||||
EntryOutput::File(_) => Vec::new(),
|
||||
EntryOutput::Symlink(_) => Vec::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DirEntryOutput<'a> {
|
||||
name: &'a str,
|
||||
name: Cow<'a, str>,
|
||||
output: EntryOutput<'a>,
|
||||
}
|
||||
|
||||
fn show_global_node_modules_dir(
|
||||
vfs_dir: &VirtualDirectory,
|
||||
) -> Vec<DirEntryOutput> {
|
||||
fn show_subset_deep(
|
||||
vfs_dir: &VirtualDirectory,
|
||||
depth: usize,
|
||||
) -> EntryOutput {
|
||||
if depth == 0 {
|
||||
EntryOutput::All
|
||||
impl<'a> DirEntryOutput<'a> {
|
||||
/// Collapses leaf nodes so they don't take up so much space when being
|
||||
/// displayed.
|
||||
///
|
||||
/// We only want to collapse leafs so that nodes of the same depth have
|
||||
/// the same indentation.
|
||||
pub fn collapse_leaf_nodes(&mut self) {
|
||||
let EntryOutput::Subset(vec) = &mut self.output else {
|
||||
return;
|
||||
};
|
||||
for dir_entry in vec.iter_mut() {
|
||||
dir_entry.collapse_leaf_nodes();
|
||||
}
|
||||
if vec.len() != 1 {
|
||||
return;
|
||||
}
|
||||
let child = &mut vec[0];
|
||||
let child_name = &child.name;
|
||||
match &mut child.output {
|
||||
EntryOutput::All(size) => {
|
||||
self.name = Cow::Owned(format!("{}/{}", self.name, child_name));
|
||||
self.output = EntryOutput::All(*size);
|
||||
}
|
||||
EntryOutput::Subset(children) => {
|
||||
if children.is_empty() {
|
||||
self.name = Cow::Owned(format!("{}/{}", self.name, child_name));
|
||||
self.output = EntryOutput::Subset(vec![]);
|
||||
}
|
||||
}
|
||||
EntryOutput::File(size) => {
|
||||
self.name = Cow::Owned(format!("{}/{}", self.name, child_name));
|
||||
self.output = EntryOutput::File(*size);
|
||||
}
|
||||
EntryOutput::Symlink(parts) => {
|
||||
let new_name = format!("{}/{}", self.name, child_name);
|
||||
self.output = EntryOutput::Symlink(parts);
|
||||
self.name = Cow::Owned(new_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn file_size(file: &VirtualFile, seen_offsets: &mut HashSet<u64>) -> Size {
|
||||
fn add_offset_to_size(
|
||||
offset: OffsetWithLength,
|
||||
size: &mut Size,
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) {
|
||||
if offset.len == 0 {
|
||||
// some empty files have a dummy offset, so don't
|
||||
// insert them into the seen offsets
|
||||
return;
|
||||
}
|
||||
|
||||
if seen_offsets.insert(offset.offset) {
|
||||
size.total += offset.len;
|
||||
size.unique += offset.len;
|
||||
} else {
|
||||
EntryOutput::Subset(show_subset(vfs_dir, depth))
|
||||
size.total += offset.len;
|
||||
}
|
||||
}
|
||||
|
||||
fn show_subset(
|
||||
vfs_dir: &VirtualDirectory,
|
||||
let mut size = Size::default();
|
||||
add_offset_to_size(file.offset, &mut size, seen_offsets);
|
||||
if file.module_graph_offset.offset != file.offset.offset {
|
||||
add_offset_to_size(file.module_graph_offset, &mut size, seen_offsets);
|
||||
}
|
||||
size
|
||||
}
|
||||
|
||||
fn dir_size(dir: &VirtualDirectory, seen_offsets: &mut HashSet<u64>) -> Size {
|
||||
let mut size = Size::default();
|
||||
for entry in &dir.entries {
|
||||
match entry {
|
||||
VfsEntry::Dir(virtual_directory) => {
|
||||
size = size + dir_size(virtual_directory, seen_offsets);
|
||||
}
|
||||
VfsEntry::File(file) => {
|
||||
size = size + file_size(file, seen_offsets);
|
||||
}
|
||||
VfsEntry::Symlink(_) => {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
size
|
||||
}
|
||||
|
||||
fn show_global_node_modules_dir<'a>(
|
||||
vfs_dir: &'a VirtualDirectory,
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) -> Vec<DirEntryOutput<'a>> {
|
||||
fn show_subset_deep<'a>(
|
||||
vfs_dir: &'a VirtualDirectory,
|
||||
depth: usize,
|
||||
) -> Vec<DirEntryOutput> {
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) -> EntryOutput<'a> {
|
||||
if depth == 0 {
|
||||
EntryOutput::All(dir_size(vfs_dir, seen_offsets))
|
||||
} else {
|
||||
EntryOutput::Subset(show_subset(vfs_dir, depth, seen_offsets))
|
||||
}
|
||||
}
|
||||
|
||||
fn show_subset<'a>(
|
||||
vfs_dir: &'a VirtualDirectory,
|
||||
depth: usize,
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) -> Vec<DirEntryOutput<'a>> {
|
||||
vfs_dir
|
||||
.entries
|
||||
.iter()
|
||||
.map(|entry| DirEntryOutput {
|
||||
name: entry.name(),
|
||||
name: Cow::Borrowed(entry.name()),
|
||||
output: match entry {
|
||||
VfsEntry::Dir(virtual_directory) => {
|
||||
show_subset_deep(virtual_directory, depth - 1)
|
||||
show_subset_deep(virtual_directory, depth - 1, seen_offsets)
|
||||
}
|
||||
VfsEntry::File(file) => {
|
||||
EntryOutput::File(file_size(file, seen_offsets))
|
||||
}
|
||||
VfsEntry::File(_) => EntryOutput::File,
|
||||
VfsEntry::Symlink(virtual_symlink) => {
|
||||
EntryOutput::Symlink(&virtual_symlink.dest_parts.0)
|
||||
}
|
||||
|
@ -612,40 +755,54 @@ fn vfs_as_display_tree(
|
|||
|
||||
// in this scenario, we want to show
|
||||
// .deno_compile_node_modules/localhost/<package_name>/<version>/*
|
||||
show_subset(vfs_dir, 3)
|
||||
show_subset(vfs_dir, 3, seen_offsets)
|
||||
}
|
||||
|
||||
fn include_all_entries<'a>(
|
||||
dir_path: &WindowsSystemRootablePath,
|
||||
vfs_dir: &'a VirtualDirectory,
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) -> Vec<DirEntryOutput<'a>> {
|
||||
if vfs_dir.name == DENO_COMPILE_GLOBAL_NODE_MODULES_DIR_NAME {
|
||||
return show_global_node_modules_dir(vfs_dir);
|
||||
return show_global_node_modules_dir(vfs_dir, seen_offsets);
|
||||
}
|
||||
|
||||
vfs_dir
|
||||
.entries
|
||||
.iter()
|
||||
.map(|entry| DirEntryOutput {
|
||||
name: entry.name(),
|
||||
output: analyze_entry(dir_path.join(entry.name()), entry),
|
||||
name: Cow::Borrowed(entry.name()),
|
||||
output: analyze_entry(dir_path.join(entry.name()), entry, seen_offsets),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn analyze_entry(path: PathBuf, entry: &VfsEntry) -> EntryOutput {
|
||||
fn analyze_entry<'a>(
|
||||
path: PathBuf,
|
||||
entry: &'a VfsEntry,
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) -> EntryOutput<'a> {
|
||||
match entry {
|
||||
VfsEntry::Dir(virtual_directory) => analyze_dir(path, virtual_directory),
|
||||
VfsEntry::File(_) => EntryOutput::File,
|
||||
VfsEntry::Dir(virtual_directory) => {
|
||||
analyze_dir(path, virtual_directory, seen_offsets)
|
||||
}
|
||||
VfsEntry::File(file) => EntryOutput::File(file_size(file, seen_offsets)),
|
||||
VfsEntry::Symlink(virtual_symlink) => {
|
||||
EntryOutput::Symlink(&virtual_symlink.dest_parts.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn analyze_dir(dir: PathBuf, vfs_dir: &VirtualDirectory) -> EntryOutput {
|
||||
fn analyze_dir<'a>(
|
||||
dir: PathBuf,
|
||||
vfs_dir: &'a VirtualDirectory,
|
||||
seen_offsets: &mut HashSet<u64>,
|
||||
) -> EntryOutput<'a> {
|
||||
if vfs_dir.name == DENO_COMPILE_GLOBAL_NODE_MODULES_DIR_NAME {
|
||||
return EntryOutput::Subset(show_global_node_modules_dir(vfs_dir));
|
||||
return EntryOutput::Subset(show_global_node_modules_dir(
|
||||
vfs_dir,
|
||||
seen_offsets,
|
||||
));
|
||||
}
|
||||
|
||||
let real_entry_count = std::fs::read_dir(&dir)
|
||||
|
@ -657,15 +814,15 @@ fn vfs_as_display_tree(
|
|||
.entries
|
||||
.iter()
|
||||
.map(|entry| DirEntryOutput {
|
||||
name: entry.name(),
|
||||
output: analyze_entry(dir.join(entry.name()), entry),
|
||||
name: Cow::Borrowed(entry.name()),
|
||||
output: analyze_entry(dir.join(entry.name()), entry, seen_offsets),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if children
|
||||
.iter()
|
||||
.all(|c| !matches!(c.output, EntryOutput::Subset(_)))
|
||||
.all(|c| !matches!(c.output, EntryOutput::Subset { .. }))
|
||||
{
|
||||
EntryOutput::All
|
||||
EntryOutput::All(children.iter().map(|c| c.output.size()).sum())
|
||||
} else {
|
||||
EntryOutput::Subset(children)
|
||||
}
|
||||
|
@ -673,13 +830,19 @@ fn vfs_as_display_tree(
|
|||
EntryOutput::Subset(include_all_entries(
|
||||
&WindowsSystemRootablePath::Path(dir),
|
||||
vfs_dir,
|
||||
seen_offsets,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
// always include all the entries for the root directory, otherwise the
|
||||
// user might not have context about what's being shown
|
||||
let child_entries = include_all_entries(&vfs.root_path, &vfs.root);
|
||||
let mut seen_offsets = HashSet::with_capacity(vfs.files.len());
|
||||
let mut child_entries =
|
||||
include_all_entries(&vfs.root_path, &vfs.root, &mut seen_offsets);
|
||||
for child_entry in &mut child_entries {
|
||||
child_entry.collapse_leaf_nodes();
|
||||
}
|
||||
DisplayTreeNode {
|
||||
text: deno_terminal::colors::italic(executable_name).to_string(),
|
||||
children: child_entries
|
||||
|
@ -1637,8 +1800,8 @@ mod test {
|
|||
let temp_dir = TempDir::new();
|
||||
temp_dir.write("root.txt", "");
|
||||
temp_dir.create_dir_all("a");
|
||||
temp_dir.write("a/a.txt", "");
|
||||
temp_dir.write("a/b.txt", "");
|
||||
temp_dir.write("a/a.txt", "data");
|
||||
temp_dir.write("a/b.txt", "other data");
|
||||
temp_dir.create_dir_all("b");
|
||||
temp_dir.write("b/a.txt", "");
|
||||
temp_dir.write("b/b.txt", "");
|
||||
|
@ -1666,10 +1829,10 @@ mod test {
|
|||
assert_eq!(
|
||||
strip_ansi_codes(&text),
|
||||
r#"executable
|
||||
├── a/*
|
||||
├── b/a.txt
|
||||
└─┬ c
|
||||
├── a.txt
|
||||
├── a/* (14B)
|
||||
├── b/a.txt (0B)
|
||||
└─┬ c (8B)
|
||||
├── a.txt (8B)
|
||||
└── b.txt --> c/a.txt
|
||||
"#
|
||||
);
|
||||
|
|
|
@ -133,6 +133,12 @@ pub struct Diagnostic {
|
|||
pub file_name: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub related_information: Option<Vec<Diagnostic>>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reports_deprecated: Option<bool>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reports_unnecessary: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
pub other: deno_core::serde_json::Map<String, deno_core::serde_json::Value>,
|
||||
}
|
||||
|
||||
impl Diagnostic {
|
||||
|
|
|
@ -1444,6 +1444,9 @@ mod tests {
|
|||
source_line: None,
|
||||
file_name: None,
|
||||
related_information: None,
|
||||
reports_deprecated: None,
|
||||
reports_unnecessary: None,
|
||||
other: Default::default(),
|
||||
}]),
|
||||
stats: Stats(vec![("a".to_string(), 12)])
|
||||
})
|
||||
|
|
|
@ -1411,19 +1411,13 @@ impl<'s> ToV8<'s> for V8MaybeStaticStr {
|
|||
self,
|
||||
scope: &mut v8::HandleScope<'s>,
|
||||
) -> Result<v8::Local<'s, v8::Value>, Self::Error> {
|
||||
// todo(https://github.com/denoland/deno_core/pull/986): remove this check
|
||||
// when upgrading deno_core
|
||||
const MAX_V8_STRING_LENGTH: usize = 536870888;
|
||||
if self.0.len() > MAX_V8_STRING_LENGTH {
|
||||
return Err(FastStringV8AllocationError);
|
||||
}
|
||||
|
||||
Ok(
|
||||
match self.0 {
|
||||
Cow::Borrowed(text) => FastString::from_static(text),
|
||||
Cow::Owned(value) => value.into(),
|
||||
}
|
||||
.v8_string(scope)
|
||||
.map_err(|_| FastStringV8AllocationError)?
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ impl v8::ValueSerializerImpl for SerializerDelegate {
|
|||
let obj = self.obj(scope);
|
||||
let key = FastString::from_static("_getSharedArrayBufferId")
|
||||
.v8_string(scope)
|
||||
.unwrap()
|
||||
.into();
|
||||
if let Some(v) = obj.get(scope, key) {
|
||||
if let Ok(fun) = v.try_cast::<v8::Function>() {
|
||||
|
@ -89,6 +90,7 @@ impl v8::ValueSerializerImpl for SerializerDelegate {
|
|||
let obj = self.obj(scope);
|
||||
let key = FastString::from_static("_getDataCloneError")
|
||||
.v8_string(scope)
|
||||
.unwrap()
|
||||
.into();
|
||||
if let Some(v) = obj.get(scope, key) {
|
||||
let fun = v
|
||||
|
@ -112,6 +114,7 @@ impl v8::ValueSerializerImpl for SerializerDelegate {
|
|||
let obj = self.obj(scope);
|
||||
let key = FastString::from_static("_writeHostObject")
|
||||
.v8_string(scope)
|
||||
.unwrap()
|
||||
.into();
|
||||
if let Some(v) = obj.get(scope, key) {
|
||||
if let Ok(v) = v.try_cast::<v8::Function>() {
|
||||
|
@ -240,6 +243,7 @@ impl v8::ValueDeserializerImpl for DeserializerDelegate {
|
|||
let obj = v8::Local::new(scope, &self.obj);
|
||||
let key = FastString::from_static("_readHostObject")
|
||||
.v8_string(scope)
|
||||
.unwrap()
|
||||
.into();
|
||||
let scope = &mut v8::AllowJavascriptExecutionScope::new(scope);
|
||||
if let Some(v) = obj.get(scope, key) {
|
||||
|
@ -250,7 +254,8 @@ impl v8::ValueDeserializerImpl for DeserializerDelegate {
|
|||
Err(_) => {
|
||||
let msg =
|
||||
FastString::from_static("readHostObject must return an object")
|
||||
.v8_string(scope);
|
||||
.v8_string(scope)
|
||||
.unwrap();
|
||||
let error = v8::Exception::type_error(scope, msg);
|
||||
scope.throw_exception(error);
|
||||
return None;
|
||||
|
|
|
@ -1091,7 +1091,7 @@ Warning Failed resolving symlink. Ignoring.
|
|||
Path: [WILDCARD]
|
||||
Message: [WILDCARD])
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
[WILDCARD]
|
||||
|
||||
|
|
|
@ -2082,6 +2082,88 @@ fn lsp_inlay_hints_not_enabled() {
|
|||
client.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_suggestion_actions_disabled() {
|
||||
let context = TestContextBuilder::new().use_temp_cwd().build();
|
||||
let temp_dir = context.temp_dir();
|
||||
let mut client = context.new_lsp_command().build();
|
||||
client.initialize_default();
|
||||
client.change_configuration(json!({
|
||||
"deno": {
|
||||
"enable": true,
|
||||
"lint": false,
|
||||
},
|
||||
"typescript": {
|
||||
"suggestionActions": {
|
||||
"enabled": false,
|
||||
},
|
||||
},
|
||||
}));
|
||||
client.read_diagnostics();
|
||||
let diagnostics = client.did_open(json!({
|
||||
"textDocument": {
|
||||
"uri": temp_dir.url().join("file.ts").unwrap(),
|
||||
"languageId": "typescript",
|
||||
"version": 1,
|
||||
"text": r#"
|
||||
// The settings should disable the suggestion for this to be async.
|
||||
function asyncLikeFunction() {
|
||||
return new Promise((r) => r(null)).then((v) => v);
|
||||
}
|
||||
console.log(asyncLikeFunction);
|
||||
|
||||
// Deprecated warnings should remain.
|
||||
/** @deprecated */
|
||||
function deprecatedFunction() {}
|
||||
console.log(deprecatedFunction);
|
||||
|
||||
// Unused warnings should remain.
|
||||
const unsusedVariable = 1;
|
||||
"#,
|
||||
},
|
||||
}));
|
||||
assert_eq!(
|
||||
json!(diagnostics.all()),
|
||||
json!([
|
||||
{
|
||||
"range": {
|
||||
"start": { "line": 10, "character": 20 },
|
||||
"end": { "line": 10, "character": 38 },
|
||||
},
|
||||
"severity": 4,
|
||||
"code": 6385,
|
||||
"source": "deno-ts",
|
||||
"message": "'deprecatedFunction' is deprecated.",
|
||||
"relatedInformation": [
|
||||
{
|
||||
"location": {
|
||||
"uri": temp_dir.url().join("file.ts").unwrap(),
|
||||
"range": {
|
||||
"start": { "line": 8, "character": 12 },
|
||||
"end": { "line": 8, "character": 24 },
|
||||
},
|
||||
},
|
||||
"message": "The declaration was marked as deprecated here.",
|
||||
},
|
||||
],
|
||||
"tags": [2],
|
||||
},
|
||||
{
|
||||
"range": {
|
||||
"start": { "line": 13, "character": 14 },
|
||||
"end": { "line": 13, "character": 29 },
|
||||
},
|
||||
"severity": 4,
|
||||
"code": 6133,
|
||||
"source": "deno-ts",
|
||||
"message": "'unsusedVariable' is declared but its value is never read.",
|
||||
"tags": [1],
|
||||
},
|
||||
]),
|
||||
);
|
||||
client.shutdown();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lsp_workspace_disable_enable_paths() {
|
||||
fn run_test(use_trailing_slash: bool) {
|
||||
|
|
|
@ -3,8 +3,10 @@ Check [WILDCARD]main.ts
|
|||
Compile [WILDCARD]main.ts to out[WILDCARD]
|
||||
Warning Environment variables from the file "environment.env" were embedded in the generated executable file
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
out[WILDLINE]
|
||||
└── main.ts
|
||||
└── main.ts ([WILDLINE])
|
||||
|
||||
Size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -1,47 +1,49 @@
|
|||
[WILDCARD]
|
||||
Compile file:///[WILDLINE]/main.ts to [WILDLINE]
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
main[WILDLINE]
|
||||
├─┬ .deno_compile_node_modules
|
||||
│ └─┬ localhost
|
||||
│ ├─┬ ansi-regex
|
||||
│ │ ├── 3.0.1/*
|
||||
│ │ └── 5.0.1/*
|
||||
│ ├── ansi-styles/4.3.0/*
|
||||
│ ├── camelcase/5.3.1/*
|
||||
│ ├── cliui/6.0.0/*
|
||||
│ ├── color-convert/2.0.1/*
|
||||
│ ├── color-name/1.1.4/*
|
||||
│ ├── cowsay/1.5.0/*
|
||||
│ ├── decamelize/1.2.0/*
|
||||
│ ├── emoji-regex/8.0.0/*
|
||||
│ ├── find-up/4.1.0/*
|
||||
│ ├── get-caller-file/2.0.5/*
|
||||
│ ├── get-stdin/8.0.0/*
|
||||
│ ├─┬ is-fullwidth-code-point
|
||||
│ │ ├── 2.0.0/*
|
||||
│ │ └── 3.0.0/*
|
||||
│ ├── locate-path/5.0.0/*
|
||||
│ ├── p-limit/2.3.0/*
|
||||
│ ├── p-locate/4.1.0/*
|
||||
│ ├── p-try/2.2.0/*
|
||||
│ ├── path-exists/4.0.0/*
|
||||
│ ├── require-directory/2.1.1/*
|
||||
│ ├── require-main-filename/2.0.0/*
|
||||
│ ├── set-blocking/2.0.0/*
|
||||
│ ├─┬ string-width
|
||||
│ │ ├── 2.1.1/*
|
||||
│ │ └── 4.2.3/*
|
||||
│ ├─┬ strip-ansi
|
||||
│ │ ├── 4.0.0/*
|
||||
│ │ └── 6.0.1/*
|
||||
│ ├── strip-final-newline/2.0.0/*
|
||||
│ ├── which-module/2.0.0/*
|
||||
│ ├── wrap-ansi/6.2.0/*
|
||||
│ ├── y18n/4.0.3/*
|
||||
│ ├── yargs/15.4.1/*
|
||||
│ └── yargs-parser/18.1.3/*
|
||||
└── main.ts
|
||||
├─┬ .deno_compile_node_modules ([WILDLINE])
|
||||
│ └─┬ localhost ([WILDLINE])
|
||||
│ ├─┬ ansi-regex ([WILDLINE])
|
||||
│ │ ├── 3.0.1/* ([WILDLINE])
|
||||
│ │ └── 5.0.1/* ([WILDLINE])
|
||||
│ ├── ansi-styles/4.3.0/* ([WILDLINE])
|
||||
│ ├── camelcase/5.3.1/* ([WILDLINE])
|
||||
│ ├── cliui/6.0.0/* ([WILDLINE])
|
||||
│ ├── color-convert/2.0.1/* ([WILDLINE])
|
||||
│ ├── color-name/1.1.4/* ([WILDLINE])
|
||||
│ ├── cowsay/1.5.0/* ([WILDLINE])
|
||||
│ ├── decamelize/1.2.0/* ([WILDLINE])
|
||||
│ ├── emoji-regex/8.0.0/* ([WILDLINE])
|
||||
│ ├── find-up/4.1.0/* ([WILDLINE])
|
||||
│ ├── get-caller-file/2.0.5/* ([WILDLINE])
|
||||
│ ├── get-stdin/8.0.0/* ([WILDLINE])
|
||||
│ ├─┬ is-fullwidth-code-point ([WILDLINE])
|
||||
│ │ ├── 2.0.0/* ([WILDLINE])
|
||||
│ │ └── 3.0.0/* ([WILDLINE])
|
||||
│ ├── locate-path/5.0.0/* ([WILDLINE])
|
||||
│ ├── p-limit/2.3.0/* ([WILDLINE])
|
||||
│ ├── p-locate/4.1.0/* ([WILDLINE])
|
||||
│ ├── p-try/2.2.0/* ([WILDLINE])
|
||||
│ ├── path-exists/4.0.0/* ([WILDLINE])
|
||||
│ ├── require-directory/2.1.1/* ([WILDLINE])
|
||||
│ ├── require-main-filename/2.0.0/* ([WILDLINE])
|
||||
│ ├── set-blocking/2.0.0/* ([WILDLINE])
|
||||
│ ├─┬ string-width ([WILDLINE])
|
||||
│ │ ├── 2.1.1/* ([WILDLINE])
|
||||
│ │ └── 4.2.3/* ([WILDLINE])
|
||||
│ ├─┬ strip-ansi ([WILDLINE])
|
||||
│ │ ├── 4.0.0/* ([WILDLINE])
|
||||
│ │ └── 6.0.1/* ([WILDLINE])
|
||||
│ ├── strip-final-newline/2.0.0/* ([WILDLINE])
|
||||
│ ├── which-module/2.0.0/* ([WILDLINE])
|
||||
│ ├── wrap-ansi/6.2.0/* ([WILDLINE])
|
||||
│ ├── y18n/4.0.3/* ([WILDLINE])
|
||||
│ ├── yargs/15.4.1/* ([WILDLINE])
|
||||
│ └── yargs-parser/18.1.3/* ([WILDLINE])
|
||||
└── main.ts ([WILDLINE])
|
||||
|
||||
Size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
Compile [WILDLINE]
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
main[WILDLINE]
|
||||
├── index.js
|
||||
├── index.js ([WILDLINE])
|
||||
├── link.js --> index.js
|
||||
└── setup.js
|
||||
└── setup.js ([WILDLINE])
|
||||
|
||||
Size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
[WILDCARD]
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
main[WILDLINE]
|
||||
├── main.ts
|
||||
└── node_modules/*
|
||||
├── main.ts ([WILDLINE])
|
||||
└── node_modules/* ([WILDLINE])
|
||||
|
||||
Size: [WILDLINE]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Check file:///[WILDLINE]/main.js
|
||||
Compile file:///[WILDLINE]
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
[WILDCARD]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Compile file:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDCARD]
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
[WILDCARD]
|
||||
|
|
|
@ -4,12 +4,14 @@ Initialize @denotest/esm-basic@1.0.0
|
|||
Check file:///[WILDCARD]/node_modules_symlink_outside/main.ts
|
||||
Compile file:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDLINE]
|
||||
|
||||
Embedded File System
|
||||
Embedded Files
|
||||
|
||||
bin[WILDLINE]
|
||||
├─┬ compile
|
||||
│ └─┬ node_modules_symlink_outside
|
||||
│ ├── main.ts
|
||||
│ └── node_modules/*
|
||||
└── some_folder/*
|
||||
├─┬ compile ([WILDLINE])
|
||||
│ └─┬ node_modules_symlink_outside ([WILDLINE])
|
||||
│ ├── main.ts ([WILDLINE])
|
||||
│ └── node_modules/* ([WILDLINE])
|
||||
└── some_folder/* ([WILDLINE])
|
||||
|
||||
Size: [WILDLINE]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue