Skip to content

Commit

Permalink
Interface SpaceKind (#810)
Browse files Browse the repository at this point in the history
* Adds Interface SpaceKind

* Enables Java interface function space

* Enables TS & TSX interface function space
  • Loading branch information
dburriss authored Mar 29, 2022
1 parent bcb3ca8 commit 0cc9bcd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,);
}

Expand Down Expand Up @@ -283,6 +288,7 @@ impl Checker for TypescriptCode {
MethodDefinition,
GeneratorFunctionDeclaration,
ClassDeclaration,
InterfaceDeclaration,
ArrowFunction
);

Expand Down Expand Up @@ -320,6 +326,7 @@ impl Checker for TsxCode {
GeneratorFunction,
GeneratorFunctionDeclaration,
ClassDeclaration,
InterfaceDeclaration,
ArrowFunction
);

Expand Down
5 changes: 4 additions & 1 deletion src/getter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl Getter for TypescriptCode {
| GeneratorFunctionDeclaration
| ArrowFunction => SpaceKind::Function,
Class | ClassDeclaration => SpaceKind::Class,
InterfaceDeclaration => SpaceKind::Interface,
Program => SpaceKind::Unit,
_ => SpaceKind::Unknown,
}
Expand Down Expand Up @@ -321,6 +322,7 @@ impl Getter for TsxCode {
| GeneratorFunctionDeclaration
| ArrowFunction => SpaceKind::Function,
Class | ClassDeclaration => SpaceKind::Class,
InterfaceDeclaration => SpaceKind::Interface,
Program => SpaceKind::Unit,
_ => SpaceKind::Unknown,
}
Expand Down Expand Up @@ -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,
}
Expand Down
3 changes: 3 additions & 0 deletions src/spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub enum SpaceKind {
Unit,
/// A `C/C++` namespace
Namespace,
/// An interface
Interface,
}

impl fmt::Display for SpaceKind {
Expand All @@ -51,6 +53,7 @@ impl fmt::Display for SpaceKind {
SpaceKind::Impl => "impl",
SpaceKind::Unit => "unit",
SpaceKind::Namespace => "namespace",
SpaceKind::Interface => "interface",
};
write!(f, "{}", s)
}
Expand Down

0 comments on commit 0cc9bcd

Please sign in to comment.