diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/rules/guava/GuavaOptionalConversionUtil.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/rules/guava/GuavaOptionalConversionUtil.java index 72492bf07fae..4ffaefea983b 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/rules/guava/GuavaOptionalConversionUtil.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/rules/guava/GuavaOptionalConversionUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -50,9 +50,9 @@ public class GuavaOptionalConversionUtil { final PsiExpression expression = expressions[0]; Matcher matcher = new Matcher(methodCall.getProject()); final MatchOptions options = new MatchOptions(); + options.setSearchPattern(GuavaOptionalConversionRule.OPTIONAL_CONVERTOR_PATTERN); options.setFileType(StdFileTypes.JAVA); - final List results = - matcher.testFindMatches(expression.getText(), GuavaOptionalConversionRule.OPTIONAL_CONVERTOR_PATTERN, options, false); + final List results = matcher.testFindMatches(expression.getText(), options, false); if (!results.isEmpty()) { final MatchResult result = results.get(0); if (result.getStart() == 0 && result.getEnd() == -1) { diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java b/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java index 747c17625095..ba8c03846aee 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2017 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; import com.intellij.openapi.fileTypes.FileType; @@ -26,34 +41,30 @@ public class Matcher extends MatcherImpl { * @throws MalformedPatternException * @throws UnsupportedPatternException */ - public void findMatches(MatchResultSink sink,MatchOptions options) throws - MalformedPatternException, UnsupportedPatternException - { + public void findMatches(MatchResultSink sink, MatchOptions options) throws MalformedPatternException, UnsupportedPatternException { super.findMatches(sink,options); } /** * Finds the matches of given pattern starting from given tree element. * @param source string for search - * @param pattern to be searched * @return list of matches found * @throws MalformedPatternException * @throws UnsupportedPatternException */ public List testFindMatches(String source, - String pattern, - MatchOptions options, - boolean filePattern, - FileType sourceFileType, - String sourceExtension, - boolean physicalSourceFile) + MatchOptions options, + boolean filePattern, + FileType sourceFileType, + String sourceExtension, + boolean physicalSourceFile) throws MalformedPatternException, UnsupportedPatternException { - return super.testFindMatches(source, pattern, options, filePattern, sourceFileType, sourceExtension, physicalSourceFile); + return super.testFindMatches(source, options, filePattern, sourceFileType, sourceExtension, physicalSourceFile); } - public List testFindMatches(String source, String pattern, MatchOptions options, boolean filePattern) + public List testFindMatches(String source, MatchOptions options, boolean filePattern) throws MalformedPatternException, UnsupportedPatternException { - return super.testFindMatches(source, pattern, options, filePattern); + return super.testFindMatches(source, options, filePattern); } /** @@ -63,10 +74,9 @@ public class Matcher extends MatcherImpl { * @throws MalformedPatternException * @throws UnsupportedPatternException */ - public void testFindMatches(MatchResultSink sink,MatchOptions options) + public void testFindMatches(MatchResultSink sink, MatchOptions options) throws MalformedPatternException, UnsupportedPatternException { - - super.testFindMatches(sink,options); + super.testFindMatches(sink, options); } /** @@ -76,9 +86,8 @@ public class Matcher extends MatcherImpl { * @throws UnsupportedPatternException */ @NotNull - public List matchByDownUp(PsiElement element, MatchOptions options) throws - MalformedPatternException, UnsupportedPatternException - { + public List matchByDownUp(PsiElement element, MatchOptions options) + throws MalformedPatternException, UnsupportedPatternException { return super.matchByDownUp(element, options); } } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java index 8a7c0b502f32..9f4a7aef4451 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java @@ -347,13 +347,11 @@ public class MatcherImpl { /** * Finds the matches of given pattern starting from given tree element. * @param source string for search - * @param pattern to be searched * @return list of matches found * @throws MalformedPatternException * @throws UnsupportedPatternException */ protected List testFindMatches(String source, - String pattern, MatchOptions options, boolean filePattern, FileType sourceFileType, @@ -370,7 +368,6 @@ public class MatcherImpl { sourceExtension, project, physicalSourceFile); - options.setSearchPattern(pattern); options.setScope(new LocalSearchScope(elements)); testFindMatches(sink, options); } @@ -385,8 +382,8 @@ public class MatcherImpl { return sink.getMatches(); } - protected List testFindMatches(String source, String pattern, MatchOptions options, boolean filePattern) { - return testFindMatches(source, pattern, options, filePattern, options.getFileType(), null, false); + protected List testFindMatches(String source, MatchOptions options, boolean filePattern) { + return testFindMatches(source, options, filePattern, options.getFileType(), null, false); } class TaskScheduler implements MatchingProcess { diff --git a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java index 426097f4b91a..bac669e88c49 100644 --- a/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java +++ b/platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java @@ -81,12 +81,11 @@ abstract class StructuralSearchTestCase extends LightQuickFixTestCase { if (transform) { MatcherImplUtil.transform(options); } - pattern = options.getSearchPattern(); options.setFileType(patternFileType); options.setDialect(patternLanguage); MatcherImpl.validate(getProject(), options); - return testMatcher.testFindMatches(in, pattern, options, filePattern, sourceFileType, sourceExtension, physicalSourceFile); + return testMatcher.testFindMatches(in, options, filePattern, sourceFileType, sourceExtension, physicalSourceFile); } protected List findMatches(String in, String pattern, boolean filePattern, FileType patternFileType) {