23 Commits
Author SHA1 Message Date
Irina Fediaeva 01e08f43e4 PY-52574: Update tests after removing Epytext docstring format
GitOrigin-RevId: d4a90a8da56ca889cf380aa5bc72ac82b0716abc
2024-10-29 21:03:06 +00:00
Mikhail GolubevandSemyon Proshev 97b22aaa13 PY-42200 Support parenthesized context managers in Python 3.9+
In case of syntactic ambiguity with previous versions of the grammar, such as
"with (expr)" or "with (expr1, expr2)", PyWithStatement is still parsed as
having its own parentheses, not a parenthesized expression or a tuple as
a single context expression. The latter case, even though syntactically legal,
is still reported by the compatibility inspection in Python <3.9.

These changes also include proper formatter and editing support (e.g. not
inserting backslashes on line breaks inside parentheses), as well as
Complete Current Statement, which now takes possible parentheses into account
while inserting a missing colon.

The changes in the formatter are somewhat ad-hoc, intended to minimize the effect
on other constructs. "With" statement is somewhat special in the sense that it's
the first compound statement (having a statement list) with its own list-like
part in parentheses.

Existing tests on with statement processing were expanded and uniformly named.

Co-authored-by: Semyon Proshev <semyon.proshev@jetbrains.com>

GitOrigin-RevId: 15c33e97f177e81b5ed23891063555df016feb05
2022-05-04 12:31:37 +00:00
Mikhail Golubev 20097f7a69 PY-49785 Properly recover from "case" keyword in the middle of a match statement
Not stopping at a statement break token and continuing recovery until a colon,
we considered the subsequent well-formed case clause to be a part of an error
message about a missing pattern, thus, moving the caret to its colon.

GitOrigin-RevId: f4ee0e12876960e989de3dee89925b65e3cf2339
2021-07-19 16:29:15 +00:00
Mikhail Golubev 353d7f24d1 PY-48014 Implement Complete Current Statement for match statement and its clauses
GitOrigin-RevId: dba29d39fc90397a2f4af8a347cfcbf208ce5c92
2021-06-24 15:04:01 +00:00
Mikhail Golubev 13afc2cbfb PY-43053 Handle Complete Current Statement after a collection at the end of a file
It's weird, however, that Python implementation might query fixers for elements
that are at completely different lines with the caret as in the originally
reported case. This confusing and error-prone behavior needs to be revised
separately.

GitOrigin-RevId: 1f48fe0e0936fb2007022dfc889c44ad32e1eaf0
2020-06-18 19:23:01 +03:00
Mikhail Golubev 16eebe034e PY-25001 Implement Complete Current Statement for collection literals
It works by automatically inserting a trailing comma before a line break in
multiline collection literals. Additionally, a colon is inserted between a key
and a value in dict literals.

Because of the language ambiguity regarding syntax of some incomplete collection
literals, colon is not inserted after the first key of a dict literal
(it's indistinguishable from a set literal with one item), and comma is not
inserted after the first item of a parenthesized tuple (it's indistinguishable
from a parenthesized expression).

The idea was taken from such implementation of Complete Current Statement for
JSON.

GitOrigin-RevId: 49ff9857d8c12476bfa9aacaed0b49faa99810fd
2020-06-10 22:57:53 +03:00
Aleksei Kniazev 3c203f5382 IDEA-CR-51590: added self parameter for methods on smart enter (PY-35163)
self is inserted for methods that are not class-/staticmethod
cls is inserted for classmethod
empty parameter list for staticmethod

GitOrigin-RevId: 9743ae50c89c069b8123b8b6eb26fb841dd1f5b2
2019-09-04 15:08:25 +00:00
Mikhail Golubev 9b49498808 PY-19279 Smart enter on function inserts colon after return type annotation 2016-04-28 14:28:28 +03:00
Mikhail Golubev a955f6c927 PY-16765 For sections inside Google code style docstring use indentation configured for Python
PyFunctionBuilder and PyDocstringGenerator require a PSI element to
use proper formatting and style for generated docstring.
2015-09-23 18:42:17 +03:00
Mikhail Golubev 3826afdf6c PY-16765 In Google docstrings smart enter adds colon and indentation after section header 2015-09-07 22:01:24 +03:00
Mikhail Golubev fbbf4dcade PY-15656 Insert closing parenthesis of parameter list right after opening one if there are no parameters 2015-04-21 15:14:26 +03:00
Mikhail Golubev 246fcae221 PY-15653 Better handling of class definitions with the list of base classes but no name node 2015-04-21 15:14:26 +03:00
Mikhail Golubev 3f519db066 PY-15653 Smart enter works better in case of function and class definitions without name element 2015-04-21 15:14:25 +03:00
Mikhail Golubev 99f4933e70 PY-9209 Insert a space after '#' sign when using smart enter in comment 2014-11-18 01:28:45 +03:00
Mikhail Golubev 5de0b14903 PY-12877 Fix complains found during review (IDEA-CR-397) 2014-09-08 12:47:15 +04:00
Mikhail Golubev 2851b82675 PY-12877 Add test for the case when no expression given in 'with' header 2014-08-05 13:03:29 +04:00
Mikhail Golubev 3089c9cb09 PY-12877 Complete statement doesn't insert colon for 'with' statement 2014-07-22 16:30:53 +04:00
Ekaterina Tuzova c0b2b413f7 fixed PY-5029 Editable auto stub string 2011-11-22 13:34:30 +01:00
Ekaterina Tuzova 42ea17e44b added empty line to comment generation 2011-04-15 12:29:22 +04:00
Ekaterina Tuzova 8432376a49 added tests for generating docstrings in python 2011-04-15 12:17:30 +04:00
Dmitry Jemerov 384a20364b smart enter shouldn't insert parentheses into decorator calls (PY-3209) 2011-03-31 21:49:54 +02:00
alexey.ivanov 87555a3ec1 PY-891 Ctrl + Shift +Enter doesn't move to next line in case of method definition 2010-04-28 22:03:55 +04:00
alexey.ivanov 056ba164b5 PY-181 Complete Statement should work for Python 2010-04-22 18:51:03 +04:00