use of org.eclipse.ceylon.javax.lang.model.element.NestingKind in project ceylon by eclipse.
the class CeylonTransformer method transformPackageInfo.
public List<JCCompilationUnit> transformPackageInfo(CeylonCompilationUnit ccu) {
final CeylonFileObject fo = (CeylonFileObject) ((CeylonPhasedUnit) ccu.phasedUnit).getFileObject();
ListBuffer<JCCompilationUnit> packageInfos = new ListBuffer<JCCompilationUnit>();
for (Tree.PackageDescriptor pack : ccu.ceylonTree.getPackageDescriptors()) {
List<JCAnnotation> packageAnnotations = expressionGen().transformAnnotations(OutputElement.PACKAGE, pack);
if (packageAnnotations.isEmpty()) {
continue;
}
JCCompilationUnit packageInfo = make().TopLevel(packageAnnotations, naming.makeQuotedFQIdent(pack.getScope().getQualifiedNameString()), List.<JCTree>nil());
// Enter.visitTopLevel(JCCompilationUnit) uses the tree.sourceFile
// to decide whether it's seeing a package-info.java
// So set up a fake one...
packageInfo.sourcefile = new JavaFileObject() {
@Override
public boolean isNameCompatible(String simpleName, Kind kind) {
return "package-info".equals(simpleName) && JavaFileObject.Kind.SOURCE == kind;
}
@Override
public URI toUri() {
return fo.toUri();
}
@Override
public String getName() {
return fo.getName();
}
@Override
public InputStream openInputStream() throws IOException {
return fo.openInputStream();
}
@Override
public OutputStream openOutputStream() throws IOException {
return fo.openOutputStream();
}
@Override
public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
return fo.openReader(ignoreEncodingErrors);
}
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return fo.getCharContent(ignoreEncodingErrors);
}
@Override
public Writer openWriter() throws IOException {
return fo.openWriter();
}
@Override
public long getLastModified() {
return fo.getLastModified();
}
@Override
public boolean delete() {
return fo.delete();
}
@Override
public Kind getKind() {
return fo.getKind();
}
@Override
public NestingKind getNestingKind() {
return fo.getNestingKind();
}
@Override
public Modifier getAccessLevel() {
return fo.getAccessLevel();
}
};
packageInfos.add(packageInfo);
}
return packageInfos.toList();
}
Aggregations