LookupElement br = createKeyword(position, PsiKeyword.BREAK);
LookupElement cont = createKeyword(position, PsiKeyword.CONTINUE);
- if (!psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
- or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
- psiElement(PsiClassInitializer.class))).accepts(position)) {
- br = TailTypeDecorator.withTail(br, TailType.SEMICOLON);
- cont = TailTypeDecorator.withTail(cont, TailType.SEMICOLON);
+ TailType tailType;
+ if (psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
+ or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
+ psiElement(PsiClassInitializer.class))).accepts(position)) {
+ tailType = TailType.HUMBLE_SPACE;
}
+ else {
+ tailType = TailType.SEMICOLON;
+ }
+ br = TailTypeDecorator.withTail(br, tailType);
+ cont = TailTypeDecorator.withTail(cont, tailType);
if (loop != null && new InsideElementFilter(new ClassFilter(PsiStatement.class)).isAcceptable(position, loop)) {
result.addElement(br);
* @return Ensures that first elements in hierarchy accepted by patterns appear in specified order
*/
public Self insideSequence(final boolean strict, @NotNull final ElementPattern<? extends ParentType>... patterns) {
- return with(new PatternCondition<T>("condInside") {
+ return with(new PatternCondition<T>("insideSequence") {
public boolean accepts(@NotNull final T t, final ProcessingContext context) {
int i = 0;
ParentType element = strict ? getParent(t) : t;
- while (element != null && i >= patterns.length) {
+ while (element != null && i < patterns.length) {
for (int j = i; j < patterns.length; j++) {
- if (patterns[j].getCondition().accepts(t, context)) {
+ if (patterns[j].accepts(element, context)) {
if (i != j) return false;
i++;
break;
}
element = getParent(element);
}
- return false;
+ return true;
}
});
}