LUCENE-9864: Enforce @Override annotation everywhere (#40)

Requiring the annotation is helpful because if an abstract method is removed, the concrete methods will then show up as compile errors: preventing dead code from being accidentally left behind.

Co-authored-by: Robert Muir <rmuir@apache.org>
This commit is contained in:
zacharymorn 2021-03-25 14:50:38 -07:00 committed by GitHub
parent a38713907d
commit 3ed87c867a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
135 changed files with 250 additions and 33 deletions

View File

@ -132,6 +132,12 @@ configure(project(":lucene:queryparser")) {
text = text.replace(
"public class QueryParser ",
'@SuppressWarnings("unused") public class QueryParser ')
text = text.replace(
"final public Query TopLevelQuery(",
"@Override final public Query TopLevelQuery(")
text = text.replace(
"public void ReInit(CharStream ",
"@Override public void ReInit(CharStream ")
return text
})
}

View File

@ -570,7 +570,7 @@ index 0000000..0cc2b60
+ )
+)
diff --git a/compiler/generator_java.c b/compiler/generator_java.c
index 2958452..966adb4 100644
index 2958452..c254dbe 100644
--- a/compiler/generator_java.c
+++ b/compiler/generator_java.c
@@ -272,7 +272,7 @@ static void generate_AE(struct generator * g, struct node * p) {
@ -582,7 +582,21 @@ index 2958452..966adb4 100644
break;
}
}
@@ -1140,6 +1140,7 @@ static void generate_class_begin(struct generator * g) {
@@ -941,9 +941,12 @@ static void generate_define(struct generator * g, struct node * p) {
* be required to allow the SnowballProgram base class to invoke them.
* FIXME: Is this avoidable?
*/
- if (q->type == t_routine && !q->used_in_among) {
+ if (q->used_in_among) {
+ g->S[0] = "public";
+ } else if (q->type == t_routine) {
g->S[0] = "private";
} else {
+ w(g, "~N~M@Override");
g->S[0] = "public";
}
g->V[0] = q;
@@ -1140,6 +1143,7 @@ static void generate_class_begin(struct generator * g) {
w(g, " {~+~N"
"~N"
"~Mprivate static final long serialVersionUID = 1L;~N"
@ -590,7 +604,7 @@ index 2958452..966adb4 100644
"~N");
}
@@ -1186,7 +1187,7 @@ static void generate_among_table(struct generator * g, struct among * x) {
@@ -1186,7 +1190,7 @@ static void generate_among_table(struct generator * g, struct among * x) {
if (v->function != 0) {
w(g, ", \"");
write_varname(g, v->function);

View File

@ -34,6 +34,7 @@ org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
org.eclipse.jdt.core.compiler.problem.unusedImport=error
org.eclipse.jdt.core.compiler.problem.unusedLocal=error
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.source=11

View File

@ -62,7 +62,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore

View File

@ -1066,6 +1066,7 @@ private boolean r_Suffix_All_alef_maqsura() {
return true;
}
@Override
public boolean stem() {
B_is_noun = true;
B_is_verb = true;

View File

@ -353,6 +353,7 @@ private boolean r_ending() {
return true;
}
@Override
public boolean stem() {
r_mark_regions();
limit_backward = cursor;

View File

@ -769,6 +769,7 @@ private boolean r_adjetiboak() {
return true;
}
@Override
public boolean stem() {
r_mark_regions();
limit_backward = cursor;

View File

@ -850,6 +850,7 @@ private boolean r_residual_suffix() {
return true;
}
@Override
public boolean stem() {
r_mark_regions();
limit_backward = cursor;

View File

@ -263,6 +263,7 @@ private boolean r_undouble() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_mark_regions();

View File

@ -595,6 +595,7 @@ private boolean r_standard_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -865,6 +865,7 @@ private boolean r_postlude() {
return true;
}
@Override
public boolean stem() {
lab0: {
int v_1 = cursor;

View File

@ -976,6 +976,7 @@ private boolean r_verb_exceptions() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_mark_regions();

View File

@ -685,6 +685,7 @@ private boolean r_tidy() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_mark_regions();

View File

@ -1060,6 +1060,7 @@ private boolean r_un_accent() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -528,6 +528,7 @@ private boolean r_standard_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -499,6 +499,7 @@ private boolean r_standard_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -2412,6 +2412,7 @@ private boolean r_step7() {
return true;
}
@Override
public boolean stem() {
limit_backward = cursor;
cursor = limit;

View File

@ -164,6 +164,7 @@ public boolean r_CONSONANT() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
if (cursor >= limit)

View File

@ -596,6 +596,7 @@ private boolean r_plur_owner() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_mark_regions();

View File

@ -264,6 +264,7 @@ private boolean r_remove_second_order_prefix() {
return true;
}
@Override
public boolean stem() {
I_measure = 0;
int v_1 = cursor;

View File

@ -365,6 +365,7 @@ private boolean r_verb_sfx() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_initial_morph();

View File

@ -859,6 +859,7 @@ private boolean r_vowel_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -1346,6 +1346,7 @@ private boolean r_measure() {
return true;
}
@Override
public boolean stem() {
B_Y_found = false;
B_stemmed = false;

View File

@ -444,6 +444,7 @@ private boolean r_fix_gd() {
return true;
}
@Override
public boolean stem() {
I_p1 = limit;
int v_1 = cursor;

View File

@ -1503,6 +1503,7 @@ private boolean r_respell() {
return true;
}
@Override
public boolean stem() {
limit_backward = cursor;
cursor = limit;

View File

@ -262,6 +262,7 @@ private boolean r_remove_category_3() {
return true;
}
@Override
public boolean stem() {
limit_backward = cursor;
cursor = limit;

View File

@ -228,6 +228,7 @@ private boolean r_other_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_mark_regions();

View File

@ -464,6 +464,7 @@ private boolean r_Step_5b() {
return true;
}
@Override
public boolean stem() {
B_Y_found = false;
int v_1 = cursor;

View File

@ -767,6 +767,7 @@ private boolean r_residual_form() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -755,6 +755,7 @@ private boolean r_vowel_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_prelude();

View File

@ -459,6 +459,7 @@ private boolean r_tidy_up() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
lab0: {

View File

@ -3658,6 +3658,7 @@ private boolean r_Step_3() {
return true;
}
@Override
public boolean stem() {
r_cyr_to_lat();
r_prelude();

View File

@ -842,6 +842,7 @@ private boolean r_residual_suffix() {
return true;
}
@Override
public boolean stem() {
r_mark_regions();
limit_backward = cursor;

View File

@ -229,6 +229,7 @@ private boolean r_other_suffix() {
return true;
}
@Override
public boolean stem() {
int v_1 = cursor;
r_mark_regions();

View File

@ -1904,6 +1904,7 @@ private boolean r_remove_tense_suffix() {
return true;
}
@Override
public boolean stem() {
B_found_vetrumai_urupu = false;
int v_1 = cursor;

View File

@ -2248,6 +2248,7 @@ private boolean r_postlude() {
return true;
}
@Override
public boolean stem() {
if (!r_more_than_one_syllable_word())
{

View File

@ -1353,6 +1353,7 @@ private boolean r_standard_suffix() {
return true;
}
@Override
public boolean stem() {
r_prelude();
int v_2 = cursor;

View File

@ -162,6 +162,7 @@ final class LegacyFieldsIndexReader extends FieldsIndex {
return hi;
}
@Override
long getStartPointer(int docID) {
if (docID < 0 || docID >= maxDoc) {
throw new IllegalArgumentException("docID out of range [0-" + maxDoc + "]: " + docID);

View File

@ -619,6 +619,7 @@ final class Lucene70DocValuesProducer extends DocValuesProducer {
long blockEndOffset;
LongValues values;
@Override
public long get(long index) {
final long block = index >>> shift;
if (this.block != block) {

View File

@ -133,6 +133,7 @@ public class Lucene60PointsWriter extends PointsWriter {
throw new IllegalStateException();
}
@Override
public void visit(int docID, byte[] packedValue) throws IOException {
writer.add(packedValue, docID);
}

View File

@ -81,6 +81,7 @@ public class CachingNaiveBayesClassifier extends SimpleNaiveBayesClassifier {
}
/** Transforms values into a range between 0 and 1 */
@Override
protected List<ClassificationResult<BytesRef>> assignClassNormalizedList(String inputDocument)
throws IOException {
String[] tokenizedText = tokenize(inputDocument);

View File

@ -477,6 +477,7 @@ public class FSTTermsReader extends FieldsProducer {
this.fsaState = -1;
}
@Override
public String toString() {
return "arc=" + fstArc + " state=" + fsaState;
}

View File

@ -108,6 +108,7 @@ final class SimpleTextBKDReader extends PointValues implements Accountable {
}
}
@Override
public void intersect(IntersectVisitor visitor) throws IOException {
intersect(getIntersectState(visitor), 1, minPackedValue, maxPackedValue);
}

View File

@ -99,6 +99,7 @@ class SimpleTextPointsWriter extends PointsWriter {
throw new IllegalStateException();
}
@Override
public void visit(int docID, byte[] packedValue) throws IOException {
writer.add(packedValue, docID);
}

View File

@ -155,6 +155,7 @@ public class Lucene86PointsWriter extends PointsWriter {
throw new IllegalStateException();
}
@Override
public void visit(int docID, byte[] packedValue) throws IOException {
writer.add(packedValue, docID);
}

View File

@ -119,6 +119,7 @@ public class FieldType implements IndexableFieldType {
*
* @see #setTokenized(boolean)
*/
@Override
public boolean tokenized() {
return this.tokenized;
}

View File

@ -347,6 +347,7 @@ public abstract class RangeFieldQuery extends Query {
return Relation.CELL_CROSSES_QUERY;
}
@Override
boolean matches(byte[] queryPackedValue, byte[] packedValue, int numDims, int bytesPerDim) {
return INTERSECTS.matches(queryPackedValue, packedValue, numDims, bytesPerDim)
&& WITHIN.matches(queryPackedValue, packedValue, numDims, bytesPerDim) == false;

View File

@ -457,6 +457,7 @@ public final class ShapeField {
}
/** pretty print the triangle vertices */
@Override
public String toString() {
String result =
(aX + ", " + aY)

View File

@ -1454,6 +1454,7 @@ public final class Tessellator {
}
/** pretty print the triangle vertices */
@Override
public String toString() {
String result =
vertex[0].x

View File

@ -65,6 +65,7 @@ public abstract class BaseTermsEnum extends TermsEnum {
}
}
@Override
public AttributeSource attributes() {
if (atts == null) {
atts = new AttributeSource();

View File

@ -31,30 +31,37 @@ public abstract class FilterSortedNumericDocValues extends SortedNumericDocValue
this.in = in;
}
@Override
public boolean advanceExact(int target) throws IOException {
return in.advanceExact(target);
}
@Override
public long nextValue() throws IOException {
return in.nextValue();
}
@Override
public int docValueCount() {
return in.docValueCount();
}
@Override
public int docID() {
return in.docID();
}
@Override
public int nextDoc() throws IOException {
return in.nextDoc();
}
@Override
public int advance(int target) throws IOException {
return in.advance(target);
}
@Override
public long cost() {
return in.cost();
}

View File

@ -33,46 +33,57 @@ public class FilterSortedSetDocValues extends SortedSetDocValues {
this.in = in;
}
@Override
public boolean advanceExact(int target) throws IOException {
return in.advanceExact(target);
}
@Override
public long nextOrd() throws IOException {
return in.nextOrd();
}
@Override
public BytesRef lookupOrd(long ord) throws IOException {
return in.lookupOrd(ord);
}
@Override
public long getValueCount() {
return in.getValueCount();
}
@Override
public long lookupTerm(BytesRef key) throws IOException {
return in.lookupTerm(key);
}
@Override
public TermsEnum termsEnum() throws IOException {
return in.termsEnum();
}
@Override
public TermsEnum intersect(CompiledAutomaton automaton) throws IOException {
return in.intersect(automaton);
}
@Override
public int docID() {
return in.docID();
}
@Override
public int nextDoc() throws IOException {
return in.nextDoc();
}
@Override
public int advance(int target) throws IOException {
return in.advance(target);
}
@Override
public long cost() {
return in.cost();
}

View File

@ -40,6 +40,7 @@ class FreqProxFields extends Fields {
}
}
@Override
public Iterator<String> iterator() {
return fields.keySet().iterator();
}
@ -137,6 +138,7 @@ class FreqProxFields extends Fields {
ord = -1;
}
@Override
public SeekStatus seekCeil(BytesRef text) {
// TODO: we could instead keep the BytesRefHash
// intact so this is a hash lookup
@ -173,6 +175,7 @@ class FreqProxFields extends Fields {
}
}
@Override
public void seekExact(long ord) {
this.ord = (int) ord;
int textStart = postingsArray.textStarts[sortedTermIDs[this.ord]];
@ -281,6 +284,7 @@ class FreqProxFields extends Fields {
* @see TermState
* @see #seekExact(BytesRef, TermState)
*/
@Override
public TermState termState() throws IOException {
return new TermState() {
@Override

View File

@ -2368,6 +2368,7 @@ public class IndexWriter
*
* <p>The Set is unmodifiable.
*/
@Override
public synchronized Set<SegmentCommitInfo> getMergingSegments() {
return Collections.unmodifiableSet(mergingSegments);
}
@ -6271,6 +6272,7 @@ public class IndexWriter
writer.merge(merge);
}
@Override
public String toString() {
return writer.segString();
}

View File

@ -97,6 +97,7 @@ public final class SoftDeletesDirectoryReaderWrapper extends FilterDirectoryRead
this.field = field;
}
@Override
protected LeafReader[] wrap(List<? extends LeafReader> readers) {
List<LeafReader> wrapped = new ArrayList<>(readers.size());
for (LeafReader reader : readers) {

View File

@ -83,6 +83,7 @@ public abstract class CachingCollector extends FilterCollector {
// doesn't mean the
// wrapped collector doesn't need it to do its job.
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
postCollection();
final LeafCollector in = this.in.getLeafCollector(context);
@ -126,6 +127,7 @@ public abstract class CachingCollector extends FilterCollector {
}
}
@Override
public void replay(Collector other) throws IOException {
postCollection();
if (!isCached()) {
@ -150,6 +152,7 @@ public abstract class CachingCollector extends FilterCollector {
scores = new ArrayList<>();
}
@Override
protected NoScoreCachingLeafCollector wrap(LeafCollector in, int maxDocsToCache) {
return new ScoreCachingLeafCollector(in, maxDocsToCache);
}

View File

@ -404,6 +404,7 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
else return Explanation.noMatch(this.toString());
}
@Override
public DoubleValuesSource rewrite(IndexSearcher searcher) throws IOException {
return this;
}

View File

@ -40,6 +40,7 @@ public abstract class IndriScorer extends Scorer {
@Override
public abstract float score() throws IOException;
@Override
public abstract float smoothingScore(int docId) throws IOException;
@Override

View File

@ -92,7 +92,6 @@ public class AxiomaticF1EXP extends Axiomatic {
"tf, term frequency computed as 1 + log(1 + log(freq)) from:",
Explanation.match((float) freq, "freq, number of occurrences of term in the document"));
}
;
@Override
protected Explanation lnExplain(BasicStats stats, double freq, double docLen) {
@ -104,15 +103,15 @@ public class AxiomaticF1EXP extends Axiomatic {
"avgdl, average length of field across all documents"),
Explanation.match((float) docLen, "dl, length of field"));
}
;
@Override
protected Explanation tflnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) tfln(stats, freq, docLen),
"tfln, mixed term frequency and document length, equals to 1");
}
;
@Override
protected Explanation idfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) idf(stats, freq, docLen),
@ -121,5 +120,4 @@ public class AxiomaticF1EXP extends Axiomatic {
(float) stats.getNumberOfDocuments(), "N, total number of documents with field"),
Explanation.match((float) stats.getDocFreq(), "n, number of documents containing term"));
}
;
}

View File

@ -83,7 +83,6 @@ public class AxiomaticF1LOG extends Axiomatic {
"tf, term frequency computed as 1 + log(1 + log(freq)) from:",
Explanation.match((float) freq, "freq, number of occurrences of term in the document"));
}
;
@Override
protected Explanation lnExplain(BasicStats stats, double freq, double docLen) {
@ -95,15 +94,15 @@ public class AxiomaticF1LOG extends Axiomatic {
"avgdl, average length of field across all documents"),
Explanation.match((float) docLen, "dl, length of field"));
}
;
@Override
protected Explanation tflnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) tfln(stats, freq, docLen),
"tfln, mixed term frequency and document length, equals to 1");
}
;
@Override
protected Explanation idfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) idf(stats, freq, docLen),
@ -112,5 +111,4 @@ public class AxiomaticF1LOG extends Axiomatic {
(float) stats.getNumberOfDocuments(), "N, total number of documents with field"),
Explanation.match((float) stats.getDocFreq(), "n, number of documents containing term"));
}
;
}

View File

@ -88,14 +88,13 @@ public class AxiomaticF2EXP extends Axiomatic {
protected Explanation tfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match((float) tf(stats, freq, docLen), "tf, term frequency, equals to 1");
}
;
@Override
protected Explanation lnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match((float) ln(stats, freq, docLen), "ln, document length, equals to 1");
}
;
@Override
protected Explanation tflnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) tfln(stats, freq, docLen),
@ -107,8 +106,8 @@ public class AxiomaticF2EXP extends Axiomatic {
(float) stats.getAvgFieldLength(),
"avgdl, average length of field across all documents"));
}
;
@Override
protected Explanation idfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) idf(stats, freq, docLen),
@ -117,5 +116,4 @@ public class AxiomaticF2EXP extends Axiomatic {
(float) stats.getNumberOfDocuments(), "N, total number of documents with field"),
Explanation.match((float) stats.getDocFreq(), "n, number of documents containing term"));
}
;
}

View File

@ -78,14 +78,13 @@ public class AxiomaticF2LOG extends Axiomatic {
protected Explanation tfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match((float) tf(stats, freq, docLen), "tf, term frequency, equals to 1");
}
;
@Override
protected Explanation lnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match((float) ln(stats, freq, docLen), "ln, document length, equals to 1");
}
;
@Override
protected Explanation tflnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) tfln(stats, freq, docLen),
@ -97,8 +96,8 @@ public class AxiomaticF2LOG extends Axiomatic {
(float) stats.getAvgFieldLength(),
"avgdl, average length of field across all documents"));
}
;
@Override
protected Explanation idfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) idf(stats, freq, docLen),
@ -107,5 +106,4 @@ public class AxiomaticF2LOG extends Axiomatic {
(float) stats.getNumberOfDocuments(), "N, total number of documents with field"),
Explanation.match((float) stats.getDocFreq(), "n, number of documents containing term"));
}
;
}

View File

@ -92,21 +92,20 @@ public class AxiomaticF3EXP extends Axiomatic {
"tf, term frequency computed as 1 + log(1 + log(freq)) from:",
Explanation.match((float) freq, "freq, number of occurrences of term in the document"));
}
;
@Override
protected Explanation lnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match((float) ln(stats, freq, docLen), "ln, document length, equals to 1");
}
;
@Override
protected Explanation tflnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) tfln(stats, freq, docLen),
"tfln, mixed term frequency and document length, equals to 1");
}
;
@Override
protected Explanation idfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) idf(stats, freq, docLen),
@ -115,5 +114,4 @@ public class AxiomaticF3EXP extends Axiomatic {
(float) stats.getNumberOfDocuments(), "N, total number of documents with field"),
Explanation.match((float) stats.getDocFreq(), "n, number of documents containing term"));
}
;
}

View File

@ -87,15 +87,15 @@ public class AxiomaticF3LOG extends Axiomatic {
protected Explanation lnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match((float) ln(stats, freq, docLen), "ln, document length, equals to 1");
}
;
@Override
protected Explanation tflnExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) tfln(stats, freq, docLen),
"tfln, mixed term frequency and document length, equals to 1");
}
;
@Override
protected Explanation idfExplain(BasicStats stats, double freq, double docLen) {
return Explanation.match(
(float) idf(stats, freq, docLen),
@ -104,5 +104,4 @@ public class AxiomaticF3LOG extends Axiomatic {
(float) stats.getNumberOfDocuments(), "N, total number of documents with field"),
Explanation.match((float) stats.getDocFreq(), "n, number of documents containing term"));
}
;
}

View File

@ -86,6 +86,7 @@ public class IndriDirichletSimilarity extends LMSimilarity {
return mu;
}
@Override
public String getName() {
return String.format(Locale.ROOT, "IndriDirichlet(%f)", getMu());
}

View File

@ -39,6 +39,7 @@ public class LambdaTTF extends Lambda {
return lambda;
}
@Override
public final Explanation explain(BasicStats stats) {
return Explanation.match(
lambda(stats),

View File

@ -16,7 +16,6 @@
*/
package org.apache.lucene.search.spans;
import java.io.IOException;
import org.apache.lucene.search.spans.FilterSpans.AcceptStatus;
/**
@ -35,7 +34,8 @@ public class SpanFirstQuery extends SpanPositionRangeQuery {
super(match, 0, end);
}
protected AcceptStatus acceptPosition(Spans spans) throws IOException {
@Override
protected AcceptStatus acceptPosition(Spans spans) {
assert spans.startPosition() != spans.endPosition()
: "start equals end: " + spans.startPosition();
if (spans.startPosition() >= end) return AcceptStatus.NO_MORE_IN_CURRENT_DOC;

View File

@ -159,6 +159,7 @@ public class SpanMultiTermQueryWrapper<Q extends MultiTermQuery> extends SpanQue
return new ArrayList<SpanQuery>();
}
@Override
protected Query build(List<SpanQuery> builder) {
return new SpanOrQuery(builder.toArray(new SpanQuery[builder.size()]));
}

View File

@ -23,6 +23,7 @@ class SpanPositionQueue extends PriorityQueue<Spans> {
super(maxSize); // do not prepopulate
}
@Override
protected boolean lessThan(Spans s1, Spans s2) {
int start1 = s1.startPosition();
int start2 = s2.startPosition();

View File

@ -47,6 +47,7 @@ public abstract class Lock implements Closeable {
* @throws LockReleaseFailedException optional specific exception) if the lock could not be
* properly released.
*/
@Override
public abstract void close() throws IOException;
/**

View File

@ -186,6 +186,7 @@ public final class FixedBitSet extends BitSet {
return (bits[i] & bitmask) != 0;
}
@Override
public void set(int index) {
assert index >= 0 && index < numBits : "index=" + index + ", numBits=" + numBits;
int wordNum = index >> 6; // div 64

View File

@ -579,6 +579,7 @@ public class OfflineSorter {
* sequence. Returns <code>true</code> otherwise.
* @throws EOFException if the file ends before the full sequence is read.
*/
@Override
public BytesRef next() throws IOException {
if (in.getFilePointer() >= end) {
return null;

View File

@ -138,6 +138,7 @@ public class SparseFixedBitSet extends BitSet {
}
/** Set the bit at index <code>i</code>. */
@Override
public void set(int i) {
assert consistent(i);
final int i4096 = i >>> 12;
@ -193,6 +194,7 @@ public class SparseFixedBitSet extends BitSet {
}
/** Clear the bit at index <code>i</code>. */
@Override
public void clear(int i) {
assert consistent(i);
final int i4096 = i >>> 12;

View File

@ -45,12 +45,14 @@ abstract class BoundsChecker {
bound = Float.NEGATIVE_INFINITY;
}
@Override
void update(float sample) {
if (sample > bound) {
bound = sample;
}
}
@Override
boolean check(float sample) {
return sample < bound;
}
@ -62,12 +64,14 @@ abstract class BoundsChecker {
bound = Float.POSITIVE_INFINITY;
}
@Override
void update(float sample) {
if (sample < bound) {
bound = sample;
}
}
@Override
boolean check(float sample) {
return sample > bound;
}

View File

@ -64,6 +64,7 @@ public final class BlockPackedWriter extends AbstractBlockPackedWriter {
super(out, blockSize);
}
@Override
protected void flush() throws IOException {
assert off > 0;
long min = Long.MAX_VALUE, max = Long.MIN_VALUE;

View File

@ -67,6 +67,7 @@ public final class MonotonicBlockPackedWriter extends AbstractBlockPackedWriter
super.add(l);
}
@Override
protected void flush() throws IOException {
assert off > 0;

View File

@ -44,8 +44,10 @@ import org.apache.lucene.util.TestUtil;
/** Base test case for testing geospatial indexing and search functionality * */
public abstract class BaseLatLonSpatialTestCase extends BaseSpatialTestCase {
@Override
protected abstract ShapeType getShapeType();
@Override
protected Object nextShape() {
return getShapeType().nextShape();
}
@ -181,16 +183,19 @@ public abstract class BaseLatLonSpatialTestCase extends BaseSpatialTestCase {
/** internal shape type for testing different shape types */
protected enum ShapeType {
POINT() {
@Override
public Point nextShape() {
return GeoTestUtil.nextPoint();
}
},
LINE() {
@Override
public Line nextShape() {
return GeoTestUtil.nextLine();
}
},
POLYGON() {
@Override
public Polygon nextShape() {
while (true) {
Polygon p = GeoTestUtil.nextPolygon();
@ -204,6 +209,7 @@ public abstract class BaseLatLonSpatialTestCase extends BaseSpatialTestCase {
}
},
MIXED() {
@Override
public Object nextShape() {
return RandomPicks.randomFrom(random(), subList).nextShape();
}

View File

@ -37,8 +37,10 @@ import org.apache.lucene.util.TestUtil;
/** Base test case for testing indexing and search functionality of cartesian geometry * */
public abstract class BaseXYShapeTestCase extends BaseSpatialTestCase {
@Override
protected abstract ShapeType getShapeType();
@Override
protected Object nextShape() {
return getShapeType().nextShape();
}
@ -207,16 +209,19 @@ public abstract class BaseXYShapeTestCase extends BaseSpatialTestCase {
/** internal shape type for testing different shape types */
protected enum ShapeType {
POINT() {
@Override
public XYPoint nextShape() {
return ShapeTestUtil.nextPoint();
}
},
LINE() {
@Override
public XYLine nextShape() {
return ShapeTestUtil.nextLine();
}
},
POLYGON() {
@Override
public XYPolygon nextShape() {
while (true) {
XYPolygon p = ShapeTestUtil.nextPolygon();
@ -230,6 +235,7 @@ public abstract class BaseXYShapeTestCase extends BaseSpatialTestCase {
}
},
MIXED() {
@Override
public Object nextShape() {
return RandomPicks.randomFrom(random(), subList).nextShape();
}

View File

@ -22,6 +22,7 @@ import org.apache.lucene.index.MergePolicy.OneMerge;
public class TestLogMergePolicy extends BaseMergePolicyTestCase {
@Override
public MergePolicy mergePolicy() {
return newLogMergePolicy(random());
}

View File

@ -34,6 +34,7 @@ public class TestNRTThreads extends ThreadedIndexingAndSearchingTestCase {
private boolean useNonNrtReaders = true;
@Before
@Override
public void setUp() throws Exception {
super.setUp();
useNonNrtReaders = random().nextBoolean();

View File

@ -26,6 +26,7 @@ import org.junit.Test;
public class TestNoMergePolicy extends BaseMergePolicyTestCase {
@Override
public MergePolicy mergePolicy() {
return NoMergePolicy.INSTANCE;
}

View File

@ -45,6 +45,7 @@ public class TestOrdinalMap extends LuceneTestCase {
private static final RamUsageTester.Accumulator ORDINAL_MAP_ACCUMULATOR =
new RamUsageTester.Accumulator() {
@Override
public long accumulateObject(
Object o,
long shallowSize,

View File

@ -22,6 +22,7 @@ import org.apache.lucene.util.TestUtil;
public class TestUpgradeIndexMergePolicy extends BaseMergePolicyTestCase {
@Override
public MergePolicy mergePolicy() {
MergePolicy in = newMergePolicy(random());
if (in instanceof TieredMergePolicy) {

View File

@ -76,6 +76,7 @@ public class TestBoolean2ScorerSupplier extends LuceneTestCase {
return 1;
}
@Override
public DocIdSetIterator iterator() {
return it;
}

View File

@ -145,6 +145,7 @@ public class TestBooleanQueryVisitSubscorers extends LuceneTestCase {
super(TopScoreDocCollector.create(10, Integer.MAX_VALUE));
}
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
final int docBase = context.docBase;
return new FilterLeafCollector(super.getLeafCollector(context)) {

View File

@ -310,59 +310,72 @@ public class TestIndexSearcher extends LuceneTestCase {
private static class RejectingMockExecutor implements ExecutorService {
@Override
public void shutdown() {}
@Override
public List<Runnable> shutdownNow() {
throw new UnsupportedOperationException();
}
@Override
public boolean isShutdown() {
throw new UnsupportedOperationException();
}
@Override
public boolean isTerminated() {
throw new UnsupportedOperationException();
}
@Override
public boolean awaitTermination(final long l, final TimeUnit timeUnit)
throws InterruptedException {
throw new UnsupportedOperationException();
}
@Override
public <T> Future<T> submit(final Callable<T> tCallable) {
throw new UnsupportedOperationException();
}
@Override
public <T> Future<T> submit(final Runnable runnable, final T t) {
throw new UnsupportedOperationException();
}
@Override
public Future<?> submit(final Runnable runnable) {
throw new UnsupportedOperationException();
}
@Override
public <T> List<Future<T>> invokeAll(final Collection<? extends Callable<T>> callables)
throws InterruptedException {
throw new UnsupportedOperationException();
}
@Override
public <T> List<Future<T>> invokeAll(
final Collection<? extends Callable<T>> callables, final long l, final TimeUnit timeUnit)
throws InterruptedException {
throw new UnsupportedOperationException();
}
@Override
public <T> T invokeAny(final Collection<? extends Callable<T>> callables)
throws InterruptedException, ExecutionException {
throw new UnsupportedOperationException();
}
@Override
public <T> T invokeAny(
final Collection<? extends Callable<T>> callables, final long l, final TimeUnit timeUnit)
throws InterruptedException, ExecutionException, TimeoutException {
throw new UnsupportedOperationException();
}
@Override
public void execute(final Runnable runnable) {
throw new RejectedExecutionException();
}

View File

@ -121,6 +121,7 @@ public class TestLRUQueryCache extends LuceneTestCase {
Thread[] threads = new Thread[3];
threads[0] =
new Thread() {
@Override
public void run() {
Document doc = new Document();
StringField f = new StringField("color", "", Store.NO);
@ -169,6 +170,7 @@ public class TestLRUQueryCache extends LuceneTestCase {
searcher.search(
q,
new FilterCollector(collector2) {
@Override
public ScoreMode scoreMode() {
return ScoreMode.COMPLETE; // will not use the cache because of scores
}

View File

@ -386,6 +386,7 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
return Float.POSITIVE_INFINITY;
}
@Override
public int docID() {
return currentDoc;
}

View File

@ -119,11 +119,13 @@ public class TestSimpleExplanationsWithFillerDocs extends TestSimpleExplanations
super.qtest(q, expDocNrs);
}
@Override
public void testMA1() throws Exception {
Assume.assumeNotNull("test is not viable with empty filler docs", EXTRA);
super.testMA1();
}
@Override
public void testMA2() throws Exception {
Assume.assumeNotNull("test is not viable with empty filler docs", EXTRA);
super.testMA2();

View File

@ -102,6 +102,7 @@ public class TestSubScorerFreqs extends LuceneTestCase {
subScorers.put(((Scorer) scorer).getWeight().getQuery(), scorer);
}
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
final int docBase = context.docBase;
return new FilterLeafCollector(super.getLeafCollector(context)) {

View File

@ -107,6 +107,7 @@ public class TestFileSwitchDirectory extends BaseDirectoryTestCase {
}
// LUCENE-3380 -- make sure we get exception if the directory really does not exist.
@Override
public void testNoDir() throws Throwable {
Path primDir = createTempDir("foo");
Path secondDir = createTempDir("bar");

View File

@ -285,6 +285,7 @@ public class TestMultiMMap extends BaseDirectoryTestCase {
}
}
@Override
public void testSliceOfSlice() throws Exception {
int upto = TEST_NIGHTLY ? 10 : 8;
for (int i = 0; i < upto; i++) {

View File

@ -334,6 +334,7 @@ public class TestFixedBitSet extends BaseBitSetTestCase<FixedBitSet> {
doPrevSetBit(bs, obs);
}
@Override
public void testPrevSetBit() {
checkPrevSetBitArray(new int[] {}, 0);
checkPrevSetBitArray(new int[] {0}, 1);

View File

@ -124,6 +124,7 @@ class MockVectorValues extends VectorValues
return advance(pos + 1);
}
@Override
public int advance(int target) {
while (++pos < values.length) {
if (seek(pos)) {

View File

@ -142,6 +142,7 @@ public final class UTF8TaxonomyWriterCache implements TaxonomyWriterCache, Accou
}
/** How many labels are currently stored in the cache. */
@Override
public int size() {
return count;
}

View File

@ -43,16 +43,19 @@ public class TestParallelDrillSideways extends TestDrillSideways {
executor = null;
}
@Override
protected DrillSideways getNewDrillSideways(
IndexSearcher searcher, FacetsConfig config, SortedSetDocValuesReaderState state) {
return new DrillSideways(searcher, config, null, state, executor);
}
@Override
protected DrillSideways getNewDrillSideways(
IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader) {
return new DrillSideways(searcher, config, taxoReader, null, executor);
}
@Override
protected DrillSideways getNewDrillSidewaysScoreSubdocsAtOnce(
IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader) {
return new DrillSideways(searcher, config, taxoReader, null, executor) {
@ -63,6 +66,7 @@ public class TestParallelDrillSideways extends TestDrillSideways {
};
}
@Override
protected DrillSideways getNewDrillSidewaysBuildFacetsResult(
IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader) {
return new DrillSideways(searcher, config, taxoReader, null, executor) {

View File

@ -32,11 +32,13 @@ final class CharSequenceIterator implements CharacterIterator {
this.end = text.length();
}
@Override
public char first() {
pos = begin;
return current();
}
@Override
public char last() {
if (end != begin) {
pos = end - 1;
@ -46,12 +48,14 @@ final class CharSequenceIterator implements CharacterIterator {
return current();
}
@Override
public char setIndex(int p) {
if (p < begin || p > end) throw new IllegalArgumentException("Invalid index");
pos = p;
return current();
}
@Override
public char current() {
if (pos >= begin && pos < end) {
return text.charAt(pos);
@ -60,6 +64,7 @@ final class CharSequenceIterator implements CharacterIterator {
}
}
@Override
public char next() {
if (pos < end - 1) {
pos++;
@ -70,6 +75,7 @@ final class CharSequenceIterator implements CharacterIterator {
}
}
@Override
public char previous() {
if (pos > begin) {
pos--;
@ -79,14 +85,17 @@ final class CharSequenceIterator implements CharacterIterator {
}
}
@Override
public int getBeginIndex() {
return begin;
}
@Override
public int getEndIndex() {
return end;
}
@Override
public int getIndex() {
return pos;
}

View File

@ -901,6 +901,7 @@ public class TestFastVectorHighlighter extends LuceneTestCase {
fieldAnalyzers.get("field")); // This is required even though we provide a token stream
Analyzer analyzer =
new DelegatingAnalyzerWrapper(Analyzer.PER_FIELD_REUSE_STRATEGY) {
@Override
public Analyzer getWrappedAnalyzer(String fieldName) {
return fieldAnalyzers.get(fieldName);
}

View File

@ -62,6 +62,7 @@ public final class PreferencesImpl implements Preferences {
}
}
@Override
public List<String> getHistory() {
return history;
}

View File

@ -79,6 +79,7 @@ public final class TabbedPaneProvider implements TabSwitcherProxy.TabSwitcher {
return tabbedPane;
}
@Override
public void switchTab(Tab tab) {
tabbedPane.setSelectedIndex(tab.index());
tabbedPane.setVisible(false);

Some files were not shown because too many files have changed in this diff Show More