mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: call checkSearchPattern() in structural replace test
This commit is contained in:
+10
-8
@@ -63,15 +63,19 @@ public class Replacer {
|
||||
public String testReplace(String in, String what, String by, ReplaceOptions options, boolean filePattern, boolean createPhysicalFile,
|
||||
FileType sourceFileType, Language sourceDialect) {
|
||||
this.options = options;
|
||||
this.options.getMatchOptions().setSearchPattern(what);
|
||||
final MatchOptions matchOptions = this.options.getMatchOptions();
|
||||
matchOptions.setSearchPattern(what);
|
||||
this.options.setReplacement(by);
|
||||
replacementBuilder=null;
|
||||
context = null;
|
||||
replaceHandler = null;
|
||||
|
||||
this.options.getMatchOptions().clearVariableConstraints();
|
||||
MatcherImplUtil.transform(this.options.getMatchOptions());
|
||||
matchOptions.clearVariableConstraints();
|
||||
MatcherImplUtil.transform(matchOptions);
|
||||
|
||||
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(matchOptions.getFileType());
|
||||
assert profile != null;
|
||||
profile.checkSearchPattern(project, matchOptions);
|
||||
checkSupportedReplacementPattern(project, options);
|
||||
|
||||
Matcher matcher = new Matcher(project);
|
||||
@@ -91,18 +95,16 @@ public class Replacer {
|
||||
lastElement = elements[elements.length-1];
|
||||
parent = firstElement.getParent();
|
||||
|
||||
this.options.getMatchOptions().setScope(
|
||||
new LocalSearchScope(parent)
|
||||
);
|
||||
matchOptions.setScope(new LocalSearchScope(parent));
|
||||
} else {
|
||||
parent = ((LocalSearchScope)options.getMatchOptions().getScope()).getScope()[0];
|
||||
firstElement = parent.getFirstChild();
|
||||
lastElement = parent.getLastChild();
|
||||
}
|
||||
|
||||
this.options.getMatchOptions().setResultIsContextMatch(true);
|
||||
matchOptions.setResultIsContextMatch(true);
|
||||
CollectingMatchResultSink sink = new CollectingMatchResultSink();
|
||||
matcher.testFindMatches(sink, this.options.getMatchOptions());
|
||||
matcher.testFindMatches(sink, matchOptions);
|
||||
|
||||
final List<ReplacementInfo> resultPtrList = new ArrayList<ReplacementInfo>();
|
||||
|
||||
|
||||
+1
-1
@@ -1294,7 +1294,7 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase {
|
||||
" private int c = 2;\n" +
|
||||
"}";
|
||||
|
||||
String s2 = "@Modifier(\"PackageLocal\") '_Type '_Instance = '_Init?;";
|
||||
String s2 = "@Modifier(\"packageLocal\") '_Type '_Instance = '_Init?;";
|
||||
String s3 = "public $Type$ $Instance$ = $Init$;";
|
||||
|
||||
String expectedResult = "class A {\n" +
|
||||
|
||||
Reference in New Issue
Block a user