Update parser & descriptor renderer to handle parenthesized types and function types properly.
Resolve annotations in parenthesized types.
AnnotationsImpl.isEmpty() returned false for targeted annotations only
(e.g., 'fun @receiver:Ann C?.foo()').
Properly keep track of targeted annotations.
(required for 'suspend' on functional types).
TYPE_REFERENCE element now has MODIFIER_LIST child, which hosts annotations and modifiers for the corresponding type reference.
Annotations and modifiers written before an extension function type are now parsed as annotations and modifiers for the functional type, not the receiver type.
So, '@Ann A.(B) -> C' was '(@Ann A).(B) -> C', and became '@Ann (A.(B) -> C)'.
NB: DSL_SCOPE_VIOLATION testData updated accordingly.
Type projection variance modifiers ('in', 'out') belong to a separate modifier list under corresponding type projection (not under a type reference).
'A<in suspend T>' is 'A<(in (suspend T))>', 'A<suspend in T>' is an error.
In stub builder, create a modifier list node to host annotations and modifiers (none so far; TODO properly serialize/deserialize types with modifiers).
Attach annotations to the closest prefix expression instead of
whole statement if no new line found after annotations
The motivation is for a simple annotated expression like '@ann x + y'
its syntax form must not change after prepending 'val z = ' just before it
This change only matters in cases of if/when/for/while having braceless
blocks
Annotations on them are parsed now as on block-level expressions, i.e.
they're attached to the whole expression
If a block statement starts with annotations treat them as they
belong to node of the statement rather than to the closest prefix expression
#KT-10210 Fixed
But still resolve them as annotations.
Mostly it's needed as begin of migration path, one day they become modifiers anyway
Some tests are dropped because they supposed that `annotation` should have parameter
Comma must present now between enum entries, semicolon between last entry & first member, constructor calls must be without colons / specifiers.
A swarm of tests fixed accordingly.
Sometimes it's allowed to parse "annotation" unescaped even if other annotations must be escaped.
A set of annotations and their options tests.
A swarm of existing tests fixed (mostly kotlin.annotation.annotation() added to txt-files).
STUB_VERSION increased. Some quick fixes slightly changed.
Fix a problem where deleting last import directive via "optimize imports" could lead to incorrect psi structure resulting in CCE, see EA-64291
New imports are inserted at the head (after package directive if present) of the file (before any comments) if no imports were present
Add test for inserting import to file where a first statement is a comment
Drop code dealing with non-existing import list in ImportInsertHelperImpl
AbstractQuickFixTest: check for unexpected actions before changes to the file are made as it relies on the first line having specific format
It's needed for better recovering for cases of changes like 'class' -> 'object'
The only sensible case when it's may be bad:
class A {
object B
constructor() : super()
}
But it seems to be rare, and ';' can be used to separate object from secondary ctor