Skip to content

Commit

Permalink
Optimize & normalize imports.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@476 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Oct 24, 2011
1 parent 0627ad7 commit 191b83a
Show file tree
Hide file tree
Showing 108 changed files with 423 additions and 430 deletions.
68 changes: 66 additions & 2 deletions checkFile.awk
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ function countLeadingSpaces(str) {
return i;
}

function startsWith(s, p) {
return length(s) > length(p) \
&& substr(s, 1, length(p)) == p;
}

BEGIN {
# pre-compute regexp for quotes, linefeed
apos = sprintf("%c", 39);
Expand All @@ -96,6 +101,8 @@ FNR == 1 {
isCpp = _isCpp(fname);
isJava = _isJava(fname);
mondrian = _isMondrian(fname);
prevImport = "";
prevImportGroup = "";
}
{
if (previousLineEndedInCloseBrace > 0) {
Expand Down Expand Up @@ -186,6 +193,63 @@ FNR == 1 {
}
}

/^package / {
thisPackage = $2;
}
/^package / && previousLineWasEmpty {
error(fname, FNR, "'package' declaration must not occur after empty line");
}
/^import / {
if (previousLineWasEmpty) {
prevImport = "";
} else {
if (!prevImport) {
error(fname, FNR, "Expected blank line before first import");
}
}
thisImport = $2;
gsub(/;/, "", thisImport);
gsub(/\*/, "", thisImport);
importGroup = "zzzzzzzzzzzzzzzzz";
if (thisPackage ~ /^mondrian.*/ && thisImport ~ /^mondrian.*/ \
|| thisPackage ~ /^org.olap4j.*/ && thisImport ~ /^org.olap4j.*/)
{
importGroup = "a";
} else if (thisImport ~ /^static/) {
importGroup = "z";
} else if (thisImport ~ /^java.*/) {
importGroup = "y";
} else if (thisImport ~ /^junit.*/) {
importGroup = "b";
} else if (thisImport ~ /^mondrian.*/) {
importGroup = "bb";
} else if (thisImport ~ /^org.apache.*/) {
importGroup = "c";
} else if (thisImport ~ /^org.eigenbase.*/) {
importGroup = "d";
} else if (thisImport ~ /^org.olap4j.*/) {
importGroup = "e";
} else {
importGroup = "f";
}
if (importGroup != prevImportGroup \
&& prevImportGroup)
{
if (!previousLineWasEmpty) {
error(fname, FNR, "Expected blank line between import groups");
} else if (prevImportGroup > importGroup) {
error(fname, FNR, "Import group out of sequence" importGroup prevImportGroup);
}
} else if (prevImport \
&& prevImport > thisImport \
&& !startsWith(prevImport, thisImport) \
&& !startsWith(thisImport, prevImport))
{
error(fname, FNR, "Import out of sorted order");
}
prevImport = thisImport;
prevImportGroup = importGroup;
}
/^$/ {
if (matchFile && previousLineEndedInOpenBrace) {
error(fname, FNR, "Empty line following open brace");
Expand Down Expand Up @@ -521,10 +585,10 @@ s ~ /{/ {
else if (s ~ /(\]\)?|=) *{/) {} # ignore e.g. "(int[]) {1, 2}" or "int[] x = {1, 2}"
else if (s ~ /\({/) {} # ignore e.g. @SuppressWarnings({"unchecked"})
else if (s ~ /{ *(\/\/|\/\*)/) {} # ignore e.g. "do { // a comment"
else if (s ~ / {}$/) {} # ignore e.g. "Constructor() {}"
else if (s ~ / \{\}$/) {} # ignore e.g. "Constructor() {}"
else if (s ~ / },$/) {} # ignore e.g. "{ yada },"
else if (s ~ / };$/) {} # ignore e.g. "{ yada };"
else if (s ~ / {};$/) {} # ignore e.g. "template <> class Foo<int> {};"
else if (s ~ / \{\};$/) {} # ignore e.g. "template <> class Foo<int> {};"
else if (s ~ / },? *\/\/.*$/) {} # ignore e.g. "{ yada }, // comment"
else if (s ~ /\\$/) {} # ignore multiline macros
else if (s ~ /{}/) { # e.g. "Constructor(){}"
Expand Down
4 changes: 2 additions & 2 deletions src/org/olap4j/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2010 Julian Hyde
// Copyright (C) 2006-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j;

import org.olap4j.metadata.Property;

import java.util.List;
import java.sql.ResultSet;
import java.util.List;

/**
* Cell returned from a {@link CellSet}.
Expand Down
4 changes: 2 additions & 2 deletions src/org/olap4j/CellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2010 Julian Hyde
// Copyright (C) 2006-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.sql.ResultSet;

/**
* Result of executing an OLAP Statement.
Expand Down
6 changes: 2 additions & 4 deletions src/org/olap4j/OlapConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2010 Julian Hyde
// Copyright (C) 2006-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -12,9 +12,7 @@
import org.olap4j.mdx.parser.MdxParserFactory;
import org.olap4j.metadata.*;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.*;
import java.util.List;
import java.util.Locale;

Expand Down
4 changes: 2 additions & 2 deletions src/org/olap4j/OlapDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2008-2010 Julian Hyde
// Copyright (C) 2008-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j;

import javax.sql.DataSource;
import java.sql.SQLException;
import javax.sql.DataSource;

/**
* <p>A factory for connections to the physical OLAP data source that this
Expand Down
2 changes: 1 addition & 1 deletion src/org/olap4j/OlapDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
package org.olap4j;

import org.olap4j.metadata.*;
import org.olap4j.metadata.Member;

import java.sql.*;
import java.util.Set;
Expand Down
6 changes: 3 additions & 3 deletions src/org/olap4j/OlapStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2006-2010 Julian Hyde
// Copyright (C) 2006-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j;

import org.olap4j.mdx.SelectNode;

import java.sql.SQLException;
import java.sql.Statement;

import org.olap4j.mdx.SelectNode;

/**
* Object used for statically executing an MDX statement and returning a
* {@link CellSet}.
Expand Down
10 changes: 5 additions & 5 deletions src/org/olap4j/driver/xmla/EmptyResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import org.olap4j.OlapWrapper;

import javax.sql.rowset.RowSetMetaDataImpl;
import java.sql.*;
import java.sql.Date;
import java.math.BigDecimal;
import java.io.InputStream;
import java.io.Reader;
import java.util.*;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.sql.Date;
import java.util.*;
import javax.sql.rowset.RowSetMetaDataImpl;

/**
* Implementation of {@link ResultSet} which returns 0 rows.
Expand Down
4 changes: 2 additions & 2 deletions src/org/olap4j/driver/xmla/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -12,8 +12,8 @@
import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;

import java.sql.*;
import java.util.Properties;
import java.util.List;
import java.util.Properties;

/**
* Instantiates classes to implement the olap4j API against the
Expand Down
12 changes: 6 additions & 6 deletions src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j.driver.xmla;

import java.sql.*;
import java.util.*;
import java.io.Reader;
import java.io.InputStream;

import org.olap4j.*;
import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;

import java.io.InputStream;
import java.io.Reader;
import java.sql.*;
import java.util.*;

/**
* Implementation of {@link Factory} for JDBC 4.0.
*
Expand Down
6 changes: 3 additions & 3 deletions src/org/olap4j/driver/xmla/XmlaHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j.driver.xmla;

import org.olap4j.OlapException;
import org.olap4j.Cell;
import org.olap4j.OlapException;

import java.sql.SQLException;

Expand Down Expand Up @@ -58,4 +58,4 @@ public OlapException toOlapException(SQLException e) {
}
}

// End XmlaHelper.java
// End XmlaHelper.java
4 changes: 2 additions & 2 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
*/
package org.olap4j.driver.xmla;

import java.sql.SQLException;

import org.olap4j.OlapDatabaseMetaData;
import org.olap4j.OlapException;
import org.olap4j.impl.Named;
import org.olap4j.impl.Olap4jUtil;
import org.olap4j.metadata.*;

import java.sql.SQLException;

/**
* Implementation of {@link org.olap4j.metadata.Catalog}
* for XML/A providers.
Expand Down
5 changes: 3 additions & 2 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -13,7 +13,8 @@
import org.olap4j.metadata.Property;

import java.sql.ResultSet;
import java.util.*;
import java.util.List;
import java.util.Map;

/**
* Implementation of {@link org.olap4j.Cell}
Expand Down
8 changes: 5 additions & 3 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
package org.olap4j.driver.xmla;

import org.olap4j.*;
import org.olap4j.mdx.ParseTreeNode;
import org.olap4j.impl.Olap4jUtil;
import static org.olap4j.driver.xmla.XmlaOlap4jUtil.*;
import org.olap4j.mdx.ParseTreeNode;
import org.olap4j.metadata.*;

import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

import java.io.*;
Expand All @@ -24,6 +24,8 @@
import java.sql.Date;
import java.util.*;

import static org.olap4j.driver.xmla.XmlaOlap4jUtil.*;

/**
* Implementation of {@link org.olap4j.CellSet}
* for XML/A providers.
Expand Down
5 changes: 3 additions & 2 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxis.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package org.olap4j.driver.xmla;

import org.olap4j.*;

import java.util.*;
import java.util.List;
import java.util.ListIterator;

/**
* Implementation of {@link org.olap4j.CellSetAxis}
Expand Down
4 changes: 2 additions & 2 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxisMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2010 Julian Hyde
// Copyright (C) 2007-2011 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -14,7 +14,7 @@
import org.olap4j.metadata.Hierarchy;
import org.olap4j.metadata.Property;

import java.util.*;
import java.util.List;

/**
* Implementation of {@link org.olap4j.CellSetMetaData}
Expand Down
Loading

0 comments on commit 191b83a

Please sign in to comment.