From 0456504acca044105fb063b4c0c844a8532c2f23 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 23 Jan 2018 15:04:54 +0300 Subject: [PATCH] PY-16412 Better names for methods --- .../intentions/PyAnnotateVariableTypeIntention.java | 4 ++-- .../intentions/PyTypeHintGenerationUtil.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateVariableTypeIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateVariableTypeIntention.java index 507e1e3a1e67..90fe303da4be 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateVariableTypeIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyAnnotateVariableTypeIntention.java @@ -191,7 +191,7 @@ public class PyAnnotateVariableTypeIntention extends PyBaseIntentionAction { if (isInstanceAttribute(target, context)) { final List classLevelAttrs = findClassLevelDefinitions(target, context); if (classLevelAttrs.isEmpty()) { - PyTypeHintGenerationUtil.insertAttributeAnnotation(target, annotationText, true); + PyTypeHintGenerationUtil.insertStandaloneAttributeAnnotation(target, annotationText, true); } else { PyTypeHintGenerationUtil.insertVariableAnnotation(classLevelAttrs.get(0), annotationText, true); @@ -210,7 +210,7 @@ public class PyAnnotateVariableTypeIntention extends PyBaseIntentionAction { if (isInstanceAttribute(target, context)) { final List classLevelAttrs = findClassLevelDefinitions(target, context); if (classLevelAttrs.isEmpty()) { - PyTypeHintGenerationUtil.insertAttributeTypeComment(target, annotationText, true, typeRanges); + PyTypeHintGenerationUtil.insertStandaloneAttributeTypeComment(target, annotationText, true, typeRanges); } else { // Use existing class level definition (say, assignment of the default value) for annotation diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java index 412fc5a4d202..0c25c5077c34 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyTypeHintGenerationUtil.java @@ -35,10 +35,10 @@ public class PyTypeHintGenerationUtil { private PyTypeHintGenerationUtil() {} - public static void insertAttributeTypeComment(@NotNull PyTargetExpression target, - @NotNull String annotation, - boolean startTemplate, - @NotNull List typeRanges) { + public static void insertStandaloneAttributeTypeComment(@NotNull PyTargetExpression target, + @NotNull String annotation, + boolean startTemplate, + @NotNull List typeRanges) { final PyClass pyClass = target.getContainingClass(); if (pyClass == null) { @@ -61,7 +61,9 @@ public class PyTypeHintGenerationUtil { } } - public static void insertAttributeAnnotation(@NotNull PyTargetExpression target, @NotNull String annotation, boolean startTemplate) { + public static void insertStandaloneAttributeAnnotation(@NotNull PyTargetExpression target, + @NotNull String annotation, + boolean startTemplate) { final LanguageLevel langLevel = LanguageLevel.forElement(target); if (langLevel.isOlderThan(LanguageLevel.PYTHON36)) { throw new IllegalArgumentException("Target '" + target.getText() + "' doesn't belong to Python 3.6+ project: " + langLevel);