jonnyboyC / kos-language-server

A language server for the Kerboscript (kOS) a language for Kerbal Space Program
MIT License
27 stars 6 forks source link

Type hinting #116

Open krisavi opened 4 years ago

krisavi commented 4 years ago
krisavi commented 4 years ago

I guess the automated test kind of got stuck.

krisavi commented 4 years ago

Seems I caused some memory leak issue in tests which I have to fix in PR.

krisavi commented 4 years ago

I was thinking of doing couple of tests yes, It needs some improvements, I found out some more issues with it. As a first step adding tests is way to go yes.

One more thing I remembered now that is missing is dynamic list generation, Parser needs improvements. I think I have defined 2-3 lists, Type hints are currently defined in one file and it is unknown what are the types they can use, Maybe autocomplete could be used to give some hints on what kind of type definitions there are.

Will look into writing some tests and improving code.

krisavi commented 4 years ago

It seems the parser config used in tests is not defining types. Have to figure out why it is ignoring all the hints.

jonnyboyC commented 4 years ago

To your first comment, I think an autocomplete would definitely be a good thing to have. I think it would probably make sense to add it in a separate PR.

For type hinting depending on which spec file your in you may need to add typeInitializer() before the tests. This is located in "/src/typeChecker/initialize". Essentially this has to be run because some of the types have circular references to each other. This is especially true with the more primitive types like structure, boolean etc.

krisavi commented 4 years ago

image

Did some magic with automatic detection of return.

krisavi commented 4 years ago

Did struggle with testing. Not sure if i can make it work. During the test, it has not done the visitParameter it seems, so it has the type declared as structure and not picking up the updated one. That is the reason why it crashes for me. Function on the other hand had parameter types defined already, which is odd. So it needs some more figuring out how I can force the token types to be defined by the time the test takes place. It seems if I run it 2 times before test checks, everything is in order. Wanted to check the order it gets parameters-variables and such declared. Hoping I will find a way to make sure it is in order that will also not make it lag with bigger scripts.

For longer script I put my whole launch, orbit, rendezvous and deorbit and recovery with last part as suicide burn, while doing science collection and transmission as one big script. Basically took all the libraries and stitched it as one file to put language server to the test.

jonnyboyC commented 4 years ago

Just as a point of reference I typically gauge speed against kerboscripts/parse_valid/ap.ks. it's about 2kloc. I believe it's the script for that sort of famous kOS quad copter.

Feel free to push code to your PR if you need another set of eyes on it. I can take a stab at writing some tests if you need some help. Definitely very interested in getting this merged!