use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class IndexDoc method indexMembers.
private void indexMembers(Scope container, List<Declaration> members) throws IOException {
for (Declaration decl : members) {
if (!tool.shouldInclude(decl)) {
continue;
}
if (decl instanceof ClassOrInterface) {
ClassOrInterface classOrInterface = (ClassOrInterface) decl;
indexMembers(classOrInterface, classOrInterface.getMembers());
}
if (indexDecl(container, decl)) {
write(",\n");
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class AbstractTransformer method makeReifiedTypeArguments.
public java.util.List<JCExpression> makeReifiedTypeArguments(Reference ref) {
ref = resolveAliasesForReifiedTypeArguments(ref);
Declaration declaration = ref.getDeclaration();
if (!supportsReified(declaration))
return Collections.emptyList();
return makeReifiedTypeArguments(getTypeArguments(ref));
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class AbstractTransformer method canUseFastFailTypeTest.
private boolean canUseFastFailTypeTest(Type type) {
if (type.getDeclaration() instanceof ClassOrInterface == false)
return false;
boolean isRaw = !type.getDeclaration().getTypeParameters().isEmpty();
Type qualifyingType = type.getQualifyingType();
if (qualifyingType == null && // ignore qualifying types of static java declarations
(Decl.isCeylon(type.getDeclaration()) || !type.getDeclaration().isStaticallyImportable())) {
Declaration declaration = type.getDeclaration();
boolean local = false;
do {
// getDeclarationContainer will skip some containers we don't want to consider, so it's not good
// for checking locality, rely on isLocal for that.
local |= Decl.isLocal(declaration);
// it may be contained in a function or value, and we want its type
Declaration enclosingDeclaration = getDeclarationContainer(declaration);
if (enclosingDeclaration instanceof TypedDeclaration) {
local = true;
// look up the containers
declaration = enclosingDeclaration;
} else if (enclosingDeclaration instanceof TypeDeclaration) {
// we can't do instanceof on a local whose outer types contain type parameters, unless the local is raw
if (enclosingDeclaration instanceof Generic && local && !isRaw && !((Generic) enclosingDeclaration).getTypeParameters().isEmpty())
return false;
// look up the containers
declaration = enclosingDeclaration;
} else {
// that's fucked up
break;
}
// go up every containing typed declaration
} while (declaration != null);
// we can fast-fail!
return true;
} else if (qualifyingType != null) {
// we can only fast-fail if the qualifying type can also be fast-failed
return canUseFastFailTypeTest(qualifyingType);
} else {
// we can fast-fail!
return true;
}
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class CeylonEnter method typeCheck.
private void typeCheck() {
final java.util.List<PhasedUnit> listOfUnits = phasedUnits.getPhasedUnits();
// Delegate to an external typechecker (e.g. the IDE build)
compilerDelegate.typeCheck(listOfUnits);
if (sp != null) {
sp.clearLine();
sp.log("Preparation phase");
}
int size = listOfUnits.size();
int i = 1;
// This phase is proper to the Java backend
ForcedCaptureVisitor fcv = new ForcedCaptureVisitor();
for (PhasedUnit pu : listOfUnits) {
if (sp != null)
progressPreparation(1, i++, size, pu);
Unit unit = pu.getUnit();
final CompilationUnit compilationUnit = pu.getCompilationUnit();
compilationUnit.visit(fcv);
for (Declaration d : unit.getDeclarations()) {
if (d instanceof TypedDeclaration && !(d instanceof Setter) && // skip already captured members
!d.isCaptured()) {
compilationUnit.visit(new MethodOrValueReferenceVisitor((TypedDeclaration) d));
}
}
}
UnsupportedVisitor uv = new UnsupportedVisitor();
JvmMissingNativeVisitor mnv = new JvmMissingNativeVisitor(modelLoader);
BoxingDeclarationVisitor boxingDeclarationVisitor = new CompilerBoxingDeclarationVisitor(gen);
BoxingVisitor boxingVisitor = new CompilerBoxingVisitor(gen);
DeferredVisitor deferredVisitor = new DeferredVisitor();
AnnotationModelVisitor amv = new AnnotationModelVisitor(gen);
DefiniteAssignmentVisitor dav = new DefiniteAssignmentVisitor();
TypeParameterCaptureVisitor tpCaptureVisitor = new TypeParameterCaptureVisitor();
InterfaceVisitor localInterfaceVisitor = new InterfaceVisitor();
// Extra phases for the compiler
// boxing visitor depends on boxing decl
i = 1;
for (PhasedUnit pu : listOfUnits) {
if (sp != null)
progressPreparation(2, i++, size, pu);
pu.getCompilationUnit().visit(uv);
}
i = 1;
for (PhasedUnit pu : listOfUnits) {
if (sp != null)
progressPreparation(3, i++, size, pu);
pu.getCompilationUnit().visit(boxingDeclarationVisitor);
}
i = 1;
// the others can run at the same time
for (PhasedUnit pu : listOfUnits) {
if (sp != null)
progressPreparation(4, i++, size, pu);
CompilationUnit compilationUnit = pu.getCompilationUnit();
compilationUnit.visit(mnv);
compilationUnit.visit(boxingVisitor);
compilationUnit.visit(deferredVisitor);
compilationUnit.visit(amv);
compilationUnit.visit(dav);
compilationUnit.visit(tpCaptureVisitor);
compilationUnit.visit(localInterfaceVisitor);
}
i = 1;
for (PhasedUnit pu : listOfUnits) {
if (sp != null)
progressPreparation(5, i++, size, pu);
CompilationUnit compilationUnit = pu.getCompilationUnit();
compilationUnit.visit(new WarningSuppressionVisitor<Warning>(Warning.class, pu.getSuppressedWarnings()));
}
collectTreeErrors(true, true);
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class DeclarationErrorVisitor method visit.
public void visit(Tree.ExtendedType that) {
that.getType().visit(this);
// error if we tried to generate a ctor for this class.
if (that.getType().getDeclarationModel() instanceof LazyClass && !((LazyClass) that.getType().getDeclarationModel()).isCeylon()) {
boolean hasPrivateCtor = false;
List<Declaration> overloads = ((LazyClass) that.getType().getDeclarationModel()).getOverloads();
if (overloads != null) {
for (Declaration ctor : overloads) {
if (!ctor.isShared()) {
hasPrivateCtor = true;
break;
}
}
}
if (hasPrivateCtor) {
that.getInvocationExpression().visit(this);
}
}
}
Aggregations