mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't suggest live template inside string literals (PY-12349)
The previous fix was unsuccessful since we ignored only string literal elements but not their subparts.
This commit is contained in:
+5
-2
@@ -43,13 +43,16 @@ public class PythonTemplateContextType extends FileTypeBasedContextType {
|
||||
if (super.isInContext(file, offset)) {
|
||||
final PsiElement element = file.findElementAt(offset);
|
||||
if (element != null) {
|
||||
return !(isAfterDot(element) || element instanceof PsiComment || element instanceof PyStringLiteralExpression ||
|
||||
isInsideParameterList(element));
|
||||
return !(isAfterDot(element) || element instanceof PsiComment || isInsideStringLiteral(element) || isInsideParameterList(element));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isInsideStringLiteral(@NotNull PsiElement element) {
|
||||
return PsiTreeUtil.getParentOfType(element, PyStringLiteralExpression.class, false) != null;
|
||||
}
|
||||
|
||||
private static boolean isInsideParameterList(@NotNull PsiElement element) {
|
||||
return PsiTreeUtil.getParentOfType(element, PyParameterList.class) != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user