Commit Graph

330 Commits

Author SHA1 Message Date
Ilya Kirillov 1535873c07 Do not try to lazy parse a block without opening bracket
It can consume the whole file in such case
which will result PsiBuilder going crazy

#KT-36191 fixed
2020-04-16 15:40:21 +03:00
Victor Petukhov cec747349e Fix PSI tests for correct parsing them by the ANTLR grammar 2020-04-02 19:02:31 +03:00
Mikhail Zarechenskiy 4aa195e912 FIC: Parse fun keyword in front of interface as a modifier 2020-01-17 19:35:05 +03:00
Ilya Chernikov 7bb9f97b11 Allow to separate top-level script declarations and statements with semicolon
This fix allows to write one-liner scripts like "val x = 3; println(x)", which
were previously rejected by the parser.
2019-12-02 16:46:54 +01:00
victor.petukhov 62d204f4d6 Support trailing comma
^KT-34743 Fixed
2019-11-01 19:40:20 +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
Igor Yakovlev da4d8a8c90 Parser invalid error advancing for postfix type parameters list #KT-30835 Fixed 2019-04-05 19:50:42 +03:00
Yaroslav Russkih 028a311949 Use https everywhere - tests and test data 2019-02-19 21:35:36 +01:00
Denis Zharkov 82537cdc8b Add recovery for missing comma between arguments
^KT-13497 Fixed
2019-01-17 14:58:01 +03:00
Denis Zharkov db53c4bea4 Add test for obsolete recovery case (semi-finished extension)
^KT-7405 Obsolete
2019-01-17 14:56:42 +03:00
Denis Zharkov 65e6e21d0f Add recovery for import lists in the middle of the file
Note, that it only works for top-level declarations

^KT-7185 Fixed
2019-01-17 14:56:42 +03:00
Denis Zharkov e6710b6fa2 Add recovery for value parameter without type or name
The case for KT-7237 belongs to /NoGTInTypeArguments test
It was fixed implicitly: before it recovery was working but the name for
the next parameter was attached to type argument list.
After that change, parameter without name gets parsed correctly (with an
error of course)

^KT-13731 Fixed
^KT-7237 Fixed
2019-01-17 14:56:42 +03:00
Denis Zharkov 5437a0e478 Add recovery for enum declaration without 'class' keyword
^KT-13703 Fixed
2019-01-17 14:56:42 +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
Nikolay Krasko 449069b1b7 Attach preceding line comments to property accessors (KT-25417)
#KT-25417 Fixed
2018-08-02 14:38:25 +03:00
Mikhail Zarechenskiy a765ee41d7 Introduce uL/UL suffix to represent numbers of unsigned long type
#KT-24663 Fixed
2018-06-27 14:21:12 +03:00
Mikhail Zarechenskiy 7c44992016 Allow any case for u suffix
#KT-24663 In Progress
2018-06-27 14:21:07 +03:00
Dmitry Petrov 67247ee490 'val' in 'when' subject can't have modifiers (annotations are ok) 2018-06-20 14:06:34 +03:00
Dmitry Petrov 53fd883e2a Additional parser tests for both subject val and expression in 'when' 2018-06-20 14:06:34 +03:00
Dmitry Petrov 8aec99f4b5 Fix parsing variable declaration in when subject
- parse destructuring declarations
- parse annotations on variable declaration in when subject
2018-06-20 14:06:34 +03:00
Mikhail Zarechenskiy bf5f710f39 Parse integers with unsigned ('u') suffix 2018-06-04 18:19:34 +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 7d66af6583 Always assign shebang comment to same position before package 2017-08-07 12:17:20 +03:00
Nikolay Krasko 8d226594ff Put comments and whitespaces under body in script files
It's more consistent to normal function body for IDE.
Doc comments in file beginning are now sticks to declarations
correctly.
Moving declarations at the end of scripts is fixed
2017-08-07 12:17:17 +03:00
Nikolay Krasko 0cd3e4f3a4 Minor: JetFile -> KtFile 2017-05-18 20:00:17 +03:00
Alexey Sedunov 5d87276cff PSI: Introduce KtImportAlias element 2017-05-16 13:10:35 +03:00
Mikhail Zarechenskiy d3fd96ceed Parse collection literals as atomic expressions 2017-03-22 17:59:58 +03:00
Nikolay Krasko afc0892d1f Synchronize state of parser and lexer for LONG_TEMPLATE_ENTRY (KT-14865)
Lexer monitors "long string template" state end and will produce
LONG_TEMPLATE_ENTRY_END token when it is reached. If parser continues
without waiting for it, it will eventually get handling token that
will produce irrelevant error. Such behaviour also breaks lazy
elements (LAMBDA_EXPRESSION in this case) contract: range of parsed text
in eager mode should be same to one parsed in lazy mode.

 #KT-14865 Fixed
2017-03-20 17:47:29 +03:00
Mikhail Zarechenskiy da53317357 Fix exception when type parameters appear in object declaration
#KT-14536 Fixed
2017-03-14 01:10:00 +03:00
Dmitry Petrov a974ed1049 Support custom accessors for top-level properties in scripts. 2017-01-26 10:12:13 +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 a3338b2230 Allow only 'out' modifier for value parameter modifiers in functional type
(comments also mention 'lazy' and 'ref'; these value parameter modifiers are unsupported, anyway).
2016-12-15 23:58:02 +03:00
Stanislav Erokhin 42440f50dc Remove soft keyword coroutine & isCoroutine from ValueParameterDescriptor. 2016-12-15 23:57:56 +03:00
Dmitry Petrov cf4fb1eb25 Since '@A R.() -> T' is now parsed as '@A (R.() -> T)',
receiver type with modifiers or annotations should be surrounded in parentheses on rendering: '(@A R).() -> T'

This also fixes stub builder tests (which check that stubs are consistent with rendered descriptors).
2016-12-15 23:57:42 +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
Mikhail Zarechenskiy 4b23c50bf8 Parse expressions like '1._foo()' after dot as references 2016-11-17 22:58:40 +03:00
Mikhail Zarechenskiy a77290e572 Lexer: support underscores in numeric literals 2016-11-08 18:46:51 +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
Denis Zharkov 75a51d915f Implement parsing of desctructuring declarations in lambdas
#KT-5828 In Progress
2016-09-19 20:22:57 +03:00
Nikolay Krasko 131e77927a Skip lazy parsable lambdas without actually parsing them 2016-09-19 18:53:51 +03:00
Denis Zharkov 4725dd3028 Implement recovery for incomplete expression before declaration
It's needed when declarations are parsed as a part of previous expression
(see tests)

Currently we apply this kind of recovery in a conservative way,
only when declaration starts at the next line, and while
the condition could be relaxed, there's no need to do this

 #KT-4948 Fixed
 #KT-7118 Fixed
2016-07-15 18:59:31 +03:00
Denis Zharkov fcb870a303 Add EOL to EXPRESSION_FOLLOW recovery set
This change is used in further commits, but it's extracted
to emphasize that testData modifications are caused by this.
2016-07-15 18:27:00 +03:00
Denis Zharkov 3aa1a56cb9 Extend recovery set when expecting property accessor
#KT-12987 Fixed
2016-07-08 16:06:47 +03:00
Denis Zharkov f1026935a0 Add recovery for properties without name
If property name is parsed on the next line and declaration is invalid
(no receiver/type/initializer), treat that name as it does not belong to property

 #KT-12987 In Progress
2016-07-08 16:06:47 +03:00