Skip to content

Commit

Permalink
Make some lua annotations
Browse files Browse the repository at this point in the history
Fix a few missing ones to eventually get more coverage
  • Loading branch information
InfusOnWoW committed Sep 24, 2023
1 parent 328d23f commit b76a6a1
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 16 deletions.
67 changes: 58 additions & 9 deletions WeakAuras/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetad
--- @class state
--- @field id auraId
--- @field cloneId string?
--- @field show boolean?
--- @field changed boolean?

--- @alias non_transmissable_field table<string, non_transmissable_field|boolean>

Expand All @@ -31,21 +33,31 @@ local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetad
--- @field AddToWatchedTriggerDelay fun(id: auraId, triggerNum: number)
--- @field anchor_frame_types table<anchorFrameTypes, string>
--- @field anchor_frame_types_group table<anchorFrameTypes, string>
--- @field anim_function_strings table<string, string>
--- @field anim_presets table<string, table>
--- @field AuraWarnings AuraWarnings
--- @field AuraEnvironmentWrappedSystem AuraEnvironmentWrappedSystem
--- @field callbacks callbacks
--- @field category_event_prototype table<string, table<string, string>>
--- @field CanHaveTooltip fun(data: auraData): boolean
--- @field CheckTalentsForLoad fun(event: string)
--- @field ContainsCustomPlaceHolder fun(input: string): boolean
--- @field ContainsAnyPlaceHolders fun(input: string): boolean
--- @field ContainsPlaceHolders fun(input: string, placeholders: string, checkDoublePercent?: boolean): boolean
--- @field CreateSubscribableObject fun(): SubscribableObject
--- @field clones table<auraId, table<string, table>>
--- @field customActionsFunctions table<auraId, table<string, function?>>
--- @field DebugLog debugLog
--- @field dynamic_texts table<string, table>
--- @field EndEvent fun(state: state): boolean?
--- @field EnsureRegion fun(id: auraId, cloneId: string?): Frame
--- @field ExecEnv table
--- @field event_prototypes table<string, prototypeData>
--- @field event_categories table<string, {name: string, default: string }>
--- @field FindUnusedId fun(prefix: string?): string
--- @field FixGroupChildrenOrderForGroup fun(data: auraData)
--- @field frames table<string, table>
--- @field function_strings table<string, string>
--- @field GetDataByUID fun(uid: uid): auraData
--- @field GetErrorHandlerId fun(id: auraId, context: string): function
--- @field GetErrorHandlerUid fun(uid: uid, context: string): function
Expand All @@ -54,20 +66,27 @@ local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetad
--- @field inverse_point_types table<string, string>
--- @field IsCLEUSubevent fun(subevent: string): boolean
--- @field IsDragonriding fun(): boolean
--- @field IsGroupType fun(data: auraData): boolean
--- @field item_slot_types string[]
--- @field LibSpecWrapper LibSpecWrapper
--- @field linked table<auraId, number>
--- @field loaded table<auraId, boolean>
--- @field LoadFunction fun(input: string): function
--- @field LoadOptions fun(msg: string?): boolean
--- @field maxTimerDuration number
--- @field multiUnitUnits multiUnitUnits
--- @field non_transmissable_fields table<string, non_transmissable_field>
--- @field non_transmissable_fields_v2000 table<string, non_transmissable_field>
--- @field orientation_types table<string, string>
--- @field orientation_with_circle_types table<string, string>
--- @field ParseNumber fun (numString: string|number): number?
--- @field point_types table<string, string>
--- @field PreShowModels fun()
--- @field PrintHelp fun()
--- @field QuotedString fun(input: string): string
--- @field regionOptions table<string, table>
--- @field regions table<auraId, table>
--- @field regionTypes table<string, table>
--- @field reset_ranged_swing_spells table<number, boolean>
--- @field reset_swing_spells table<number, boolean>
--- @field noreset_swing_spells table<number, boolean>
Expand All @@ -80,18 +99,24 @@ local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetad
--- @field StartProfileSystem fun(system: string)
--- @field StopProfileAura fun(id: auraId)
--- @field StopProfileSystem fun(system: string)
--- @field subRegionOptions table<string, table>
--- @field subRegionTypes table<string, table>
--- @field tick_placement_modes table<string, string>
--- @field tinySecondFormat fun(value: string|number): string?
--- @field TraverseAll fun(data: auraData): traverseFunction, auraData
--- @field TraverseAllChildren fun(data: auraData): traverseFunction, auraData
--- @field TraverseGroups fun(data: auraData): traverseFunction, auraData
--- @field TraverseLeafs fun(data: auraData): traverseFunction, auraData
--- @field TraverseLeafsOrAura fun(data: auraData): traverseFunction, auraData
--- @field TraverseParents fun(data: auraData): traverseFunction, auraData
--- @field TraverseSubGroups fun(data: auraData): traverseFunction, auraData
--- @field triggerTypes table<string, table>
--- @field triggerTypesOptions table<string, any>
--- @field UIDtoID fun(uid: uid): auraId
--- @field UnitEventList table<string, boolean>
--- @field UnitPlayerControlledFixed fun(unit: string): boolean
--- @field UpdatedTriggerState fun(id: auraId)
--- @field validate fun(input: table, default:table)
--- @field watched_trigger_events table<auraId, table<integer, table<integer, boolean>>>

--- @alias triggerTypes
Expand All @@ -110,24 +135,48 @@ local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetad

--- @class triggerData
--- @field buffShowOn string
--- @field debuffType string
--- @field essence number?
--- @field event string|nil
--- @field itemTypeName table|nil
--- @field instance_size table|nil
--- @field itemName string?
--- @field itemSetName string?
--- @field itemTypeName table|ni
--- @field range number?l
--- @field realSpellName string?
--- @field rune number?
--- @field spellName string?
--- @field subeventPrefix string?
--- @field subeventSuffix string?
--- @field type triggerTypes
--- @field unit string?
--- @field use_showOn boolean|nil
--- @field use_alwaystrue boolean|nil
--- @field subeventPrefix string?
--- @field subeventSuffix string?

---@class prototypeDataArgs
---@field name string
---@field required boolean?
---@field display string
---@field type "unit"|nil
---@field init "string"|nil
---@field values any
---@field desc string?
---@field store boolean?
---@field test string?


---@class prototypeData
---@field durationFunc fun(trigger: triggerData): number, number, boolean?
---@field init fun(trigger: triggerData)
---@field durationFunc (fun(trigger: triggerData): number, number, boolean?)|nil
---@field init (fun(trigger: triggerData):string?)|nil
---@field useModRate boolean?
---@field timedrequired boolean?
---@field GetNameAndIcon fun(trigger: triggerData): string?, string?
---@field iconFunc fun(trigger: triggerData): string?
---@field nameFunc fun(trigger: triggerData): string?

---@field GetNameAndIcon (fun(trigger: triggerData): string?, string?)|nil
---@field iconFunc (fun(trigger: triggerData): string?)|nil
---@field nameFunc (fun(trigger: triggerData): string?)|nil
---@field events (fun(tigger: triggerData): table)|nil
---@field internal_events (fun(tigger: triggerData): table)|nil
---@field name string
---@field statesParamater "unit"|"one"|"all"|nil

--- @class triggerUntriggerData
--- @field trigger triggerData
Expand Down
8 changes: 4 additions & 4 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ if WeakAuras.IsRetail() then
talentCheckFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
talentCheckFrame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")

--- @type table<number, {rank: number, spellId: number}
--- @type table<number, {rank: number, spellId: number}>
local selectedTalentsById = {}

Private.CheckTalentsForLoad = function(event)
Expand Down Expand Up @@ -5497,7 +5497,7 @@ Private.event_prototypes = {
nameFunc = function(trigger)
local item = GetInventoryItemID("player", trigger.itemSlot or 0);
if (item) then
return GetItemInfo(item);
return (GetItemInfo(item))
end
end,
stacksFunc = function(trigger)
Expand Down Expand Up @@ -5575,7 +5575,7 @@ Private.event_prototypes = {
nameFunc = function(trigger)
local item = GetInventoryItemID("player", trigger.itemSlot or 0);
if (item) then
return GetItemInfo(item)
return (GetItemInfo(item))
else
return ""
end
Expand Down Expand Up @@ -9855,7 +9855,7 @@ Private.event_prototypes = {
}
},
nameFunc = function(trigger)
return GetSpellInfo(trigger.spellName or 0)
return (GetSpellInfo(trigger.spellName or 0))
end,
iconFunc = function(trigger)
local _, _, icon = GetSpellInfo(trigger.spellName or 0);
Expand Down
2 changes: 2 additions & 0 deletions WeakAuras/RegionTypes/AuraBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ local funcs = {
local function create(parent)
-- Create overall region (containing everything else)
local region = CreateFrame("Frame", nil, parent);
--- @cast region table|Frame
region.regionType = "aurabar"
region:SetMovable(true);
region:SetResizable(true);
Expand All @@ -1073,6 +1074,7 @@ local function create(parent)
end

local bar = CreateFrame("Frame", nil, region);
--- @cast bar table|Frame
Mixin(bar, Private.SmoothStatusBarMixin);

-- Now create a bunch of textures
Expand Down
2 changes: 2 additions & 0 deletions WeakAuras/RegionTypes/Icon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ local function create(parent, data)
local font = "GameFontHighlight";

local region = CreateFrame("Frame", nil, parent);
--- @cast region table|Frame
region.regionType = "icon"
region:SetMovable(true);
region:SetResizable(true);
Expand Down Expand Up @@ -228,6 +229,7 @@ local function create(parent, data)
local button
if MSQ then
button = CreateFrame("Button", nil, region)
--- @cast button table|Button
button.data = data
region.button = button;
button:EnableMouse(false);
Expand Down
7 changes: 4 additions & 3 deletions WeakAurasOptions/OptionsFrames/Update.lua
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,11 @@ local function BuildUidMap(data, children, type)
--- @type table<uid, UidMapData>
map = {
},
type = type -- Either old or new, only used for error checking
type = type, -- Either old or new, only used for error checking
root = data.uid,
totalCount = #children + 1,
idToUid = {}
}
uidMap.root = data.uid
uidMap.totalCount = #children + 1

-- Build helper map from id to uid
local idToUid = {}
Expand Down
2 changes: 2 additions & 0 deletions WeakAurasTemplates/TriggerTemplates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ end
local function createThumbnail(parent)
-- Preview frame
local borderframe = CreateFrame("Frame", nil, parent);
--- @cast borderframe table|Frame
borderframe:SetWidth(32);
borderframe:SetHeight(32);

Expand All @@ -470,6 +471,7 @@ local function createThumbnail(parent)

-- Main region
local region = CreateFrame("Frame", nil, borderframe);
--- @cast region table|Frame
borderframe.region = region;

-- Preview children
Expand Down

0 comments on commit b76a6a1

Please sign in to comment.