751 public Void visitThrows(ThrowsTree tree, Void ignore) { |
751 public Void visitThrows(ThrowsTree tree, Void ignore) { |
752 ReferenceTree exName = tree.getExceptionName(); |
752 ReferenceTree exName = tree.getExceptionName(); |
753 Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); |
753 Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName)); |
754 if (ex == null) { |
754 if (ex == null) { |
755 env.messages.error(REFERENCE, tree, "dc.ref.not.found"); |
755 env.messages.error(REFERENCE, tree, "dc.ref.not.found"); |
756 } else if (ex.asType().getKind() == TypeKind.DECLARED |
756 } else if (isThrowable(ex.asType())) { |
757 && env.types.isAssignable(ex.asType(), env.java_lang_Throwable)) { |
|
758 switch (env.currElement.getKind()) { |
757 switch (env.currElement.getKind()) { |
759 case CONSTRUCTOR: |
758 case CONSTRUCTOR: |
760 case METHOD: |
759 case METHOD: |
761 if (isCheckedException(ex.asType())) { |
760 if (isCheckedException(ex.asType())) { |
762 ExecutableElement ee = (ExecutableElement) env.currElement; |
761 ExecutableElement ee = (ExecutableElement) env.currElement; |
769 } else { |
768 } else { |
770 env.messages.error(REFERENCE, tree, "dc.invalid.throws"); |
769 env.messages.error(REFERENCE, tree, "dc.invalid.throws"); |
771 } |
770 } |
772 warnIfEmpty(tree, tree.getDescription()); |
771 warnIfEmpty(tree, tree.getDescription()); |
773 return scan(tree.getDescription(), ignore); |
772 return scan(tree.getDescription(), ignore); |
|
773 } |
|
774 |
|
775 private boolean isThrowable(TypeMirror tm) { |
|
776 switch (tm.getKind()) { |
|
777 case DECLARED: |
|
778 case TYPEVAR: |
|
779 return env.types.isAssignable(tm, env.java_lang_Throwable); |
|
780 } |
|
781 return false; |
774 } |
782 } |
775 |
783 |
776 private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) { |
784 private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) { |
777 boolean found = false; |
785 boolean found = false; |
778 for (TypeMirror tl : list) { |
786 for (TypeMirror tl : list) { |