Skip to content

Commit 0cc9bcd

Browse files
authored
Interface SpaceKind (#810)
* Adds Interface SpaceKind * Enables Java interface function space * Enables TS & TSX interface function space
1 parent bcb3ca8 commit 0cc9bcd

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎src/checker.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ impl Checker for JavaCode {
209209
mk_checker!(is_call, MethodInvocation);
210210
mk_checker!(is_func, MethodDeclaration);
211211
mk_checker!(is_closure,);
212-
mk_checker!(is_func_space, Program, ClassDeclaration);
212+
mk_checker!(
213+
is_func_space,
214+
Program,
215+
ClassDeclaration,
216+
InterfaceDeclaration
217+
);
213218
mk_checker!(is_non_arg,);
214219
}
215220

@@ -283,6 +288,7 @@ impl Checker for TypescriptCode {
283288
MethodDefinition,
284289
GeneratorFunctionDeclaration,
285290
ClassDeclaration,
291+
InterfaceDeclaration,
286292
ArrowFunction
287293
);
288294

@@ -320,6 +326,7 @@ impl Checker for TsxCode {
320326
GeneratorFunction,
321327
GeneratorFunctionDeclaration,
322328
ClassDeclaration,
329+
InterfaceDeclaration,
323330
ArrowFunction
324331
);
325332

‎src/getter.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ impl Getter for TypescriptCode {
251251
| GeneratorFunctionDeclaration
252252
| ArrowFunction => SpaceKind::Function,
253253
Class | ClassDeclaration => SpaceKind::Class,
254+
InterfaceDeclaration => SpaceKind::Interface,
254255
Program => SpaceKind::Unit,
255256
_ => SpaceKind::Unknown,
256257
}
@@ -321,6 +322,7 @@ impl Getter for TsxCode {
321322
| GeneratorFunctionDeclaration
322323
| ArrowFunction => SpaceKind::Function,
323324
Class | ClassDeclaration => SpaceKind::Class,
325+
InterfaceDeclaration => SpaceKind::Interface,
324326
Program => SpaceKind::Unit,
325327
_ => SpaceKind::Unknown,
326328
}
@@ -515,8 +517,9 @@ impl Getter for JavaCode {
515517

516518
let typ = node.object().kind_id();
517519
match typ.into() {
518-
InterfaceDeclaration | ClassDeclaration => SpaceKind::Class,
520+
ClassDeclaration => SpaceKind::Class,
519521
MethodDeclaration | LambdaExpression => SpaceKind::Function,
522+
InterfaceDeclaration => SpaceKind::Interface,
520523
Program => SpaceKind::Unit,
521524
_ => SpaceKind::Unknown,
522525
}

‎src/spaces.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub enum SpaceKind {
3838
Unit,
3939
/// A `C/C++` namespace
4040
Namespace,
41+
/// An interface
42+
Interface,
4143
}
4244

4345
impl fmt::Display for SpaceKind {
@@ -51,6 +53,7 @@ impl fmt::Display for SpaceKind {
5153
SpaceKind::Impl => "impl",
5254
SpaceKind::Unit => "unit",
5355
SpaceKind::Namespace => "namespace",
56+
SpaceKind::Interface => "interface",
5457
};
5558
write!(f, "{}", s)
5659
}

0 commit comments

Comments
 (0)