use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class ExpressionTransformer method transform.
public JCTree transform(Tree.PackageLiteral expr) {
at(expr);
Package pkg = (Package) expr.getImportPath().getModel();
return makePackageLiteralCall(pkg);
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class CodegenUtil method getJavaNameOfDeclaration.
/**
* <p>Returns the fully qualified name java name of the given declaration,
* for example
* {@code ceylon.language.sum_.sum} or {@code my.package.Outer.Inner}.
* for any toplevel or externally visible Ceylon declaration.</p>
*
* <p>Used by the IDE to support finding/renaming Ceylon declarations
* called from Java.</p>
* */
public static String getJavaNameOfDeclaration(Declaration decl) {
Scope s = decl.getScope();
while (!(s instanceof Package)) {
if (!(s instanceof TypeDeclaration)) {
throw new IllegalArgumentException();
}
s = s.getContainer();
}
String result;
Naming n = new Naming(null, null);
if (decl instanceof TypeDeclaration) {
result = n.makeTypeDeclarationName((TypeDeclaration) decl, DeclNameFlag.QUALIFIED);
// remove initial .
result = result.substring(1);
if (decl.isAnonymous()) {
result += "." + Unfix.get_.toString();
}
} else if (decl instanceof TypedDeclaration) {
if (decl.isToplevel()) {
result = n.getName((TypedDeclaration) decl, Naming.NA_FQ | Naming.NA_WRAPPER | Naming.NA_MEMBER);
// remove initial .
result = result.substring(1);
} else {
Scope container = decl.getContainer();
if (container instanceof TypeDeclaration) {
String qualifier = getJavaNameOfDeclaration((TypeDeclaration) container);
result = qualifier + n.getName((TypedDeclaration) decl, Naming.NA_MEMBER);
} else {
throw new IllegalArgumentException();
}
}
} else {
throw new RuntimeException();
}
return result;
}
Aggregations