Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dev/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END

Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
Portions Copyright (c) 2018, Chris Fraire <cfraire@me.com>.
Portions Copyright (c) 2018-2019, Chris Fraire <cfraire@me.com>.

-->

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.1//EN"
"https://checkstyle.org/dtds/suppressions_1_1.dtd">
Expand All @@ -34,8 +35,8 @@ Portions Copyright (c) 2018, Chris Fraire <cfraire@me.com>.
|BlockingObjectPool\.java|OGKTextVecField\.java|OGKTextField\.java|
|LazilyInstantiate\.java" />

<suppress checks="ParameterNumber" files="CtagsReader\.java|Definitions\.java|PerlLexHelper\.java|
|JFlexXrefUtils\.java|RubyLexHelper\.java|FileAnalyzerFactory\.java|SearchController\.java|
<suppress checks="ParameterNumber" files="CtagsReader\.java|Definitions\.java|
|JFlexXrefUtils\.java|FileAnalyzerFactory\.java|SearchController\.java|
|Context\.java|HistoryContext\.java|Suggester\.java" />

<suppress checks="MethodLength" files="Indexer\.java" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017-2018, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2017-2019, Chris Fraire <cfraire@me.com>.
*/
package org.opengrok.indexer.analysis.ada;

Expand Down Expand Up @@ -51,11 +51,11 @@ protected AdaAnalyzer(AnalyzerFactory factory) {
* Gets a version number to be used to tag processed documents so that
* re-analysis can be re-done later if a stored version number is different
* from the current implementation.
* @return 20180208_00
* @return 20190118_01
*/
@Override
protected int getSpecializedVersionNo() {
return 20180208_00; // Edit comment above too!
return 20190118_01; // Edit comment above too!
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,32 @@
*/

/*
* Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
* Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>.
*/

package org.opengrok.indexer.analysis.ada;

import java.io.IOException;

import org.opengrok.indexer.analysis.JFlexJointLexer;
import org.opengrok.indexer.analysis.JFlexSymbolMatcher;
import org.opengrok.indexer.analysis.Resettable;

/**
* Represents an API for object's using {@link AdaLexHelper}
*/
interface AdaLexer extends JFlexJointLexer {
}

/**
* Represents a helper for Ada lexers
* Represents an abstract base class for Ada lexers.
*/
class AdaLexHelper implements Resettable {

private final AdaLexer lexer;

private final int SCOMMENT;

AdaLexHelper(int sCOMMENT, AdaLexer lexer) {
if (lexer == null) {
throw new IllegalArgumentException("`lexer' is null");
}
this.lexer = lexer;
this.SCOMMENT = sCOMMENT;
}

/**
* Resets the instance to an initial state.
*/
@Override
public void reset() {
// noop
}
abstract class AdaLexer extends JFlexSymbolMatcher
implements JFlexJointLexer, Resettable {

/**
* Write {@code value} to output -- if it contains any EOLs then the
* {@code startNewLine()} is called in lieu of outputting EOL.
* Writes {@code value} to output -- if it contains any EOLs then the
* {@link JFlexJointLexer#startNewLine()} is called in lieu of outputting
* EOL.
*/
public void takeLiteral(String value, String className)
throws IOException {

lexer.disjointSpan(className);
disjointSpan(className);

int off = 0;
do {
Expand All @@ -74,7 +52,7 @@ public void takeLiteral(String value, String className)
ni = value.indexOf("\n", off);
if (ri == -1 && ni == -1) {
String sub = value.substring(off);
lexer.offer(sub);
offer(sub);
break;
}
if (ri != -1 && ni != -1) {
Expand All @@ -93,22 +71,28 @@ public void takeLiteral(String value, String className)
}

String sub = value.substring(off, i);
lexer.offer(sub);
lexer.disjointSpan(null);
lexer.startNewLine();
lexer.disjointSpan(className);
offer(sub);
disjointSpan(null);
startNewLine();
disjointSpan(className);
off = i + w;
} while (off < value.length());

lexer.disjointSpan(null);
disjointSpan(null);
}

/**
* Calls {@link AdaLexer#phLOC()} if the yystate is not SCOMMENT.
* Calls {@link #phLOC()} if the yystate is not SCOMMENT.
*/
public void chkLOC() {
if (lexer.yystate() != SCOMMENT) {
lexer.phLOC();
if (yystate() != SCOMMENT()) {
phLOC();
}
}

/**
* Subclasses must override to get the constant value created by JFlex to
* represent SCOMMENT.
*/
abstract int SCOMMENT();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2017-2018, Chris Fraire <cfraire@me.com>.
* Copyright (c) 2017-2019, Chris Fraire <cfraire@me.com>.
*/

package org.opengrok.indexer.analysis.eiffel;
Expand Down Expand Up @@ -48,11 +48,11 @@ protected EiffelAnalyzer(AnalyzerFactory factory) {
* Gets a version number to be used to tag processed documents so that
* re-analysis can be re-done later if a stored version number is different
* from the current implementation.
* @return 20180208_00
* @return 20190118_00
*/
@Override
protected int getSpecializedVersionNo() {
return 20180208_00; // Edit comment above too!
return 20190118_00; // Edit comment above too!
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,35 @@
*/

/*
* Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
* Copyright (c) 2017, 2019, Chris Fraire <cfraire@me.com>.
*/

package org.opengrok.indexer.analysis.eiffel;

import java.io.IOException;

import org.opengrok.indexer.analysis.JFlexJointLexer;
import org.opengrok.indexer.analysis.JFlexSymbolMatcher;
import org.opengrok.indexer.analysis.Resettable;
import org.opengrok.indexer.web.HtmlConsts;

/**
* Represents an API for object's using {@link EiffelLexHelper}.
*/
interface EiffelLexer extends JFlexJointLexer {
}

/**
* Represents a helper for Eiffel lexers.
* Represents an abstract base class for Eiffel lexers.
*/
class EiffelLexHelper implements Resettable {

private final EiffelLexer lexer;

private final int VSTRING;
private final int SCOMMENT;
abstract class EiffelLexer extends JFlexSymbolMatcher
implements JFlexJointLexer, Resettable {

/**
* When matching a Verbatim_string, the expected closer is stored here.
*/
private String vstring_closer;

EiffelLexHelper(int vSTRING, int sCOMMENT, EiffelLexer lexer) {
if (lexer == null) {
throw new IllegalArgumentException("`lexer' is null");
}
this.lexer = lexer;
this.VSTRING = vSTRING;
this.SCOMMENT = sCOMMENT;
}

/**
* Resets the instance to an initial state.
*/
@Override
public void reset() {
super.reset();
vstring_closer = null;
}

Expand Down Expand Up @@ -94,9 +78,9 @@ public void vop(String opener) throws IOException {
}
vstring_closer = close0 + alpha + "\"";

lexer.yypush(VSTRING);
lexer.disjointSpan(HtmlConsts.STRING_CLASS);
lexer.offer(opener);
yypush(VSTRING());
disjointSpan(HtmlConsts.STRING_CLASS);
offer(opener);
}

/**
Expand All @@ -112,26 +96,38 @@ public void maybeEndVerbatim(String capture) throws IOException {
int npushback;
if (!capture.startsWith(vstring_closer)) {
// Nope--so just write the double quote, and push back the rest.
lexer.offer(capture.substring(0, 1));
offer(capture.substring(0, 1));
npushback = capture.length() - 1;
} else {
lexer.offer(vstring_closer);
lexer.disjointSpan(null);
lexer.yypop();
offer(vstring_closer);
disjointSpan(null);
yypop();
npushback = capture.length() - vstring_closer.length();
vstring_closer = null;
}
if (npushback > 0) {
lexer.yypushback(npushback);
yypushback(npushback);
}
}

/**
* Calls {@link EiffelLexer#phLOC()} if the yystate is not SCOMMENT.
* Calls {@link #phLOC()} if the yystate is not SCOMMENT.
*/
public void chkLOC() {
if (lexer.yystate() != SCOMMENT) {
lexer.phLOC();
if (yystate() != SCOMMENT()) {
phLOC();
}
}

/**
* Subclasses must override to get the constant value created by JFlex to
* represent SCOMMENT.
*/
abstract int SCOMMENT();

/**
* Subclasses must override to get the constant value created by JFlex to
* represent VSTRING.
*/
abstract int VSTRING();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2017-2019, Chris Fraire <cfraire@me.com>.
*/
package org.opengrok.indexer.analysis.fortran;

Expand All @@ -45,11 +45,11 @@ public class FortranAnalyzer extends AbstractSourceCodeAnalyzer {
* Gets a version number to be used to tag processed documents so that
* re-analysis can be re-done later if a stored version number is different
* from the current implementation.
* @return 20180208_00
* @return 20190118_00
*/
@Override
protected int getSpecializedVersionNo() {
return 20180208_00; // Edit comment above too!
return 20190118_00; // Edit comment above too!
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017-2018, Chris Fraire <cfraire@me.com>.
* Portions Copyright (c) 2017-2019, Chris Fraire <cfraire@me.com>.
*/
package org.opengrok.indexer.analysis.perl;

Expand Down Expand Up @@ -49,11 +49,11 @@ protected PerlAnalyzer(AnalyzerFactory factory) {
* Gets a version number to be used to tag processed documents so that
* re-analysis can be re-done later if a stored version number is different
* from the current implementation.
* @return 20180208_00
* @return 20190118_01
*/
@Override
protected int getSpecializedVersionNo() {
return 20180208_00; // Edit comment above too!
return 20190118_01; // Edit comment above too!
}

/**
Expand Down
Loading