From 6e7aeea50bf5153ef4cf473fb2121f03ab271522 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 16 Apr 2019 17:36:54 +0200 Subject: [PATCH] SSR: cleanup --- .../impl/matcher/GlobalMatchingVisitor.java | 4 ++-- .../impl/matcher/handlers/MatchingHandler.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java index 068c3f05998d..546476214a64 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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. +// Copyright 2000-2019 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.structuralsearch.impl.matcher; import com.intellij.dupLocator.AbstractMatchingVisitor; @@ -173,11 +173,11 @@ public class GlobalMatchingVisitor extends AbstractMatchingVisitor { */ @Override public boolean matchSequentially(NodeIterator patternNodes, NodeIterator matchNodes) { - final PsiElement current = patternNodes.current(); if (!patternNodes.hasNext()) { while (matchNodes.current() instanceof PsiComment) matchNodes.advance(); return !matchNodes.hasNext(); } + final PsiElement current = patternNodes.current(); return matchContext.getPattern().getHandler(current).matchSequentially(patternNodes, matchNodes, matchContext); } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java index 07bc73e1711e..30cb860834c8 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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. +// Copyright 2000-2019 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.structuralsearch.impl.matcher.handlers; import com.intellij.dupLocator.iterators.NodeIterator; @@ -83,12 +83,12 @@ public abstract class MatchingHandler { } private static void skipComments(NodeIterator matchNodes, PsiElement patternNode) { - final boolean skipComment = !(patternNode instanceof PsiComment); - while (skipComment && matchNodes.current() instanceof PsiComment) matchNodes.advance(); + if (patternNode instanceof PsiComment) return; + while (matchNodes.current() instanceof PsiComment) matchNodes.advance(); } private static void skipIfNecessary(NodeIterator nodes, PsiElement elementToMatchWith, MatchingStrategy strategy) { - while (strategy.shouldSkip(nodes.current(), elementToMatchWith)) { + while (nodes.hasNext() && strategy.shouldSkip(nodes.current(), elementToMatchWith)) { nodes.advance(); } } @@ -201,7 +201,7 @@ public abstract class MatchingHandler { } protected static boolean validateSatisfactionOfHandlers(NodeIterator patternNodes, MatchContext context) { - for (;patternNodes.hasNext(); patternNodes.advance()) { + for (; patternNodes.hasNext(); patternNodes.advance()) { if (!context.getPattern().getHandler(patternNodes.current()).validate(context, 0)) { return false; }