intellij-postfix-templates icon indicating copy to clipboard operation
intellij-postfix-templates copied to clipboard

Python: Please add support for other class names too.

Open sairam4123 opened this issue 4 years ago • 2 comments

I am trying to add a converters like this:

.int : Convert into int
    ANY -> int($expr$)$END$
.str : Convert into str
    ANY -> str($expr$)$END$
.frozenset : Convert into frozenset
    list -> frozenset($expr$)$END$
    tuple -> frozenset($expr$)$END$
    set -> frozenset($expr$)$END$
    dict -> frozenset($expr$)$END$
.set : Convert into set
    ANY -> set($expr$)$END$
.list : Convert into list
    ANY -> list($expr$)$END$
.dict : Convert into dict
    ANY -> dict($expr$)$END$
.tuple : Convert into tuple
    ANY -> tuple($expr$)$END$
.bool : Convert into bool
    ANY -> bool($expr$)$END$
.frozenset : Convert into frozenset
    list -> frozenset($expr$)$END$
    tuple -> frozenset($expr$)$END$
    set -> frozenset($expr$)$END$
    dict -> frozenset($expr$)$END$

this can be simplified even further using like this

.frozenset : Convert into frozenset
    iter -> frozenset($expr$)$END$

But as there's no class like iterable in Postfix here. So, the workaround would be this:

.frozenset : Convert into frozenset
    list -> frozenset($expr$)$END$
    tuple -> frozenset($expr$)$END$
    set -> frozenset($expr$)$END$
    dict -> frozenset($expr$)$END$

So it would be nice if you add support for other classes too. like frozenset, iter, ... Thank you!

sairam4123 avatar Jul 10 '20 04:07 sairam4123

I've added support for frozenset type and introduced "complex" types, which can include multiple types, like "iter" mentioned by you.

It's not really flexible, and it may be possible to implement checks for the type methods

It seems tuples currently are not working due to their names being different, e.g.: according to documentation, iterator should have iter method. But this feature is quite large.

Also, it seems the "tuple" type is not detected correctly (for the entire Python CPT): (1, 2, 3) will have (int, int, int) type name, but "tuple" is expected. I'm trying to get the correct name differently, but it should be tested.

ikopysov avatar Oct 30 '20 03:10 ikopysov

Is there any progress on this?

sairam4123 avatar Dec 27 '20 06:12 sairam4123