Giter VIP home page Giter VIP logo

vscode-wow-api's Introduction

vscode-wow-api's People

Contributors

chriskader avatar dependabot[bot] avatar emmericp avatar etern213 avatar gjfleo avatar ketho avatar kozoaku avatar meorawr avatar nightwarden24 avatar oppzippy avatar rbleuse avatar snakybo avatar stanzilla avatar thatnerdjosh avatar torhal avatar wutname1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-wow-api's Issues

Fields on CreateFrame() objects give an undefined-field warning

When setting fields on objects returned from CreateFrame() and using them, the language server gives an undefined-field warning.

local f = CreateFrame("Frame")
f.test = "123"
print(f.test)

I'm not sure why this is happening. Manually annotating it with ---@type Frame seems to fix it though.

Child Frames/Fields

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")

No support for Line UI object

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.
image

It'd be nice if we had it, so I'd like to propose this feature request.

Thanks for the invaluable development! ♥

Idea: Better handling of templates in CreateFrame?

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:

  1. explicitly define all templates as classes inheriting from Frame. Given that only BackdropTemplate exists this is just:

---@class BackdropTemplate: Frame

Now you can cast frame to BackdropTemplate or add an @type annotation :)

  1. Ideally 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 :)

Any way to get older expansions?

Specifically, I'm interested in coding for vanilla (1.12.1).
Not sure how hard that would be to add.
I see that the wiki entries contain "Game Flavors" and "Added in" fields. And there's vanilla wiki, too.

C_CVar.SetCVar value parameter

The function C_CVar.SetCVar value parameter can either be a string or number type but the extension just has it as a string

image

Some missing API's or wrong API parameters

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

xpcall arguments

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

Unable to use main.lua

image

Using this in WSL2, since LuaSec refused to install with luarocks on the windows side.

UIFrameFadeOut and UIFrameFadeIn wrong parameter types

---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

Missing UnitId

There are some missing unitIds after Patch 10.0.0. (Wowpedia)

Patch 10.0.0 (2022-10-25): Added anyenemy, anyfriend, anyinteract, softenemy, softfriend, and softinteract.

Lots of GetNumX() functions lack return type

---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumFlyouts)
function GetNumFlyouts() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGroupChannels)
function GetNumGroupChannels() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGroupMembers)
function GetNumGroupMembers(groupType) end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildBankMoneyTransactions)
function GetNumGuildBankMoneyTransactions() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildBankTabs)
function GetNumGuildBankTabs() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildBankTransactions)
function GetNumGuildBankTransactions(tab) end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildChallenges)
function GetNumGuildChallenges() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildEvents)
function GetNumGuildEvents() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildMembers)
function GetNumGuildMembers() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildNews)
function GetNumGuildNews() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildPerks)
function GetNumGuildPerks() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildRewards)
function GetNumGuildRewards() end
---[Documentation](https://warcraft.wiki.gg/wiki/API_GetNumGuildTradeSkill)
function GetNumGuildTradeSkill() end

These and others sound like they return numbers

GameTooltip missing from _G

image

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)

Frame Templates

Thanks for this amazing extension, it makes addon development so much easier.

Is there some way to handle the typing of Frame templates such as BackdropTemplate that I'm missing, or is that currently not supported?

image

Improper arguments for some API functions

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)

Objects returned from CreateFrame() share methods

When using CreateFrame() all objects returned will share the same methods, e.g. local f = CreateFrame("Frame") would have the methods from GameTooltip after running local tooltip = CreateFrame("GameTooltip")

Cannot clean up EmmyLua from Sumneko's libraries path on uninstall

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.

Support for 10.0.2

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.:

image

Any help here really appreciated!

Returning an array of classes doesn't provide completion

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

It's annotated as an array of GossipOptionUIInfo
image

But it doesn't provide completion.
image

not working.... help me

hello~ my friend!
is not working.....

image

I need code intellisence ...
but do not working...

what should i do??

Adding more WoW-specific types would be helpful

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:

Examples:

For some of the types I didn't find official names so I just came up with one based on what made sense.

ChatTypeId
image

I gave the name: https://wowpedia.fandom.com/wiki/API_GameTooltip_SetOwner#Arguments
image

I gave the name: https://wowpedia.fandom.com/wiki/Hyperlinks#Types
image

Also used for Widget API SetJustiyH & SetJustifyV:
https://wowwiki-archive.fandom.com/wiki/XML/JUSTIFYH
https://wowwiki-archive.fandom.com/wiki/XML/JUSTIFYV
image


Type.lua:

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

CreateFrame <T> undefined fields

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:

image
image

InterfaceOptionsFrame_OpenToCategory undefined global

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
}]

Invalid arguments

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.

Global strings showing as undefined

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?

image

Add globals to settings.json

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.

Region:IsMouseOver

I'm not sure what to edit on the Wiki page to correct the definition in the extension, but there are two problems:

  • The type definition in the extension requires all parameters, but they're all optional.
  • The Wiki says this is a ScriptRegion method, where the extension uses Region.

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.

Unknown references through addon namespaces

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.

Example:

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:
image

Annotation and jump to definition does work when it's global (as it did previously with the namespace as well):
image

It might be related to this issue, I'm not sure: #28 (comment)

Missing ruRU in GlobalStrings locale option

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."
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.