langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
97 |
97 |
98 /** |
98 /** |
99 * The configuration this VisibleMemberMap was created with. |
99 * The configuration this VisibleMemberMap was created with. |
100 */ |
100 */ |
101 private final Configuration configuration; |
101 private final Configuration configuration; |
|
102 private final Utils utils; |
102 |
103 |
103 private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache = new HashMap<>(); |
104 private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache = new HashMap<>(); |
104 private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = new HashMap<>(); |
105 private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = new HashMap<>(); |
105 private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap = new HashMap<>(); |
106 private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap = new HashMap<>(); |
106 |
107 |
119 int kind, |
120 int kind, |
120 Configuration configuration) { |
121 Configuration configuration) { |
121 this.classdoc = classdoc; |
122 this.classdoc = classdoc; |
122 this.kind = kind; |
123 this.kind = kind; |
123 this.configuration = configuration; |
124 this.configuration = configuration; |
|
125 this.utils = configuration.utils; |
124 new ClassMembers(classdoc, STARTLEVEL).build(); |
126 new ClassMembers(classdoc, STARTLEVEL).build(); |
125 } |
127 } |
126 |
128 |
127 /** |
129 /** |
128 * Return the list of visible classes in this map. |
130 * Return the list of visible classes in this map. |
171 private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) { |
173 private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) { |
172 List<ProgramElementDoc> results = new ArrayList<>(); |
174 List<ProgramElementDoc> results = new ArrayList<>(); |
173 for (ClassDoc currentClass : visibleClasses) { |
175 for (ClassDoc currentClass : visibleClasses) { |
174 if (currentClass != classdoc && |
176 if (currentClass != classdoc && |
175 currentClass.isPackagePrivate() && |
177 currentClass.isPackagePrivate() && |
176 !Util.isLinkable(currentClass, configuration)) { |
178 !utils.isLinkable(currentClass, configuration)) { |
177 // Document these members in the child class because |
179 // Document these members in the child class because |
178 // the parent is inaccessible. |
180 // the parent is inaccessible. |
179 results.addAll(getMembersFor(currentClass)); |
181 results.addAll(getMembersFor(currentClass)); |
180 } |
182 } |
181 } |
183 } |
268 members.add(programElementDoc); |
270 members.add(programElementDoc); |
269 } |
271 } |
270 |
272 |
271 public boolean isEqual(MethodDoc member) { |
273 public boolean isEqual(MethodDoc member) { |
272 for (ProgramElementDoc element : members) { |
274 for (ProgramElementDoc element : members) { |
273 if (Util.executableMembersEqual(member, (MethodDoc) element)) { |
275 if (utils.executableMembersEqual(member, (MethodDoc) element)) { |
274 members.add(member); |
276 members.add(member); |
275 return true; |
277 return true; |
276 } |
278 } |
277 } |
279 } |
278 return false; |
280 return false; |
463 default: |
465 default: |
464 members = new ProgramElementDoc[0]; |
466 members = new ProgramElementDoc[0]; |
465 } |
467 } |
466 // Deprected members should be excluded or not? |
468 // Deprected members should be excluded or not? |
467 if (configuration.nodeprecated) { |
469 if (configuration.nodeprecated) { |
468 return Util.excludeDeprecatedMembersAsList(members); |
470 return utils.excludeDeprecatedMembersAsList(members); |
469 } |
471 } |
470 return Arrays.asList(members); |
472 return Arrays.asList(members); |
471 } |
473 } |
472 |
474 |
473 /** |
475 /** |
494 return targetMembers.toArray(new AnnotationTypeElementDoc[]{}); |
496 return targetMembers.toArray(new AnnotationTypeElementDoc[]{}); |
495 } |
497 } |
496 |
498 |
497 private boolean found(List<ProgramElementDoc> list, ProgramElementDoc elem) { |
499 private boolean found(List<ProgramElementDoc> list, ProgramElementDoc elem) { |
498 for (ProgramElementDoc pgmelem : list) { |
500 for (ProgramElementDoc pgmelem : list) { |
499 if (Util.matches(pgmelem, elem)) { |
501 if (utils.matches(pgmelem, elem)) { |
500 return true; |
502 return true; |
501 } |
503 } |
502 } |
504 } |
503 return false; |
505 return false; |
504 } |
506 } |
690 } |
692 } |
691 |
693 |
692 private boolean isPropertyGetterOrSetter(MethodDoc[] members, |
694 private boolean isPropertyGetterOrSetter(MethodDoc[] members, |
693 MethodDoc methodDoc) { |
695 MethodDoc methodDoc) { |
694 boolean found = false; |
696 boolean found = false; |
695 String propertyName = Util.propertyNameFromMethodName(configuration, methodDoc.name()); |
697 String propertyName = utils.propertyNameFromMethodName(configuration, methodDoc.name()); |
696 if (!propertyName.isEmpty()) { |
698 if (!propertyName.isEmpty()) { |
697 String propertyMethodName = propertyName + "Property"; |
699 String propertyMethodName = propertyName + "Property"; |
698 for (MethodDoc member: members) { |
700 for (MethodDoc member: members) { |
699 if (member.name().equals(propertyMethodName)) { |
701 if (member.name().equals(propertyMethodName)) { |
700 found = true; |
702 found = true; |