source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
-[[package]]
-name = "aho-corasick"
-version = "0.7.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
-dependencies = [
- "memchr",
-]
-
[[package]]
name = "ansi_term"
version = "0.12.1"
"ide_db",
"indexmap",
"itertools 0.10.0",
- "lazy_static",
"log",
"oorandom",
"profile",
"pulldown-cmark",
"pulldown-cmark-to-cmark",
- "regex",
"rustc-hash",
"ssr",
"stdx",
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
- "aho-corasick",
- "memchr",
"regex-syntax",
- "thread_local",
]
[[package]]
ssr = { path = "../ssr", version = "0.0.0" }
completion = { path = "../completion", version = "0.0.0" }
-lazy_static = "1.4.0"
-regex = "1.4.3"
-env_logger = { version = "0.8.1", default-features = false }
-
# ide should depend only on the top-level `hir` package. if you need
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
hir = { path = "../hir", version = "0.0.0" }
[dev-dependencies]
expect-test = "1.1"
+env_logger = { version = "0.8.1", default-features = false }
\ No newline at end of file
SyntaxNode, TextRange, TextSize,
};
-use lazy_static::lazy_static;
-
#[derive(Debug, PartialEq, Eq)]
pub enum FoldKind {
Comment,
// Fold groups of comments
if let Some(comment) = ast::Comment::cast(token) {
if !visited_comments.contains(&comment) {
- // regions are not really comments
- use regex::Regex;
- lazy_static! {
- static ref RE_START: Regex =
- Regex::new(r"^\s*//\s*#?region\b").unwrap();
- static ref RE_END: Regex =
- Regex::new(r"^\s*//\s*#?endregion\b").unwrap();
- }
- if RE_START.is_match(comment.text()) {
+ // regions are not real comments
+ if comment.text().trim().starts_with("// region:") {
regions_starts.push(comment.syntax().text_range().start());
- } else if RE_END.is_match(comment.text()) {
+ } else if comment.text().trim().starts_with("// endregion") {
if !regions_starts.is_empty() {
res.push(Fold {
range: TextRange::new(
}
if let Some(c) = ast::Comment::cast(token) {
if c.kind() == group_kind {
- // regions are not really comments
- use regex::Regex;
- lazy_static! {
- static ref RE_START: Regex =
- Regex::new(r"^\s*//\s*#?region\b").unwrap();
- static ref RE_END: Regex =
- Regex::new(r"^\s*//\s*#?endregion\b").unwrap();
- }
- if RE_START.is_match(c.text()) || RE_END.is_match(c.text()) {
+ // regions are not real comments
+ if c.text().trim().starts_with("// region:")
+ || c.text().trim().starts_with("// endregion")
+ {
break;
} else {
visited.insert(c.clone());