Commit Graph

16 Commits

Author SHA1 Message Date
Dmitry Jemerov
b1f84676d1 Update tests according to new formatter behavior 2017-06-14 11:40:41 +02:00
Denis Zharkov
dcc98e3839 Improve check for statements-only postfix templates
Before this change the check was quite complicated
because of cases like:
for (i in 1..9)
    foo(i)<caret>

It's not located in a block, but in the same time it's a stament.
So we had a tricky heuristics that if is parent is not a block, then
we should check if element isn't used as expression.

Of course this heuristics is wrong, e.g. for import/package nodes.

The solution is to reuse similar logic from BasicExpressionTypingVisitor.
it has been checked once that statement container is one of:
- KtBlockExpression
- KtContainerNodeForControlStructureBody
- KtWhenEntry

So there's no need to check anything else

 #KT-14986 Fixed
 #KT-14483 Fixed
2017-03-15 10:47:12 +03:00
Denis Zharkov
bd88919411 Refine predicate for 'iter' postfix template
Use IterableTypesDetection to determine if the given expression may be iterated

 #KT-14134 Fixed
 #KT-14129 Fixed
2017-03-15 10:47:12 +03:00
Denis Zharkov
0120085443 Refine expression kind definition in postfix templates
- Do not treat if without else as values
- Some statements aren't contained in block (see tests)

 #KT-14107 Fixed
 #KT-14110 Fixed
2016-10-03 10:36:48 +03:00
Denis Zharkov
3c24996073 Refine default postfix templates selector
There is new settings checkCanBeUsedAsValue
Also expression filtering are split into to parts:
- getNonFilteredExpressions is trivially goes until it reaches
first block body of some declarations
- all additional filtering is merged into Condition that is passed into
PostfixTemplateExpressionSelectorBase super-call

Notable changes for users:
- do not suggest try for non-top-level expressions
- do not suggest var/par/etc for loops
2016-10-03 10:36:48 +03:00
Denis Zharkov
ba2d2a036e Suggest postfix templates on lambda expressions 2016-10-03 10:36:48 +03:00
Denis Zharkov
54d9b4bee6 Do not suggest assignment as a subject in postfix templates
#KT-14077 Fixed
2016-10-03 10:36:48 +03:00
Denis Zharkov
18146fafdf Allow if/when/try postfix templates in expression position
#KT-14078 Fixed
2016-10-03 10:36:48 +03:00
Denis Zharkov
bff9dd4ef5 Suggest assert/return postfix templates only for statements
#KT-14079 Fixed
 #KT-14090 Fixed
2016-10-03 10:36:48 +03:00
Denis Zharkov
ce128c5d6e Do not suggest operation references in postfix templates
#KT-14087 Fixed
2016-10-03 10:36:48 +03:00
Denis Zharkov
23c0bdbd05 Add filtering of suggested expressions for postfix templates
Do not suggest qualified expression's selector or a part of user type
because they aren't really independent expressions
2016-09-22 18:11:22 +03:00
Denis Zharkov
189705727f Implement a bunch of string based postfix templates
#KT-4710 Fixed
2016-09-20 15:26:48 +03:00
Denis Zharkov
1b391123e6 Implement for/iter postfix templates
#KT-4710 In Progress
2016-09-20 15:26:47 +03:00
Denis Zharkov
b702886f0d Introduce var/val postfix templates
#KT-4710 In Progress
2016-09-20 15:26:45 +03:00
Denis Zharkov
4d28199cc2 Implement if/else/null/notnull/when/try postfix templates
#KT-4710 In Progress
2016-09-20 15:26:42 +03:00
Denis Zharkov
f18b9cceb3 Implement 'not' postfix template
#KT-4710 In Progress
2016-09-20 15:26:39 +03:00