Commit Graph

69 Commits

Author SHA1 Message Date
Victor Petukhov cec747349e Fix PSI tests for correct parsing them by the ANTLR grammar 2020-04-02 19:02:31 +03:00
victor.petukhov 6a679d86ab Support non-parenthesized annotations on functional types without receiver
^KT-31734 Fixed
2019-07-17 16:18:15 +03:00
Denis Zharkov 3707812fc2 Revert "Temporary remove some tests after a fix for KT-24937"
This reverts commit ddb4e8b128.
2019-01-15 12:35:12 +03:00
Denis Zharkov ddb4e8b128 Temporary remove some tests after a fix for KT-24937
Otherwise, our project is failed to be indexed
2018-12-11 09:45:39 +03:00
Denis Zharkov 5992896d76 Relax assertion in parser for a recovery case with annotations
^KT-24937 Fixed
2018-12-11 09:45:14 +03:00
Mikhail Zarechenskiy 8f8143d3ed Fix IAE for wrong use-site @file annotation
#EA-100189 Fixed
2017-08-07 18:49:57 +03:00
Nikolay Krasko 0cd3e4f3a4 Minor: JetFile -> KtFile 2017-05-18 20:00:17 +03:00
Mikhail Zarechenskiy d3fd96ceed Parse collection literals as atomic expressions 2017-03-22 17:59:58 +03:00
Dmitry Petrov b9f9894310 KT-15677 KT-15775
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.
2017-01-19 09:53:17 +03:00
Dmitry Petrov a15d423db4 Support modifiers on types in parser
(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).
2016-12-15 23:57:41 +03:00
Nikolay Krasko 08d628537c Assign trailing and preceding whitespaces to lambda block until the last comment in parser 2016-10-27 14:26:10 +03:00
Denis Zharkov bec84b1d7b Change parsing of annotations on block level expressions
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
2016-10-12 11:39:04 +03:00
Denis Zharkov 9ff439e39e Change annotations parsing in bodies of operators
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
2016-10-12 11:39:04 +03:00
Mikhail Glukhikh e7d290f726 Refactor PSI for destructuring declarations in for: they are now children of KtParameter and not instead of it 2016-10-06 21:03:19 +03:00
Denis Zharkov 7353b08f09 Change parsing of statements starting with annotations
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
2016-10-05 10:29:29 +03:00
Nikolay Krasko 131e77927a Skip lazy parsable lambdas without actually parsing them 2016-09-19 18:53:51 +03:00
Nikolay Krasko 52cd7109c7 Use left bound element types to tight empty delegation contructor call to declaration
CONSTRUCTOR_DELEGATION_CALL and CONSTRUCTOR_DELEGATION_REFERENCE types were modified.
2016-05-12 17:25:19 +03:00
Valentin Kipyatkov 68853fecc3 Removed support for "typealias" declarations from the parser
#KT-10683 Fixed
2016-01-19 19:31:44 +03:00
Mikhail Glukhikh b78d481bb1 delegate use-site targeted annotations: parser, front-end, codegen with some tests #KT-10502 Fixed 2016-01-19 11:38:41 +03:00
Dmitry Jemerov 009e3f9cd7 rename PSI classes according to current terminology:
KtMultiDeclaration(Entry) -> KtDestructuringDeclaration(Entry)
KtFunctionLiteralExpression -> KtLambdaExpression
KtFunctionLiteralArgument -> KtLambdaArgument
KtDelegationSpecifierList -> KtSuperTypeList
KtDelegationSpecifier -> KtSuperTypeListEntry
KtDelegatorToSuperClass -> KtSuperTypeEntry
KtDelegatorToSuperCall -> KtSuperTypeCallEntry
KtDelegationByExpressionSpecifier ->KtDelegatedSuperTypeEntry
2015-12-10 16:15:13 +01:00
Pavel V. Talanov dbd49c37c1 Psi: Introduce KtScriptInitializer, a separate entity for script initializers which are quite a bit different from class initializers 2015-11-19 22:57:07 +03:00
Valentin Kipyatkov 52dc23012f Changed parsing of object and enum entries to drop "KtObjectDeclarationName" 2015-11-05 23:21:22 +03:00
Svetlana Isakova 6c4771147a Added more tests on annotations for nullable types 2015-10-16 21:58:43 +03:00
Valentin Kipyatkov 292ea7625c Removed obosolete modifier "ref" from tests 2015-10-15 19:20:11 +03:00
Valentin Kipyatkov 87cfccc2d9 Removed all places in parser where obsolete annotation syntax was allowed 2015-10-15 19:20:10 +03:00
Valentin Kipyatkov d84020b1f3 Removed special support for parsing annotations for multi-declaration in for 2015-10-15 19:20:08 +03:00
Valentin Kipyatkov 98dc8f234e Drop suppport for annotation syntax without '@' from parser 2015-10-15 19:20:07 +03:00
Svetlana Isakova b709b431ea Parse annotations on nullable types 2015-10-12 16:28:48 +03:00
Svetlana Isakova b49a3f8e00 Added test for annotations on nullable types 2015-10-12 16:28:48 +03:00
Dmitry Jemerov 1523d5bcbf removing static type assertions work in progress 2015-10-12 11:11:23 +02:00
Svetlana Isakova 9b1030de2e Annotations on type projection belong to type reference 2015-10-09 11:05:52 +03:00
Yan Zhulanow 9eeb89a6aa Rename sparam to setparam 2015-10-08 18:31:06 +03:00
Dmitry Jemerov 4ca434da54 remove support for 'trait' keyword 2015-09-22 15:00:24 +02:00
Denis Zharkov 02aafe4262 Report syntax error on unescaped annotation
Also adjust parser testData
2015-09-18 09:34:26 +03:00
Denis Zharkov daa2c8372d Do not parse '@' as a part of modifier 2015-09-18 09:34:25 +03:00
Denis Zharkov fc447e2d2f Parse some builtin annotations as modifiers
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
2015-09-08 08:53:35 +03:00
Mikhail Glukhikh 8f7b29f80a Annotation rename: target --> @Target 2015-09-07 13:42:26 +03:00
Denis Zharkov 31244edec9 Deprecate deprecated in favor of Deprecated 2015-09-04 18:19:31 +03:00
Denis Zharkov 26f9bd7b63 Deprecate some of JVM flag annotations in favor of capitilized themselves 2015-09-04 18:19:31 +03:00
Yan Zhulanow a1eb544807 Parser tests for targeted annotations 2015-08-31 15:07:15 +03:00
Yan Zhulanow 2bacbc9046 Support @field: annotations 2015-08-31 15:05:02 +03:00
Yan Zhulanow 0c87639514 Fix annotation list parsing: @identifier:[a b c] 2015-08-27 18:16:06 +03:00
Mikhail Glukhikh 3f14e74b08 Drop old enum syntax. Comma / semicolon are now a syntactic part of enum entry.
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.
2015-08-11 10:38:10 +03:00
Mikhail Glukhikh 1eac4d67de "annotation" is now parsed as an identifier. It is no longer a soft keyword.
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.
2015-07-14 16:24:55 +03:00
Denis Zharkov cf4b1ab7cd Drop obsolete annotations syntax 2015-06-12 09:55:00 +03:00
Pavel V. Talanov 07d35d305e Create import list psi element even if no directives are present
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
2015-06-08 20:51:04 +03:00
Denis Zharkov 9c574469ca Parsing: allow primary ctor in object syntactically
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
2015-06-02 14:07:48 +03:00
Denis Zharkov e4f54b5d2e Parsing: support '@[ann1 ann2]', '@file:ann' and '@file:[ann]' cases 2015-05-20 09:24:56 +03:00
Denis Zharkov f6aadec7e2 Minor, rename tests onFile -> onFileObsolete 2015-05-20 09:24:56 +03:00
Denis Zharkov 083966389a Minor, get rid of repeating parsing semantics 2015-05-20 09:24:55 +03:00