asledgehammer / candle-compiler Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v3.0
License: GNU Lesser General Public License v3.0
Right now all generic classes are represented without the generic aspect. Generic classes are not actually supported by LuaLS right now, but annotating them as generic would still benefit developers. For example, IsoCell.getZombieList
is annotated as returning ArrayList
- annotating this as ArrayList<IsoZombie>
instead would save a visit to the javadocs.
The annotations for this are quite simple:
---@generic T
---@class ArrayList<T>
---@return ArrayList<IsoZombie>
Unfortunately, the type inference ArrayList<T>.get -> T
is not possible with LuaLS's current lack of support for generic classes - class methods annotated with the generic get dropped by intellisense completely. Because of this, defining generic classes has no actual effect on the type checker, making this issue a low priority.
Currently we use a decorative ---@implement
to annotate what interfaces that a class implements. I suggest that we instead have implementing classes inherit from them.
The benefit to this would be when a method's return type is an interface - for example, IsoZombie
's getThumpTarget
returns a Thumpable
. There's basically nothing you can do with this without raising a warning.
local thumpable = zombie:getThumpTarget()
---@cast thumpable IsoThumpable
---@type IsoThumpable
local thumpable = zombie:getThumpTarget()
Both of these snippets raise a warning in the type checker as it doesn't see Thumpable
as assignable to IsoThumpable
(though they do still work).
If we were to do this, we'd also need to generate stubs for non-exposed interfaces that are implemented by exposed classes (I'm not really sure why there are exposed interfaces, but only they are currently annotated) - for example, Thumpable
from the previous example isn't exposed, which means you can't call the interface methods without a warning either. We'd also need to undo the work on 'flattening' interfaces into their implementing classes.
I recall us having some trouble with interfaces before, so there may be a pitfall to this approach I'm missing. If there is, we could instead just alias all interfaces as a union type of all exposed implementing classes for similar effect - in fact we've already done this manually for Map and List.
return:
type: org.lwjgl.util.vector.Quaternion
Needs to be
return:
type: Quaternion
We could probably put in a fullType variable as well.
Need to get rid of <
, >
, etc.
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.