Skip to content

refactor(filter): restore scripts from decompiled to source version#201

Open
zndxcvbn wants to merge 3 commits into
mainfrom
refactor-filter-as
Open

refactor(filter): restore scripts from decompiled to source version#201
zndxcvbn wants to merge 3 commits into
mainfrom
refactor-filter-as

Conversation

@zndxcvbn

@zndxcvbn zndxcvbn commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor

    • Improved internal code quality and type safety across filter components to enhance maintainability and reduce potential errors.
    • Modernized filter architecture patterns, including matching and sorting logic, while preserving all existing functionality.
  • Chores

    • Added interface definitions to improve code organization.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2bf84055-d3ea-46c3-bcce-c40c342231b4

📥 Commits

Reviewing files that changed from the base of the PR and between bf1f270 and 1260639.

📒 Files selected for processing (2)
  • source/actionscript/Common/skyui/filter/IFilter.as
  • source/actionscript/Common/skyui/filter/ItemTypeFilter.as
✅ Files skipped from review due to trivial changes (1)
  • source/actionscript/Common/skyui/filter/IFilter.as
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/actionscript/Common/skyui/filter/ItemTypeFilter.as

📝 Walkthrough

Walkthrough

Three filter classes in the skyui.filter package are refactored to use ActionScript type annotations and explicit class structure. A new IFilter interface is introduced, and ItemTypeFilter and SortFilter are converted from untyped code to typed implementations with private fields, typed method signatures, and public event-dispatcher API declarations while preserving behavioral equivalence.

Changes

Filter Type Safety and Class Structure

Layer / File(s) Summary
Filter interface contract
source/actionscript/Common/skyui/filter/IFilter.as
New IFilter interface defines the contract for filter implementations with documentation for an applyFilter method signature.
ItemTypeFilter type annotations and class structure
source/actionscript/Common/skyui/filter/ItemTypeFilter.as
ItemTypeFilter converted to typed form with explicit _matcherFunc and _itemFilter private fields, typed constructor, typed getter, and explicit public var declarations for event-dispatcher API.
ItemTypeFilter public method signatures
source/actionscript/Common/skyui/filter/ItemTypeFilter.as
changeFilterFlag and setPartitionedFilterMode updated with typed parameters; matcher selection uses ternary operator.
ItemTypeFilter filtering and matching logic
source/actionscript/Common/skyui/filter/ItemTypeFilter.as
applyFilter refactored to use for loop with post-splice index decrement; isMatch forwards to matcher; static matchers entryMatchesFilter and entryMatchesPartitionedFilter are typed with explicit byte extraction for partitioned matching.
SortFilter type annotations and refactor
source/actionscript/Common/skyui/filter/SortFilter.as
SortFilter converted to typed AS3 class with private _sortAttributes and _sortOptions, typed constructor, typed setSortBy with early-return and dispatch logic, and refactored applyFilter that computes _sortFlag per item via loop, temporarily injects enabled and _sortFlag for sortOn, then removes them to restore state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main objective: refactoring filter scripts by restoring them from decompiled to source form. It accurately reflects the core changes across ItemTypeFilter, SortFilter, and the new IFilter interface.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@source/actionscript/Common/skyui/filter/IFiIlter.as`:
- Line 1: The filename contains a typo: rename the file currently named
IFiIlter.as to exactly IFilter.as so it matches the declared interface
skyui.filter.IFilter; ensure the filesystem and any references/imports use the
new filename (IFilter.as) so the ActionScript compiler can resolve the
interface.
- Around line 3-5: Uncomment and restore the interface method signature in
IFiIlter by adding the applyFilter declaration (public function
applyFilter(filteredItems:Array):Void;) so implementations like ItemTypeFilter
implement the contract; ensure the parameter name matches the implementation
(filteredItems) and include the :Void return type to match ItemTypeFilter.as.

In `@source/actionscript/Common/skyui/filter/ItemTypeFilter.as`:
- Line 76: Change the a_flag parameter type from Boolean to Number for both
entryMatchesFilter and entryMatchesPartitionedFilter (they are declared as
a_flag: Boolean now) because the code performs numeric/bitwise operations
((a_entry.filterFlag & a_flag), comparisons like a_flag == 0xFFFFFFFF, byte0 ==
a_flag) and call sites pass _itemFilter (Number); update the signatures to
a_flag: Number and add explicit :Boolean return type annotations to the
functions to reflect they return a boolean result.
- Line 12: The getter function get itemFilter is missing an explicit return
type; update the getter declaration (function get itemFilter) to include the
return type annotation ": Number" so the signature reads get itemFilter():
Number and ensure any returned value matches Number to satisfy the typed
refactor.
- Line 68: The isMatch function's a_flag parameter is untyped; update the
signature of isMatch to declare a_flag: Number and add a Boolean return type
(e.g., isMatch(a_entry: Object, a_flag: Number): Boolean) so it matches the
typed refactor and the matcher functions it delegates to.

In `@source/actionscript/Common/skyui/filter/SortFilter.as`:
- Around line 29-35: The sort config can be null/unset causing runtime errors;
add defensive guards in setSortBy and applyFilter to handle null/undefined/empty
values: in setSortBy (function setSortBy) ensure that when a_sortAttributes or
a_sortOptions is null/undefined you assign safe defaults (e.g., empty arrays)
and only update this._sortAttributes/this._sortOptions with validated arrays; in
applyFilter (method applyFilter) early-return or skip sorting when
this._sortAttributes or this._sortOptions are null/empty and ensure any code
that iterates or indexes into these members checks length before use so sorting
is only attempted with valid arrays.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e345ee9f-a23d-4b42-8f20-afe77503eb28

📥 Commits

Reviewing files that changed from the base of the PR and between 25920a0 and bf1f270.

📒 Files selected for processing (3)
  • source/actionscript/Common/skyui/filter/IFiIlter.as
  • source/actionscript/Common/skyui/filter/ItemTypeFilter.as
  • source/actionscript/Common/skyui/filter/SortFilter.as

Comment thread source/actionscript/Common/skyui/filter/IFilter.as
Comment thread source/actionscript/Common/skyui/filter/IFilter.as
Comment thread source/actionscript/Common/skyui/filter/ItemTypeFilter.as
Comment thread source/actionscript/Common/skyui/filter/ItemTypeFilter.as Outdated
Comment thread source/actionscript/Common/skyui/filter/ItemTypeFilter.as
Comment on lines +29 to +35
public function setSortBy(a_sortAttributes: Array, a_sortOptions: Array)
{
if (this._sortAttributes == a_sortAttributes && this._sortOptions == a_sortOptions)
return;

this._sortAttributes = a_sortAttributes;
this._sortOptions = a_sortOptions;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add defensive guards for unset/null sort config before sorting.

applyFilter assumes _sortAttributes/_sortOptions are initialized and non-empty. If setSortBy is skipped or receives null, this will throw at runtime.

Suggested fix
 public function setSortBy(a_sortAttributes: Array, a_sortOptions: Array)
 {
+    if (a_sortAttributes == null || a_sortOptions == null || a_sortAttributes.length == 0)
+        return;
+
     if (this._sortAttributes == a_sortAttributes && this._sortOptions == a_sortOptions)
         return;
         
     this._sortAttributes = a_sortAttributes;
     this._sortOptions = a_sortOptions;
@@
 public function applyFilter(a_filteredList: Array)
 {
+    if (a_filteredList == null || this._sortAttributes == null || this._sortOptions == null || this._sortAttributes.length == 0)
+        return;
+
     var primaryAttribute = this._sortAttributes[0];

Also applies to: 41-57

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@source/actionscript/Common/skyui/filter/SortFilter.as` around lines 29 - 35,
The sort config can be null/unset causing runtime errors; add defensive guards
in setSortBy and applyFilter to handle null/undefined/empty values: in setSortBy
(function setSortBy) ensure that when a_sortAttributes or a_sortOptions is
null/undefined you assign safe defaults (e.g., empty arrays) and only update
this._sortAttributes/this._sortOptions with validated arrays; in applyFilter
(method applyFilter) early-return or skip sorting when this._sortAttributes or
this._sortOptions are null/empty and ensure any code that iterates or indexes
into these members checks length before use so sorting is only attempted with
valid arrays.

@zndxcvbn zndxcvbn changed the title refactor(filter): restore actionscripts from decompiled to source version refactor(filter): restore scripts from decompiled to source version May 18, 2026
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.

1 participant