<s> package org . eclipse . jdt . internal . compiler . lookup ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . ast . ASTNode ; import org . eclipse . jdt . internal . compiler . ast . AbstractMethodDeclaration ; import org . eclipse . jdt . internal . compiler . ast . CaseStatement ; import org . eclipse . jdt . internal . compiler . ast . TypeDeclaration ; import org . eclipse . jdt . internal . compiler . ast . TypeReference ; public final class LocalTypeBinding extends NestedTypeBinding { final static char [ ] LocalTypePrefix = { '$' , 'L' , 'o' , 'c' , 'a' , 'l' , '$' } ; private InnerEmulationDependency [ ] dependents ; public ArrayBinding [ ] localArrayBindings ; public CaseStatement enclosingCase ; public int sourceStart ; public MethodBinding enclosingMethod ; public LocalTypeBinding ( ClassScope scope , SourceTypeBinding enclosingType , CaseStatement switchCase , ReferenceBinding anonymousOriginalSuperType ) { super ( new char [ ] [ ] { CharOperation . concat ( LocalTypeBinding . LocalTypePrefix , scope . referenceContext . name ) } , scope , enclosingType ) ; TypeDeclaration typeDeclaration = scope . referenceContext ; if ( ( typeDeclaration . bits & ASTNode . IsAnonymousType ) != 0 ) { this . tagBits |= TagBits . AnonymousTypeMask ; } else { this . tagBits |= TagBits . LocalTypeMask ; } this . enclosingCase = switchCase ; this . sourceStart = typeDeclaration . sourceStart ; MethodScope methodScope = scope . enclosingMethodScope ( ) ; AbstractMethodDeclaration methodDeclaration = methodScope . referenceMethod ( ) ; if ( methodDeclaration != null ) { this . enclosingMethod = methodDeclaration . binding ; } } public void addInnerEmulationDependent ( BlockScope dependentScope , boolean wasEnclosingInstanceSupplied ) { int index ; if ( this . dependents == null ) { index = 0 ; this . dependents = new InnerEmulationDependency [ 1 ] ; } else { index = this . dependents . length ; for ( int i = 0 ; i < index ; i ++ ) if ( this . dependents [ i ] . scope == dependentScope ) return ; System . arraycopy ( this . dependents , 0 , ( this . dependents = new InnerEmulationDependency [ index + 1 ] ) , 0 , index ) ; } this . dependents [ index ] = new InnerEmulationDependency ( dependentScope , wasEnclosingInstanceSupplied ) ; } public ReferenceBinding anonymousOriginalSuperType ( ) { if ( this . superInterfaces != Binding . NO_SUPERINTERFACES ) { return this . superInterfaces [ 0 ] ; } if ( ( this . tagBits & TagBits . HierarchyHasProblems ) == 0 ) { return this . superclass ; } if ( this . scope != null ) { TypeReference typeReference = this . scope . referenceContext . allocation . type ; if ( typeReference != null ) { return ( ReferenceBinding ) typeReference . resolvedType ; } } return this . superclass ; } public char [ ] computeUniqueKey ( boolean isLeaf ) { char [ ] outerKey = outermostEnclosingType ( ) . computeUniqueKey ( isLeaf ) ; int semicolon = CharOperation . lastIndexOf ( ';' , outerKey ) ; StringBuffer sig = new StringBuffer ( ) ; sig . append ( outerKey , 0 , semicolon ) ; sig . append ( '$' ) ; sig . append ( String . valueOf ( this . sourceStart ) ) ; if ( ! isAnonymousType ( ) ) { sig . append ( '$' ) ; sig . append ( this . sourceName ) ; } sig . append ( outerKey , semicolon , outerKey . length - semicolon ) ; int sigLength = sig . length ( ) ; char [ ] uniqueKey = new char [ sigLength ] ; sig . getChars ( 0 , sigLength , uniqueKey , 0 ) ; return uniqueKey ; } public char [ ] constantPoolName ( ) { if ( this . constantPoolName == null && this . scope != null ) { this . constantPoolName = this . scope . compilationUnitScope ( ) . computeConstantPoolName ( this ) ; } return this . constantPoolName ; } ArrayBinding createArrayType ( int dimensionCount , LookupEnvironment lookupEnvironment ) { if ( this . localArrayBindings == null ) { this . localArrayBindings = new ArrayBinding [ ] { new ArrayBinding ( this , dimensionCount , lookupEnvironment ) } ; return this . localArrayBindings [ 0 ] ; } int length = this . localArrayBindings . length ; for ( int i = 0 ; i < length ; i ++ ) if ( this . localArrayBindings [ i ] . dimensions == dimensionCount ) return this . localArrayBindings [ i ] ; System . arraycopy ( this . localArrayBindings , 0 , this . localArrayBindings = new ArrayBinding [ length + 1 ] , 0 , length ) ; return this . localArrayBindings [ length ] = new ArrayBinding ( this , dimensionCount , lookupEnvironment ) ; } public char [ ] genericTypeSignature ( ) { if ( this . genericReferenceTypeSignature == null && this . constantPoolName == null ) { if ( isAnonymousType ( ) ) setConstantPoolName ( superclass ( ) . sourceName ( ) ) ; else setConstantPoolName ( sourceName ( ) ) ; } return super . genericTypeSignature ( ) ; } public char [ ] readableName ( ) { char [ ] readableName ; if ( isAnonymousType ( ) ) { readableName = CharOperation . concat ( TypeConstants . ANONYM_PREFIX , anonymousOriginalSuperType ( ) . readableName ( ) , TypeConstants . ANONYM_SUFFIX ) ; } else if ( isMemberType ( ) ) { readableName = CharOperation . concat ( enclosingType ( ) . readableName ( ) , this . sourceName , '.' ) ; } else { readableName = this . sourceName ; } TypeVariableBinding [ ] typeVars ; if ( ( typeVars = typeVariables ( ) ) != Binding . NO_TYPE_VARIABLES ) { StringBuffer nameBuffer = new StringBuffer ( 10 ) ; nameBuffer . append ( readableName ) . append ( '<' ) ; for ( int i = 0 , length = typeVars . length ; i < length ; i ++ ) { if ( i > 0 ) nameBuffer . append ( ',' ) ; nameBuffer . append ( typeVars [ i ] . readableName ( ) ) ; } nameBuffer . append ( '>' ) ; int nameLength = nameBuffer . length ( ) ; readableName = new char [ nameLength ] ; nameBuffer . getChars ( 0 , nameLength , readableName , 0 ) ; } return readableName ; } public char [ ] shortReadableName ( ) { char [ ] shortReadableName ; if ( isAnonymousType ( ) ) { shortReadableName = CharOperation . concat ( TypeConstants . ANONYM_PREFIX , anonymousOriginalSuperType ( ) . shortReadableName ( ) , TypeConstants . ANONYM_SUFFIX ) ; } else if ( isMemberType ( ) ) { shortReadableName = CharOperation . concat ( enclosingType ( ) . shortReadableName ( ) , this . sourceName , '.' ) ; } else { shortReadableName = this . sourceName ; } TypeVariableBinding [ ] typeVars ; if ( ( typeVars = typeVariables ( ) ) != Binding . NO_TYPE_VARIABLES ) { StringBuffer nameBuffer = new StringBuffer ( 10 ) ; nameBuffer . append ( shortReadableName ) . append ( '<' ) ; for ( int i = 0 , length = typeVars . length ; i < length ; i ++ ) { if ( i > 0 ) nameBuffer . append ( ',' ) ; nameBuffer . append ( typeVars [ i ] . shortReadableName ( ) ) ; } nameBuffer . append ( '>' ) ; int nameLength = nameBuffer . length ( ) ; shortReadableName = new char [ nameLength ] ; nameBuffer . getChars ( 0 , nameLength , shortReadableName , 0 ) ; } return shortReadableName ; } public void setAsMemberType ( ) { this . tagBits |= TagBits . MemberTypeMask ; } public void setConstantPoolName ( char [ ] computedConstantPoolName ) { this . constantPoolName = computedConstantPoolName ; } public char [ ] signature ( ) { if ( this . signature == null && this . constantPoolName == null ) { if ( isAnonymousType ( ) ) setConstantPoolName ( superclass ( ) . sourceName ( ) ) ; else setConstantPoolName ( sourceName ( ) ) ; } return super . signature ( ) ; } public char [ ] sourceName ( ) { if ( isAnonymousType ( ) ) { return CharOperation . concat ( TypeConstants . ANONYM_PREFIX , anonymousOriginalSuperType ( ) . sourceName ( ) , TypeConstants . ANONYM_SUFFIX ) ; } else return this . sourceName ; } public String toString ( ) { if ( isAnonymousType ( ) ) return "" + super . toString ( ) ; if ( isMemberType ( ) ) return "" + new String ( sourceName ( ) ) + " " + super . toString ( ) ; return "" + new String ( sourceName ( ) ) + " " + super . toString ( ) ; } public void updateInnerEmulationDependents ( ) { if ( this . dependents != null ) { for ( int i = 0 ; i < this . dependents . length ; i ++ ) { InnerEmulationDependency dependency = this . dependents [ i ] ; dependency . scope . propagateInnerEmulation ( this , dependency . wasEnclosingInstanceSupplied ) ; } } } } </s>