Lines 64-69
Link Here
|
64 |
} |
64 |
} |
65 |
|
65 |
|
66 |
/* |
66 |
/* |
|
|
67 |
* Search node with a given staring position in javadoc objects arrays. |
68 |
*/ |
69 |
public ASTNode getNodeStartingAt(int start) { |
70 |
int length = 0; |
71 |
// parameters array |
72 |
if (this.paramReferences != null) { |
73 |
length = this.paramReferences.length; |
74 |
for (int i=0; i<length; i++) { |
75 |
JavadocSingleNameReference param = this.paramReferences[i]; |
76 |
if (param.sourceStart==start) { |
77 |
return param; |
78 |
} |
79 |
} |
80 |
} |
81 |
// array of invalid syntax tags parameters |
82 |
if (this.invalidParameters != null) { |
83 |
length = this.invalidParameters.length; |
84 |
for (int i=0; i<length; i++) { |
85 |
JavadocSingleNameReference param = this.invalidParameters[i]; |
86 |
if (param.sourceStart==start) { |
87 |
return param; |
88 |
} |
89 |
} |
90 |
} |
91 |
// type parameters array |
92 |
if (this.paramTypeParameters != null) { |
93 |
length = this.paramTypeParameters.length; |
94 |
for (int i=0; i<length; i++) { |
95 |
JavadocSingleTypeReference param = this.paramTypeParameters[i]; |
96 |
if (param.sourceStart==start) { |
97 |
return param; |
98 |
} |
99 |
} |
100 |
} |
101 |
// thrown exception array |
102 |
if (this.exceptionReferences != null) { |
103 |
length = this.exceptionReferences.length; |
104 |
for (int i=0; i<length; i++) { |
105 |
TypeReference typeRef = this.exceptionReferences[i]; |
106 |
if (typeRef.sourceStart==start) { |
107 |
return typeRef; |
108 |
} |
109 |
} |
110 |
} |
111 |
// references array |
112 |
if (this.seeReferences != null) { |
113 |
length = this.seeReferences.length; |
114 |
for (int i=0; i<length; i++) { |
115 |
org.eclipse.jdt.internal.compiler.ast.Expression expression = this.seeReferences[i]; |
116 |
if (expression.sourceStart==start) { |
117 |
return expression; |
118 |
} else if (expression instanceof JavadocAllocationExpression) { |
119 |
JavadocAllocationExpression allocationExpr = (JavadocAllocationExpression) this.seeReferences[i]; |
120 |
// if binding is valid then look at arguments |
121 |
if (allocationExpr.binding != null && allocationExpr.binding.isValidBinding()) { |
122 |
if (allocationExpr.arguments != null) { |
123 |
for (int j=0, l=allocationExpr.arguments.length; j<l; j++) { |
124 |
if (allocationExpr.arguments[j].sourceStart == start) { |
125 |
return allocationExpr.arguments[j]; |
126 |
} |
127 |
} |
128 |
} |
129 |
} |
130 |
} else if (expression instanceof JavadocMessageSend) { |
131 |
JavadocMessageSend messageSend = (JavadocMessageSend) this.seeReferences[i]; |
132 |
// if binding is valid then look at arguments |
133 |
if (messageSend.binding != null && messageSend.binding.isValidBinding()) { |
134 |
if (messageSend.arguments != null) { |
135 |
for (int j=0, l=messageSend.arguments.length; j<l; j++) { |
136 |
if (messageSend.arguments[j].sourceStart == start) { |
137 |
return messageSend.arguments[j]; |
138 |
} |
139 |
} |
140 |
} |
141 |
} |
142 |
} |
143 |
} |
144 |
} |
145 |
return null; |
146 |
} |
147 |
|
148 |
/* |
67 |
* @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuffer) |
149 |
* @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuffer) |
68 |
*/ |
150 |
*/ |
69 |
public StringBuffer print(int indent, StringBuffer output) { |
151 |
public StringBuffer print(int indent, StringBuffer output) { |
Lines 288-293
Link Here
|
288 |
} |
370 |
} |
289 |
} |
371 |
} |
290 |
|
372 |
|
|
|
373 |
// Verify type references |
374 |
// TODO (frederic) fix for bug 119857 |
375 |
/* |
376 |
if (fieldRef.binding != null && fieldRef.binding.isValidBinding() && fieldRef.receiverType instanceof ReferenceBinding) { |
377 |
ReferenceBinding resolvedType = (ReferenceBinding) fieldRef.receiverType; |
378 |
verifyTypeReference(fieldRef.receiver, scope, source15, resolvedType); |
379 |
} |
380 |
*/ |
381 |
|
291 |
// That's it for field references |
382 |
// That's it for field references |
292 |
return; |
383 |
return; |
293 |
} |
384 |
} |
Lines 295-337
Link Here
|
295 |
// Verify type references |
386 |
// Verify type references |
296 |
if ((reference instanceof JavadocSingleTypeReference || reference instanceof JavadocQualifiedTypeReference) && reference.resolvedType instanceof ReferenceBinding) { |
387 |
if ((reference instanceof JavadocSingleTypeReference || reference instanceof JavadocQualifiedTypeReference) && reference.resolvedType instanceof ReferenceBinding) { |
297 |
ReferenceBinding resolvedType = (ReferenceBinding) reference.resolvedType; |
388 |
ReferenceBinding resolvedType = (ReferenceBinding) reference.resolvedType; |
298 |
if (reference.resolvedType.isValidBinding()) { |
389 |
verifyTypeReference(reference, scope, source15, resolvedType); |
299 |
|
|
|
300 |
// member types |
301 |
if (resolvedType.isMemberType()) { |
302 |
ReferenceBinding topLevelType = resolvedType; |
303 |
int depth = 0; |
304 |
while (topLevelType.enclosingType() != null) { |
305 |
topLevelType = topLevelType.enclosingType(); |
306 |
depth++; |
307 |
} |
308 |
ClassScope topLevelScope = scope.classScope(); |
309 |
// when scope is not on compilation unit type, then inner class may not be visible... |
310 |
if (topLevelScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE || |
311 |
!CharOperation.equals(topLevelType.sourceName, topLevelScope.referenceContext.name)) { |
312 |
topLevelScope = topLevelScope.outerMostClassScope(); |
313 |
if (reference instanceof JavadocSingleTypeReference) { |
314 |
// inner class single reference can only be done in same unit |
315 |
if ((!source15 && depth == 1) || topLevelType != topLevelScope.referenceContext.binding) { |
316 |
if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers(); |
317 |
scope.problemReporter().javadocNotVisibleReference(reference.sourceStart, reference.sourceEnd, scopeModifiers); |
318 |
} |
319 |
} else { |
320 |
// inner class qualified reference can only be done in same package |
321 |
if (topLevelType.getPackage() != topLevelScope.referenceContext.binding.getPackage()) { |
322 |
if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers(); |
323 |
scope.problemReporter().javadocNotVisibleReference(reference.sourceStart, reference.sourceEnd, scopeModifiers); |
324 |
} |
325 |
} |
326 |
} |
327 |
} |
328 |
|
329 |
// reference must have enough visibility to be used |
330 |
if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, resolvedType)) { |
331 |
if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers(); |
332 |
scope.problemReporter().javadocNotVisibleReference(reference.sourceStart, reference.sourceEnd, scopeModifiers); |
333 |
} |
334 |
} |
335 |
} |
390 |
} |
336 |
|
391 |
|
337 |
// Verify that message reference are not used for @value tags |
392 |
// Verify that message reference are not used for @value tags |
Lines 344-349
Link Here
|
344 |
scope.problemReporter().javadocInvalidValueReference(msgSend.sourceStart, msgSend.sourceEnd, scopeModifiers); |
399 |
scope.problemReporter().javadocInvalidValueReference(msgSend.sourceStart, msgSend.sourceEnd, scopeModifiers); |
345 |
} |
400 |
} |
346 |
|
401 |
|
|
|
402 |
// Verify type references |
403 |
// TODO (frederic) fix for bug 119857 |
404 |
/* |
405 |
if (msgSend.binding != null && msgSend.binding.isValidBinding() && msgSend.actualReceiverType instanceof ReferenceBinding) { |
406 |
ReferenceBinding resolvedType = (ReferenceBinding) msgSend.actualReceiverType; |
407 |
verifyTypeReference(msgSend.receiver, scope, source15, resolvedType); |
408 |
} |
409 |
*/ |
347 |
} |
410 |
} |
348 |
|
411 |
|
349 |
// Verify that constructor reference are not used for @value tags |
412 |
// Verify that constructor reference are not used for @value tags |
Lines 356-361
Link Here
|
356 |
scope.problemReporter().javadocInvalidValueReference(alloc.sourceStart, alloc.sourceEnd, scopeModifiers); |
419 |
scope.problemReporter().javadocInvalidValueReference(alloc.sourceStart, alloc.sourceEnd, scopeModifiers); |
357 |
} |
420 |
} |
358 |
|
421 |
|
|
|
422 |
// Verify type references |
423 |
// TODO (frederic) fix for bug 119857 |
424 |
/* |
425 |
if (alloc.binding != null && alloc.binding.isValidBinding() && alloc.resolvedType instanceof ReferenceBinding) { |
426 |
ReferenceBinding resolvedType = (ReferenceBinding) alloc.resolvedType; |
427 |
verifyTypeReference(alloc.type, scope, source15, resolvedType); |
428 |
} |
429 |
*/ |
359 |
} |
430 |
} |
360 |
|
431 |
|
361 |
// Verify that there's no type variable reference |
432 |
// Verify that there's no type variable reference |
Lines 640-725
Link Here
|
640 |
} |
711 |
} |
641 |
} |
712 |
} |
642 |
} |
713 |
} |
643 |
|
714 |
|
644 |
/* |
715 |
private void verifyTypeReference(Expression reference, Scope scope, boolean source15, ReferenceBinding resolvedType) { |
645 |
* Search node with a given staring position in javadoc objects arrays. |
716 |
if (resolvedType.isValidBinding()) { |
646 |
*/ |
717 |
int scopeModifiers = -1; |
647 |
public ASTNode getNodeStartingAt(int start) { |
718 |
|
648 |
int length = 0; |
719 |
// member types |
649 |
// parameters array |
720 |
if (resolvedType.isMemberType()) { |
650 |
if (this.paramReferences != null) { |
721 |
ReferenceBinding topLevelType = resolvedType; |
651 |
length = this.paramReferences.length; |
722 |
int depth = 0; |
652 |
for (int i=0; i<length; i++) { |
723 |
while (topLevelType.enclosingType() != null) { |
653 |
JavadocSingleNameReference param = this.paramReferences[i]; |
724 |
topLevelType = topLevelType.enclosingType(); |
654 |
if (param.sourceStart==start) { |
725 |
depth++; |
655 |
return param; |
726 |
} |
656 |
} |
727 |
ClassScope topLevelScope = scope.classScope(); |
657 |
} |
728 |
// when scope is not on compilation unit type, then inner class may not be visible... |
658 |
} |
729 |
if (topLevelScope.parent.kind != Scope.COMPILATION_UNIT_SCOPE || |
659 |
// array of invalid syntax tags parameters |
730 |
!CharOperation.equals(topLevelType.sourceName, topLevelScope.referenceContext.name)) { |
660 |
if (this.invalidParameters != null) { |
731 |
topLevelScope = topLevelScope.outerMostClassScope(); |
661 |
length = this.invalidParameters.length; |
732 |
if (reference instanceof JavadocSingleTypeReference) { |
662 |
for (int i=0; i<length; i++) { |
733 |
// inner class single reference can only be done in same unit |
663 |
JavadocSingleNameReference param = this.invalidParameters[i]; |
734 |
if ((!source15 && depth == 1) || topLevelType != topLevelScope.referenceContext.binding) { |
664 |
if (param.sourceStart==start) { |
735 |
if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers(); |
665 |
return param; |
736 |
scope.problemReporter().javadocInvalidMemberTypeQualification(reference.sourceStart, reference.sourceEnd, scopeModifiers); |
666 |
} |
737 |
} |
667 |
} |
738 |
} else if (reference instanceof JavadocQualifiedTypeReference) { |
668 |
} |
739 |
JavadocQualifiedTypeReference qualifiedTypeReference = (JavadocQualifiedTypeReference) reference; |
669 |
// type parameters array |
740 |
// inner class qualified reference can only be done in same package |
670 |
if (this.paramTypeParameters != null) { |
741 |
if ((qualifiedTypeReference.tokens.length != resolvedType.enclosingType().compoundName.length+1) && topLevelType.getPackage() != topLevelScope.referenceContext.binding.getPackage()) { |
671 |
length = this.paramTypeParameters.length; |
742 |
if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers(); |
672 |
for (int i=0; i<length; i++) { |
743 |
scope.problemReporter().javadocInvalidMemberTypeQualification(reference.sourceStart, reference.sourceEnd, scopeModifiers); |
673 |
JavadocSingleTypeReference param = this.paramTypeParameters[i]; |
|
|
674 |
if (param.sourceStart==start) { |
675 |
return param; |
676 |
} |
677 |
} |
678 |
} |
679 |
// thrown exception array |
680 |
if (this.exceptionReferences != null) { |
681 |
length = this.exceptionReferences.length; |
682 |
for (int i=0; i<length; i++) { |
683 |
TypeReference typeRef = this.exceptionReferences[i]; |
684 |
if (typeRef.sourceStart==start) { |
685 |
return typeRef; |
686 |
} |
687 |
} |
688 |
} |
689 |
// references array |
690 |
if (this.seeReferences != null) { |
691 |
length = this.seeReferences.length; |
692 |
for (int i=0; i<length; i++) { |
693 |
org.eclipse.jdt.internal.compiler.ast.Expression expression = this.seeReferences[i]; |
694 |
if (expression.sourceStart==start) { |
695 |
return expression; |
696 |
} else if (expression instanceof JavadocAllocationExpression) { |
697 |
JavadocAllocationExpression allocationExpr = (JavadocAllocationExpression) this.seeReferences[i]; |
698 |
// if binding is valid then look at arguments |
699 |
if (allocationExpr.binding != null && allocationExpr.binding.isValidBinding()) { |
700 |
if (allocationExpr.arguments != null) { |
701 |
for (int j=0, l=allocationExpr.arguments.length; j<l; j++) { |
702 |
if (allocationExpr.arguments[j].sourceStart == start) { |
703 |
return allocationExpr.arguments[j]; |
704 |
} |
705 |
} |
706 |
} |
707 |
} |
708 |
} else if (expression instanceof JavadocMessageSend) { |
709 |
JavadocMessageSend messageSend = (JavadocMessageSend) this.seeReferences[i]; |
710 |
// if binding is valid then look at arguments |
711 |
if (messageSend.binding != null && messageSend.binding.isValidBinding()) { |
712 |
if (messageSend.arguments != null) { |
713 |
for (int j=0, l=messageSend.arguments.length; j<l; j++) { |
714 |
if (messageSend.arguments[j].sourceStart == start) { |
715 |
return messageSend.arguments[j]; |
716 |
} |
717 |
} |
718 |
} |
744 |
} |
719 |
} |
745 |
} |
720 |
} |
746 |
} |
721 |
} |
747 |
} |
|
|
748 |
|
749 |
// reference must have enough visibility to be used |
750 |
if (!canBeSeen(scope.problemReporter().options.reportInvalidJavadocTagsVisibility, resolvedType)) { |
751 |
if (scopeModifiers == -1) scopeModifiers = scope.getDeclarationModifiers(); |
752 |
scope.problemReporter().javadocNotVisibleReference(reference.sourceStart, reference.sourceEnd, scopeModifiers); |
753 |
} |
722 |
} |
754 |
} |
723 |
return null; |
|
|
724 |
} |
755 |
} |
725 |
} |
756 |
} |