Skip to content

Commit

Permalink
Enhancements to checkFile; fix some formatting.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@532 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed May 15, 2012
1 parent 1152987 commit a41091b
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 29 deletions.
77 changes: 65 additions & 12 deletions checkFile.awk
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function _matchFile(fname) {
|| fname ~ "/fennel/" \
|| fname ~ "/extensions/" \
|| fname ~ "/com/sqlstream/" \
|| fname ~ "/linq4j/" \
|| fname ~ "/optiq/" \
|| strict > 0;
}
function _isCpp(fname) {
Expand All @@ -44,6 +46,9 @@ function _isJava(fname) {
function _isMondrian(fname) {
return fname ~ /mondrian/;
}
function _isOlap4j(fname) {
return fname ~ "/org/olap4j/";
}
function push(val) {
switchStack[switchStackLen++] = val;
}
Expand All @@ -70,7 +75,6 @@ function afterFile() {
function unmatchedOpenParens(s) {
i = index(s, "(");
if (i == 0) {
if (0) print FNR, "unmatchedOpenParens=0";
return 0;
}
openCount = 1;
Expand All @@ -81,12 +85,10 @@ function unmatchedOpenParens(s) {
}
if (c == ")") {
if (--openCount == 0) {
if (0) print FNR, "unmatchedOpenParens=0 (b)";
return 0;
}
}
}
if (0) print FNR, "unmatchedOpenParens=1";
return 1;
}

Expand Down Expand Up @@ -122,6 +124,45 @@ FNR == 1 {
mondrian = _isMondrian(fname);
prevImport = "";
prevImportGroup = "";

delete headers;
headerCount = 0;
if ($0 ~ /Generated By:JavaCC/ \
|| $0 ~ /This class is generated/) {
# generated; skip whole file
nextfile
} else if (fname ~ /XmlaOlap4jDriverVersion.java/ \
|| fname ~ /package-info.java/) {
# generated; does not contain standard header
} else if (1) {
headers[headerCount++] = "/\\*$";
if (_isOlap4j(fname)) {
headers[headerCount++] = /^\/\/ \$Id: /;
headers[headerCount++] = "//";
}
headers[headerCount++] = "// Licensed to Julian Hyde under one or more contributor license$";
headers[headerCount++] = "// agreements. See the NOTICE file distributed with this work for$";
headers[headerCount++] = "// additional information regarding copyright ownership.$";
headers[headerCount++] = "//$";
headers[headerCount++] = "// Julian Hyde licenses this file to you under the Apache License,$";
headers[headerCount++] = "// Version 2.0 \\(the \"License\"\\); you may not use this file except in$";
headers[headerCount++] = "// compliance with the License. You may obtain a copy of the License at:$";
headers[headerCount++] = "//$";
headers[headerCount++] = "// http://www.apache.org/licenses/LICENSE-2.0$";
headers[headerCount++] = "//$";
headers[headerCount++] = "// Unless required by applicable law or agreed to in writing, software$";
headers[headerCount++] = "// distributed under the License is distributed on an \"AS IS\" BASIS,$";
headers[headerCount++] = "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.$";
headers[headerCount++] = "// See the License for the specific language governing permissions and$";
headers[headerCount++] = "// limitations under the License.$";
headers[headerCount++] = "*/$";
}
}
FNR < headerCount {
if ($0 !~ headers[FNR - 1]) {
error(fname, FNR, "Does not match expected header line: " headers[FNR - 1] "\n");
headerCount = 0; # prevent further errors from this file
}
}
{
if (previousLineEndedInCloseBrace > 0) {
Expand Down Expand Up @@ -230,19 +271,28 @@ FNR == 1 {
gsub(/;/, "", thisImport);
gsub(/\*/, "", thisImport);
if (thisPackage ~ /^mondrian.*/ && thisImport ~ /^mondrian.*/ \
|| thisPackage ~ /^net.hydromatic.*/ && thisImport ~ /^net.hydromatic.*/ \
|| thisPackage ~ /^org.olap4j.*/ && thisImport ~ /^org.olap4j.*/)
{
importGroup = "a";
} else if (thisImport ~ /^static/) {
importGroup = "z";
} else if (thisImport ~ /^java.*/) {
importGroup = "y";
if (thisPackage ~ /^org.eigenbase.*/) {
importGroup = "aa";
} else {
importGroup = "y";
}
} else if (thisImport ~ /^junit.*/) {
importGroup = "b";
} else if (thisImport ~ /^mondrian.*/) {
importGroup = "bb";
} else if (thisImport ~ /^openjava.*/) {
importGroup = "cc";
} else if (thisImport ~ /^org.apache.*/) {
importGroup = "c";
} else if (thisImport ~ /^org.codehaus.*/) {
importGroup = "ccc";
} else if (thisImport ~ /^org.eigenbase.*/) {
importGroup = "d";
} else if (thisImport ~ /^org.olap4j.*/) {
Expand All @@ -268,7 +318,9 @@ FNR == 1 {
prevImport = thisImport;
prevImportGroup = importGroup;
}
/^\/\/ Copyright .* Julian/ && strict {
/^\/\/ Copyright .* Julian/ && strict > 1 {
# We assume that '--strict' is only invoked on files currently being
# edited. Therefore we would expect the copyright to be current.
if ($0 !~ /-2012/) {
error(fname, FNR, "copyright is not current");
}
Expand All @@ -277,22 +329,22 @@ FNR == 1 {
# Order of qualifiers: "public/private/protected static final abstract class ..."
s2 = s;
gsub(/\(.*$/, "", s2);
if (s2 ~ /abstract .*final/) {
if (s2 ~ /abstract .*final /) {
error(fname, FNR, "'final' must come before 'abstract'");
}
if (s2 ~ /final .*static/) {
if (s2 ~ /final .*static /) {
error(fname, FNR, "'static' must come before 'final'");
}
if (s2 ~ /abstract .*static/) {
if (s2 ~ /abstract .*static /) {
error(fname, FNR, "'static' must come before 'abstract'");
}
if (s2 ~ /static .*(public|protected|private)/) {
if (s2 ~ /static .*(public|protected|private) /) {
error(fname, FNR, "'public/private/protected' must come before 'static'");
}
if (s2 ~ /final .*(public|protected|private)/) {
if (s2 ~ /final .*(public|protected|private) /) {
error(fname, FNR, "'public/private/protected' must come before 'final'");
}
if (s2 ~ /abstract .*(public|protected|private)/) {
if (s2 ~ /abstract .*(public|protected|private) /) {
error(fname, FNR, "'public/private/protected' must come before 'abstract'");
}
}
Expand Down Expand Up @@ -692,8 +744,9 @@ length($0) > maxLineLength \
&& $0 !~ /\$Id: / \
&& $0 !~ /^import / \
&& $0 !~ /http:/ \
&& $0 !~ /https:/ \
&& $0 !~ /\/\/ Expect "/ \
&& s !~ /^ *(\+ |<< )?string\)?[;,]?$/ {
&& s !~ /^ *(\+ |<< |: |\?)?string\)?[;,]?$/ {
error( \
fname, \
FNR, \
Expand Down
4 changes: 3 additions & 1 deletion checkFile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ doCheck() {
;;

# Only validate .java and .jj files at present.
*.java|*.jj|*.h|*.cpp)
*.java|*.h|*.cpp)
;;

*)
Expand Down Expand Up @@ -283,6 +283,8 @@ if [ -s /tmp/checkFile_output_$$.txt ]; then
status=1
fi

rm -f /tmp/checkFile_output_$$.txt

exit $status

# End checkFile.sh
Expand Down
16 changes: 8 additions & 8 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1052,14 +1052,14 @@ public String generateRequest(
if (metadataRequest.requiresDatasourceName()) {
final String dataSourceInfo;
switch (BackendFlavor.getFlavor(context.olap4jConnection)) {
case ESSBASE:
dataSourceInfo =
context.olap4jConnection.getOlapDatabase()
.getDataSourceInfo();
break;
default:
dataSourceInfo =
context.olap4jConnection.getDatabase();
case ESSBASE:
dataSourceInfo =
context.olap4jConnection.getOlapDatabase()
.getDataSourceInfo();
break;
default:
dataSourceInfo =
context.olap4jConnection.getDatabase();
}
buf.append(" <DataSourceInfo>");
xmlEncode(buf, dataSourceInfo);
Expand Down
15 changes: 7 additions & 8 deletions src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,13 @@ public CellSet executeOlapQuery(String mdx) throws OlapException {

final String dataSourceInfo;
switch (BackendFlavor.getFlavor(olap4jConnection)) {
case ESSBASE:
dataSourceInfo =
olap4jConnection.getOlapDatabase()
.getDataSourceInfo();
break;
default:
dataSourceInfo =
olap4jConnection.getDatabase();
case ESSBASE:
dataSourceInfo =
olap4jConnection.getOlapDatabase().getDataSourceInfo();
break;
default:
dataSourceInfo =
olap4jConnection.getDatabase();
}

StringBuilder buf = new StringBuilder(
Expand Down

0 comments on commit a41091b

Please sign in to comment.