Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface SpaceKind #810

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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