PY-16412 Better names for methods

This commit is contained in:
Mikhail Golubev
2018-02-05 21:41:59 +03:00
committed by Andrey Vlasovskikh
parent bf5a0dd8b1
commit 0456504acc
2 changed files with 9 additions and 7 deletions
@@ -191,7 +191,7 @@ public class PyAnnotateVariableTypeIntention extends PyBaseIntentionAction {
if (isInstanceAttribute(target, context)) {
final List<PyTargetExpression> 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<PyTargetExpression> 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
@@ -35,10 +35,10 @@ public class PyTypeHintGenerationUtil {
private PyTypeHintGenerationUtil() {}
public static void insertAttributeTypeComment(@NotNull PyTargetExpression target,
@NotNull String annotation,
boolean startTemplate,
@NotNull List<TextRange> typeRanges) {
public static void insertStandaloneAttributeTypeComment(@NotNull PyTargetExpression target,
@NotNull String annotation,
boolean startTemplate,
@NotNull List<TextRange> 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);