mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: Java string literal should not match char fix
This commit is contained in:
+11
-13
@@ -1090,23 +1090,21 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
public void visitLiteralExpression(final PsiLiteralExpression const1) {
|
||||
final PsiLiteralExpression const2 = getExpression(PsiLiteralExpression.class);
|
||||
if (const2 == null) return;
|
||||
final PsiType type1 = const1.getType();
|
||||
if (type1 != null && !myMatchingVisitor.setResult(type1.equals(const2.getType()))) {
|
||||
return;
|
||||
}
|
||||
final MatchingHandler handler = (MatchingHandler)const1.getUserData(CompiledPattern.HANDLER_KEY);
|
||||
if (handler instanceof SubstitutionHandler) {
|
||||
final PsiType type1 = const1.getType();
|
||||
if (type1 != null && !type1.equals(const2.getType())) {
|
||||
myMatchingVisitor.setResult(false);
|
||||
}
|
||||
else {
|
||||
int offset = 0;
|
||||
int length = const2.getTextLength();
|
||||
final String text = const2.getText();
|
||||
int offset = 0;
|
||||
int length = const2.getTextLength();
|
||||
final String text = const2.getText();
|
||||
|
||||
if (StringUtil.isQuotedString(text)) {
|
||||
length--;
|
||||
offset++;
|
||||
}
|
||||
myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(const2, offset, length, myMatchingVisitor.getMatchContext()));
|
||||
if (StringUtil.isQuotedString(text)) {
|
||||
length--;
|
||||
offset++;
|
||||
}
|
||||
myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(const2, offset, length, myMatchingVisitor.getMatchContext()));
|
||||
}
|
||||
else if (handler != null) {
|
||||
myMatchingVisitor.setResult(handler.match(const1, const2, myMatchingVisitor.getMatchContext()));
|
||||
|
||||
+1
@@ -282,6 +282,7 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
"}";
|
||||
assertEquals("match literal by value", 1, findMatchesCount(s3, "32"));
|
||||
assertEquals("match char with substitution", 3, findMatchesCount(s3, "\\''_x\\'"));
|
||||
assertEquals("string literal should not match char", 0, findMatchesCount(s3, "\"a\""));
|
||||
}
|
||||
|
||||
public void testCovariantArraySearch() {
|
||||
|
||||
Reference in New Issue
Block a user