<s> package org . eclipse . jdt . internal . compiler . ast ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ASTVisitor ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . CompilerOptions ; import org . eclipse . jdt . internal . compiler . lookup . * ; import org . eclipse . jdt . internal . compiler . parser . JavadocTagConstants ; public class Javadoc extends ASTNode { public JavadocSingleNameReference [ ] paramReferences ; public JavadocSingleTypeReference [ ] paramTypeParameters ; public TypeReference [ ] exceptionReferences ; public JavadocReturnStatement returnStatement ; public Expression [ ] seeReferences ; public long [ ] inheritedPositions = null ; public JavadocSingleNameReference [ ] invalidParameters ; public long valuePositions = - 1 ; public Javadoc ( int sourceStart , int sourceEnd ) { this . sourceStart = sourceStart ; this . sourceEnd = sourceEnd ; } boolean canBeSeen ( int visibility , int modifiers ) { if ( modifiers < 0 ) return true ; switch ( modifiers & ExtraCompilerModifiers . AccVisibilityMASK ) { case ClassFileConstants . AccPublic : return true ; case ClassFileConstants . AccProtected : return ( visibility != ClassFileConstants . AccPublic ) ; case ClassFileConstants . AccDefault : return ( visibility == ClassFileConstants . AccDefault || visibility == ClassFileConstants . AccPrivate ) ; case ClassFileConstants . AccPrivate : return ( visibility == ClassFileConstants . AccPrivate ) ; } return true ; } public ASTNode getNodeStartingAt ( int start ) { int length = 0 ; if ( this . paramReferences != null ) { length = this . paramReferences . length ; for ( int i = 0 ; i < length ; i ++ ) { JavadocSingleNameReference param = this . paramReferences [ i ] ; if ( param . sourceStart == start ) { return param ; } } } if ( this . invalidParameters != null ) { length = this . invalidParameters . length ; for ( int i = 0 ; i < length ; i ++ ) { JavadocSingleNameReference param = this . invalidParameters [ i ] ; if ( param . sourceStart == start ) { return param ; } } } if ( this . paramTypeParameters != null ) { length = this . paramTypeParameters . length ; for ( int i = 0 ; i < length ; i ++ ) { JavadocSingleTypeReference param = this . paramTypeParameters [ i ] ; if ( param . sourceStart == start ) { return param ; } } } if ( this . exceptionReferences != null ) { length = this . exceptionReferences . length ; for ( int i = 0 ; i < length ; i ++ ) { TypeReference typeRef = this . exceptionReferences [ i ] ; if ( typeRef . sourceStart == start ) { return typeRef ; } } } if ( this . seeReferences != null ) { length = this . seeReferences . length ; for ( int i = 0 ; i < length ; i ++ ) { org . eclipse . jdt . internal . compiler . ast . Expression expression = this . seeReferences [ i ] ; if ( expression . sourceStart == start ) { return expression ; } else if ( expression instanceof JavadocAllocationExpression ) { JavadocAllocationExpression allocationExpr = ( JavadocAllocationExpression ) this . seeReferences [ i ] ; if ( allocationExpr . binding != null && allocationExpr . binding . isValidBinding ( ) ) { if ( allocationExpr . arguments != null ) { for ( int j = 0 , l = allocationExpr . arguments . length ; j < l ; j ++ ) { if ( allocationExpr . arguments [ j ] . sourceStart == start ) { return allocationExpr . arguments [ j ] ; } } } } } else if ( expression instanceof JavadocMessageSend ) { JavadocMessageSend messageSend = ( JavadocMessageSend ) this . seeReferences [ i ] ; if ( messageSend . binding != null && messageSend . binding . isValidBinding ( ) ) { if ( messageSend . arguments != null ) { for ( int j = 0 , l = messageSend . arguments . length ; j < l ; j ++ ) { if ( messageSend . arguments [ j ] . sourceStart == start ) { return messageSend . arguments [ j ] ; } } } } } } } return null ; } public StringBuffer print ( int indent , StringBuffer output ) { printIndent ( indent , output ) . append ( "/**n" ) ; if ( this . paramReferences != null ) { for ( int i = 0 , length = this . paramReferences . length ; i < length ; i ++ ) { printIndent ( indent + 1 , output ) . append ( " * @param " ) ; this . paramReferences [ i ] . print ( indent , output ) . append ( '\n' ) ; } } if ( this . paramTypeParameters != null ) { for ( int i = 0 , length = this . paramTypeParameters . length ; i < length ; i ++ ) { printIndent ( indent + 1 , output ) . append ( " * @param <" ) ; this . paramTypeParameters [ i ] . print ( indent , output ) . append ( ">n" ) ; } } if ( this . returnStatement != null ) { printIndent ( indent + 1 , output ) . append ( " * @" ) ; this . returnStatement . print ( indent , output ) . append ( '\n' ) ; } if ( this . exceptionReferences != null ) { for ( int i = 0 , length = this . exceptionReferences . length ; i < length ; i ++ ) { printIndent ( indent + 1 , output ) . append ( " * @throws " ) ; this . exceptionReferences [ i ] . print ( indent , output ) . append ( '\n' ) ; } } if ( this . seeReferences != null ) { for ( int i = 0 , length = this . seeReferences . length ; i < length ; i ++ ) { printIndent ( indent + 1 , output ) . append ( " * @see " ) ; this . seeReferences [ i ] . print ( indent , output ) . append ( '\n' ) ; } } printIndent ( indent , output ) . append ( " */n" ) ; return output ; } public void resolve ( ClassScope scope ) { if ( this . inheritedPositions != null ) { int length = this . inheritedPositions . length ; for ( int i = 0 ; i < length ; ++ i ) { int start = ( int ) ( this . inheritedPositions [ i ] >>> 32 ) ; int end = ( int ) this . inheritedPositions [ i ] ; scope . problemReporter ( ) . javadocUnexpectedTag ( start , end ) ; } } int paramTagsSize = this . paramReferences == null ? 0 : this . paramReferences . length ; for ( int i = 0 ; i < paramTagsSize ; i ++ ) { JavadocSingleNameReference param = this . paramReferences [ i ] ; scope . problemReporter ( ) . javadocUnexpectedTag ( param . tagSourceStart , param . tagSourceEnd ) ; } resolveTypeParameterTags ( scope , true ) ; if ( this . returnStatement != null ) { scope . problemReporter ( ) . javadocUnexpectedTag ( this . returnStatement . sourceStart , this . returnStatement . sourceEnd ) ; } int throwsTagsLength = this . exceptionReferences == null ? 0 : this . exceptionReferences . length ; for ( int i = 0 ; i < throwsTagsLength ; i ++ ) { TypeReference typeRef = this . exceptionReferences [ i ] ; int start , end ; if ( typeRef instanceof JavadocSingleTypeReference ) { JavadocSingleTypeReference singleRef = ( JavadocSingleTypeReference ) typeRef ; start = singleRef . tagSourceStart ; end = singleRef . tagSourceEnd ; } else if ( typeRef instanceof JavadocQualifiedTypeReference ) { JavadocQualifiedTypeReference qualifiedRef = ( JavadocQualifiedTypeReference ) typeRef ; start = qualifiedRef . tagSourceStart ; end = qualifiedRef . tagSourceEnd ; } else { start = typeRef . sourceStart ; end = typeRef . sourceEnd ; } scope . problemReporter ( ) . javadocUnexpectedTag ( start , end ) ; } int seeTagsLength = this . seeReferences == null ? 0 : this . seeReferences . length ; for ( int i = 0 ; i < seeTagsLength ; i ++ ) { resolveReference ( this . seeReferences [ i ] , scope ) ; } boolean source15 = scope . compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ; if ( ! source15 && this . valuePositions != - 1 ) { scope . problemReporter ( ) . javadocUnexpectedTag ( ( int ) ( this . valuePositions >>> 32 ) , ( int ) this . valuePositions ) ; } } public void resolve ( CompilationUnitScope unitScope ) { } public void resolve ( MethodScope methScope ) { AbstractMethodDeclaration methDecl = methScope . referenceMethod ( ) ; boolean overriding = methDecl == null || methDecl . binding == null ? false : ! methDecl . binding . isStatic ( ) && ( ( methDecl . binding . modifiers & ( ExtraCompilerModifiers . AccImplementing | ExtraCompilerModifiers . AccOverriding ) ) != 0 ) ; int seeTagsLength = this . seeReferences == null ? 0 : this . seeReferences . length ; boolean superRef = false ; for ( int i = 0 ; i < seeTagsLength ; i ++ ) { resolveReference ( this . seeReferences [ i ] , methScope ) ; if ( methDecl != null && ! superRef ) { if ( ! methDecl . isConstructor ( ) ) { if ( overriding && this . seeReferences [ i ] instanceof JavadocMessageSend ) { JavadocMessageSend messageSend = ( JavadocMessageSend ) this . seeReferences [ i ] ; if ( messageSend . binding != null && messageSend . binding . isValidBinding ( ) && messageSend . actualReceiverType instanceof ReferenceBinding ) { ReferenceBinding methodReceiverType = ( ReferenceBinding ) messageSend . actualReceiverType ; TypeBinding superType = methDecl . binding . declaringClass . findSuperTypeOriginatingFrom ( methodReceiverType ) ; if ( superType != null && superType . original ( ) != methDecl . binding . declaringClass && CharOperation . equals ( messageSend . selector , methDecl . selector ) ) { if ( methScope . environment ( ) . methodVerifier ( ) . doesMethodOverride ( methDecl . binding , messageSend . binding . original ( ) ) ) { superRef = true ; } } } } } else if ( this . seeReferences [ i ] instanceof JavadocAllocationExpression ) { JavadocAllocationExpression allocationExpr = ( JavadocAllocationExpression ) this . seeReferences [ i ] ; if ( allocationExpr . binding != null && allocationExpr . binding . isValidBinding ( ) ) { ReferenceBinding allocType = ( ReferenceBinding ) allocationExpr . resolvedType . original ( ) ; ReferenceBinding superType = ( ReferenceBinding ) methDecl . binding . declaringClass . findSuperTypeOriginatingFrom ( allocType ) ; if ( superType != null && superType . original ( ) != methDecl . binding . declaringClass ) { MethodBinding superConstructor = methScope . getConstructor ( superType , methDecl . binding . parameters , allocationExpr ) ; if ( superConstructor . isValidBinding ( ) && superConstructor . original ( ) == allocationExpr . binding . original ( ) ) { if ( superConstructor . areParametersEqual ( methDecl . binding ) ) { superRef = true ; } } } } } } } if ( ! superRef && methDecl != null && methDecl . annotations != null ) { int length = methDecl . annotations . length ; for ( int i = 0 ; i < length && ! superRef ; i ++ ) { superRef = ( methDecl . binding . tagBits & TagBits . AnnotationOverride ) != 0 ; } } boolean reportMissing = methDecl == null || ! ( ( overriding && this . inheritedPositions != null ) || superRef || ( methDecl . binding . declaringClass != null && methDecl . binding . declaringClass . isLocalType ( ) ) ) ; if ( ! overriding && this . inheritedPositions != null ) { int length = this . inheritedPositions . length ; for ( int i = 0 ; i < length ; ++ i ) { int start = ( int ) ( this . inheritedPositions [ i ] >>> 32 ) ; int end = ( int ) this . inheritedPositions [ i ] ; methScope . problemReporter ( ) . javadocUnexpectedTag ( start , end ) ; } } CompilerOptions compilerOptions = methScope . compilerOptions ( ) ; resolveParamTags ( methScope , reportMissing , compilerOptions . reportUnusedParameterIncludeDocCommentReference ) ; resolveTypeParameterTags ( methScope , reportMissing ) ; if ( this . returnStatement == null ) { if ( reportMissing && methDecl != null ) { if ( methDecl . isMethod ( ) ) { MethodDeclaration meth = ( MethodDeclaration ) methDecl ; if ( meth . binding . returnType != TypeBinding . VOID ) { methScope . problemReporter ( ) . javadocMissingReturnTag ( meth . returnType . sourceStart , meth . returnType . sourceEnd , methDecl . binding . modifiers ) ; } } } } else { this . returnStatement . resolve ( methScope ) ; } resolveThrowsTags ( methScope , reportMissing ) ; boolean source15 = compilerOptions . sourceLevel >= ClassFileConstants . JDK1_5 ; if ( ! source15 && methDecl != null && this . valuePositions != - 1 ) { methScope . problemReporter ( ) . javadocUnexpectedTag ( ( int ) ( this . valuePositions >>> 32 ) , ( int ) this . valuePositions ) ; } int length = this . invalidParameters == null ? 0 : this . invalidParameters . length ; for ( int i = 0 ; i < length ; i ++ ) { this . invalidParameters [ i ] . resolve ( methScope , false , false ) ; } } private void resolveReference ( Expression reference , Scope scope ) { int problemCount = scope . referenceContext ( ) . compilationResult ( ) . problemCount ; switch ( scope . kind ) { case Scope . METHOD_SCOPE : reference . resolveType ( ( MethodScope ) scope ) ; break ; case Scope . CLASS_SCOPE : reference . resolveType ( ( ClassScope ) scope ) ; break ; } boolean hasProblems = scope . referenceContext ( ) . compilationResult ( ) . problemCount > problemCount ; boolean source15 = scope . compilerOptions ( ) . sourceLevel >= ClassFileConstants . JDK1_5 ; int scopeModifiers = - 1 ; if ( reference instanceof JavadocFieldReference ) { JavadocFieldReference fieldRef = ( JavadocFieldReference ) reference ; if ( fieldRef . methodBinding != null ) { if ( fieldRef . tagValue == JavadocTagConstants . TAG_VALUE_VALUE ) { if ( scopeModifiers == - 1 ) scopeModifiers = scope . getDeclarationModifiers ( ) ; scope . problemReporter ( ) . javadocInvalidValueReference ( fieldRef . sourceStart , fieldRef . sourceEnd , scopeModifiers ) ; } else if ( fieldRef . actualReceiverType != null ) { if ( scope . enclosingSourceType ( ) . isCompatibleWith ( fieldRef . actualReceiverType ) ) { fieldRef . bits |= ASTNode . SuperAccess ; } fieldRef . methodBinding = scope . findMethod ( ( ReferenceBinding ) fieldRef . actualReceiverType , fieldRef . token , new TypeBinding [ 0 ] , fieldRef ) ; } } else if ( source15 && fieldRef . binding != null && fieldRef . binding . isValidBinding ( ) ) { if ( fieldRef . tagValue == JavadocTagConstants . TAG_VALUE_VALUE && ! fieldRef . binding . isStatic ( ) ) { if ( scopeModifiers == - 1 ) scopeModifiers = scope . getDeclarationModifiers ( ) ; scope . problemReporter ( ) . javadocInvalidValueReference ( fieldRef . sourceStart , fieldRef . sourceEnd , scopeModifiers ) ; } } if ( ! hasProblems && fieldRef . binding != null && fieldRef . binding . isValidBinding ( ) && fieldRef . actualReceiverType instanceof ReferenceBinding ) { ReferenceBinding resolvedType = ( ReferenceBinding ) fieldRef . actualReceiverType ; verifyTypeReference ( fieldRef , fieldRef . receiver , scope , source15 , resolvedType , fieldRef . binding . modifiers ) ; } return ; } if ( ! hasProblems && ( reference instanceof JavadocSingleTypeReference || reference instanceof JavadocQualifiedTypeReference ) && reference . resolvedType instanceof ReferenceBinding ) { ReferenceBinding resolvedType = ( ReferenceBinding ) reference . resolvedType ; verifyTypeReference ( reference , reference , scope , source15 , resolvedType , resolvedType . modifiers ) ; } if ( reference instanceof JavadocMessageSend ) { JavadocMessageSend msgSend = ( JavadocMessageSend ) reference ; if ( source15 && msgSend . tagValue == JavadocTagConstants . TAG_VALUE_VALUE ) { if ( scopeModifiers == - 1 ) scopeModifiers = scope . getDeclarationModifiers ( ) ; scope . problemReporter ( ) . javadocInvalidValueReference ( msgSend . sourceStart , msgSend . sourceEnd , scopeModifiers ) ; } if ( ! hasProblems && msgSend . binding != null && msgSend . binding . isValidBinding ( ) && msgSend . actualReceiverType instanceof ReferenceBinding ) { ReferenceBinding resolvedType = ( ReferenceBinding ) msgSend . actualReceiverType ; verifyTypeReference ( msgSend , msgSend . receiver , scope , source15 , resolvedType , msgSend . binding . modifiers ) ; } } else if ( reference instanceof JavadocAllocationExpression ) { JavadocAllocationExpression alloc = ( JavadocAllocationExpression ) reference ; if ( source15 && alloc . tagValue == JavadocTagConstants . TAG_VALUE_VALUE ) { if ( scopeModifiers == - 1 ) scopeModifiers = scope . getDeclarationModifiers ( ) ; scope . problemReporter ( ) . javadocInvalidValueReference ( alloc . sourceStart , alloc . sourceEnd , scopeModifiers ) ; } if ( ! hasProblems && alloc . binding != null && alloc . binding . isValidBinding ( ) && alloc . resolvedType instanceof ReferenceBinding ) { ReferenceBinding resolvedType = ( ReferenceBinding ) alloc . resolvedType ; verifyTypeReference ( alloc , alloc . type , scope , source15 , resolvedType , alloc . binding . modifiers ) ; } } if ( reference . resolvedType != null && reference . resolvedType . isTypeVariable ( ) ) { scope . problemReporter ( ) . javadocInvalidReference ( reference . sourceStart , reference . sourceEnd ) ; } } private void resolveParamTags ( MethodScope scope , boolean reportMissing , boolean considerParamRefAsUsage ) { AbstractMethodDeclaration methodDecl = scope . referenceMethod ( ) ; int paramTagsSize = this . paramReferences == null ? 0 : this . paramReferences . length ; if ( methodDecl == null ) { for ( int i = 0 ; i < paramTagsSize ; i ++ ) { JavadocSingleNameReference param = this . paramReferences [ i ] ; scope . problemReporter ( ) . javadocUnexpectedTag ( param . tagSourceStart , param . tagSourceEnd ) ; } return ; } int argumentsSize = methodDecl . arguments == null ? 0 : methodDecl . arguments . length ; if ( paramTagsSize == 0 ) { if ( reportMissing ) { for ( int i = 0 ; i < argumentsSize ; i ++ ) { Argument arg = methodDecl . arguments [ i ] ; scope . problemReporter ( ) . javadocMissingParamTag ( arg . name , arg . sourceStart , arg . sourceEnd , methodDecl . binding . modifiers ) ; } } } else { LocalVariableBinding [ ] bindings = new LocalVariableBinding [ paramTagsSize ] ; int maxBindings = 0 ; for ( int i = 0 ; i < paramTagsSize ; i ++ ) { JavadocSingleNameReference param = this . paramReferences [ i ] ; param . resolve ( scope , true , considerParamRefAsUsage ) ; if ( param . binding != null && param . binding . isValidBinding ( ) ) { boolean found = false ; for ( int j = 0 ; j < maxBindings && ! found ; j ++ ) { if ( bindings [ j ] == param . binding ) { scope . problemReporter ( ) . javadocDuplicatedParamTag ( param . token , param . sourceStart , param . sourceEnd , methodDecl . binding . modifiers ) ; found = true ; } } if ( ! found ) { bindings [ maxBindings ++ ] = ( LocalVariableBinding ) param . binding ; } } } if ( reportMissing ) { for ( int i = 0 ; i < argumentsSize ; i ++ ) { Argument arg = methodDecl . arguments [ i ] ; boolean found = false ; for ( int j = 0 ; j < maxBindings && ! found ; j ++ ) { LocalVariableBinding binding = bindings [ j ] ; if ( arg . binding == binding ) { found = true ; } } if ( ! found ) { scope . problemReporter ( ) . javadocMissingParamTag ( arg . name , arg . sourceStart , arg . sourceEnd , methodDecl . binding . modifiers ) ; } } } } } private void resolveTypeParameterTags ( Scope scope , boolean reportMissing ) { int paramTypeParamLength = this . paramTypeParameters == null ? 0 : this . paramTypeParameters . length ; TypeParameter [ ] parameters = null ; TypeVariableBinding [ ] typeVariables = null ; int modifiers = - 1 ; switch ( scope . kind ) { case Scope . METHOD_SCOPE : AbstractMethodDeclaration methodDeclaration = ( ( MethodScope ) scope ) . referenceMethod ( ) ; if ( methodDeclaration == null ) { for ( int i = 0 ; i < paramTypeParamLength ; i ++ ) { JavadocSingleTypeReference param = this . paramTypeParameters [ i ] ; scope . problemReporter ( ) . javadocUnexpectedTag ( param . tagSourceStart , param . tagSourceEnd ) ; } return ; } parameters = methodDeclaration . typeParameters ( ) ; typeVariables = methodDeclaration . binding . typeVariables ; modifiers = methodDeclaration . binding . modifiers ; break ; case Scope . CLASS_SCOPE : TypeDeclaration typeDeclaration = ( ( ClassScope ) scope ) . referenceContext ; parameters = typeDeclaration . typeParameters ; typeVariables = typeDeclaration . binding . typeVariables ; modifiers = typeDeclaration . binding . modifiers ; break ; } if ( typeVariables == null || typeVariables . length == 0 ) { for ( int i = 0 ; i < paramTypeParamLength ; i ++ ) { JavadocSingleTypeReference param = this . paramTypeParameters [ i ] ; scope . problemReporter ( ) . javadocUnexpectedTag ( param . tagSourceStart , param . tagSourceEnd ) ; } return ; } if ( parameters != null ) { int typeParametersLength = parameters . length ; if ( paramTypeParamLength == 0 ) { if ( reportMissing ) { for ( int i = 0 , l = typeParametersLength ; i < l ; i ++ ) { scope . problemReporter ( ) . javadocMissingParamTag ( parameters [ i ] . name , parameters [ i ] . sourceStart , parameters [ i ] . sourceEnd , modifiers ) ; } } } else if ( typeVariables . length == typeParametersLength ) { TypeVariableBinding [ ] bindings = new TypeVariableBinding [ paramTypeParamLength ] ; for ( int i = 0 ; i < paramTypeParamLength ; i ++ ) { JavadocSingleTypeReference param = this . paramTypeParameters [ i ] ; TypeBinding paramBindind = param . internalResolveType ( scope ) ; if ( paramBindind != null && paramBindind . isValidBinding ( ) ) { if ( paramBindind . isTypeVariable ( ) ) { boolean duplicate = false ; for ( int j = 0 ; j < i && ! duplicate ; j ++ ) { if ( bindings [ j ] == param . resolvedType ) { scope . problemReporter ( ) . javadocDuplicatedParamTag ( param . token , param . sourceStart , param . sourceEnd , modifiers ) ; duplicate = true ; } } if ( ! duplicate ) { bindings [ i ] = ( TypeVariableBinding ) param . resolvedType ; } } else { scope . problemReporter ( ) . javadocUndeclaredParamTagName ( param . token , param . sourceStart , param . sourceEnd , modifiers ) ; } } } for ( int i = 0 ; i < typeParametersLength ; i ++ ) { TypeParameter parameter = parameters [ i ] ; boolean found = false ; for ( int j = 0 ; j < paramTypeParamLength && ! found ; j ++ ) { if ( parameter . binding == bindings [ j ] ) { found = true ; bindings [ j ] = null ; } } if ( ! found && reportMissing ) { scope . problemReporter ( ) . javadocMissingParamTag ( parameter . name , parameter . sourceStart , parameter . sourceEnd , modifiers ) ; } } for ( int i = 0 ; i < paramTypeParamLength ; i ++ ) { if ( bindings [ i ] != null ) { JavadocSingleTypeReference param = this . paramTypeParameters [ i ] ; scope . problemReporter ( ) . javadocUndeclaredParamTagName ( param . token , param . sourceStart , param . sourceEnd , modifiers ) ; } } } } } private void resolveThrowsTags ( MethodScope methScope , boolean reportMissing ) { AbstractMethodDeclaration md = methScope . referenceMethod ( ) ; int throwsTagsLength = this . exceptionReferences == null ? 0 : this . exceptionReferences . length ; if ( md == null ) { for ( int i = 0 ; i < throwsTagsLength ; i ++ ) { TypeReference typeRef = this . exceptionReferences [ i ] ; int start = typeRef . sourceStart ; int end = typeRef . sourceEnd ; if ( typeRef instanceof JavadocQualifiedTypeReference ) { start = ( ( JavadocQualifiedTypeReference ) typeRef ) . tagSourceStart ; end = ( ( JavadocQualifiedTypeReference ) typeRef ) . tagSourceEnd ; } else if ( typeRef instanceof JavadocSingleTypeReference ) { start = ( ( JavadocSingleTypeReference ) typeRef ) . tagSourceStart ; end = ( ( JavadocSingleTypeReference ) typeRef ) . tagSourceEnd ; } methScope . problemReporter ( ) . javadocUnexpectedTag ( start , end ) ; } return ; } int boundExceptionLength = ( md . binding == null ) ? 0 : md . binding . thrownExceptions . length ; int thrownExceptionLength = md . thrownExceptions == null ? 0 : md . thrownExceptions . length ; if ( throwsTagsLength == 0 ) { if ( reportMissing ) { for ( int i = 0 ; i < boundExceptionLength ; i ++ ) { ReferenceBinding exceptionBinding = md . binding . thrownExceptions [ i ] ; if ( exceptionBinding != null && exceptionBinding . isValidBinding ( ) ) { int j = i ; while ( j < thrownExceptionLength && exceptionBinding != md . thrownExceptions [ j ] . resolvedType ) j ++ ; if ( j < thrownExceptionLength ) { methScope . problemReporter ( ) . javadocMissingThrowsTag ( md . thrownExceptions [ j ] , md . binding . modifiers ) ; } } } } } else { int maxRef = 0 ; TypeReference [ ] typeReferences = new TypeReference [ throwsTagsLength ] ; for ( int i = 0 ; i < throwsTagsLength ; i ++ ) { TypeReference typeRef = this . exceptionReferences [ i ] ; typeRef . resolve ( methScope ) ; TypeBinding typeBinding = typeRef . resolvedType ; if ( typeBinding != null && typeBinding . isValidBinding ( ) && typeBinding . isClass ( ) ) { typeReferences [ maxRef ++ ] = typeRef ; } } for ( int i = 0 ; i < boundExceptionLength ; i ++ ) { ReferenceBinding exceptionBinding = md . binding . thrownExceptions [ i ] ; if ( exceptionBinding != null ) exceptionBinding = ( ReferenceBinding ) exceptionBinding . erasure ( ) ; boolean found = false ; for ( int j = 0 ; j < maxRef && ! found ; j ++ ) { if ( typeReferences [ j ] != null ) { TypeBinding typeBinding = typeReferences [ j ] . resolvedType ; if ( exceptionBinding == typeBinding ) { found = true ; typeReferences [ j ] = null ; } } } if ( ! found && reportMissing ) { if ( exceptionBinding != null && exceptionBinding . isValidBinding ( ) ) { int k = i ; while ( k < thrownExceptionLength && exceptionBinding != md . thrownExceptions [ k ] . resolvedType ) k ++ ; if ( k < thrownExceptionLength ) { methScope . problemReporter ( ) . javadocMissingThrowsTag ( md . thrownExceptions [ k ] , md . binding . modifiers ) ; } } } } for ( int i = 0 ; i < maxRef ; i ++ ) { TypeReference typeRef = typeReferences [ i ] ; if ( typeRef != null ) { boolean compatible = false ; for ( int j = 0 ; j < thrownExceptionLength && ! compatible ; j ++ ) { TypeBinding exceptionBinding = md . thrownExceptions [ j ] . resolvedType ; if ( exceptionBinding != null ) { compatible = typeRef . resolvedType . isCompatibleWith ( exceptionBinding ) ; } } if ( ! compatible && ! typeRef . resolvedType . isUncheckedException ( false ) ) { methScope . problemReporter ( ) . javadocInvalidThrowsClassName ( typeRef , md . binding . modifiers ) ; } } } } } private void verifyTypeReference ( Expression reference , Expression typeReference , Scope scope , boolean source15 , ReferenceBinding resolvedType , int modifiers ) { if ( resolvedType . isValidBinding ( ) ) { int scopeModifiers = - 1 ; if ( ! canBeSeen ( scope . problemReporter ( ) . options . reportInvalidJavadocTagsVisibility , modifiers ) ) { scope . problemReporter ( ) . javadocHiddenReference ( typeReference . sourceStart , reference . sourceEnd , scope , modifiers ) ; return ; } if ( reference != typeReference ) { if ( ! canBeSeen ( scope . problemReporter ( ) . options . reportInvalidJavadocTagsVisibility , resolvedType . modifiers ) ) { scope . problemReporter ( ) . javadocHiddenReference ( typeReference . sourceStart , typeReference . sourceEnd , scope , resolvedType . modifiers ) ; return ; } } if ( resolvedType . isMemberType ( ) ) { ReferenceBinding topLevelType = resolvedType ; int packageLength = topLevelType . fPackage . compoundName . length ; int depth = resolvedType . depth ( ) ; int idx = depth + packageLength ; char [ ] [ ] computedCompoundName = new char [ idx + 1 ] [ ] ; computedCompoundName [ idx ] = topLevelType . sourceName ; while ( topLevelType . enclosingType ( ) != null ) { topLevelType = topLevelType . enclosingType ( ) ; computedCompoundName [ -- idx ] = topLevelType . sourceName ; } for ( int i = packageLength ; -- i >= 0 ; ) { computedCompoundName [ -- idx ] = topLevelType . fPackage . compoundName [ i ] ; } ClassScope topLevelScope = scope . classScope ( ) ; if ( topLevelScope . parent . kind != Scope . COMPILATION_UNIT_SCOPE || ! CharOperation . equals ( topLevelType . sourceName , topLevelScope . referenceContext . name ) ) { topLevelScope = topLevelScope . outerMostClassScope ( ) ; if ( typeReference instanceof JavadocSingleTypeReference ) { if ( ( ! source15 && depth == 1 ) || topLevelType != topLevelScope . referenceContext . binding ) { boolean hasValidImport = false ; if ( source15 ) { CompilationUnitScope unitScope = topLevelScope . compilationUnitScope ( ) ; ImportBinding [ ] imports = unitScope . imports ; int length = imports == null ? 0 : imports . length ; mainLoop : for ( int i = 0 ; i < length ; i ++ ) { char [ ] [ ] compoundName = imports [ i ] . compoundName ; int compoundNameLength = compoundName . length ; if ( ( imports [ i ] . onDemand && compoundNameLength == computedCompoundName . length - 1 ) || ( compoundNameLength == computedCompoundName . length ) ) { for ( int j = compoundNameLength ; -- j >= 0 ; ) { if ( CharOperation . equals ( imports [ i ] . compoundName [ j ] , computedCompoundName [ j ] ) ) { if ( j == 0 ) { hasValidImport = true ; ImportReference importReference = imports [ i ] . reference ; if ( importReference != null ) { importReference . bits |= ASTNode . Used ; } break mainLoop ; } } else { break ; } } } } if ( ! hasValidImport ) { if ( scopeModifiers == - 1 ) scopeModifiers = scope . getDeclarationModifiers ( ) ; scope . problemReporter ( ) . javadocInvalidMemberTypeQualification ( typeReference . sourceStart , typeReference . sourceEnd , scopeModifiers ) ; } } else { if ( scopeModifiers == - 1 ) scopeModifiers = scope . getDeclarationModifiers ( ) ; scope . problemReporter ( ) . javadocInvalidMemberTypeQualification ( typeReference . sourceStart , typeReference . sourceEnd , scopeModifiers ) ; return ; } } } } } if ( scope . referenceCompilationUnit ( ) . isPackageInfo ( ) && typeReference instanceof JavadocSingleTypeReference ) { if ( resolvedType . fPackage . compoundName . length > 0 ) { scope . problemReporter ( ) . javadocInvalidReference ( typeReference . sourceStart , typeReference . sourceEnd ) ; return ; } } } } public void traverse ( ASTVisitor visitor , BlockScope scope ) { if ( visitor . visit ( this , scope ) ) { if ( this . paramReferences != null ) { for ( int i = 0 , length = this . paramReferences . length ; i < length ; i ++ ) { this . paramReferences [ i ] . traverse ( visitor , scope ) ; } } if ( this . paramTypeParameters != null ) { for ( int i = 0 , length = this . paramTypeParameters . length ; i < length ; i ++ ) { this . paramTypeParameters [ i ] . traverse ( visitor , scope ) ; } } if ( this . returnStatement != null ) { this . returnStatement . traverse ( visitor , scope ) ; } if ( this . exceptionReferences != null ) { for ( int i = 0 , length = this . exceptionReferences . length ; i < length ; i ++ ) { this . exceptionReferences [ i ] . traverse ( visitor , scope ) ; } } if ( this . seeReferences != null ) { for ( int i = 0 , length = this . seeReferences . length ; i < length ; i ++ ) { this . seeReferences [ i ] . traverse ( visitor , scope ) ; } } } visitor . endVisit ( this , scope ) ; } public void traverse ( ASTVisitor visitor , ClassScope scope ) { if ( visitor . visit ( this , scope ) ) { if ( this . paramReferences != null ) { for ( int i = 0 , length = this . paramReferences . length ; i < length ; i ++ ) { this . paramReferences [ i ] . traverse ( visitor , scope ) ; } } if ( this . paramTypeParameters != null ) { for ( int i = 0 , length = this . paramTypeParameters . length ; i < length ; i ++ ) { this . paramTypeParameters [ i ] . traverse ( visitor , scope ) ; } } if ( this . returnStatement != null ) { this . returnStatement . traverse ( visitor , scope ) ; } if ( this . exceptionReferences != null ) { for ( int i = 0 , length = this . exceptionReferences . length ; i < length ; i ++ ) { this . exceptionReferences [ i ] . traverse ( visitor , scope ) ; } } if ( this . seeReferences != null ) { for ( int i = 0 , length = this . seeReferences . length ; i < length ; i ++ ) { this . seeReferences [ i ] . traverse ( visitor , scope ) ; } } } visitor . endVisit ( this , scope ) ; } } </s>