Skip to content

Commit

Permalink
Version 1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gquerret committed May 31, 2016
1 parent 0a63d73 commit e33ef30
Show file tree
Hide file tree
Showing 30 changed files with 267 additions and 72 deletions.
5 changes: 4 additions & 1 deletion BaseTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1206,4 +1206,7 @@ PARENTFIELDSBEFORE=1208
PARENTFIELDSAFTER=1209
ENUM=1210
FLAGS=1211
Last_Token_Number=1212
GETCODEPAGE=1212
HEIGHTCHARS=1213
HEIGHTPIXELS=1214
Last_Token_Number=1215
5 changes: 4 additions & 1 deletion ProParserTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,7 @@ PARENTFIELDSBEFORE=1208
PARENTFIELDSAFTER=1209
ENUM=1210
FLAGS=1211
Last_Token_Number=1212
GETCODEPAGE=1212
HEIGHTCHARS=1213
HEIGHTPIXELS=1214
Last_Token_Number=1215
2 changes: 1 addition & 1 deletion database-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>1.1.10</version>
<version>1.1.11</version>

<name>OpenEdge database definition lexer and parser</name>
<url>http://riverside-software.fr/</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ dropIndex:
'DROP' 'INDEX' index=QUOTED_STRING 'ON' table=QUOTED_STRING;

footer:
'.' 'PSC' ('bufpool' '=' 'yes')? UNQUOTED_STRING '=' UNQUOTED_STRING '.' NUMBER?;
'.' 'PSC'? ('bufpool' '=' 'yes')? (UNQUOTED_STRING '=' UNQUOTED_STRING)? '.' NUMBER?;

fragment INT:
('0'..'9');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
public class DescriptiveErrorListener extends BaseErrorListener {
private static final Logger LOG = LoggerFactory.getLogger(DescriptiveErrorListener.class);

public static DescriptiveErrorListener INSTANCE = new DescriptiveErrorListener();

@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
String msg, RecognitionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;

import org.antlr.v4.runtime.ANTLRErrorListener;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
Expand All @@ -25,41 +26,22 @@ private DumpFileUtils() {
}

public static final ParseTree getDumpFileParseTree(File file) throws IOException {
// Quick and dirty
LineProcessor<Charset> charsetReader = new LineProcessor<Charset>() {
private Charset charset = Charset.defaultCharset();

@Override
public Charset getResult() {
return charset;
}

@Override
public boolean processLine(String arg0) throws IOException {
if (arg0.startsWith("cpstream=")) {
try {
charset = Charset.forName(arg0.substring(9));
} catch (IllegalCharsetNameException | UnsupportedCharsetException uncaught) {
// Undefined for example...
}
return false;
}
return true;
}
};
// Trying to read codepage from DF footer
LineProcessor<Charset> charsetReader = new DFCodePageProcessor();
Files.readLines(file, Charset.defaultCharset(), charsetReader);

return getDumpFileParseTree(new InputStreamReader(new FileInputStream(file), charsetReader.getResult()));
}

public static final ParseTree getDumpFileParseTree(Reader reader) throws IOException {
ANTLRErrorListener listener = new DescriptiveErrorListener();
DumpFileGrammarLexer lexer = new DumpFileGrammarLexer(new ANTLRInputStream(reader));
lexer.removeErrorListeners();
lexer.addErrorListener(DescriptiveErrorListener.INSTANCE);
lexer.addErrorListener(listener);
CommonTokenStream tokens = new CommonTokenStream(lexer);
DumpFileGrammarParser parser = new DumpFileGrammarParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(DescriptiveErrorListener.INSTANCE);
parser.addErrorListener(listener);

return parser.dump();
}
Expand All @@ -71,4 +53,25 @@ public static final DatabaseDescription getDatabaseDescription(File file) throws
return visitor.getDatabase();
}

private static class DFCodePageProcessor implements LineProcessor<Charset> {
private Charset charset = Charset.defaultCharset();

@Override
public Charset getResult() {
return charset;
}

@Override
public boolean processLine(String arg0) throws IOException {
if (arg0.startsWith("cpstream=")) {
try {
charset = Charset.forName(arg0.substring(9));
} catch (IllegalCharsetNameException | UnsupportedCharsetException uncaught) {
// Undefined for example...
}
return false;
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public Void visitAddField(AddFieldContext ctx) {
if (t.getName().equalsIgnoreCase(ctx.table.getText()))
table = t;
}
table.addField(field);
if (table != null) {
table.addField(field);
} else {
// Log error
}

return visitChildren(ctx);
}
Expand Down Expand Up @@ -196,7 +200,11 @@ public Void visitAddIndex(AddIndexContext ctx) {
if (t.getName().equalsIgnoreCase(ctx.table.getText()))
table = t;
}
table.addIndex(index);
if (table != null) {
table.addIndex(index);
} else {
// Log error ?
}

return visitChildren(ctx);
}
Expand Down Expand Up @@ -234,10 +242,14 @@ public Void visitIndexField(IndexFieldContext ctx) {
if (t.getName().equalsIgnoreCase(tableName))
table = t;
}
if (table != null) {
IndexField idxFld = new IndexField(table.getField(ctx.field.getText()),
"ascending".equalsIgnoreCase(ctx.order.getText()));
indexes.peek().addField(idxFld);
} else {
// Log error ?
}

IndexField idxFld = new IndexField(table.getField(ctx.field.getText()),
"ascending".equalsIgnoreCase(ctx.order.getText()));
indexes.peek().addField(idxFld);
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions openedge-checks-shaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks-shaded</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>

<name>OpenEdge checks (shaded)</name>
<url>http://riverside-software.fr/</url>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
Expand Down
6 changes: 3 additions & 3 deletions openedge-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>

<name>OpenEdge checks</name>
<url>http://riverside-software.fr/</url>
Expand Down Expand Up @@ -38,12 +38,12 @@
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>1.1.10</version>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>proparse</groupId>
<artifactId>proparse</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
4 changes: 2 additions & 2 deletions openedge-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
<version>1.9.1</version>
<version>1.9.2</version>
<packaging>sonar-plugin</packaging>

<name>OpenEdge plugin for SonarQube</name>
Expand Down Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks-shaded</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void analyse(Project project, SensorContext context) {

context.saveMeasure(file, new Measure(OpenEdgeMetrics.TRANSACTIONS, sb.toString()));
context.saveMeasure(file, new Measure(OpenEdgeMetrics.NUM_TRANSACTIONS, (double) parser.getTransactionBlocks().size()));
if (parser.getMainBlock().isTransaction()) {
if ((parser.getMainBlock() != null) && parser.getMainBlock().isTransaction()) {
NewIssue issue = context.newIssue();
issue.forRule(
RuleKey.of(OpenEdgeRulesDefinition.REPOSITORY_KEY, OpenEdgeRulesDefinition.LARGE_TRANSACTION_SCOPE)).at(
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<packaging>pom</packaging>
<version>1.9.1</version>
<version>1.9.2</version>
<name>OpenEdge plugin for SonarQube</name>
<url>http://www.riverside-software.fr/</url>
<description>Open source code analysis for OpenEdge</description>
Expand Down
5 changes: 4 additions & 1 deletion proparse/BaseTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1206,4 +1206,7 @@ PARENTFIELDSBEFORE=1208
PARENTFIELDSAFTER=1209
ENUM=1210
FLAGS=1211
Last_Token_Number=1212
GETCODEPAGE=1212
HEIGHTCHARS=1213
HEIGHTPIXELS=1214
Last_Token_Number=1215
5 changes: 4 additions & 1 deletion proparse/ProParserTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,7 @@ PARENTFIELDSBEFORE=1208
PARENTFIELDSAFTER=1209
ENUM=1210
FLAGS=1211
Last_Token_Number=1212
GETCODEPAGE=1212
HEIGHTCHARS=1213
HEIGHTPIXELS=1214
Last_Token_Number=1215
2 changes: 1 addition & 1 deletion proparse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>proparse</groupId>
<artifactId>proparse</artifactId>
<version>1.0.6</version>
<version>1.0.7</version>

<name>Proparse</name>
<url>http://riverside-software.fr/</url>
Expand Down
10 changes: 7 additions & 3 deletions proparse/src/main/antlr/JPTreeParser.g
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ functioncall throws TreeParserException
| #(FRAMEDOWN (LEFTPAREN ID RIGHTPAREN)? )
| #(FRAMELINE (LEFTPAREN ID RIGHTPAREN)? )
| #(FRAMEROW (LEFTPAREN ID RIGHTPAREN)? )
| #(GETCODEPAGES (funargs)? )
| #(GETCODEPAGE funargs )
| #(GUID LEFTPAREN (expression)? RIGHTPAREN )
| #(IF expression THEN expression ELSE expression )
| ldbnamefunc
Expand Down Expand Up @@ -610,6 +610,7 @@ noargfunc throws TreeParserException
| GENERATEPBESALT
| GENERATERANDOMKEY
| GENERATEUUID
| GETCODEPAGES
| GATEWAYS
| GOPENDING
| ISATTRSPACE
Expand Down Expand Up @@ -811,7 +812,7 @@ systemhandlename throws TreeParserException
| COMSELF | CURRENTWINDOW | DEBUGGER | DEFAULTWINDOW
| ERRORSTATUS | FILEINFORMATION | FOCUS | FONTTABLE | LASTEVENT | LOGMANAGER
| MOUSE | PROFILER | RCODEINFORMATION | SECURITYPOLICY | SELF | SESSION
| SOURCEPROCEDURE | SUPER | TARGETPROCEDURE | TEXTCURSOR | THISOBJECT | THISPROCEDURE | WEBCONTEXT
| SOURCEPROCEDURE | SUPER | TARGETPROCEDURE | TEXTCURSOR | THISOBJECT | THISPROCEDURE | WEBCONTEXT | ACTIVEFORM
;
Expand Down Expand Up @@ -1086,6 +1087,9 @@ columnformat throws TreeParserException
| #(LABELBGCOLOR expression )
| #(LABELFGCOLOR expression )
| #(LEXAT field (columnformat)? )
| #(HEIGHT NUMBER )
| #(HEIGHTPIXELS NUMBER )
| #(HEIGHTCHARS NUMBER )
| #(WIDTH NUMBER )
| #(WIDTHPIXELS NUMBER )
| #(WIDTHCHARS NUMBER )
Expand Down Expand Up @@ -1264,7 +1268,7 @@ createsocketstate throws TreeParserException
;
createtemptablestate throws TreeParserException
: #(CREATE TEMPTABLE field (#(IN_KW WIDGETPOOL expression))? (NOERROR_KW)? state_end )
: #(CREATE TEMPTABLE (field | widattr) (#(IN_KW WIDGETPOOL expression))? (NOERROR_KW)? state_end )
;
createwidgetstate throws TreeParserException
Expand Down
20 changes: 14 additions & 6 deletions proparse/src/main/antlr/TreeParser01.g
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ functioncall throws TreeParserException
| #(FRAMEDOWN (LEFTPAREN ID RIGHTPAREN)? )
| #(FRAMELINE (LEFTPAREN ID RIGHTPAREN)? )
| #(FRAMEROW (LEFTPAREN ID RIGHTPAREN)? )
| #(GETCODEPAGES (funargs)? )
| #(GETCODEPAGE funargs )
| #(GUID LEFTPAREN (expression)? RIGHTPAREN )
| #(IF expression THEN expression ELSE expression )
| ldbnamefunc
Expand Down Expand Up @@ -468,22 +468,27 @@ choosestate throws TreeParserException
;

classstate throws TreeParserException
: #( c:CLASS {action.classState(#c);}
: #( c:CLASS
TYPE_NAME
( #(INHERITS TYPE_NAME)
| #(IMPLEMENTS TYPE_NAME (COMMA TYPE_NAME)* )
| USEWIDGETPOOL
| ABSTRACT
| FINAL
| SERIALIZABLE
| abstractKw:ABSTRACT
| finalKw:FINAL
| serializableKw:SERIALIZABLE
)*
{action.classState(#c, #abstractKw, #finalKw, #serializableKw);}
block_colon
code_block
#(END (CLASS)? )
state_end
)
;

interfacestate throws TreeParserException
: #(i:INTERFACE {action.interfaceState(#i);} TYPE_NAME (interface_inherits)? block_colon code_block #(END (INTERFACE)?) state_end )
;

clearstate throws TreeParserException
: #(c:CLEAR (frame_ref)? (ALL)? (NOPAUSE)? state_end {action.clearState(#c);} )
;
Expand Down Expand Up @@ -526,6 +531,9 @@ columnformat throws TreeParserException
| #(LABELBGCOLOR expression )
| #(LABELFGCOLOR expression )
| #(LEXAT af:fld[ContextQualifier.SYMBOL] {action.lexat(#af);} (columnformat)? )
| #(HEIGHT NUMBER )
| #(HEIGHTPIXELS NUMBER )
| #(HEIGHTCHARS NUMBER )
| #(WIDTH NUMBER )
| #(WIDTHPIXELS NUMBER )
| #(WIDTHCHARS NUMBER )
Expand Down Expand Up @@ -579,7 +587,7 @@ createsocketstate throws TreeParserException
;

createtemptablestate throws TreeParserException
: #(CREATE TEMPTABLE fld[ContextQualifier.UPDATING] (#(IN_KW WIDGETPOOL expression))? (NOERROR_KW)? state_end )
: #(CREATE TEMPTABLE (fld[ContextQualifier.UPDATING] | widattr) (#(IN_KW WIDGETPOOL expression))? (NOERROR_KW)? state_end )
;

createwidgetstate throws TreeParserException
Expand Down
Loading

0 comments on commit e33ef30

Please sign in to comment.