mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
one (1) single or double quote is not a quoted string (EA-59280)
This commit is contained in:
+1
-1
@@ -481,7 +481,7 @@ public abstract class StructuralSearchProfileBase extends StructuralSearchProfil
|
||||
private void visitLiteral(PsiElement literal) {
|
||||
String value = literal.getText();
|
||||
|
||||
if (value.length() > 2 && StringUtil.isQuotedString(value)) {
|
||||
if (StringUtil.isQuotedString(value)) {
|
||||
if (mySubstitutionPatterns == null) {
|
||||
final String[] prefixes = myGlobalVisitor.getContext().getPattern().getTypedVarPrefixes();
|
||||
mySubstitutionPatterns = createPatterns(prefixes);
|
||||
|
||||
@@ -1331,6 +1331,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
public static boolean isQuotedString(@NotNull String text) {
|
||||
if (text.length() < 2) return false;
|
||||
return startsWithChar(text, '\"') && endsWithChar(text, '\"')
|
||||
|| startsWithChar(text, '\'') && endsWithChar(text, '\'');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -178,6 +178,16 @@ public class StringUtilTest extends TestCase {
|
||||
assertEquals("foo|", StringUtil.unquoteString("foo|", '|'));
|
||||
}
|
||||
|
||||
public void testIsQuotedString() {
|
||||
assertFalse(StringUtil.isQuotedString(""));
|
||||
assertFalse(StringUtil.isQuotedString("'"));
|
||||
assertFalse(StringUtil.isQuotedString("\""));
|
||||
assertTrue(StringUtil.isQuotedString("\"\""));
|
||||
assertTrue(StringUtil.isQuotedString("''"));
|
||||
assertTrue(StringUtil.isQuotedString("'ab'"));
|
||||
assertTrue(StringUtil.isQuotedString("\"foo\""));
|
||||
}
|
||||
|
||||
public void testJoin() {
|
||||
assertEquals("foo,,bar", StringUtil.join(Arrays.asList("foo", "", "bar"), ","));
|
||||
assertEquals("foo,,bar", StringUtil.join(new String[]{"foo", "", "bar"}, ","));
|
||||
|
||||
Reference in New Issue
Block a user