justinmahar / SublimeCSAutocompletePlus

CoffeeScript autocompletions and more!
172 stars 12 forks source link

What can we do with methods of Global object (also Math and JSON)? #6

Closed degorov closed 11 years ago

degorov commented 11 years ago

Maybe Ctrl+Tab on "nothing" should pop-up the list of them?

decodeURI(encURI)
decodeURIComponent(encURI)
encodeURI(URI)
encodeURIComponent(str)
eval(str)
isFinite(num)
isNaN(val)
parseFloat(str)
parseInt(str, [radix])

Math and JSON objects do have only static props and methods, so I think we can treat them the same way - just add them all to pop-up-on-nothing list (Math.cos(x) etc). If you create a settings file (or section in existing one) for Global, Math and JSON, I can help with its contents!

As for properties of Global object (Infinity, NaN and undefined), I think it's better to leave them in keywords file, because they are actually always used errrrrr... as keywords :)

justinmahar commented 11 years ago

Hmm.. Well, we can add Math and JSON to built-in types and only add static properties and methods. Problem solved there. As for the others.. that will be trickier. Right now autocomplete depends on a dot being there... I'm in the midst of rewriting the plugin to use classes and not a steaming heap of util functions. I'll think about how to incorporate this... for now, your keywords file might be the best option.

justinmahar commented 11 years ago
{
            "name": "Math",
            "enabled": true,
            "constructors": [],
            "static_properties": [
                {"name": "E"},
                {"name": "LN10"},
                {"name": "LN2"},
                {"name": "LOG10E"}
                // etc...
            ],
            "static_methods":
            [
                {"name":"abs", "args": [{"name": "blahblahblah"}]},
                {"name":"acos", "args": [{"name": "blahblahblah"}]},
                {"name":"asin", "args": [{"name": "blahblahblah"}]}
                // etc...
            ],
            "instance_properties": [],
            "instance_methods": []
        }
justinmahar commented 11 years ago

FYI, I added JSON to built-in types.

degorov commented 11 years ago

I wanted to say that Math's methods are practically never used like Math class members, but rather as a single "command" Math.cos(x) and so on. But if someone extends the Math prototype with own functions, this simplification will fail. So, you are right! I will supply Math members later today. And those 9 global methods can be added to keywords as for now.

justinmahar commented 11 years ago

I see what you mean. Okay, sounds good!