mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-16412 Better names for methods
This commit is contained in:
committed by
Andrey Vlasovskikh
parent
bf5a0dd8b1
commit
0456504acc
+2
-2
@@ -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
|
||||
|
||||
+7
-5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user