3
);
- final String s125 = "a=1;";
- final String s126 = "'t:[regex(a)]";
-
- try {
- findMatchesCount(s125,s126);
- assertFalse("spaces around reg exp check",false);
- } catch(MalformedPatternException ex) {}
-
final String s101 = "class A { void b() { String d; String e; String[] f; f.length=1; f.length=1; } }";
final String s102 = "'_:[ref('T)] '_;";
1
);
- final String s103 = " a=1; ";
- final String s104 = "'T:{ ;";
- try {
- findMatchesCount(s103,s104);
- assertFalse("incorrect reg exp",false);
- } catch(MalformedPatternException ex) {
- }
-
- final String s106 = "'_ReturnType 'MethodName('_ParameterType '_Parameter);";
- final String s105 = " aaa; ";
-
- try {
- findMatchesCount(s105,s106);
- assertFalse("incorrect reg exp 2",false);
- } catch(UnsupportedPatternException ex) {
- }
-
String s107 = "class A {\n" +
" /* */\n" +
" void a() {\n" +
+/*
+ * Copyright 2000-2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.structuralsearch.impl.matcher.compiler;
import com.intellij.structuralsearch.MalformedPatternException;
test("'a:[regex( .* ) ]");
}
+ @Test(expected = MalformedPatternException.class)
+ public void testInvalidRegex() {
+ test("'T:{ ;");
+ }
+
+ @Test
+ public void testNoSpacesSurroundingRegexNeeded() {
+ test("'t:[regex(a)]");
+ final MatchVariableConstraint constraint = myOptions.getVariableConstraint("t");
+ assertEquals("a", constraint.getRegExp());
+ }
+
private void test(String pattern) {
myOptions.setSearchPattern(pattern);
StringToConstraintsTransformer.transformOldPattern(myOptions);