8172810: ModuleElement should declare and provide appropriate modifiers

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2017-01-30 17:43:18 -08:00
parent 28110a1e7e
commit ea2592fd1d
3 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -62,6 +62,15 @@ public interface ModuleElement extends Element, QualifiedNameable {
@Override
List<? extends Element> getEnclosedElements();
/**
* Returns {@code true} if this is an open module and {@code
* false} otherwise.
*
* @return {@code true} if this is an open module and {@code
* false} otherwise
*/ // TODO: add @jls to unnamed module section
boolean isOpen();
/**
* Returns {@code true} if this is an unnamed module and {@code
* false} otherwise.

View File

@ -947,6 +947,11 @@ public abstract class Symbol extends AnnoConstruct implements Element {
this.type = new ModuleType(this);
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public boolean isOpen() {
return flags.contains(ModuleFlags.OPEN);
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public boolean isUnnamed() {
return name.isEmpty() && owner == null;

View File

@ -306,9 +306,9 @@ public class PrintingProcessor extends AbstractProcessor {
defaultAction(e, false);
if (!e.isUnnamed()) {
// TODO: openness of the module not currently exposed
// by the language model API, but should be printed
// here once available.
if (e.isOpen()) {
writer.print("open ");
}
writer.println("module " + e.getQualifiedName() + " {");
indentation++;
for (ModuleElement.Directive directive : e.getDirectives()) {