use of com.jetbrains.python.psi.PyAnnotation in project intellij-community by JetBrains.
the class PyFunctionFixer method doApply.
@Override
public void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyFunction function) throws IncorrectOperationException {
final PsiElement colon = PyPsiUtils.getFirstChildOfType(function, PyTokenTypes.COLON);
if (!isFakeFunction(function) && colon == null) {
final PyParameterList parameterList = function.getParameterList();
if (function.getNameNode() == null) {
processor.registerUnresolvedError(parameterList.getTextOffset());
}
final int colonOffset;
final PyAnnotation annotation = function.getAnnotation();
if (annotation != null) {
colonOffset = annotation.getTextRange().getEndOffset();
} else {
colonOffset = parameterList.getTextRange().getEndOffset();
}
editor.getDocument().insertString(colonOffset, ":");
}
}
Aggregations