mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18816 Test that glued and long string literals are not saved in stubs
This commit is contained in:
@@ -39,7 +39,7 @@ import static com.jetbrains.python.psi.PyUtil.as;
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
public class PyTypingAliasStubType extends CustomTargetExpressionStubType<PyTypingAliasStub> {
|
||||
private static final int STRING_LITERAL_LENGTH_THRESHOLD = 120;
|
||||
private static final int STRING_LITERAL_LENGTH_THRESHOLD = 100;
|
||||
|
||||
private static final Pattern TYPE_ANNOTATION_LIKE = Pattern.compile("\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*" +
|
||||
"(\\.\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)*" +
|
||||
@@ -96,7 +96,7 @@ public class PyTypingAliasStubType extends CustomTargetExpressionStubType<PyTypi
|
||||
|
||||
final PyStringLiteralExpression pyString = as(expression, PyStringLiteralExpression.class);
|
||||
if (pyString != null) {
|
||||
if (pyString.getStringNodes().size() != 1 && pyString.getTextLength() > STRING_LITERAL_LENGTH_THRESHOLD) {
|
||||
if (pyString.getStringNodes().size() != 1 || pyString.getTextLength() > STRING_LITERAL_LENGTH_THRESHOLD) {
|
||||
return false;
|
||||
}
|
||||
final String content = pyString.getStringValue();
|
||||
|
||||
@@ -5,6 +5,9 @@ __version__ = '0.1'
|
||||
S1_ok = "foo"
|
||||
S2_ok = "foo.bar"
|
||||
S3_ok = "foo.bar[baz]"
|
||||
too_long_string = "foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo.foo"
|
||||
natural_text = "Foo is baz."
|
||||
glued_string = 'foo' '.bar'
|
||||
|
||||
# Such expressions are kept as qualified expressions in PyTargetExpressionStub
|
||||
# with initializer type of ReferenceExpression instead of custom stubs for
|
||||
|
||||
Reference in New Issue
Block a user