-
Notifications
You must be signed in to change notification settings - Fork 60
feat(kotlin): Implement complete metrics support for Kotlin language #1215
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
base: master
Are you sure you want to change the base?
Changes from all commits
8eefb34
f621fbf
9fe08e7
fb5924b
a1fd008
e84af86
9e25ead
d295339
30bb1c2
14fe85a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| src | ||
| root |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 1768922402:/home/marlonsc/mozilla-rust-code-analisis/src/metrics/abc.rs:src | ||
| 1768924638:/home/marlonsc/mozilla-rust-code-analisis/Cargo.toml:root | ||
| 1768925046:/home/marlonsc/mozilla-rust-code-analisis/src/node.rs:src | ||
| 1768925048:/home/marlonsc/mozilla-rust-code-analisis/src/langs.rs:src | ||
| 1768925051:/home/marlonsc/mozilla-rust-code-analisis/src/tools.rs:src | ||
| 1768925211:/home/marlonsc/mozilla-rust-code-analisis/src/macros.rs:src |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -576,4 +576,52 @@ impl Getter for JavaCode { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| impl Getter for KotlinCode {} | ||||||||
| impl Getter for KotlinCode { | ||||||||
| fn get_space_kind(node: &Node) -> SpaceKind { | ||||||||
| use Kotlin::*; | ||||||||
|
|
||||||||
| let typ = node.kind_id().into(); | ||||||||
| match typ { | ||||||||
| ClassDeclaration => SpaceKind::Class, | ||||||||
| FunctionDeclaration | Constructor | AnnotatedLambda => SpaceKind::Function, | ||||||||
| SourceFile => SpaceKind::Unit, | ||||||||
| _ => SpaceKind::Unknown, | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| fn get_op_type(node: &Node) -> HalsteadType { | ||||||||
| use Kotlin::*; | ||||||||
|
|
||||||||
| let typ = node.kind_id(); | ||||||||
|
|
||||||||
| match typ.into() { | ||||||||
| // Operator: function calls | ||||||||
| CallExpression | ||||||||
| // Operator: control flow | ||||||||
| | If | Else | When | Try | Catch | Throw | For | While | Continue | Break | Do | Finally | ||||||||
| // Operator: keywords | ||||||||
| | Return | Abstract | Final | Super | This | ||||||||
| // Operator: brackets and comma and terminators (separators) | ||||||||
| | SEMI | COMMA | COLONCOLON | LBRACE | LBRACK | LPAREN | RBRACE | RBRACK | RPAREN | DOTDOT | DOT | ||||||||
| // Operator: operators | ||||||||
| | EQ | LT | GT | BANG | QMARKCOLON | AsQMARK | COLON // no grammar for lambda operator -> | ||||||||
| | EQEQ | LTEQ | GTEQ | BANGEQ | AMPAMP | PIPEPIPE | PLUSPLUS | DASHDASH | ||||||||
| | PLUS | DASH | STAR | SLASH | PERCENT | ||||||||
| | PLUSEQ | DASHEQ | STAREQ | SLASHEQ | PERCENTEQ => { | ||||||||
| HalsteadType::Operator | ||||||||
| } | ||||||||
| // Operands: variables, constants, literals | ||||||||
| // StringLiteral covers both line strings and multi-line strings in this grammar | ||||||||
| RealLiteral | IntegerLiteral | HexLiteral | BinLiteral | CharacterLiteralToken1 | UniCharacterLiteralToken1 | ||||||||
| | LiteralConstant | StringLiteral | StringContent | LambdaLiteral | FunctionLiteral | ||||||||
| | ObjectLiteral | UnsignedLiteral | LongLiteral | BooleanLiteral | CharacterLiteral => { | ||||||||
|
||||||||
| | ObjectLiteral | UnsignedLiteral | LongLiteral | BooleanLiteral | CharacterLiteral => { | |
| | ObjectLiteral | UnsignedLiteral | LongLiteral | BooleanLiteral | CharacterLiteral | |
| | Identifier | SimpleIdentifier => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
is_non_argimplementation includesPIPEPIPE(||) as a non-argument token, but this doesn't match the typical pattern from other language implementations which focus on delimiters and structural elements. The inclusion ofUnaryExpressionalso seems unusual - other implementations typically only include punctuation tokens. This may cause issues with parameter counting in functions that use these operators.