use of com.jetbrains.python.codeInsight.editorActions.smartEnter.enterProcessors.PyCommentBreakerEnterProcessor in project intellij-community by JetBrains.
the class PySmartEnterProcessor method process.
private void process(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile psiFile, final int attempt) throws TooManyAttemptsException {
if (attempt > MAX_ATTEMPTS) {
throw new TooManyAttemptsException();
}
try {
commit(editor);
if (myFirstErrorOffset != Integer.MAX_VALUE) {
editor.getCaretModel().moveToOffset(myFirstErrorOffset);
}
//myFirstErrorOffset = Integer.MAX_VALUE;
PsiElement statementAtCaret = getStatementAtCaret(editor, psiFile);
if (statementAtCaret == null) {
if (!new PyCommentBreakerEnterProcessor().doEnter(editor, psiFile, false)) {
SmartEnterUtil.plainEnter(editor);
}
return;
}
List<PsiElement> queue = new ArrayList<>();
collectAllElements(statementAtCaret, queue, true);
queue.add(statementAtCaret);
for (PsiElement element : queue) {
for (PyFixer fixer : ourFixers) {
fixer.apply(editor, this, element);
if (LookupManager.getInstance(project).getActiveLookup() != null) {
return;
}
PyPsiUtils.assertValid(element);
if (isUncommited(project) || !element.isValid()) {
process(project, editor, psiFile, attempt + 1);
return;
}
}
}
doEnter(statementAtCaret, editor);
} catch (IncorrectOperationException e) {
LOG.error(e);
}
}
Aggregations