ketho / vscode-wow-api Goto Github PK
View Code? Open in Web Editor NEWWoW extension for VSCode
Home Page: https://marketplace.visualstudio.com/items?itemName=ketho.wow-api
License: MIT License
WoW extension for VSCode
Home Page: https://marketplace.visualstudio.com/items?itemName=ketho.wow-api
License: MIT License
I noticed that child frames or fields created by default when some Frame Types are created are not included in the type defs.
Example would be:
local f = CreateFrame("CheckButton", nil, UIParent)
If I reference f.text
I am told by the extension in VSCode that it is an undefined field. However, .text
is created as a FontString at the root of f
and is the text that is attached to the button. The only way I have found around this is to define a custom class, like shown below, that extends the default class to include the field.
---@class CheckButton_E : CheckButton
---@field text FontString
local f = CreateFrame("CheckButton", nil, UIParent)
f.text:SetText("Test")
You forgot about bitwise operations when you added standard Lua functions.
Thus, they are considered as undefined globals
Hey!
I did some with with Line objects and I noticed warnings were yelling at me it's undefined. Alas, I suppose definitions have not yet been included for them.
It'd be nice if we had it, so I'd like to propose this feature request.
Thanks for the invaluable development! ♥
I have code like this:
frame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
(...)
frame:ApplyBackdrop()
frame:Show()
The definition for CreateFrame makes Frame of type BackdropTemplate|Frame
which means it triggers param-type-mismatch
on frame:ApplyBackdrop()
because BackdropTemplate|Frame
!= BackdropTemplate
. I also can't cast frame to the template type because it doesn't inherit from Frame, so it would then fail on frame:Show()
instead.
Suggestion for a fix in two steps:
Frame
. Given that only BackdropTemplate exists this is just:---@class BackdropTemplate: Frame
Now you can cast frame to BackdropTemplate or add an @type annotation :)
CreateFrame
would already return the correct type, but I don't think "return type is arg4 if it exists, arg1 otherwise" can be fully modeled in the type system.However, there is a work-around, we can duplicate the definition with different parameter numbers!
---[Documentation](https://warcraft.wiki.gg/wiki/API_CreateFrame)
---@generic T
---@param frameType `T` | FrameType
---@param name? string
---@param parent? any
---@return T frame
function CreateFrame(frameType, name, parent) end
---[Documentation](https://warcraft.wiki.gg/wiki/API_CreateFrame)
---@generic Tp
---@param frameType FrameType | string
---@param name? string
---@param parent? any
---@param template? `Tp` | TemplateType
---@param id? number
---@return Tp frame
function CreateFrame(frameType, name, parent, template, id) end
It's a bit ugly because template isn't the last parameter, but no one uses id
anyways I think.
The class definition together with the duplicate CreateFrame make my example work correctly without any annotations :)
IsSpellKnown => the function received at least 2 arguments, but got 1 (isPetSpell is optional)
GetShapeshiftForm => the function received at least 1 arguments, but got 0. (flag is optional)
I get squiggly underlines under InventorySlotId constants which I have researched and used successfully from the Wowpedia article. Here's a screenshot showing this in vs code.
Hi,
thanks for that amazing extension :)
I habe found some API's which requires wrong parameters:
GetActiveSpecGroup() -> the parameter is required but it is optional
GetSpellLevelLearned(spellId) --> Missing
UIFrameFadeIn and UIFrameFadeOut --> required the wrong types tables instead of dbl
UnitBuff() --> first parameter retirees a string not a integer
PlaySoundFile() --> missing
UnitPower() --> has optional parameters
UnitPowerMax() --> has optional parameters
UnitIsMercenary() -- parameter unit = string --> missing
SetSpecialization() --> second parameter is optional
GetAddOnMemoryUsage() --> parameter: index --> missing
GetAddOnCPUUsage() --> parameter: index --> missing
In 5.1 xpcall has 2 arguments, optionals were added in 5.2
WoW use 5.2 xpcall, i don't know if something can be done about it with vscode-wow-api
---FrameXML
--- Convenience function to do a simple fade in
---@param frame Frame
---@param timeToFade table
---@param startAlpha table
---@param endAlpha table
function UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha) end
---FrameXML
--- Convenience function to do a simple fade out
---@param frame Frame
---@param timeToFade table
---@param startAlpha table
---@param endAlpha table
function UIFrameFadeOut(frame, timeToFade, startAlpha, endAlpha) end
should be
---FrameXML
--- Convenience function to do a simple fade in
---@param frame Frame
---@param timeToFade number
---@param startAlpha number
---@param endAlpha number
function UIFrameFadeIn(frame, timeToFade, startAlpha, endAlpha) end
---FrameXML
--- Convenience function to do a simple fade out
---@param frame Frame
---@param timeToFade number
---@param startAlpha number
---@param endAlpha number
function UIFrameFadeOut(frame, timeToFade, startAlpha, endAlpha) end
There are some missing unitIds after Patch 10.0.0. (Wowpedia)
Patch 10.0.0 (2022-10-25): Added
anyenemy
,anyfriend
,anyinteract
,softenemy
,softfriend
, andsoftinteract
.
vscode-wow-api/EmmyLua/API/GlobalAPI/API3.lua
Lines 603 to 640 in 98df833
These and others sound like they return numbers
When using nil as second param to SetScript you currently get a warning, looks like in
you defined that though.Not sure what's up
Quick reproduction code:
---@param tooltip GameTooltip
---@param tooltipData table
local function HandleTooltip(tooltip, tooltipData)
if tooltip ~= _G.GameTooltip then
return
end
--[[
Rest of the code here
]]
end
-- Tooltip integration
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, HandleTooltip)
Hey!
I found a minor annotation error, the "cursor" parameter for the API function SetCursor
should be optional.
I changed line 1278 in API4.lua to (and updated the wiki page:
---@param cursor? string
🫰
Specifically in my situation I'm using UnitGUID("questnpc")
. This is valid syntax in every API version since vanilla 1.0. This value is listed on the Wowpedia article for UnitId, so I figured I'd open an issue report for it.
To clarify, this value does not always return the exact same target as npc
, and there are programmatic uses for it.
GetSpellPowerCost => The function received a maximum of 0 arguments, but got 1
GetSpellCount => The function received a maximum of 0 arguments, but got 1
GetSpellCooldown => The function received a maximum of 0 arguments, but got 1
GetSpellTexture => The function received a maximum of 0 arguments, but got 1
UnitStagger => The function received a maximum of 0 arguments, but got 1
GetSpecialization => the function received at least 3 arguments, but got 0 (they should be optional)
Uninstalling the extension does not appear to work, starting somewhere around the August 2021 vscode release.
It relied on vscode deleting the actual extension files instead of marking them in:
C:\Users\<user>\.vscode\extensions\.obsolete
Removing them from Sumneko's external libraries path does not seem possible when uninstalling, since we don't have access to the vscode api in the uninstall hook.
Hey @Ketho !
Are there any plans to add support for DF 10.0.2 in line? Or would that need to be done on a different project?
I got the language server and this plugin to work for most things, but still get some warnings regarding certain globals, e.g.:
Any help here really appreciated!
When returning an array of class types, the language server sees it's an array of that type; but it doesn't provide completion.
The language server possibly might have never supported this feature, but I'm not sure.
---@class GossipOptionUIInfo
---@field gossipOptionID number?
---@field name string
---@field icon fileID
---@field rewards GossipOptionRewardInfo[]
---@field status Enum.GossipOptionStatus
---@field spellID number?
---@field flags number
---@field overrideIconID fileID?
---@field selectOptionWhenOnlyOption boolean
---@field orderIndex number
---[Documentation](https://wowpedia.fandom.com/wiki/API_C_GossipInfo.GetOptions)
---@return GossipOptionUIInfo[] info
function C_GossipInfo.GetOptions() end
Hey!
I find myself adding more and more @alias
definitions as I work - some of the complex types which are missing from the extension's definitions (or I couldn't find them - in that case a documentation in the wiki with the list of currently supported types could be useful) would be cool to have.
See:
For some of the types I didn't find official names so I just came up with one based on what made sense.
I gave the name: https://wowpedia.fandom.com/wiki/API_GameTooltip_SetOwner#Arguments
I gave the name: https://wowpedia.fandom.com/wiki/Hyperlinks#Types
Also used for Widget API SetJustiyH & SetJustifyV:
https://wowwiki-archive.fandom.com/wiki/XML/JUSTIFYH
https://wowwiki-archive.fandom.com/wiki/XML/JUSTIFYV
I think these could be added to Type.lua, in fact I added the above mentioned examples already (changing it to a txt to be uploadable):
Type.lua.txt
local frame = CreateFrame("FRAME");
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:SetScript("OnEvent", HandleEvent);
...
(field) FRAME.RegisterEvent: unknown
(field) FRAME.RegisterUnitEvent: unknown
(field) FRAME.SetScript: unknown
(field) FRAME.GetScript: unknown
(field) FRAME.SetAllPoints: unknown
(field) FRAME.SetPoint: unknown
(field) FRAME.UnregisterEvent: unknown
(field) FRAME.Hide: unknown
(field) FRAME.Show: unknown
(field) FRAME.EnableMouse: unknown
(field) FRAME.SetPoint: unknown
(field) FRAME.SetHeight: unknown
(field) FRAME.SetWidth: unknown
(field) FRAME.SetSize: unknown
(field) FRAME.CreateTexture: unknown
(field) FRAME.CreateFontString: unknown
(field) FRAME.SetClipsChildren: unknown
(field) FRAME.OnSizeChanged: unknown
(field) FRAME.SetRotatesTexture: unknown
(field) FRAME.HookScript: unknown
(field) FRAME.SetMovable: unknown
(field) FRAME.SetResizable: unknown
(field) FRAME.SetMinResize: unknown
(field) FRAME.width: unknown
(field) FRAME.height: unknown
local hsvFrame = CreateFrame("Colorselect")
hsvFrame:SetColorRGB(r1, g1, b1)
hsvFrame:SetColorHSV(h3, s3, v3)
(field) Colorselect.GetColorRGB: unknown
(field) Colorselect.GetColorHSV: unknown
(field) Colorselect.SetColorRGB: unknown
(field) Colorselect.SetColorHSV: unknown
local cooldown = CreateFrame("COOLDOWN", "WeakAurasCooldown"..frameId, region, "CooldownFrameTemplate");
(field) COOLDOWN|CooldownFrameTemplate.SetDrawBling: unknown
(field) COOLDOWN|CooldownFrameTemplate.SetFrameLevel: unknown
(field) COOLDOWN|CooldownFrameTemplate.SetAllPoints: unknown
local border = CreateFrame("frame", nil, region, BackdropTemplateMixin and "BackdropTemplate")
(field) BackdropTemplate|frame.SetFrameLevel: unknown
local popupFrame = CreateFrame("EditBox", "WADebugEditBox", UIParent)
(field) EditBox.SetFontObject: unknown
local scrollFrame = CreateFrame("ScrollFrame", "WADebugEditBoxScrollFrame", UIParent, "UIPanelScrollFrameTemplate")
:SetMovable
:SetFrameStrata
:SetSize
:SetPoint
:SetHitRectInsets
:SetScrollChild
:StartMoving
:StopMovingOrSizing
:GetLeft, GetTop etc..
:Hide
Textures:
The wiki page has the return type, so not sure where/how this is going wrong: https://warcraft.wiki.gg/wiki/API_C_NamePlate.GetNamePlates?action=edit
GetNumTalentTabs and GetTalentTabInfo which are in the TBC Classic API seem to be missing.
Is there a way I can set the extension to use the TBC Classic API? I found only 1 setting, and it wasn't this.
Thanks for your extension.
Undefined global `InterfaceOptionsFrame_OpenToCategory`.
[{
"resource": "/c:/Games/World of Warcraft/_retail_/Interface/AddOns/ItemUpgradeTip/ItemUpgradeTip.lua",
"owner": "_generated_diagnostic_collection_name_#3",
"code": "undefined-global",
"severity": 4,
"message": "Undefined global `InterfaceOptionsFrame_OpenToCategory`.",
"source": "Lua Diagnostics.",
"startLineNumber": 77,
"startColumn": 13,
"endLineNumber": 77,
"endColumn": 49
}]
local unitLoadFrame = CreateFrame("FRAME");
unitLoadFrame:RegisterUnitEvent("UNIT_FLAGS", "player");
RegisterUnitEvent => the function received at least 4 arguments, but got 3.
local bg = bar:CreateTexture(nil, "ARTWORK")
bg:SetSnapToPixelGrid(false)
SetSnapToPixelGrid => The function received a maximum of 1 arguments, but got 2.
wiki say it has no arg but it's use with false in blizzard code like at https://github.com/Gethe/wow-ui-source/blob/d390b8491460485729248ca2cedbee0e43ee75f7/Interface/SharedXML/NineSlice.lua#L189 or https://github.com/Gethe/wow-ui-source/blob/6afa01a5eeda40242adb956f385cfe408e7bbae6/Interface/AddOns/Blizzard_NamePlates/Blizzard_ClassNameplateBar_DeathKnight.lua#L39
local mask = CreateFrame("ScrollFrame", nil, borderframe);
local content = CreateFrame("Frame", nil, mask);
mask:SetScrollChild(content);
SetScrollChild => The function received a maximum of 1 arguments, but got 2.
(global) SmoothStatusBarMixin: unknown
(method) EditBox:SetCountInvisibleLetters() => The function received a maximum of 1 arguments, but got 2.
Most Global strings are not getting picked up as defined for me. I saw you were planning on adding them in #9 and there are some commits around it, did something get broken?
I'll need to find a way to populate the settings.json
(or a separate file that adds to settings.json) because I don't want to document everything in EmmyLua, just marking something as global would be enough.
"Lua.diagnostics.globals": [
"WorldMapFrame"
]
Especially since using empty or bad emmylua annotations is arguably worse instead of marking globals for the undefined-global
warnings.
I'm not sure what to edit on the Wiki page to correct the definition in the extension, but there are two problems:
If this is actually something I could fix myself via the Wiki page for the next extension release, I'd like to know so I skip the ticket-filing process if/when this happens again.
Hey!
I'm communicating between different files of my addons through the provided addon namespaces. Previously, annotations and references were pulled through the namespace so I could Ctrl+click to jump to a function shared in the namespace from one file to another or I could see the EmmyLua annotation on a function defined in another file for instance.
More specifically, I use a global table shared between addons, which contains subtables with version keys. A specific key is shared in the addon namespace so all files of the addon can access the specific subtable of that global table with that key (if multiple addons are on the same version, they can access the same subtable with the identical key - that's the idea in a nutshell).
Now, this functionality is broken. I'm not sure if it was broken by the main Lua extension of sumneko or WoW API specifically.
Code in file 1:
--Addon identifier name, namespace table
local addonNameSpace, ns = ...
--This is a hello
ns.Hello = function() end
--This is a global hello
Hello = function() end
Code in file 2:
--Addon identifier name, namespace table
local addonNameSpace, ns = ...
ns.Hello()
Hello()
Annotation and jump to definition doesn't work when it's through the namespace table:
Annotation and jump to definition does work when it's global (as it did previously with the namespace as well):
It might be related to this issue, I'm not sure: #28 (comment)
Description
There is no ruRU in the drop-down list of GlobalStrings locale option.
Solution
Compare these two lists:
local locales = {
"deDE",
"enUS", -- same as enGB
"esES", "esMX",
"frFR",
"itIT",
"koKR",
"ptBR", -- same as ptPT
"ruRU",
"zhCN", "zhTW",
}
"wowAPI.locale": {
"type": "string",
"default": "enUS",
"enum": [
"enUS",
"deDE",
"esES",
"esMX",
"frFR",
"itIT",
"koKR",
"ptBR",
"zhCN",
"zhTW"
],
"markdownDescription": "Sets the GlobalStrings locale for code completion and hover."
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.