mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed tests after PY-8961 fix (formatter for py 3 parameter annotations)
This commit is contained in:
+10
-9
@@ -71,16 +71,17 @@ public class SpecifyTypeInPy3AnnotationsIntention extends TypeIntention {
|
||||
parameter = (PyParameter)parameter.replace(namedParameter);
|
||||
parameter = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(parameter);
|
||||
editor.getCaretModel().moveToOffset(parameter.getTextOffset());
|
||||
PyAnnotation annotation = namedParameter.getAnnotation();
|
||||
assert annotation != null;
|
||||
PyExpression annotationValue = annotation.getValue();
|
||||
PyAnnotation annotation = parameter instanceof PyNamedParameter? ((PyNamedParameter)parameter).getAnnotation() : null;
|
||||
if (annotation != null) {
|
||||
PyExpression annotationValue = annotation.getValue();
|
||||
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(parameter);
|
||||
int replacementStart = annotation.getStartOffsetInParent() + annotationValue.getStartOffsetInParent();
|
||||
builder.replaceRange(TextRange.create(replacementStart,
|
||||
replacementStart + annotationValue.getTextLength()), PyNames.OBJECT);
|
||||
Template template = ((TemplateBuilderImpl)builder).buildInlineTemplate();
|
||||
TemplateManager.getInstance(project).startTemplate(editor, template);
|
||||
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(parameter);
|
||||
int replacementStart = annotation.getStartOffsetInParent() + annotationValue.getStartOffsetInParent();
|
||||
builder.replaceRange(TextRange.create(replacementStart,
|
||||
replacementStart + annotationValue.getTextLength()), PyNames.OBJECT);
|
||||
Template template = ((TemplateBuilderImpl)builder).buildInlineTemplate();
|
||||
TemplateManager.getInstance(project).startTemplate(editor, template);
|
||||
}
|
||||
}
|
||||
|
||||
private void annotateReturnType(Project project, PsiElement resolved) {
|
||||
|
||||
@@ -254,7 +254,7 @@ public class PyElementGeneratorImpl extends PyElementGenerator {
|
||||
@NotNull LanguageLevel languageLevel) {
|
||||
String parameterText = name;
|
||||
if (annotation != null)
|
||||
parameterText += " : " + annotation;
|
||||
parameterText += ": " + annotation;
|
||||
if (defaultValue != null)
|
||||
parameterText += " = " + defaultValue;
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
def g(x : object=None ):
|
||||
def g(x: object=None):
|
||||
return x
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
def foo(a : object, b):
|
||||
def foo(a: object, b):
|
||||
a.
|
||||
b = 1
|
||||
Reference in New Issue
Block a user