1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java Fri May 03 15:08:47 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java Fri May 03 17:44:38 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -48,9 +48,9 @@ 1.11 */ 1.12 public static class Input { 1.13 /** 1.14 - * The method to search documentation from. 1.15 + * The element to search documentation from. 1.16 */ 1.17 - public MethodDoc method = null; 1.18 + public ProgramElementDoc element; 1.19 /** 1.20 * The taglet to search for documentation on behalf of. Null if we want 1.21 * to search for overall documentation. 1.22 @@ -84,54 +84,55 @@ 1.23 */ 1.24 public boolean isTypeVariableParamTag = false; 1.25 1.26 - public Input() {} 1.27 - 1.28 - public Input(MethodDoc method, InheritableTaglet taglet, Tag tag, 1.29 + public Input(ProgramElementDoc element, InheritableTaglet taglet, Tag tag, 1.30 boolean isFirstSentence, boolean isInheritDocTag) { 1.31 - this.method = method; 1.32 + this(element); 1.33 this.taglet = taglet; 1.34 this.tag = tag; 1.35 this.isFirstSentence = isFirstSentence; 1.36 this.isInheritDocTag = isInheritDocTag; 1.37 } 1.38 1.39 - public Input(MethodDoc method, InheritableTaglet taglet, String tagId) { 1.40 - this.method = method; 1.41 + public Input(ProgramElementDoc element, InheritableTaglet taglet, String tagId) { 1.42 + this(element); 1.43 this.taglet = taglet; 1.44 this.tagId = tagId; 1.45 } 1.46 1.47 - public Input(MethodDoc method, InheritableTaglet taglet, String tagId, 1.48 + public Input(ProgramElementDoc element, InheritableTaglet taglet, String tagId, 1.49 boolean isTypeVariableParamTag) { 1.50 - this.method = method; 1.51 + this(element); 1.52 this.taglet = taglet; 1.53 this.tagId = tagId; 1.54 this.isTypeVariableParamTag = isTypeVariableParamTag; 1.55 } 1.56 1.57 - public Input(MethodDoc method, InheritableTaglet taglet) { 1.58 - this.method = method; 1.59 + public Input(ProgramElementDoc element, InheritableTaglet taglet) { 1.60 + this(element); 1.61 this.taglet = taglet; 1.62 } 1.63 1.64 - public Input(MethodDoc method) { 1.65 - this.method = method; 1.66 + public Input(ProgramElementDoc element) { 1.67 + if (element == null) 1.68 + throw new NullPointerException(); 1.69 + this.element = element; 1.70 } 1.71 1.72 - public Input(MethodDoc method, boolean isFirstSentence) { 1.73 - this.method = method; 1.74 + public Input(ProgramElementDoc element, boolean isFirstSentence) { 1.75 + this(element); 1.76 this.isFirstSentence = isFirstSentence; 1.77 } 1.78 1.79 public Input copy() { 1.80 - Input clone = new Input(); 1.81 - clone.method = this.method; 1.82 + Input clone = new Input(this.element); 1.83 clone.taglet = this.taglet; 1.84 clone.tagId = this.tagId; 1.85 clone.tag = this.tag; 1.86 clone.isFirstSentence = this.isFirstSentence; 1.87 clone.isInheritDocTag = this.isInheritDocTag; 1.88 clone.isTypeVariableParamTag = this.isTypeVariableParamTag; 1.89 + if (clone.element == null) 1.90 + throw new NullPointerException(); 1.91 return clone; 1.92 1.93 } 1.94 @@ -164,8 +165,8 @@ 1.95 1.96 /** 1.97 * When automatically inheriting throws tags, you sometime must inherit 1.98 - * more than one tag. For example if the method declares that it throws 1.99 - * IOException and the overidden method has throws tags for IOException and 1.100 + * more than one tag. For example if the element declares that it throws 1.101 + * IOException and the overridden element has throws tags for IOException and 1.102 * ZipException, both tags would be inherited because ZipException is a 1.103 * subclass of IOException. This subclass of DocFinder.Output allows 1.104 * multiple tag inheritence. 1.105 @@ -174,9 +175,9 @@ 1.106 } 1.107 1.108 /** 1.109 - * Search for the requested comments in the given method. If it does not 1.110 - * have comments, return documentation from the overriden method if possible. 1.111 - * If the overriden method does not exist or does not have documentation to 1.112 + * Search for the requested comments in the given element. If it does not 1.113 + * have comments, return documentation from the overriden element if possible. 1.114 + * If the overriden element does not exist or does not have documentation to 1.115 * inherit, search for documentation to inherit from implemented methods. 1.116 * 1.117 * @param input the input object used to perform the search. 1.118 @@ -186,14 +187,14 @@ 1.119 public static Output search(Input input) { 1.120 Output output = new Output(); 1.121 if (input.isInheritDocTag) { 1.122 - //Do nothing because "method" does not have any documentation. 1.123 + //Do nothing because "element" does not have any documentation. 1.124 //All it has it {@inheritDoc}. 1.125 } else if (input.taglet == null) { 1.126 //We want overall documentation. 1.127 output.inlineTags = input.isFirstSentence ? 1.128 - input.method.firstSentenceTags() : 1.129 - input.method.inlineTags(); 1.130 - output.holder = input.method; 1.131 + input.element.firstSentenceTags() : 1.132 + input.element.inlineTags(); 1.133 + output.holder = input.element; 1.134 } else { 1.135 input.taglet.inherit(input, output); 1.136 } 1.137 @@ -204,25 +205,38 @@ 1.138 output.isValidInheritDocTag = false; 1.139 Input inheritedSearchInput = input.copy(); 1.140 inheritedSearchInput.isInheritDocTag = false; 1.141 - if (input.method.overriddenMethod() != null) { 1.142 - inheritedSearchInput.method = input.method.overriddenMethod(); 1.143 - output = search(inheritedSearchInput); 1.144 - output.isValidInheritDocTag = true; 1.145 - if (output != null && output.inlineTags.length > 0) { 1.146 - return output; 1.147 + if (input.element instanceof MethodDoc) { 1.148 + MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod(); 1.149 + if (overriddenMethod != null) { 1.150 + inheritedSearchInput.element = overriddenMethod; 1.151 + output = search(inheritedSearchInput); 1.152 + output.isValidInheritDocTag = true; 1.153 + if (output.inlineTags.length > 0) { 1.154 + return output; 1.155 + } 1.156 } 1.157 - } 1.158 - //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does 1.159 - // not pass all implemented interfaces, we will use the 1.160 - // appropriate method here. 1.161 - MethodDoc[] implementedMethods = 1.162 - (new ImplementedMethods(input.method, null)).build(false); 1.163 - for (int i = 0; i < implementedMethods.length; i++) { 1.164 - inheritedSearchInput.method = implementedMethods[i]; 1.165 - output = search(inheritedSearchInput); 1.166 - output.isValidInheritDocTag = true; 1.167 - if (output != null && output.inlineTags.length > 0) { 1.168 - return output; 1.169 + //NOTE: When we fix the bug where ClassDoc.interfaceTypes() does 1.170 + // not pass all implemented interfaces, we will use the 1.171 + // appropriate element here. 1.172 + MethodDoc[] implementedMethods = 1.173 + (new ImplementedMethods((MethodDoc) input.element, null)).build(false); 1.174 + for (int i = 0; i < implementedMethods.length; i++) { 1.175 + inheritedSearchInput.element = implementedMethods[i]; 1.176 + output = search(inheritedSearchInput); 1.177 + output.isValidInheritDocTag = true; 1.178 + if (output.inlineTags.length > 0) { 1.179 + return output; 1.180 + } 1.181 + } 1.182 + } else if (input.element instanceof ClassDoc) { 1.183 + ProgramElementDoc superclass = ((ClassDoc) input.element).superclass(); 1.184 + if (superclass != null) { 1.185 + inheritedSearchInput.element = superclass; 1.186 + output = search(inheritedSearchInput); 1.187 + output.isValidInheritDocTag = true; 1.188 + if (output.inlineTags.length > 0) { 1.189 + return output; 1.190 + } 1.191 } 1.192 } 1.193 return output;