fixed tests after PY-8961 fix (formatter for py 3 parameter annotations)

This commit is contained in:
Ekaterina Tuzova
2013-03-04 21:16:55 +04:00
parent f09ff98920
commit f34f661bb9
4 changed files with 13 additions and 12 deletions
@@ -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