Skip to content

Commit

Permalink
Allowing packages to reference themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling committed Jan 2, 2019
1 parent 6fbbcbe commit 692e24c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Void visitCompilationUnit(CompilationUnitTree tree, Void p) {
}

if (packageOfCurrentCompilationUnit == null) {
throw new IllegalArgumentException("Package " +packageName + " is not configured.");
throw new IllegalArgumentException("Package " + packageName + " is not configured.");
}

return super.visitCompilationUnit(tree, p);
Expand All @@ -72,7 +72,8 @@ public Void visitVariable(VariableTree node, Void p) {
PackageElement pakkage = elements.getPackageOf(jcTree.type.asElement());
String qualifiedName = pakkage.getQualifiedName().toString();

if (!packageDependencies.isWhitelisted(qualifiedName)) {
if (!packageOfCurrentCompilationUnit.getName().equals(qualifiedName) &&
!packageDependencies.isWhitelisted(qualifiedName)) {
if (!qualifiedName.isEmpty() && !packageOfCurrentCompilationUnit.reads(qualifiedName)) {
if (reportingPolicy == ReportingPolicy.ERROR) {
log.error(jcTree.pos, DeptectiveMessages.ILLEGAL_PACKAGE_DEPENDENCY, packageOfCurrentCompilationUnit, qualifiedName);
Expand Down

0 comments on commit 692e24c

Please sign in to comment.