package com.redhat.ceylon.compiler.typechecker.util;

import com.redhat.ceylon.compiler.typechecker.analyzer.Warning;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.compiler.typechecker.tree.Visitor;
import com.redhat.ceylon.model.typechecker.model.Declaration;
import com.redhat.ceylon.model.typechecker.model.TypeDeclaration;

public class DeprecationVisitor extends Visitor {
    
    @Override
    public void visit(Tree.MemberOrTypeExpression that) {
        super.visit(that);
        Declaration d = that.getDeclaration();
		if (d!=null && d.isDeprecated()) {
		    that.addUsageWarning(Warning.deprecation,
                    "declaration is deprecated: '" + 
                        d.getName() + "'");
        }
    }
    @Override
    public void visit(Tree.SimpleType that) {
    	super.visit(that);
        TypeDeclaration d = that.getDeclarationModel();
		if (d!=null && d.isDeprecated()) {
		    that.addUsageWarning(Warning.deprecation, 
                    "type is deprecated: '" + 
                        d.getName() + "'");
        }
    }
    @Override
    public void visit(Tree.ImportMemberOrType that) {
        super.visit(that);
        Declaration d = that.getDeclarationModel();
		if (d!=null && d.isDeprecated()) {
		    that.addUsageWarning(Warning.deprecation,
                    "imported declaration is deprecated: '" + 
                            d.getName() + "'");
        }
    }

    @Override
    public void visit(Tree.CompilerAnnotation that) {
        super.visit(that);
        that.addUsageWarning(Warning.compilerAnnotation,
                    "compiler annotations are an unsupported language feature");
    }
    
}

@@ -228,16 +228,134 @@
 isitor;%0A
+import com.redhat.ceylon.model.typechecker.model.Class;%0Aimport com.redhat.ceylon.model.typechecker.model.Constructor;%0A
 import c
@@ -861,32 +861,437 @@
 %22'%22);%0A        %7D%0A
+%09%09if (d instanceof Class && %0A%09%09        that.getDirectlyInvoked()) %7B%0A%09%09    Class c = (Class) d;%0A            Constructor dc = c.getDefaultConstructor();%0A            if (dc!=null && dc.isDeprecated()) %7B%0A                that.addUsageWarning(Warning.deprecation,%0A                        %22declaration is deprecated: default constructor of '%22 + %0A                            d.getName() + %22'%22);%0A            %7D%0A%09%09%7D%0A
     %7D%0A    @Overr

fix #1437 deprecated default constructors