Skip to content

Transfer comments when removing statements - #297

Merged
jeparlefrancais merged 4 commits into
mainfrom
transfer-statement-tokens
Aug 11, 2025
Merged

jeparlefrancais merged 4 commits into
mainfrom
transfer-statement-tokens

Conversation

@jeparlefrancais

@jeparlefrancais jeparlefrancais commented Aug 11, 2025 •

Copy link
Copy Markdown
Contributor

Closes #260

This PR changes how darklua handle tokens when filtering statements. Now, it will move the existing comments before and after a removed statement to the next statement.

This will mostly have an effect on the remove_types rule, which will stop removing comments around type declarations.

  • add entry to the changelog

@github-actions

Copy link
Copy Markdown

Coverage after merging transfer-statement-tokens into main will be

87.13%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src/generator
   mod.rs98.66%100%100%98.54%389, 405, 409
src/nodes
   arguments.rs89.32%100%93.62%88.55%100–106, 108–110, 143–144, 192–193, 211–213, 216, 245–249, 251, 335–337, 343, 99
   block.rs95.18%100%97.22%94.89%337–342, 361–362, 378, 384, 394–398, 400–402, 404–405, 409–414
   function_call.rs90.91%100%90.91%90.91%131–133, 155–157, 173–175
   identifier.rs94.67%100%92.31%95.16%86–88
   token.rs93.09%100%94.59%92.82%110, 185, 255–257, 26–31, 319, 83, 95
   variable.rs68.57%100%83.33%65.52%26–27, 31–32, 38–42, 44
src/nodes/expressions
   binary.rs93.29%100%96.55%92.98%108, 315, 324–326, 74–76, 84–86, 88–90, 94–99
   field.rs81.82%100%77.78%82.86%65–67, 71–73
   function.rs76.85%100%77.50%76.69%117, 167–169, 239–241, 260–263, 267–270, 272–285, 287–288, 55–58
   if_expression.rs83.45%100%85.71%82.91%116–118, 146–155, 159–161, 32–35
   index.rs72.55%100%80%70.73%82–84, 88–96
   interpolated_string.rs75.10%100%80.43%73.89%18–23, 240–242, 25–30, 32, 34, 346–349, 35, 353–356, 358–359, 36, 360–365, 369–374, 39–40, 82–84, 93–95
   mod.rs82.55%100%97.37%79.70%107–117, 119–126, 133–137, 139–143, 145–149, 220–222, 346, 400
   number.rs91.34%100%92.86%91.02%236–238, 278–282, 284, 296–300, 302–303, 330–331, 379–380, 426, 429–434, 436, 489
   parenthese.rs58.18%100%63.64%56.82%70–72, 77–80, 84–87, 89–96
   prefix.rs59.42%100%72.73%56.90%108–110, 126–128, 36–38, 42–44, 48–49, 57–63, 65, 72, 74–75
   string.rs87.94%100%89.23%87.64%132–138, 160–162, 19–24, 254–256, 26–31, 33, 35–37, 40–41
   table.rs86.02%100%88.64%85.42%185–189, 332–334, 371–374, 378–381, 383–391, 54–56
   type_cast.rs92.86%100%91.67%93.18%81–83
   unary.rs90.91%100%88.89%91.43%81–83
src/nodes/statements
   assign.rs87.78%100%88.24%87.67%140–145, 71–73
   compound_assign.rs90.24%100%85.71%91.18%127–129, 150–152
   do_statement.rs92.16%100%90%92.68%62–64
   function.rs89.44%100%92.45%88.74%119–121, 205–207, 372–374, 398–401, 405–417
   generic_for.rs79.61%100%85%78.31%115–117, 154–157, 161–168, 67–69
   if_statement.rs81.08%100%82.86%80.67%157–159, 184–189, 191–193, 195–196, 212–214, 224–227, 35–41
   last_statement.rs73.98%100%85.71%71.57%106–108, 118–121, 123, 125, 129–132, 165, 171, 181–187, 189–193, 195, 197
   local_assign.rs96.01%100%95%96.17%208, 69–71, 91–94
   local_function.rs94.19%100%93.18%94.42%100, 117–121, 260–262, 98–99
   mod.rs91.86%100%100%90.14%88, 90–93, 97–98
   numeric_for.rs80.91%100%85%80%144–146, 161–164, 168–175, 78–80
   repeat_statement.rs79.66%100%83.33%78.72%100–101, 82–84, 89–92, 99
   type_declaration.rs86.61%100%96%85.43%140–142, 158–161, 163–166, 186–189, 191–194, 267–270, 272–275, 294, 307
   while_statement.rs93.44%100%91.67%93.88%77–79
src/nodes/types
   array.rs73.68%100%85.71%70.97%51–59
   expression_type.rs71.79%100%85.71%68.75%51–60
   function.rs86.02%100%89.74%85.03%101–106, 108, 208–216, 302–304, 60–62
   generics.rs86.01%100%85.88%86.03%139–141, 149–151, 159–161, 327–329, 35–37, 444, 466, 477, 491–493, 495, 542–544, 575–577, 581–583, 587–589, 59, 593–595, 60–64, 783–787, 790–791, 793–797, 799
   intersection.rs81.98%100%80%82.42%105–110, 130–135, 72–74
   mod.rs61.70%100%87.50%56.41%100–103, 105–113, 115, 128–131, 133, 83–91, 93–97, 99
   optional.rs82.50%100%87.50%81.25%59–64
   parenthese.rs69.57%100%77.78%67.57%59–61, 63–71
   string_type.rs80.72%100%78.95%81.25%61–63, 67–69, 85–87, 89–91
   table.rs80.92%100%85.42%79.91%109–111, 196–198, 224–225, 233–234, 257–258, 291–299, 349–351, 364–368, 378–380, 412–421
   type_field.rs90.24%100%88.89%90.63%61–63
   type_name.rs69.39%100%72.41%68.64%114–116, 132–134, 144–146, 160–169, 187–189, 205–207, 226–227, 38–39, 55–57, 77–79, 81, 83
   type_pack.rs75.53%100%80%74.32%100–102, 104–113, 132–134, 76–78
   union.rs81.13%100%78.95%81.61%100–104, 122–127, 60–62, 99
   variadic_type_pack.rs66.67%100%62.50%67.86%51–53, 57–59, 61–63
src/rules
   append_text_comment.rs82.29%100%88.89%81.53%102–105, 123–124, 167–172, 204–206, 32–38, 49, 51–54

@jeparlefrancais
jeparlefrancais merged commit def0526 into main Aug 11, 2025
@jeparlefrancais
jeparlefrancais deleted the transfer-statement-tokens branch August 11, 2025 17:29
@jeparlefrancais jeparlefrancais mentioned this pull request Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transfer comment tokens when filtering statements

1 participant