clippy lints

This commit is contained in:
Blaž Hrastnik 2021-03-01 17:37:31 +09:00
parent 2088c45075
commit a16c6e2585
4 changed files with 35 additions and 39 deletions

View File

@ -274,13 +274,13 @@ fn is_word(ch: char) -> bool {
#[derive(Debug, Eq, PartialEq)]
enum Category {
Whitespace,
EOL,
Eol,
Word,
Punctuation,
}
fn categorize(ch: char) -> Category {
if ch == '\n' {
Category::EOL
Category::Eol
} else if ch.is_ascii_whitespace() {
Category::Whitespace
} else if ch.is_ascii_punctuation() {

View File

@ -1,5 +1,5 @@
use crate::{Change, Rope, RopeSlice, Transaction};
pub use helix_syntax::LANG;
pub use helix_syntax::Lang;
pub use helix_syntax::{get_language, get_language_name};
use std::collections::HashMap;
@ -21,7 +21,7 @@ pub struct LanguageConfiguration {
//
// root_path
//
pub(crate) language_id: LANG,
pub(crate) language_id: Lang,
pub(crate) highlight_config: OnceCell<Option<Arc<HighlightConfiguration>>>,
// tags_config OnceCell<> https://github.com/tree-sitter/tree-sitter/pull/583
}
@ -87,7 +87,7 @@ impl Loader {
LanguageConfiguration {
scope: "source.rust".to_string(),
file_types: vec!["rs".to_string()],
language_id: LANG::Rust,
language_id: Lang::Rust,
highlight_config: OnceCell::new(),
//
path: "../helix-syntax/languages/tree-sitter-rust".into(),
@ -95,7 +95,7 @@ impl Loader {
LanguageConfiguration {
scope: "source.toml".to_string(),
file_types: vec!["toml".to_string()],
language_id: LANG::Toml,
language_id: Lang::Toml,
highlight_config: OnceCell::new(),
//
path: "../helix-syntax/languages/tree-sitter-toml".into(),
@ -160,7 +160,7 @@ pub struct Syntax {
impl Syntax {
// buffer, grammar, config, grammars, sync_timeout?
pub fn new(
/*language: LANG,*/ source: &Rope,
/*language: Lang,*/ source: &Rope,
config: Arc<HighlightConfiguration>,
) -> Self {
// fetch grammar for parser based on language string
@ -779,10 +779,10 @@ impl HighlightConfiguration {
non_local_variable_patterns,
injection_content_capture_index,
injection_language_capture_index,
local_scope_capture_index,
local_def_capture_index,
local_def_value_capture_index,
local_ref_capture_index,
local_scope_capture_index,
})
}
@ -1475,7 +1475,7 @@ fn test_parser() {
.map(String::from)
.collect();
let language = get_language(LANG::Rust);
let language = get_language(Lang::Rust);
let mut config = HighlightConfiguration::new(
language,
&std::fs::read_to_string(

View File

@ -13,13 +13,11 @@ fn get_debug() -> bool {
fn collect_tree_sitter_dirs(ignore: Vec<String>) -> Vec<String> {
let mut dirs = Vec::new();
for entry in fs::read_dir("languages").unwrap() {
if let Ok(entry) = entry {
let path = entry.path();
let dir = path.file_name().unwrap().to_str().unwrap().to_string();
if !ignore.contains(&dir) {
dirs.push(dir);
}
for entry in fs::read_dir("languages").unwrap().flatten() {
let path = entry.path();
let dir = path.file_name().unwrap().to_str().unwrap().to_string();
if !ignore.contains(&dir) {
dirs.push(dir);
}
}
dirs
@ -31,24 +29,22 @@ fn collect_src_files(dir: &str) -> (Vec<String>, Vec<String>) {
let mut c_files = Vec::new();
let mut cpp_files = Vec::new();
let path = PathBuf::from("languages").join(&dir).join("src");
for entry in fs::read_dir(path).unwrap() {
if let Ok(entry) = entry {
let path = entry.path();
if path
.file_stem()
.unwrap()
.to_str()
.unwrap()
.starts_with("binding")
{
continue;
}
if let Some(ext) = path.extension() {
if ext == "c" {
c_files.push(path.to_str().unwrap().to_string());
} else if ext == "cc" || ext == "cpp" || ext == "cxx" {
cpp_files.push(path.to_str().unwrap().to_string());
}
for entry in fs::read_dir(path).unwrap().flatten() {
let path = entry.path();
if path
.file_stem()
.unwrap()
.to_str()
.unwrap()
.starts_with("binding")
{
continue;
}
if let Some(ext) = path.extension() {
if ext == "c" {
c_files.push(path.to_str().unwrap().to_string());
} else if ext == "cc" || ext == "cpp" || ext == "cxx" {
cpp_files.push(path.to_str().unwrap().to_string());
}
}
}

View File

@ -13,7 +13,7 @@ macro_rules! mk_extern {
macro_rules! mk_enum {
( $( $camel:ident ),* ) => {
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LANG {
pub enum Lang {
$(
$camel,
)*
@ -25,11 +25,11 @@ macro_rules! mk_enum {
macro_rules! mk_get_language {
( $( ($camel:ident, $name:ident) ),* ) => {
#[must_use]
pub fn get_language(lang: LANG) -> Language {
pub fn get_language(lang: Lang) -> Language {
unsafe {
match lang {
$(
LANG::$camel => $name(),
Lang::$camel => $name(),
)*
}
}
@ -41,10 +41,10 @@ macro_rules! mk_get_language {
macro_rules! mk_get_language_name {
( $( $camel:ident ),* ) => {
#[must_use]
pub const fn get_language_name(lang: LANG) -> &'static str {
pub const fn get_language_name(lang: Lang) -> &'static str {
match lang {
$(
LANG::$camel => stringify!($camel),
Lang::$camel => stringify!($camel),
)*
}
}