mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
SSR: simplify matcher, only use internal match context and pattern
Prevents confusion between internal match context and passed in options and patterns, because options and patterns can no longer be passed in through methods. It is now more clear when a new matcher needs to be created: every pattern has its own matcher. This also means that SSBasedInspection no longer operates on match contexts, but uses and caches matchers. This fixes a case of duplicate highlights in the inspection. GitOrigin-RevId: 6e52fef819d5e6bbb02f7cc9a56b1f56968d8c45
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9be86cc281
commit
52a03eb981
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.refactoring.typeMigration.rules.guava;
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
@@ -48,11 +34,11 @@ public class GuavaOptionalConversionUtil {
|
||||
final PsiExpression[] expressions = argumentList.getExpressions();
|
||||
if (expressions.length == 1) {
|
||||
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<MatchResult> results = matcher.testFindMatches(expression.getText(), options, false);
|
||||
final Matcher matcher = new Matcher(methodCall.getProject(), options);
|
||||
final List<MatchResult> results = matcher.testFindMatches(expression.getText(), false, StdFileTypes.JAVA, false);
|
||||
if (!results.isEmpty()) {
|
||||
final MatchResult result = results.get(0);
|
||||
if (result.getStart() == 0 && result.getEnd() == -1) {
|
||||
|
||||
Reference in New Issue
Block a user