SSR: introduce DefaultMatchResultSink

This commit is contained in:
Bas Leijdekkers
2015-11-11 19:45:44 +01:00
parent 9e4233ee23
commit 46fd9b2a9d
3 changed files with 53 additions and 39 deletions
@@ -0,0 +1,49 @@
/*
* Copyright 2000-2015 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.progress.ProgressIndicator;
import com.intellij.psi.PsiFile;
/**
* @author Bas Leijdekkers
*/
public class DefaultMatchResultSink implements MatchResultSink {
@Override
public void newMatch(MatchResult result) {
}
@Override
public void processFile(PsiFile element) {
}
@Override
public void setMatchingProcess(MatchingProcess matchingProcess) {
}
@Override
public void matchingFinished() {
}
@Override
public ProgressIndicator getProgressIndicator() {
return null;
}
}
@@ -158,28 +158,11 @@ public class MatcherImpl {
matchContext.setSink(
new DuplicateFilteringResultSink(
new MatchResultSink() {
new DefaultMatchResultSink() {
@Override
public void newMatch(MatchResult result) {
processor.process(result, configuration);
}
@Override
public void processFile(PsiFile element) {
}
@Override
public void setMatchingProcess(MatchingProcess matchingProcess) {
}
@Override
public void matchingFinished() {
}
@Override
public ProgressIndicator getProgressIndicator() {
return null;
}
}
)
);
@@ -1,38 +1,20 @@
package com.intellij.structuralsearch.plugin.util;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.psi.PsiFile;
import com.intellij.structuralsearch.DefaultMatchResultSink;
import com.intellij.structuralsearch.MatchResult;
import com.intellij.structuralsearch.MatchResultSink;
import com.intellij.structuralsearch.MatchingProcess;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class CollectingMatchResultSink implements MatchResultSink {
public class CollectingMatchResultSink extends DefaultMatchResultSink {
private final List<MatchResult> matches = new ArrayList<MatchResult>();
@Override
public void newMatch(MatchResult result) {
matches.add(result);
}
/* Notifies sink about starting the matching for given element
* @param element the current file
*/
public void processFile(PsiFile element) {
}
public void matchingFinished() {
}
public ProgressIndicator getProgressIndicator() {
return null;
}
public void setMatchingProcess(MatchingProcess process) {
}
@NotNull
public List<MatchResult> getMatches() {
return matches;