Also fixed the problem that whitespaces inside literal parts of f-strings were
matched as PsiWhitespaces instead of FSTRING_TEXT tokens and updated all relevant
test data.
When the terminating quote is either at the beginning of a string literal or
inside it, either in the given f-string itself or inside a nested one and
either in normal fragment or in a fragment located inside a format part of
another fragment. Normal string literals and nested f-strings are also checked
separately.
Both packages/module names and names of individual imported symbols in
"from" imports are sorted case-insensitively if it's enabled.
To keep things simple I decided not to replicate the exact scheme used
by isort to order names in "from" imports where they have different priority
depending on whether they are ALL_CAPS or CamelCased (check the issue for
related discussion).
Using PyTypeParser for this purpose is, first, too heavyweight since it does a lot of
unnecessary work, and, second, introduces unexpected problems related to the fact
that it was originally intended to resolve types in docstrings and thus too permissive
and depends on surrounding context such as existing imports.
In this case we must fetch real type from generator.
We also should open union if one is returned instead
of generator itself.
Any decorator leads to weak type (Union[Any, T]). To fix it, we use KnownDecorators (its better to use EP there)
This solution uses a custom key to mark an injected file as unsuitable for line
commenting, but we should rather generalize it in some other way instead of
further hardcoding language-specific string prefixes in CommentByLineCommentHandler.
Reviewed in IDEA-CR-35030.
Python Console generates declaration stubs where docstring for a class is moved
to its __init__. It's a somewhat add-hoc solution for the problem, we should
probably fix this controversial behavior of the debugger as well.
At the moment we render them "as is" only escaping their text
similarly to how it's done for TypeScript, not trimming it
to the first line as in case of target expression initializers.
Extracted detection of the right reference owner under the caret.
Resolving in all the different places now uses the same resolve context.
Also I reduce visibility of the shared methods.
Otherwise, we can't really tell whether the use wants to annotate the return type
of the method or the type of the qualifier in cases like the "param.met<caret>hod()".
It's better to be more explicit and ask them to invoke the intention on the right
element directly.
Handle the cases when the caret is at the end of an identifier using
TargetElementUtil#adjustOffset.
Additionally, manually check that these elements are actually writable
before applying the respective changes and don't suggest these intention actions
if there are several possible definitions (though, we'd better show them all
in a popup in this case).
Otherwise, we may end up modifying dozens of library definitions without notifying
user about it anyhow in case of ambiguity in resolve results.
when both its type and optional name are omitted. Just as the reference implementation
in sphinxcontrib.napoleon we now require a trailing colon on the first line of a field
to treat this text as the return type, otherwise it's considered the return value description.
Also, I dropped support for named return and yield values in Google Code Style docstrings,
as Napoleon doesn't feature them as well.