From 0cc9bcdf51464777ccc1a0cf1fab9883cca6dc7e Mon Sep 17 00:00:00 2001 From: Devon Burriss Date: Tue, 29 Mar 2022 15:22:16 +0200 Subject: [PATCH] Interface SpaceKind (#810) * Adds Interface SpaceKind * Enables Java interface function space * Enables TS & TSX interface function space --- src/checker.rs | 9 ++++++++- src/getter.rs | 5 ++++- src/spaces.rs | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/checker.rs b/src/checker.rs index 475049866..ba99cbb04 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -209,7 +209,12 @@ impl Checker for JavaCode { mk_checker!(is_call, MethodInvocation); mk_checker!(is_func, MethodDeclaration); mk_checker!(is_closure,); - mk_checker!(is_func_space, Program, ClassDeclaration); + mk_checker!( + is_func_space, + Program, + ClassDeclaration, + InterfaceDeclaration + ); mk_checker!(is_non_arg,); } @@ -283,6 +288,7 @@ impl Checker for TypescriptCode { MethodDefinition, GeneratorFunctionDeclaration, ClassDeclaration, + InterfaceDeclaration, ArrowFunction ); @@ -320,6 +326,7 @@ impl Checker for TsxCode { GeneratorFunction, GeneratorFunctionDeclaration, ClassDeclaration, + InterfaceDeclaration, ArrowFunction ); diff --git a/src/getter.rs b/src/getter.rs index ec7f95828..704326dc3 100644 --- a/src/getter.rs +++ b/src/getter.rs @@ -251,6 +251,7 @@ impl Getter for TypescriptCode { | GeneratorFunctionDeclaration | ArrowFunction => SpaceKind::Function, Class | ClassDeclaration => SpaceKind::Class, + InterfaceDeclaration => SpaceKind::Interface, Program => SpaceKind::Unit, _ => SpaceKind::Unknown, } @@ -321,6 +322,7 @@ impl Getter for TsxCode { | GeneratorFunctionDeclaration | ArrowFunction => SpaceKind::Function, Class | ClassDeclaration => SpaceKind::Class, + InterfaceDeclaration => SpaceKind::Interface, Program => SpaceKind::Unit, _ => SpaceKind::Unknown, } @@ -515,8 +517,9 @@ impl Getter for JavaCode { let typ = node.object().kind_id(); match typ.into() { - InterfaceDeclaration | ClassDeclaration => SpaceKind::Class, + ClassDeclaration => SpaceKind::Class, MethodDeclaration | LambdaExpression => SpaceKind::Function, + InterfaceDeclaration => SpaceKind::Interface, Program => SpaceKind::Unit, _ => SpaceKind::Unknown, } diff --git a/src/spaces.rs b/src/spaces.rs index 73d943243..04d9ac263 100644 --- a/src/spaces.rs +++ b/src/spaces.rs @@ -38,6 +38,8 @@ pub enum SpaceKind { Unit, /// A `C/C++` namespace Namespace, + /// An interface + Interface, } impl fmt::Display for SpaceKind { @@ -51,6 +53,7 @@ impl fmt::Display for SpaceKind { SpaceKind::Impl => "impl", SpaceKind::Unit => "unit", SpaceKind::Namespace => "namespace", + SpaceKind::Interface => "interface", }; write!(f, "{}", s) }