From 3886cec4a30827f265ca5ade7d0f1edce1875dce Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 16 Apr 2019 17:35:42 +0200 Subject: [PATCH] SSR: minor optimization --- .../matcher/handlers/TopLevelMatchingHandler.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.java index 4d09282f557e..1f24458c176f 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.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; @@ -48,11 +48,10 @@ public final class TopLevelMatchingHandler extends MatchingHandler implements De matchContext.getPattern().getStrategy().continueMatching(matchedNode) && matchContext.shouldRecursivelyMatch() ) { - matchContext.getMatcher().matchContext( - new SsrFilteringNodeIterator( - new SiblingNodeIterator(matchedNode.getFirstChild()) - ) - ); + PsiElement child = matchedNode.getFirstChild(); + if (child != null) { + matchContext.getMatcher().matchContext(new SsrFilteringNodeIterator(new SiblingNodeIterator(child))); + } } return matched; }